Skip to content

Confirm collapsed TUI paste when prompt embeds a [Pasted text #N] marker literal (#2228)#2231

Merged
atomantic merged 1 commit into
mainfrom
claim/issue-2228
Jul 6, 2026
Merged

Confirm collapsed TUI paste when prompt embeds a [Pasted text #N] marker literal (#2228)#2231
atomantic merged 1 commit into
mainfrom
claim/issue-2228

Conversation

@atomantic

@atomantic atomantic commented Jul 6, 2026

Copy link
Copy Markdown
Owner

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 > 1 is false), and the hidden body also defeats the verifyPasteRendered text fallback — so the agent died paste-not-rendered despite the paste landing.

isPasteConfirmed now 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 (new isCollapsedPasteChip / 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 (promptMarkerCount subtraction 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 for isCollapsedPasteChip.

…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'.
@atomantic atomantic merged commit 50d6ebc into main Jul 6, 2026
2 checks passed
@atomantic atomantic deleted the claim/issue-2228 branch July 6, 2026 16: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.

TUI paste confirm: self-marker-containing multi-line prompt can still false-negative

1 participant