From a43e52e70a29ac67d9ef65115cf18f27604c3914 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 25 May 2026 05:37:02 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Defer=20expensive=20text=20?= =?UTF-8?q?analysis=20during=20streaming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Wrapped `visibleOutput` in `useDeferredValue` before passing it to `analyzeText` in `playground-view.tsx`. This ensures that the expensive text analysis and deterministic rubric scoring do not block the main thread during rapid character-by-character fake streaming updates. Co-authored-by: aloewright <3641844+aloewright@users.noreply.github.com> --- .jules/bolt.md | 3 +++ apps/quill/client/components/playground-view.tsx | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 00000000..14deda20 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-05-24 - [Defer Expensive Synchronous Work During Fake Streaming] +**Learning:** Fake text streaming with `setInterval` at rapid intervals (e.g. 24ms) can severely block the main thread if expensive synchronous computations (like text analysis/scoring) depend directly on the streaming state. +**Action:** Always wrap rapidly changing state in `useDeferredValue` before feeding it into expensive `useMemo` hooks to keep the UI thread unblocked. diff --git a/apps/quill/client/components/playground-view.tsx b/apps/quill/client/components/playground-view.tsx index 511226b4..cd8a7878 100644 --- a/apps/quill/client/components/playground-view.tsx +++ b/apps/quill/client/components/playground-view.tsx @@ -1,6 +1,6 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; import { AnimatePresence, motion } from "framer-motion"; -import { useEffect, useMemo, useRef, useState } from "react"; +import { useDeferredValue, useEffect, useMemo, useRef, useState } from "react"; import { USE_CASE_PRESETS } from "../../src/lib/presets"; import { analyzeText, scoreDeterministic } from "../../src/lib/rubric"; import type { Guide, UseCase } from "../../src/lib/types"; @@ -255,7 +255,12 @@ export function PlaygroundView({ }; }, [output]); - const snapshot = useMemo(() => analyzeText(visibleOutput), [visibleOutput]); + const deferredVisibleOutput = useDeferredValue(visibleOutput); + + const snapshot = useMemo( + () => analyzeText(deferredVisibleOutput), + [deferredVisibleOutput] + ); const { score, details } = useMemo( () => guide