Confirm collapsed TUI paste when prompt embeds a [Pasted text #N] marker literal (#2228)#2231
Merged
Conversation
…als (#2228) The #2192 marker gate subtracts the prompt's own echoed [Pasted text #N] count so an inline echo isn't mistaken for the TUI's commit. That is wrong when Claude Code collapses a multi-line self-marker-containing prompt into its own single chip and hides the body: count (1) > promptMarkerCount (1) is false, and the hidden body defeats the verifyPasteRendered fallback too, so the agent died paste-not-rendered despite the paste landing. isPasteConfirmed now also recognizes Claude's collapsed-chip shape (a marker present alongside the 'paste again to expand' affordance) as authoritative delivery. That chrome only rides on the TUI's own genuine commit, never on an echoed prompt literal, so it can't re-introduce the echoed-marker false-positive the subtraction guards (the inline/uncollapsed path has no such chrome and keeps subtracting). Also corrects the misleading comment claiming the collapsed transcript paste 'simply falls back to the timer, which is safe'.
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.
Summary
Closes #2228 — a TUI-transcript-analysis prompt that itself embeds a
[Pasted text #N]literal could still false-negative the paste-confirmation gate.The marker-authoritative gate (from #2192/#2229) subtracts the marker count the prompt itself carried, so an echoed
[Pasted text #N]isn't mistaken for the TUI's own commit. That is correct for the inline (uncollapsed) path, but wrong when Claude Code collapses a multi-line self-marker-containing prompt into its own single chip and hides the body: the buffer then shows one marker while the prompt also carried one (1 > 1is false), and the hidden body also defeats theverifyPasteRenderedtext fallback — so the agent diedpaste-not-rendereddespite the paste landing.isPasteConfirmednow also recognizes Claude Code's collapsed-chip shape — a paste-commit marker present alongside the "paste again to expand" affordance — as authoritative proof of delivery (newisCollapsedPasteChip/COLLAPSED_PASTE_CHIP_PATTERN). That chrome is emitted by the TUI itself and never rides in on an echoed prompt literal, so it can't re-introduce the echoed-marker false-positive the subtraction guards (the inline/uncollapsed echo path has no such chrome and keeps subtracting). A misleading comment claiming the collapsed transcript paste "simply falls back to the timer, which is safe" is corrected.This is complementary to #2229 (marker-trust) which landed on main separately — both checks now live in
isPasteConfirmed(promptMarkerCountsubtraction first, then the collapsed-chip rescue, then the text fallback).Test plan
cd server && npm test -- lib/tuiHandshake.test.js— 95 passed. New cases cover the collapsed-chip-with-embedded-marker rescue, the real-incident transcript, the inline-echo-without-chrome rejection (guards against reintroducing the false-positive), and unit tests forisCollapsedPasteChip.