Repository navigation
Fix transcript replacements racing chat publication - #25965
Merged
Merged
Conversation
12 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
After: the replacement appears.
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
Review
The new experimental
native-chat.transcript-consumed-boundarygate 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
Notes
No new subprocesses, polling or transport fields. One independently owned fingerprint allocation of at most 64 bytes per cursor.
Checklist