Skip to content

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

Description

@atomantic

Context

Follow-up from the #2192 paste-verification fix (PR for fix/tui-paste-marker-verification). That PR makes isPasteConfirmed treat the TUI's paste-commit marker as authoritative: countPasteMarkers(buffer) > promptMarkerCount. promptMarkerCount is subtracted so the prompt's own echoed [Pasted text #N] literals aren't mistaken for the TUI's commit marker.

The remaining edge

That subtraction is correct for the inline (uncollapsed) paste path, but wrong for the collapsed path that the PR otherwise fixes:

  • A claude-code-tui CoS task whose prompt is multi-line AND literally contains one or more [Pasted text #N …] substrings (e.g. a TUI-transcript-analysis task — the domain TUI agent prompt-submit handshake: dead paste-marker path + false-success on unsubmitted prompt #1229's promptMarkerCount was added for).
  • Claude collapses the multi-line paste into its own single [Pasted text #M] chip and hides the body — including the prompt's embedded marker literals. So the buffer carries only Claude's 1 chip while promptMarkerCount ≥ 1 (counted from the prompt text).
  • countPasteMarkers(buffer)=1 > promptMarkerCount=1false, and the hidden body defeats the verifyPasteRendered text fallback too → paste declared swallowed, retried 3×, agent dies paste-not-rendered despite the paste landing.

The common case (0-marker prompt) is correct: collapse yields 1 > 0 → confirmed. Only prompts that embed marker literals hit this.

The code comment in tuiHandshake.js (isPasteConfirmed) claims such a transcript paste "simply falls back to the timer, which is safe" — but with the body hidden the fallback text check also fails, so it fails the agent rather than being safe. Fix the comment as part of the fix.

Possible mitigations

  • When the buffer shows Claude's collapsed-chip shape (a marker present but body absent), treat any marker ≥ 1 as delivery regardless of promptMarkerCount — a collapsed chip is the TUI's own commit by construction.
  • Or gate the promptMarkerCount subtraction to the markerless/uncollapsed path only.

Both need care to avoid re-introducing the echoed-marker false-positive the subtraction was guarding against. Add a regression test with a self-marker-containing multi-line prompt transcript.

Severity

Low / narrow — only self-marker-containing multi-line prompts. Deferred out of the original fix (which unblocks the 100%-reproduction common case) on reviewer recommendation.

Metadata

Metadata

Assignees

Labels

in-progressClaimed and being workedplanTracked by /do:replan

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions