Skip to content

fix: trust paste-commit marker so Claude Code TUI agents stop failing paste-not-rendered#2229

Merged
atomantic merged 1 commit into
mainfrom
fix/tui-paste-marker-verification
Jul 5, 2026
Merged

fix: trust paste-commit marker so Claude Code TUI agents stop failing paste-not-rendered#2229
atomantic merged 1 commit into
mainfrom
fix/tui-paste-marker-verification

Conversation

@atomantic

Copy link
Copy Markdown
Owner

Problem

The #2192 paste-verification guard confirmed a pasted prompt had landed in a TUI by searching the post-paste buffer for the prompt's literal text. That broke every claude-code-tui CoS agent (100% reproduction across real runs, 2026-07-05 — agent-65e4d17f, agent-1f0bda99, agent-656efa6e, …), because Claude Code:

  1. Collapses a multi-line bracketed paste into a [Pasted text #N +M lines] chip and hides the body text — so the literal prompt text is genuinely absent from the buffer even though the paste landed perfectly.
  2. Reflows single lines using cursor-positioning escapes instead of literal space bytes between words — so after ANSI-stripping, Onthetaskspage… has no spaces and a single-space-normalized substring match fails.

Both made the text check false-negative, so agents retried 3× and died with paste-not-rendered despite the paste succeeding.

Fix

Tests

Real 2026-07-05 incident transcripts (ANSI-stripped, verbatim from raw.txt) are pinned as regression tests: the collapsed-chip-hides-body case, the space-less reflow case, the echoed-marker-not-mistaken-for-commit case, and the genuinely-swallowed case. Full server suite green (16702 passed).

Follow-up

A narrow remaining edge — a multi-line prompt that itself embeds literal [Pasted text #N] chips can still false-negative — is tracked in #2228 (low severity; deferred on reviewer recommendation so this fix ships the 100%-repro common case).

https://claude.ai/code/session_01S64MA1pN4QiuXiT8uUVJd7

…ling paste-not-rendered

#2192's paste verification confirmed delivery by finding the prompt's literal
text in the TUI buffer. Claude Code collapses a multi-line bracketed paste into
a [Pasted text #N] chip and hides the body text, and reflows single lines with
cursor-positioning escapes instead of literal spaces — so the text check
false-negatived and every claude-code-tui CoS agent died with paste-not-rendered
after 3 retries despite the paste landing (100% repro, 2026-07-05).

- New isPasteConfirmed(): the TUI's own paste-commit marker count exceeding the
  prompt's own marker count is authoritative proof of delivery, checked first;
  literal-text verification is the fallback only for the markerless path.
- verifyPasteRendered() now compares with all whitespace removed, so a space-less
  reflowed line still matches.
- agentTuiSpawning.js submits on marker/text confirmation and only retries/fails
  when a markerless paste never renders (the genuine #2192 swallowed case).
- Pinned real-incident transcripts as regression tests.

Claude-Session: https://claude.ai/code/session_01S64MA1pN4QiuXiT8uUVJd7
@atomantic atomantic merged commit 0580b5d into main Jul 5, 2026
2 checks passed
@atomantic atomantic deleted the fix/tui-paste-marker-verification branch July 5, 2026 23:06
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.

1 participant