Skip to content

perf(cursor-prompt): batch streaming result updates#504

Closed
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-cursor-prompt-stream-batching
Closed

perf(cursor-prompt): batch streaming result updates#504
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-cursor-prompt-stream-batching

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

What changed

  • Added a cursor prompt result batcher that appends streamed chunks to the authoritative result ref immediately, then flushes the visible React state with requestAnimationFrame or a short timer fallback.
  • Wired useCursorPrompt to force-flush on stream done/error, cancel pending repaints on close/unmount, and keep reset behavior clearing the refs used by apply/finalization.
  • Added focused streaming simulation coverage for baseline behavior, frame coalescing, final flush, apply-before-visible-flush, and cancellation cleanup.

Why

Long Cursor Prompt responses previously updated visible state once per streamed chunk even though apply/finalization already read from refs. That could cause unnecessary renderer churn during large streams. Batching preserves the streaming preview while reducing visible state updates to frame cadence.

Compatibility impact

No IPC, public hook shape, or i18n changes. Apply still reads the authoritative ref, stream completion/error forces the final visible flush, and cancellation still stops in-flight requests while avoiding a hidden prompt repaint.

How tested

  • Baseline before production edit: focused simulation reported 500 visible result updates for 500 chunks.
  • node --test scripts/test-cursor-prompt-stream-batching.mjs: batched path reported 1 visible result update for 500 chunks; final flush, apply-before-flush, and cancellation tests passed.
  • node --test scripts/test-*.mjs: passed 29 tests, skipped 1 live Electron test because Electron is not launchable here.
  • node scripts/check-i18n.mjs: exited 0; reported existing Italian locale gaps in settings.ai.whisper.vocabulary and settings.extensions.appSearchScope.
  • Codex LSP diagnostics on changed TypeScript files: no errors. Broader renderer scan found existing unrelated errors in App.tsx, CameraExtension.tsx, QuickLinkManager.tsx, SnippetManager.tsx, and LiquidGlassSurface.tsx.
  • node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js run build:main: passed.
  • node /opt/homebrew/lib/node_modules/npm/bin/npm-cli.js run build:renderer: passed with Vite CJS API and stale Browserslist warnings.

@JustYannicc JustYannicc changed the title [codex] Batch cursor prompt stream updates perf(ai): batch cursor prompt stream updates Jul 3, 2026
@JustYannicc JustYannicc changed the title perf(ai): batch cursor prompt stream updates perf(cursor-prompt): batch streaming result updates Jul 3, 2026
@JustYannicc

Copy link
Copy Markdown
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.

@JustYannicc JustYannicc closed this Jul 3, 2026
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.

1 participant