Skip to content

Automations mint a new thread on every fire; the store grows without bound #134

Closed

Description

@currentbits

Problem

electron/automations.js:108 (runAutomation) calls services.createThread() each time an automation fires. Nothing ever archives or deletes these threads. electron/store.js has caps only for per-thread lists (MAX_MESSAGES_PER_THREAD, store.js:165); there is no cap on the number of threads, messagesByThread keys, or any pruning of old threads anywhere.

Impact

One hourly automation = 24 threads/day, roughly 8,700/year, each with its own transcript. Every debounced save re-stringifies the entire blob, and sidebar/search/summaries scale with total threads. The store file grows monotonically even for a user who deletes nothing, and automation threads are the worst case because the growth needs zero user action. This feeds directly into the store-size pain of #124.

Fix direction

Activity

  1. added
    bug
    plan:todo
    plan:doing
    plan:done
    and removed
    plan:todo
    plan:doing
    on Aug 16, 2026
  2. currentbits commented on Aug 17, 2026

    @currentbits
    OwnerAuthor

    Fixed on branch coder/automations-mint-a-new-thread-on-every-f-9a04e0 (awaiting the worktree merge).

    • createThread now takes an optional automationId and stamps it on the thread (electron/services.js). No store migration: migrateThread spreads ...t, and absent = falsy on old rows.
    • runAutomation tags the thread it mints and, after startRun settles, purges everything past the newest 20 for that automation (MAX_THREADS_PER_AUTOMATION), skipping threads that are working, worktree-backed, or pinned. Skipped threads still occupy a keep slot. purgeThread drops the messagesByThread / workLogByThread / usage entries with the row.
    • Prune has its own try/catch: a retention failure never stamps lastError or fails the fire.

    Tests: 4 new cases in electron/test/automations.test.js (cap holds and keeps the newest, purged transcripts are gone, live/pinned/worktree threads survive, other automations and hand-made threads untouched). npm run test:electron 805/806, npm run test:renderer 716/716, npm run typecheck clean. The single electron failure (wireClient x webBridge over a real socket) fails on main too, unrelated.

    Not done, deliberately: no settings knob for the retention number, and no global thread-count cap — the other unbounded minter (orchestrator fork threads) is #213.

  3. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions