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
Boot: ~600 ms synchronous JSON.parse of the 183 MB store blocks the main process before first paint #639
Measured on the live machine (2026-08-21, nightly): replaying the store load in node against the real coder-store.json (183 MB) costs 19 ms read + 581 ms JSON.parse — all synchronous on the main process. Store constructs with this.data = this._load() (electron/store.js:1019) → _readFile does readFileSync + JSON.parse (store.js:1032-1033) before any IPC handler can answer.
#618 reorders createWindow vs the boot chain, but even with the window up, the renderer's first real data (threads:list) still waits on this parse. And the cost grows with the store: +18-20 MB/week (~10%/week) on this machine.
Composition, for sizing the fix: 162 MB of the 181 MB of messagesByThread is the tool field (~70k tool-call records, each already truncated to 2 KB input / 4 KB output at write). Message text is only 9 MB total. So the parse cost is almost entirely transcript volume the sidebar never reads.
Fix direction (independent of, and much smaller than, #225 sharding):
Parse the envelope (threads, projects, settings, …) at boot; lazy-hydrate each thread's message array on first threads:get for that thread. The sidebar and Agents tab need only the envelope.
Or move the parse to a worker thread and unblock the IPC loop.
Acceptance: time-to-first-interactive-paint no longer scales with total transcript volume; boot parse of the threads-only envelope stays under ~50 ms at current size.
Implemented on this branch: boot now JSON.parse's the envelope (~1.6 MB, 5–17 ms on the live 193 MB store) instead of the whole blob (332 msJSON.parse).
electron/jsonEnvelope.js cuts messagesByThread out by walking the prefix until that key, then lastIndexOf of sibling keys (workLogByThread, settings, …). It does not skip-scan 191 MB of transcripts.
Each thread's array is JSON.parse'd on first getMessages / threads:get. getLastAssistantMessage peeks the raw array so threads:summaries does not hydrate tool payloads.
A hydrate-only session reuses the original messages JSON on save. First mutating save indexes the raw slice so unhydrated threads splice back in.
New saves emit messagesByThread last so the next boot takes the last-key path.
Independent of #225 (per-thread files still wanted for flush CPU/disk). Acceptance: envelope parse no longer scales with transcript volume; measured well under 50 ms at current size.
Follow-up on this branch (coder/fork-fork-boot-600-ms-synchronous-json-p-ce848d): Agents-tab threads:summaries no longer peeks/hydrates messagesByThread.
Persist lastAssistantPreview: { text, at } | null on the thread row at setMessages / appendMessage.
Load-migrate rows that lack the field by peeking (not hydrating); persist so later boots stay envelope-only.
threadSummaries reads only that envelope field.
Tests: summaries after reload without getMessages; appendMessage updates the preview; blank assistant falls through.
Live store (read-only, 2026-08-21): 194 MB, 624 threads, envelope parse ~14 ms. First upgrade still skip-scans once (~270 ms) to fill the field; after persist, boot does not.
Follow-up #644 defers the first-upgrade lastAssistantPreview peek off Store construct so time-to-first-paint stays envelope-only. Implemented on coder/fork-fork-fork-boot-600-ms-synchronous-j-3f0c95.
Landed on main in the 2026-08-22 backlog merge (2d33d30..bf7c4dc, released as nightly nightly-202608220926-bf7c4dc).
Evidence on main: electron/jsonEnvelope.js; messagesByThread hydrates lazily per thread
The branch had been finished for a while but was never merged; verification after landing: typecheck clean, vite build ok, core 38/38, renderer 1468/1468, memory 204/204, electron 1848/1848.
Activity
currentbits commentedon Aug 21, 2026
Implemented on this branch: boot now JSON.parse's the envelope (~1.6 MB, 5–17 ms on the live 193 MB store) instead of the whole blob (332 ms
JSON.parse).electron/jsonEnvelope.jscutsmessagesByThreadout by walking the prefix until that key, thenlastIndexOfof sibling keys (workLogByThread,settings, …). It does not skip-scan 191 MB of transcripts.JSON.parse'd on firstgetMessages/threads:get.getLastAssistantMessagepeeks the raw array sothreads:summariesdoes not hydrate tool payloads.messagesByThreadlast so the next boot takes the last-key path.Independent of #225 (per-thread files still wanted for flush CPU/disk). Acceptance: envelope parse no longer scales with transcript volume; measured well under 50 ms at current size.
currentbits commentedon Aug 21, 2026
Follow-up on this branch (
coder/fork-fork-boot-600-ms-synchronous-json-p-ce848d): Agents-tabthreads:summariesno longer peeks/hydratesmessagesByThread.lastAssistantPreview: { text, at } | nullon the thread row atsetMessages/appendMessage.threadSummariesreads only that envelope field.Tests: summaries after reload without
getMessages; appendMessage updates the preview; blank assistant falls through.Live store (read-only, 2026-08-21): 194 MB, 624 threads, envelope parse ~14 ms. First upgrade still skip-scans once (~270 ms) to fill the field; after persist, boot does not.
currentbits commentedon Aug 21, 2026
Follow-up #644 defers the first-upgrade lastAssistantPreview peek off Store construct so time-to-first-paint stays envelope-only. Implemented on
coder/fork-fork-fork-boot-600-ms-synchronous-j-3f0c95.currentbits commentedon Aug 22, 2026
Landed on
mainin the 2026-08-22 backlog merge (2d33d30..bf7c4dc, released as nightlynightly-202608220926-bf7c4dc).Evidence on main: electron/jsonEnvelope.js; messagesByThread hydrates lazily per thread
The branch had been finished for a while but was never merged; verification after landing: typecheck clean,
vite buildok, core 38/38, renderer 1468/1468, memory 204/204, electron 1848/1848.