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
Cap transcript growth and stop whole-store synchronous stringify on flush #89
electron/store.js:613-632 — appendMessage/appendWorkLog never cap transcript size. electron/runner.js:854 already admits "the largest threads are megabytes". saveNow (store.js:579-580) does a synchronous JSON.stringify of the entire blob plus writeFileSync on every flush, and lastPushByThread in runner.js:860 retains full message arrays per thread for the process lifetime. A few heavy long-lived threads will progressively stall the main process during active runs.
Options: per-thread retention cap (drop/compact old messages), per-thread store files so a flush only writes the dirty thread, or async stringify/write off the event loop.
Per-thread retention caps in electron/store.js: 1000 messages / 500 work-log items per thread, with overflow slack (100/50). Appends may overshoot the cap by the slack; crossing cap + slack drops the oldest entries back to the cap and plants a single event marker so the gap is visible in the transcript. The slack amortizes the index-shifting drop (it breaks the runner's prefix diff, forcing one full transcript push) over ~100 appends instead of every append.
Async debounced flush: save()'s debounced flush now stringifies once (bounded by the caps) and writes tmp-then-rename via fs.promises, off the event loop. saveNow() stays synchronous for the exit hook / shutdown / tests, and a write-generation counter keeps an in-flight async flush from renaming a stale payload over a saveNow(). Flush failures re-mark dirty and retry instead of throwing async.
lastPushByThread (runner.js) retains shallow slices that share element refs with the store; with the caps its per-thread footprint is now bounded. Comments updated.
Also armed the process exit hook once instead of registering one listener per save() call.
Not taken: per-thread store files (the heavier option). The stringify itself still runs on the main thread but is now bounded by the caps.
Tests: cap boundary at cap+slack untouched, marker shape / single-marker-on-append, work-log cap, coalesced async flush, stale async flush never overwrites a saveNow(). Electron suite: 767/768; the one failure (budget-spend.test.js settings shape, missing notifications key) is pre-existing on master from the #87 work, unrelated.
Activity
currentbits commentedon Aug 16, 2026
Implemented:
electron/store.js: 1000 messages / 500 work-log items per thread, with overflow slack (100/50). Appends may overshoot the cap by the slack; crossing cap + slack drops the oldest entries back to the cap and plants a singleeventmarker so the gap is visible in the transcript. The slack amortizes the index-shifting drop (it breaks the runner's prefix diff, forcing one full transcript push) over ~100 appends instead of every append.save()'s debounced flush now stringifies once (bounded by the caps) and writes tmp-then-rename viafs.promises, off the event loop.saveNow()stays synchronous for the exit hook / shutdown / tests, and a write-generation counter keeps an in-flight async flush from renaming a stale payload over asaveNow(). Flush failures re-mark dirty and retry instead of throwing async.lastPushByThread(runner.js) retains shallow slices that share element refs with the store; with the caps its per-thread footprint is now bounded. Comments updated.save()call.Not taken: per-thread store files (the heavier option). The stringify itself still runs on the main thread but is now bounded by the caps.
Tests: cap boundary at cap+slack untouched, marker shape / single-marker-on-append, work-log cap, coalesced async flush, stale async flush never overwrites a
saveNow(). Electron suite: 767/768; the one failure (budget-spend.test.jssettings shape, missingnotificationskey) is pre-existing on master from the #87 work, unrelated.Merge pull request #121 from currentbits/coder/cap-transcript-growth-…