Repository navigation
fix(native-chat): retire chat echoes whose transcript row carries the TUI clear byte - #15656
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between e3327c2 and bec15294be0d68656f3a7074af199b6a86c3e548. 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughNative chat text normalization now removes ANSI sequences and terminal control bytes before image-marker detection and whitespace normalization. Tests cover captured Claude transcripts, control-byte preservation during decoding, image-marker handling, and whitespace normalization. Pending-send matching and image ordinal counting now use shared text normalization, with tests for repeated sends, pruning, empty normalized text, leading Ctrl+U bytes, and missing transcript matches. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/shared/native-chat-image-transcript-markers.ts (1)
40-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReduce the incident narratives in code comments.
Keep the reason for control-byte normalization, but use short comments and let test names state the scenario.
src/shared/native-chat-image-transcript-markers.ts#L40-L47: replace the multi-line docblock with a brief statement about stripping controls before marker processing.src/main/native-chat/transcript-line-decoders-claude-control-bytes.test.ts#L8-L12: remove the session narrative and retain only the fixture purpose.src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts#L101-L104: reduce the explanation to the Ctrl+U matching condition.mobile/src/session/mobile-native-chat-pending-retirement.test.ts#L326-L330: remove the incident narrative and retain the reconciliation condition.As per coding guidelines, comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior.
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a267041e-e597-4737-8343-b1643e84fee1
📒 Files selected for processing (5)
mobile/src/session/mobile-native-chat-pending-retirement.test.tssrc/main/native-chat/transcript-line-decoders-claude-control-bytes.test.tssrc/renderer/src/components/native-chat/native-chat-pending-occurrence.test.tssrc/shared/native-chat-image-transcript-markers.test.tssrc/shared/native-chat-image-transcript-markers.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
|
Review loop round 1 — one finding fixed, one declined as out of scope. Fixed (medium):
This is pre-existing, but it was unreachable for mobile-sent rows until this PR — before the control-byte strip those rows never matched anything, so nothing retired. Since the strip makes them match, it had to be fixed here rather than deferred. The desktop sibling already normalizes both sides through Red-then-green in The third case in that file (a single-line repeat, which never regressed) passes in both states, so the assertion is targeted rather than blanket. Re-verified after the fix: Declined (low): the rendered bubble and Copy still carry the byte. Accurate, and I've added it to the "still broken" section. Not fixed here because it is a different surface with a much wider blast radius: the strip would have to go into |
`earlierOutstanding` compared a raw `pending.text.trim()` against the whitespace-collapsed `origin.normalizedText`, so the two never matched for a multi-line send. A repeat then claimed the ordinal its predecessor already held: both echoes carried expectedOccurrence 1, and the first landing row retired both - the user's second bubble vanished before its own row existed. Pre-existing, but unreachable for mobile-sent rows until the control-byte strip made those rows match at all. The desktop sibling already normalizes both sides through nativeChatPendingMatchKey. Found by the review loop on #15656.
A prompt made only of image markers, whitespace, or control bytes normalizes to '' on BOTH sides: the send has nothing to look up, and its own transcript row normalizes to null, so `landedCounts` never records it and the glue matcher skips it. The optimistic bubble pinned at the tail for the life of the session. Record no echo for such a send - the rule slash commands already get, for the same reason. Image echoes keep theirs: their text is empty by design and they reconcile by counting image turns after their tail. Also make the new test's origin helper call countUserTextOccurrences rather than re-implement it, so it cannot pass against a private copy of exactly the normalization this PR is about. Found by the review loop on #15656.
The image ordinal is SELECTED on `origin.normalizedText === ''` but was COUNTED on a raw `pending.text.trim() === ''`. A photo captioned with only `[Image #N]` markers is selected into the image branch yet not counted, so the next caption-less photo is handed an ordinal already taken. Each echo claims one message id in findLandedImagePreviewEchoes, so the second bubble is stranded for the life of the session. Same asymmetry as the repeat-send ordinal two lines above. Also replaces a vacuous assertion in the previous commit's test: it passed `pending[KEY] ?? []` into retirement right after asserting that key was undefined, so it asserted retire([]) === []. It now builds the stranded echo by hand and pins the fact that motivates suppressing it at the source. Found by the review loop on #15656.
The guard traded a stuck bubble for a vanished message. A prompt made only of `[Image #N]` markers renders as `blocks: []` in the transcript too (measured), so suppressing its optimistic echo left the composer cleared and nothing on screen at all - the send looks lost. A bubble pinned at the tail is the softer failure, and mobile has no PENDING_SEND_LIMIT to bound it. The input stays broken either way; the real fix is to stop the row rendering empty, which is a render-path change well outside this PR. Kept as a named KNOWN GAP test so the next reader finds both failure modes documented. The image-echo ordinal normalization from the same round is unaffected and stays - it is an independent, provable fix. Found by the review loop on #15656.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
mobile/src/session/mobile-native-chat-pending-echo.ts (1)
56-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winShorten the new TypeScript comments.
Both comments contain multi-line implementation narratives. Keep one concise line at each site and move the detailed rationale to external review documentation.
mobile/src/session/mobile-native-chat-pending-echo.ts#L56-L59: replace the ordinal explanation with a short invariant.mobile/src/session/mobile-native-chat-pending-echo.test.ts#L104-L109: replace the known-gap analysis with a short statement.Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0fdf6192-7da6-4eb3-83d7-776450251356
📒 Files selected for processing (2)
mobile/src/session/mobile-native-chat-pending-echo.test.tsmobile/src/session/mobile-native-chat-pending-echo.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
Native chat brackets every image path as a paste - buildMobileImagePastePayload writes ESC[200~<path>ESC[201~ into the agent's input line - and an agent without bracketed-paste mode records those markers literally, exactly as it records the bundled Ctrl+U byte. Stripping lone control bytes removed the ESC and stranded the printable tail, so the row normalized to `[200~/tmp/a.png[201~` and the image echo pinned at the tail for the same reason the text echo did. Run stripAnsiEscapeSequences first - the ordering that module's own doc comment requires - then the control strip. Same module, no new dependency. Found by the review loop on #15656.
The comment claimed the strip handles an agent that "records the markers literally", but it only fires when the ESC introducer survived into the row. A TUI that consumes the ESC and echoes just `[200~...[201~` is out of reach on purpose: bare `[200~` is text a user could type. Found by the review loop on #15656.
33ae874 to
bec1529
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Review catch from the peer on #15656. Drainage is evidence that a TEXT match will never arrive, so it must not speak for echoes the count pass deliberately holds. It did: a photo echo and a marker-only caption were both stranded once any later send landed. Both delete content rather than reposition it. An image echo is the only place the photo is visible until its preview rebinds, and a caption of only `[Image #N]` markers has a transcript row that renders empty - so dropping the echo makes the message vanish, which fails harder than the stuck bubble it replaced. Verified both new guards fail against the previous rule.
The peer's #15656 pins escape-sequences-before-control-bytes for the MATCHING normalizer. The display strip repeats that ordering and nothing on this branch held it: `buildMobileImagePastePayload` wraps a path as `ESC[200~<path>ESC[201~`, so taking ESC off as just another control byte strands the printable `[200~` and `[201~` tails in the bubble. Verified load-bearing - reversing the two strips renders `[200~/tmp/photo.png[201~ look at this`.
Manual QA — native chat duplicate echo (PR #15656)Verdict: PASS — both exact flows were exercised at This is a retry after a prior startup-race attach. Identity was re-checked after CDP attach. Identity / platform
Actions (user-visible)Desktop
Mobile
Setup APIs only prepared repo/settings/pairing mint. Sends, tab launch, pairing confirm, and composer input were UI actions (Electron CDP / Visible evidenceDesktop after the desktop send — one user bubble, one Desktop after the mobile send — desktop bubble still once, mobile bubble once, Mobile iPhone 17 Pro Max after the mobile send — mobile multiline bubble once, Accessibility tree on mobile counted Transcript / logs (no secrets)Claude JSONL session
That Ctrl+U prefix is the reported transport byte. Echo retirement matched it, so the optimistic bubble did not stick. The rendered bubble/Copy still carrying the byte is the already-declined out-of-scope gap. Desktop Playwright console: 0 errors. Warnings only (tooltip controlled/uncontrolled, React Grab outdated, one xterm task-queue deadline). Electron log: Claude usage refresh 429 (statusline, not the Code session), ws-transport 6769 in use so OS-assigned port, isolated-profile orchestration recovery Cleanup
Gaps
|
Desktop native chat QA — BLOCKED overallTested PR head PASS — local desktop
BLOCKED — SSH/Linux remote
EvidenceClaude repeated sends (two landed bubbles): Claude unusual characters: Codex repeated sends and unusual characters: Sanitized SSH blocker view: |
Manual QA correction — retract PASS for mobile protocolRetracting the PASS in #15656 (comment). Coordinator enforcement asked for the exact tool that opened the pairing deep link. It was not
Because the pairing deep link was opened with Updated verdict: BLOCKED (mobile protocol). Desktop Electron CDP evidence is unchanged; it is not a substitute for a valid mobile run. No code changed. PR not merged. |
Image attachment regression QA — FAILTested the exact PR head, Desktop Native Chat
Image-only paste: Caption preserved / marker hidden: Two images in one message: Paced interleave passing: Rapid interleave failure (combined text A + image B is visible in the top image bubble): Mobile Native ChatBLOCKED. I created and exclusively targeted an owned simulator ( Verdict
No merge performed. |
Codex revision passRevised the implementation at Changed
Kept and why
Non-vacuity proofTemporarily removing terminal sanitization failed 6 root assertions (including the real decoder path and desktop pending prune) and the mobile acceptance assertion: Temporarily restoring the two raw All neutering was restored before the green run. Verified on Node 24.18.0
Manual QA status is intentionally unchanged: mobile remains BLOCKED after the earlier protocol-invalid PASS was retracted; SSH native chat remains BLOCKED because its transcript was unavailable; zero-delay desktop image/text interleave remains a separate FAIL to route as follow-up work. The residual rendered/clipboard control-byte work remains covered by #16117. |
cfa06a3 to
431a903
Compare
Native mobile QA (send-and-reconcile)Verdict: PASS Platform / device: iOS Simulator, iPhone 17 Pro Max, iOS 26.5 ( Flow exercised
Result
ScreenshotsApp loaded and already paired: Connected native chat before send: After send, reconciled once with no control byte: Local copies (not committed): |
Final review status — readyReviewed and revised at exact head
Residual scope remains documented: marker-only text has a pre-existing reconciliation hole, and the separately reported zero-delay image/text interleave writes a combined authoritative transcript row rather than exercising this duplicate-echo mismatch. Neither was broadened into this focused fix. |
Corrected mobile A/B QA — long multiline paste pathVerdict: PASS with pre-fix contrast. This supersedes the earlier short single-line PASS in #15656 (comment). That send did not prove the bracketed-paste defect. Environment
Same-shaped trigger payloadBoth builds received a 26-line mobile native-chat message: Current PR head — PASSCommit:
Requested base control — FAILS pre-fixCommit:
This control demonstrably fails before the fix and passes on the PR head, exercising the actual multiline paste path rather than a vacuous typed-send path. Cleanup: Metro sessions stopped, screenshots were not committed, and the QA worktree was restored clean to branch |
A mobile send that Claude Code takes off its queue mid-turn is recorded only as `queue-operation` + `queued_command` attachment records — never a `type:"user"` row. Confirmed against the live session JSONL behind the report: the two sends that DID land carry the Ctrl+U byte (fixed by #15656), while the third was enqueued and `remove`d with no user record written at all. The decoder publishes nothing for those records, so that echo has no landing to match and never retires. Because pending renders at the tail, it replays below every turn that follows and the conversation reads as re-ordered — the reported symptom, exactly three stale bubbles. Retire an echo once the queue has drained past it: every send issued after it has been accounted for. That is positive evidence rather than a timer, so it can never drop a send whose row is merely slow, and it leaves the glue barrier case alone because a later send is still outstanding there. Also take the same transport bytes out of user turns for DISPLAY, so the bubble shows — and Copy yields — what was typed rather than invisible terminal machinery, reusing the strip #15656 introduced for matching.
Review catch from the peer on #15656. Drainage is evidence that a TEXT match will never arrive, so it must not speak for echoes the count pass deliberately holds. It did: a photo echo and a marker-only caption were both stranded once any later send landed. Both delete content rather than reposition it. An image echo is the only place the photo is visible until its preview rebinds, and a caption of only `[Image #N]` markers has a transcript row that renders empty - so dropping the echo makes the message vanish, which fails harder than the stuck bubble it replaced. Verified both new guards fail against the previous rule.
The peer's #15656 pins escape-sequences-before-control-bytes for the MATCHING normalizer. The display strip repeats that ordering and nothing on this branch held it: `buildMobileImagePastePayload` wraps a path as `ESC[200~<path>ESC[201~`, so taking ESC off as just another control byte strands the printable `[200~` and `[201~` tails in the bubble. Verified load-bearing - reversing the two strips renders `[200~/tmp/photo.png[201~ look at this`.
) (cherry picked from commit efa3b97)

















ELI5
Mobile chat showed a message immediately, then failed to retire that temporary bubble when the real transcript row arrived. The terminal clear command could be recorded as part of the prompt, so the two copies no longer compared equal.
What changed
Image sends keep their existing paste flow, which already clears separately. Codex command typing keeps its per-key terminal-control path.
Reliability contract
Compatibility
The change reuses the existing optional
terminal.sendrequest shape; it adds no RPC field, stream opcode, persisted value, route, or protocol-version requirement. Local, daemon, SSH, WSL, and relay execution keep the same host routing, and the behavior is provider-neutral across supported agents. Older hosts already accept the standalone non-submitting terminal write.Privacy
The test fixture contains synthetic identifiers and prompt text only. The PR branch was rewritten to a single commit so an earlier captured fixture is no longer retained in branch history.
Known remaining gap
A literal prompt consisting only of image-marker text still has a pre-existing reconciliation hole because normalization intentionally removes the entire value. The regression test documents it; changing that render/retirement contract is outside this focused fix.
Testing
tsc --noEmitoxlintandoxfmt --checkgit diff --checkVisual proof
Native iOS QA passed on an iPhone 17 Pro Max simulator: the text-only prompt reconciled to exactly one bubble with no visible control byte.
Linked issue
Reported by @BrennanKB5 on 2026-08-20.