You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generic provider stream path writes the store and pushes IPC per raw stdout chunk, unthrottled #640
The generic provider's onChunk (electron/runner.js:2333-2347) runs on every raw stdout data event — arbitrary byte-boundary chunks, dozens per second on a fast stream — and each chunk does:
store.updateMessage(threadId, assistantMsgId, { text }) — copy-on-write: getMessages().slice() + findIndex + setMessages over the whole message list (electron/store.js:1851-1858)
store.save() (arms the flush debounce — fine on its own)
pushDetail(threadId, realState) — full getThreadDetail (another getMessages().slice()), a firstChanged rescan of messages + workLog, and an IPC thread:updated to the renderer
The codex (runner.js:3762 throttledPush) and kimi/opencode (runner.js:4142) stream paths already coalesce with a trailing-edge throttle; the generic path never got it. For a capped thread (1000+ messages) every chunk is several O(messages) array passes plus a renderer round-trip, purely to append a few characters.
Fix: route the generic onChunk through the same throttledPush-style coalescer (batch the in-memory text update to one store write + one push per ~100-150 ms window, with a final flush on onDone). Behaviour should be visually identical; the store-write and IPC rate stops tracking stdout chunking.
Generic onChunk now goes through the same 250ms leading+trailing coalescer as kimi/opencode: pending text is applied in one updateMessage + pushDetail per window, with a final flush on onDone and on clearRun (stop/error/quit) so a delayed write cannot drop the last characters.
Tests in electron/test/runner.test.js (generic onChunk throttle (#640)): 20 sync chunks → ≤2 store writes and ≤3 assistant thread:updated tails; stop still lands the full text.
Activity
currentbits commentedon Aug 22, 2026
Generic
onChunknow goes through the same 250ms leading+trailing coalescer as kimi/opencode: pending text is applied in oneupdateMessage+pushDetailper window, with a final flush ononDoneand onclearRun(stop/error/quit) so a delayed write cannot drop the last characters.Tests in
electron/test/runner.test.js(generic onChunk throttle (#640)): 20 sync chunks → ≤2 store writes and ≤3 assistantthread:updatedtails; stop still lands the full text.