Repository navigation
Cap automation threads at the newest 20 per automation (#134) - #216
Merged
currentbits merged 2 commits intoAug 17, 2026
Merged
Conversation
Automation fires mint a new thread each time with no cleanup. Stamp automationId on createThread and purge older ones after each run, skipping live, pinned, and worktree threads.
The retention commit moved the only threads:changed broadcast past startRun, so a long automation run left its thread invisible in the sidebar until it finished. Broadcast at creation as before, and again after the prune so deleted rows disappear. Co-Authored-By: Claude Opus 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/automations-mint-a-new-thread-on-every-f-9a04e0
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.
Fixes #134.
Why
runAutomationcalledservices.createThread()on every fire and nothing ever removed those threads. One hourly automation mints ~24 threads/day, ~8,700/year, each with its own transcript in the single-JSON store — and every debounced save re-stringifies the whole blob. Nothing here needs user action, so the store grew monotonically for a user who deletes nothing.store.jshad per-thread caps (MAX_MESSAGES_PER_THREAD,MAX_WORKLOG_ITEMS_PER_THREAD) but no cap on the number of threads.What changed
electron/services.js—createThreadaccepts an optionalautomationIdand stamps it on the thread (nullon hand-made threads). No store migration:migrateThreadspreads...t, so the field survives load and is simply absent on old rows.electron/automations.js—runAutomationtags the thread it mints withauto.idand, afterstartRunsettles, prunes that automation's threads down to the newestMAX_THREADS_PER_AUTOMATION(20) viaservices.purgeThread, which also drops the thread'smessagesByThread/workLogByThread/ usage entries.working, worktree-backed, or pinned. Skipped threads still occupy a keep slot, so the cap is not silently exceeded to compensate.lastErroror fail the fire.threads:changedis broadcast at thread creation as before (a long run should not leave its thread invisible in the sidebar) and again after the prune so deleted rows disappear.Tests
Four cases added to
electron/test/automations.test.js: the cap holds and keeps the newest threads, purged transcripts are gone frommessagesByThread, live/pinned/worktree threads survive, and other automations plus hand-made threads are untouched.npm run test:electron805/806,npm run test:renderer716/716,npm run typecheckclean. The single electron failure (wireClient x webBridge over a real socket) fails onmaintoo and is unrelated.Deliberately not done
No settings knob for the retention number and no global thread-count cap. An audit of every other programmatic thread-minting path found one more unbounded case — orchestrator fork threads are archived but never deleted — tracked separately in #213.
🤖 Generated with Claude Code