Skip to content

debug(#283): instrument transcriptStatus transitions + suspected drop points - #296

Closed
Juliusolsson05 wants to merge 1 commit into
mainfrom
fix/283-transcript-status-diagnostics
Closed

Juliusolsson05 wants to merge 1 commit into
mainfrom
fix/283-transcript-status-diagnostics

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

What this is

Diagnostic instrumentation for #283 — not the fix. This is the "separate PR" the issue's own Status section calls for: every on-paper ordering preserves the session id, so the stuck-at-loading interleaving needs a runtime timeline before fixing at source.

Background (#283)

On startup (rehydrate) and on resuming a killed session, a pane can stay stuck at transcriptStatus: 'loading' forever; a manual reload unsticks it. Two write paths can each silently drop an in-flight initial-history load's terminal status write:

  1. loadInitialHistoryForSession writes 'loading' unconditionally (prev[id] ?? emptyRuntime()) but writes the terminal 'ready'/'error' only inside if (!current) return prev. If the runtime entry is dropped or re-keyed (idMap remap) while the load awaits IPC, the terminal write hits a missing key and is thrown away — the surviving runtime stays 'loading'.
  2. commitRehydratedState rebuilds the runtimes map from a fresh out = {} and forces any non-ready/error status back to 'loading' for sessions with a providerSessionId. If no loader then drives it to 'ready', the pane is parked — exactly "stuck until manual reload" (reload re-invokes the loader under a stable id).

What it adds

  • transcriptStatusTrace.ts (new): traceTranscriptStatus appends a STATE / transcript_status entry (from -> to @ site) per transition into the existing per-session feed-debug.jsonl — the channel the issue reporter already reads. No parallel log system (consistent with Consolidate debug infrastructure into one home, remove ad-hoc console.* scatter, enforce a typed logger boundary #102's "one debug home"). Two console warns tag the discard and force-to-loading paths with greppable [transcript-stuck][283].
  • initialHistory.ts: trace all four status writes; warn on both !current bails before they swallow the terminal write.
  • rehydrate.ts: warn when the rebuild drops a still-loading old key on re-key, or forces a providerSessionId session back to loading.

Safety

Diagnostic only — no behavior change. Renderer-only; typechecks clean (tsconfig.web.json, 0 errors in touched files). Reproduce once, read the timeline (feed-debug.jsonl transcript_status series + [transcript-stuck][283] console lines), then fix at source and delete this instrumentation.

🤖 Generated with Claude Code

…ted drop points

Stuck-at-'loading' on startup/resume could not be root-caused on paper —
every ordering traced preserved the session id — so this adds the timeline
the issue's "Status" section asked for before fixing at source.

Two write paths can each silently drop an in-flight initial-history load's
terminal status write:

  1. loadInitialHistoryForSession writes 'loading' unconditionally but writes
     'ready'/'error' only inside `if (!current) return prev`. A drop/re-key of
     the runtime entry mid-await discards the terminal write.
  2. commitRehydratedState rebuilds runtimes from a fresh `out = {}` and forces
     non-ready/error back to 'loading'; if no loader then drives it, the pane
     is parked at 'loading'.

Instrumentation:
  - transcriptStatusTrace.ts: traceTranscriptStatus appends a STATE
    `transcript_status` feed-debug entry (from -> to @ site) per transition,
    reusing the existing per-session feed-debug.jsonl channel (no parallel
    log system, per #102). Two console warns flag the discard (`!current`
    bail) and the rehydrate force-to-loading paths with a greppable
    `[transcript-stuck][283]` tag.
  - initialHistory.ts: trace all four status writes; warn on both `!current`
    bails before they swallow the terminal write.
  - rehydrate.ts: warn when the rebuild drops a still-'loading' old key on
    re-key, or forces a providerSessionId session back to 'loading'.

Diagnostic only — no behavior change. Reproduce once, read the timeline,
then fix at source and delete this instrumentation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Juliusolsson05

Copy link
Copy Markdown
Owner Author

Closing as superseded. While this was in flight, #284 (diag(#283): instrument transcript-load lifecycle) merged to main with the same drop-point detection (RESOLVE-DROPPED / ERROR-DROPPED / loading-set / ready-set). Stacking a second overlapping diagnostic isn't worth it. The two genuinely-additive pieces here — a durable transcript_status series in feed-debug.jsonl (vs #284's console-only warns) and rehydrate-rebuild coverage — can be folded into the eventual #283 fix PR if still useful. #283 stays open for the actual fix.

@Juliusolsson05
Juliusolsson05 deleted the fix/283-transcript-status-diagnostics branch June 18, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant