Skip to content

userData image stores (tool-images/, attachments/) are never pruned; reads are sync base64 on the main thread #145

Closed

Description

@currentbits

Problem

electron/tool-images.js:8-9 and electron/attachments.js:91-92 both admit in comments that nothing is ever pruned. Reads are synchronous whole-file base64 conversions on the main thread: tool-images.js:91-92, attachments.js:133-136 (up to MAX_IMAGE_BYTES = 20MB, about 27MB of base64 per IPC reply).

Impact

Disk usage grows monotonically with every screenshot and paste, and opening a thread with several large images blocks the main process on multi-MB readFileSync + base64 per image per render. The sync reads feed into the main-thread stall cluster of #124.

Fix direction

  • Prune images for archived/deleted threads (and a global size cap).
  • Serve images over a file:// or custom protocol handler instead of base64 over IPC, or at least read them async.

Activity

  1. added
    bug
    plan:todo
    on Aug 16, 2026
  2. currentbits commented on Aug 20, 2026

    @currentbits
    OwnerAuthor

    Folding in #625, which was filed for this same defect from a live disk inventory (closed as duplicate).

    Measured on the daily driver 2026-08-20:

    worktrees               27.6 GB   owned by GC (#316/#559)     ok
    coder-store.json.bak       177 MB no owner
    coder-store.json           163 MB per-thread caps (#89), aggregate unbounded (#225)
    memory.db                   44 MB memory-server janitor
    tool-images                 28 MB no owner
    attachments                  5 MB no owner
    

    tool-images grew 19 MB / 114 files -> 28 MB / 159 files in one day, roughly +9 MB/day under normal use.

    The shortcut comment at electron/tool-images.js:8-9 gates the decision on two premises and both have expired:

    // ponytail: files are never pruned - a screenshot is ~200KB and nothing else
    // in userData is pruned either. Add an age sweep on boot if it ever grows.

    "nothing else in userData is pruned either" was true when written (2026-08-15) and false since #559 shipped worktree retention. "if it ever grows" - it grew. electron/attachments.js:92 carries the same note without even the trigger condition.

    33 MB next to 27.6 GB of worktrees is a rounding error in absolute terms; the point is that it is unbounded and has no owner. This issue keeps its second, separate half (sync readFileSync + base64 on the main thread) as well.

  3. added
    plan:doing
    and removed
    plan:todo
    on Aug 22, 2026
  4. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Implementing on this issue (plan:doing).

    Prune (no archived-transcript hydrate):

    • New tool images land in tool-images/<threadId>/ (legacy flat files still read).
    • Drop tool-images/<tid>/ and attachments/<tid>/ when the thread is archived or gone.
    • Legacy flat files: delete if not referenced by a live thread (hydrate live threads only).
    • Global cap 512MB, oldest files first, after the thread pass.
    • Runs on boot (15s sweep), archive, delete, remove-project, automation thread prune.

    Reads (stop sync base64 on the main thread):

    • Desktop: solenta-media:// protocol, net.fetch of the file, CSP img-src updated. IPC returns the URL after a cheap access(), no base64.
    • Web: same IPC, serveDataUrls so the handler readFiles async and still replies with a data URL.

    Unarchive does not restore deleted bytes.

  5. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Landed in this worktree.

    • Prune: archived/deleted thread dirs under tool-images/ and attachments/, plus unreferenced legacy flat files (live transcripts only), plus a 512MB oldest-first cap. Runs on boot (15s sweep), archive, delete, remove-project, automation prune.
    • Desktop reads: solenta-media:// protocol (net.fetch of the file). IPC returns the URL after access(), no base64.
    • Web reads: same handlers, serveDataUrls so they readFile async and still reply with a data URL.

    New tool images are stored as tool-images/<threadId>/<uuid>.png. Unarchive does not restore deleted bytes.

  6. added
    plan:done
    and removed
    plan:doing
    on Aug 22, 2026
  7. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Landed from Solenta thread "Fork: userData image stores (tool-images/, attachments/) are". Closed on merge.

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