Skip to content

Fix transcript replacements racing chat publication - #25965

Merged
nwparker merged 1 commit into
mainfrom
nwparker/transcript-drain-boundary
Oct 6, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/transcript-drain-boundary

Conversation

@nwparker

@nwparker nwparker commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Chat can keep showing an old conversation when its transcript is rewritten during an update. This fixes the missed replacement and the underlying CI failure.

What Changed

The watcher previously read its saved fingerprint from the live file after publishing messages. A larger rewrite during publication paired the old cursor with the replacement's bytes, so the next pass skipped the new conversation. Both readers now retain the bytes they actually consumed. Snapshot continuation goes through the same replacement check before reading more.

Watcher tests now unsubscribe even after a failed assertion, preventing the leaked watcher from causing the next test to fail. The rendered regression reuses the existing Claude transcript fixture.

Why

The cursor and its fingerprint must describe the same read. Retrying CI or lengthening the timeout would leave messages missing. Retaining at most 64 owned bytes fixes that invariant and removes the extra read after publication, without adding timers or polling.

Linked Issue

Discovered in the unit shard failure on main-based picker CI. The larger in-place replacement test timed out; its leaked watcher then caused the following test to fail.

Visual Proof

Same hidden Electron test and real transcript file, with the larger rewrite forced exactly when the host publishes the original snapshot. Host reading, IPC delivery and chat rendering run normally. A seeded Claude session keeps this hermetic; no real agent or message send is involved.

Before: main keeps the original conversation.

Original transcript remains visible

After: the replacement appears.

Replacement transcript is rendered

The identical rendered test fails on main and passes three consecutive times with the fix. It also checks that a subsequent ordinary append appears exactly once.

Testing

  • Locally validated rendered behavior in hidden Electron on macOS.
  • Added deterministic rewrite regressions for append, initial snapshot and replacement snapshot publication, plus independent 64-byte allocation checks.
  • Full native-chat suite: 322 files, 2,852 tests passed.
  • Focused reliability command: 32 tests passed. New and existing first-flush rendered tests: 6/6 passed across three runs.
  • Full typecheck, full oxlint, changed-code quality, reliability manifest and Electron build passed.
  • Full PR CI passed: all five unit shards, relay integration, both rendered regressions, Linux/Windows packaging and final verification gates.

Review

The new experimental native-chat.transcript-consumed-boundary gate records the publication race, delivery/cleanup oracle and resource budget. The shared host reader keeps existing WSL filesystem routing and wire shapes. Actual local Claude JSONL/Electron coverage is proven; physical SSH/WSL/runtime hosts and interactive Windows behavior remain coverage gaps. CI also passes both rendered regressions on Linux. Arbitrary concurrent multi-chunk overwrites are outside this focused gate.

Agent skill upstream boundary

  • Not applicable; no upstream skill implementation copied.

Notes

No new subprocesses, polling or transport fields. One independently owned fingerprint allocation of at most 64 bytes per cursor.

Checklist

  • Small, focused root-cause fix.
  • Explained user-visible behavior, mechanism and choice of approach.
  • Before/after visual proof attached.
  • Self-reviewed correctness and resource ownership.
  • Cross-platform and remote-host impact considered, with coverage gaps stated.
  • Local checks and full PR CI passed, including packaging and all test shards.

@nwparker
nwparker merged commit 40f0319 into main Oct 6, 2026
36 checks passed
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