Skip to content

Crash recovery hydrates working-thread transcripts at boot (#639 leftover) #643

Closed

Description

@currentbits

Parent: #639 lazy-hydrates messagesByThread so boot does not JSON.parse transcripts.

recoverInterruptedRuns (electron/store.js) still does data.messagesByThread[t.id] for every thread with status === working. That goes through the lazy proxy and hydrates the full array before appending the crash event. A force-quit with N in-flight runs reintroduces N JSON.parse of transcript blobs on the next boot.

Plan

  • Append the crash event onto the lazy JSON range (string splice before ]) without parsing the array.
  • Fall back to a tiny hydrated [event] only when the thread has no lazy range.
  • Keep lazy.intact when the splice lands in the existing raw blob so the first save does not skip-scan every transcript.

Tests

  • Lazy fixture with a working thread and a large tool payload must not JSON.parse that payload during Store construct.
  • Thread stays unhydrated; getMessages later includes the crash event; sibling idle threads stay lazy.
  • Two working threads (range shift) + save/reload persist the event.

Live store is ~/Library/Application Support/Solenta/coder-store.json — read-only.

Activity

  1. added
    plan:doing
    plan:done
    and removed
    plan:doing
    on Aug 21, 2026
  2. currentbits commented on Aug 21, 2026

    @currentbits
    OwnerAuthor

    Implemented on coder/fork-fork-fork-boot-600-ms-synchronous-j-f9107c (on top of the #639 lazy-hydrate checkpoint).

    recoverInterruptedRuns no longer reads data.messagesByThread[id] (that hydrates via the proxy). It splices the crash event onto the lazy JSON range with appendJsonArrayItem and keeps lazy.intact, so the first save does not skip-scan every transcript. Missing-key threads get a tiny hydrated [event].

    Tests: 70 pass (store + json-envelope + threads-summaries), including two working threads with 8 KB tool canaries that must not be JSON.parsed during Store construct.

    Live store (read-only, envelope only): 194 MB, 626 threads, 2 currently working. Envelope parse ~15 ms. Did not construct Store against the live file.

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

    @currentbits
    OwnerAuthor

    Audit 2026-08-22: not on main. appendJsonArrayItem does not exist in the tree — the fix is still only on coder/fork-fork-fork-boot-600-ms-synchronous-j-f9107c. Relabelled plan:doing.

  5. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Landed on main in the 2026-08-22 backlog merge (2d33d30..bf7c4dc), as part of the #639 lazy-hydrate branch.

    Evidence on main: recoverInterruptedRuns(store, data) (electron/store.js:1013) now calls store._appendLazyMessage() (store.js:1286), which splices the crash-recovery message into the raw JSON range instead of hydrating the transcript. The comment at store.js:1007 cites this issue directly.

  6. added
    plan:done
    and removed
    plan:doing
    on Aug 22, 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

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions