Repository navigation
Cap per-thread transcripts and flush the store off the event loop (fixes #89) - #121
Merged
currentbits merged 1 commit intoAug 16, 2026
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/cap-transcript-growth-and-stop-whole-sto-ecb01d
branch
October 3, 2026 16:07
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.
Why
A few heavy long-lived threads progressively stalled the main process during active runs (#89, found in the 2026-08-16 improvement audit):
appendMessage/appendWorkLognever capped transcript size, so the one-JSON-blob store grew to megabytes.writeFileSyncon the event loop.lastPushByThreadin the runner retained per-thread message arrays, unbounded, for the process lifetime.What changed
electron/store.js): 1000 messages / 500 work-log items per thread, with overflow slack (100/50). Crossing cap + slack drops the oldest entries back to the cap and plants a singleeventmarker so the gap is visible in the transcript instead of silent. The slack amortizes the index-shifting drop, which breaks the runner's prefix diff and forces one full transcript push, over ~100 appends instead of every append. The renderer already merges shrinking transcripts correctly (src/threadPatch.ts).save()'s flush now stringifies once per burst (bounded by the caps) and writes tmp-then-rename viafs.promises, off the event loop.saveNow()stays synchronous for the exit hook, shutdown and tests. A write-generation counter keeps an in-flight async flush from renaming a stale payload over asaveNow(); stale tmp files are discarded. Flush failures re-mark dirty and retry instead of throwing async.lastPushByThread(electron/runner.js): retains shallow slices sharing element refs with the store, so with the caps its per-thread footprint is bounded. Comments updated.save()call.Not taken: per-thread store files (the heavier option from the issue). The stringify itself still runs on the main thread but is now bounded by the caps; if profiling shows it again, per-thread files are the next step.
Tests
saveNow().budget-spend.test.jssettings shape, missingnotificationskey) reproduces on the clean base and is pre-existing from the Desktop-notification preference: global toggle and per-thread mute #87 work, unrelated to this change.Docs: decision logged in
docs/ISSUES.md; Store section ofdocs/ARCHITECTURE.mdupdated.