Skip to content

⚡ Bolt: Use deferred value for expensive rubric scoring#54

Open
aloewright wants to merge 2 commits into
mainfrom
bolt-perf-defer-rubric-scoring-2776428546645636422
Open

⚡ Bolt: Use deferred value for expensive rubric scoring#54
aloewright wants to merge 2 commits into
mainfrom
bolt-perf-defer-rubric-scoring-2776428546645636422

Conversation

@aloewright

Copy link
Copy Markdown
Owner

💡 What: Wrap the rapidly updating visibleOutput state in useDeferredValue before passing it to analyzeText in playground-view.tsx.
🎯 Why: visibleOutput updates every ~24ms during fake streaming. Passing it directly to analyzeText (an expensive synchronous operation) blocks the main thread on every tick.
📊 Impact: Prevents main thread blocking and jank during the streaming text effect, keeping the UI responsive.
🔬 Measurement: Verify visually or via performance tools that the playground UI does not lag or drop frames during text generation/streaming.


PR created automatically by Jules for task 2776428546645636422 started by @aloewright

Co-authored-by: aloewright <3641844+aloewright@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 30, 2026 05:45
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@aloewright, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 38 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09848f56-6383-46e1-95d5-9fcf3b0bb300

📥 Commits

Reviewing files that changed from the base of the PR and between bab8f67 and e60ea11.

📒 Files selected for processing (2)
  • .jules/bolt.md
  • apps/quill/client/components/playground-view.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-perf-defer-rubric-scoring-2776428546645636422

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 30, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
postpilot e60ea11 May 30 2026, 05:52 AM

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a performance optimization in the PlaygroundView component by wrapping visibleOutput in React's useDeferredValue to defer the expensive synchronous analyzeText computation during rapid state updates. This learning is also documented in .jules/bolt.md. The reviewer suggests further performance improvements, including memoizing the rendering of the RubricSnapshot component to prevent unnecessary re-renders, and replacing a dynamic key on the output container to avoid layout thrashing.

Comment on lines +262 to +264
const deferredOutput = useDeferredValue(visibleOutput);

const snapshot = useMemo(() => analyzeText(deferredOutput), [deferredOutput]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While wrapping visibleOutput in useDeferredValue successfully prevents the expensive analyzeText computation from running on every 24ms tick, the <RubricSnapshot> component (and its children like <CountUp>) will still re-render on every single tick. This is because PlaygroundView re-renders whenever visibleOutput changes, and <RubricSnapshot> is not memoized.

To fully unlock the performance benefits of useDeferredValue and prevent unnecessary DOM updates/re-renders of the rubric UI, we should memoize the rendering of <RubricSnapshot> using useMemo:

const rubricSnapshotView = useMemo(() => {
  if (!guide) return null;
  return (
    <RubricSnapshot
      details={details}
      overallPct={Math.round(score * 100)}
      rubric={guide.eval_rubric}
      snapshot={snapshot}
    />
  );
}, [details, score, guide, snapshot]);

And then render it in the JSX at the bottom of the file:

{visibleOutput.length > 0 && rubricSnapshotView}

💡 Additional Performance Tip

We also noticed that the <motion.pre> element at line 510 uses key={out-${visibleOutput.length}}. This causes the entire output container to unmount and remount on every single character update (every 24ms), which triggers layout thrashing and resets scroll positions. Consider using a stable key (or no key if it's not in a list) to keep the DOM node stable during streaming.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Co-authored-by: aloewright <3641844+aloewright@users.noreply.github.com>
@aloewright aloewright enabled auto-merge (squash) June 4, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants