perf(ai): batch streaming and status updates#531
Open
JustYannicc wants to merge 9 commits into
Open
Conversation
This was referenced Jul 3, 2026
Contributor
|
Reviewed the full diff. This is a clean, well-tested batching refactor across four AI subsystems (chat stream, cursor prompt, Raycast `useAI`, and settings model-status polling). I traced the behavior-critical paths and could not find a correctness regression. Strengths
Concerns / potential bugs
Suggestions (non-blocking)
Verdict: 🟡 Approve with minor comments 🤖 Automated review by Claude Code (Opus 4.8). |
Collaborator
Author
|
Addressed the remaining PR feedback/proof gap for #531. What changed:
Verification on commit
|
Collaborator
Author
|
Follow-up after the verification pass: I pushed commit Correction/clarification:
Verification:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
useAIstreaming data updates with frame/timer scheduling and synchronous terminal flushes.Why
Streaming AI text and settings model status polling previously caused renderer-visible state updates once per token/chunk or once per individual status poll. That created avoidable React work during long responses and while the AI settings tab sat open. The new helpers preserve authoritative data immediately while reducing visible updates to flush cadence or actual semantic status changes.
Compatibility impact
No IPC contracts, public hook return shapes, user-facing strings, or locale files changed. Chat and Cursor Prompt still flush final content before persistence/apply, stream errors still surface with the accumulated text, cancellation/abort paths clear pending repaint work,
useAIstill callsonDatawith the final full text, and model download progress still updates because progress fields participate in equality checks.How tested
node scripts/test-ai-chat-stream-batching.mjspassed; baseline 240 chunks -> 240 visible updates / 240 layout measurements / 267,795 simulated markdown chars, batched burst -> 1 visible update / 1 layout measurement / 2,290 simulated markdown chars.node --test scripts/test-cursor-prompt-stream-batching.mjspassed; baseline 500 chunks -> 500 visible result updates, batched -> 1 visible update, plus final flush/apply-before-visible-flush/cancellation coverage.node --test scripts/test-use-ai-stream-batching.mjspassed; baseline 600 chunks -> 600 visible updates, batched -> 1 visible update, real hook harness -> 3 renders / 1 visible data update, plus final data/error/abort coverage.node --test scripts/test-ai-model-status-polling.mjspassed; unchanged 5-tick baseline -> 15 state updates / 15 commits, coalesced unchanged -> 0 updates / 0 commits, all-changing -> 5 updates / 5 commits.pnpm testpassed on this standalone branch: 40 pass / 1 skipped live Electron test.pnpm run check:i18ncompleted on this standalone branch; it still reports existing Italian locale gaps unrelated to this PR.git diff --check origin/main..HEADpassed.AITab.tsxstill reports existing unrelated diagnostics outside this diff../node_modules/.bin/tsc --noEmit --target ES2020 --module ESNext --moduleResolution bundler --jsx react-jsx --strict --esModuleInterop --skipLibCheck src/renderer/src/utils/ai-chat-stream-buffer.ts src/renderer/src/hooks/cursorPromptResultBatcher.ts src/renderer/src/raycast-api/hooks/use-ai.ts src/renderer/src/settings/aiModelStatusPolling.tspassed.Performance evidence
node scripts/test-ai-chat-stream-batching.mjsbaseline 240 chunks -> 240 visible updates / 240 layout measurements / 267,795 simulated markdown chars, batched burst -> 1 visible update / 1 layout measurement / 2,290 simulated markdown chars.node --test scripts/test-cursor-prompt-stream-batching.mjsbaseline 500 chunks -> 500 visible result updates, batched -> 1 visible update.node --test scripts/test-use-ai-stream-batching.mjsbaseline 600 chunks -> 600 visible updates, batched -> 1 visible update, real hook harness -> 3 renders / 1 visible data update.node --test scripts/test-ai-model-status-polling.mjsunchanged 5-tick baseline -> 15 state updates / 15 commits, coalesced unchanged -> 0 updates / 0 commits, all-changing -> 5 updates / 5 commits.Stack validation
pnpm exec tsc -p tsconfig.renderer.json --noEmit --pretty falsewas run and still fails becauseorigin/mainhas existing renderer typing debt outside this patch area, includingApp.tsx,CameraExtension.tsx, launcher command model/keyboard controls, Raycast runtime files,AITab.tsx, and quicklink icon typing.codex/consolidate-validation-checks(fix(validation): restore project checks) plus this branch:pnpm exec tsc -p tsconfig.renderer.json --noEmit --pretty falsepassed.pnpm testpassed: 41 pass / 1 skipped live Electron test.pnpm run check:i18npassed.git diff --check codex/consolidate-validation-checks..HEADpassed.Replaces