Skip to content

perf(ai): batch chat stream updates#492

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

perf(ai): batch chat stream updates#492
JustYannicc wants to merge 1 commit into
SuperCmdLabs:mainfrom
JustYannicc:codex/perf-ai-chat-stream-batching

Conversation

@JustYannicc

Copy link
Copy Markdown
Collaborator

Summary

  • Batch AI chat streaming message visibility through a 40ms stream buffer instead of updating React state for every chunk.
  • Keep the authoritative assistant response in the buffer and force a flush before completion, error handling, cancellation, and mode transitions.
  • Add a focused stream batching harness that records update/render-work counts and covers scheduled streaming, final completion flush, and error flush persistence.

Metrics

Focused harness: node scripts/test-ai-chat-stream-batching.mjs

Mode Chunks Visible updates Layout measurements Simulated markdown reparse chars Elapsed
Unbatched baseline 240 240 240 267,795 0.055ms
Batched burst 240 1 1 2,290 0.094ms

Baseline was first captured before the production hook change with 240 visible updates for 240 chunks.

Validation

  • node scripts/test-ai-chat-stream-batching.mjs passed.
  • node --test 'scripts/test-*.mjs' passed: 25 pass, 1 skipped live Electron test.
  • ./node_modules/.bin/tsc --noEmit --target ES2020 --module ESNext --moduleResolution bundler --jsx react-jsx --strict --esModuleInterop --skipLibCheck src/renderer/src/hooks/useAiChat.ts src/renderer/src/utils/ai-chat-stream-buffer.ts passed.
  • ./node_modules/.bin/vite build passed.
  • node scripts/check-i18n.mjs completed; it still reports existing Italian locale gaps for settings.ai.whisper.vocabulary and settings.extensions.appSearchScope.

Notes

  • Whole-repo tsc --noEmit still fails on existing unrelated diagnostics outside this change.
  • Local pnpm test was blocked by pnpm build-script approval; the underlying package test command was run directly with node --test 'scripts/test-*.mjs'.

@JustYannicc JustYannicc changed the title [codex] Batch AI chat stream updates perf(ai): batch chat stream 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