perf(ai): batch Raycast useAI streaming#525
Closed
JustYannicc wants to merge 1 commit into
Closed
Conversation
Collaborator
Author
|
Consolidated into #531, which combines the AI chat streaming, Cursor Prompt streaming, Raycast useAI streaming, and AI status polling performance work in one upstream PR. Closing this superseded scoped PR in favor of the consolidated replacement. |
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
useAI, publishing visibledatawithrequestAnimationFrameor a short timer instead of onesetDatacall per streamed chunk.__supercmdRaycastAI.ask()streams covering the legacy baseline, batched update count, final data,onData, error flush, and abort cancellation.Why
useAIpreviously appended streamed chunks withsetData(prev => prev + chunk). For token-sized streams this creates one visible state update and one growing string copy per chunk. The new test records a 600-chunk legacy baseline at 600 visible updates, while the batched path publishes the same text in 1 visible update and the real hook harness renders 3 times total.Compatibility impact
Raycast
useAIbehavior remains compatible:datastill resolves to the complete final text,onDataremains a final full-text callback,onErrorstill receives request errors, non-streaming mode still sets the full text on completion, and aborted requests do not publish stale pending chunks. No user-facing strings or locale files changed.How tested
__supercmdRaycastAI.ask()legacy stream path innode --test scripts/test-use-ai-stream-batching.mjsreported 600 visible updates for 600 chunks.useAIhook harness reported 3 renders with 1 visible data update.node --test scripts/test-use-ai-stream-batching.mjs: pass, 5 tests.node --test scripts/test-*.mjs: pass on the scopedorigin/mainPR branch, 29 pass / 1 skip../node_modules/.bin/tsc -p tsconfig.renderer.json: pass oncodex/perf-integration-stack; on raworigin/mainit still reports existing unrelated renderer errors outside this PR.Stack validation
This issue was found and validated from
codex/perf-integration-stack, which contains the active performance fix stack. The implementation was first validated there with the focused stream batching tests, renderer typecheck, and the full Node integration stack suite: 134 pass / 1 skip. The upstream PR branch is intentionally scoped againstorigin/mainby cherry-picking only this fix commit.