Chapin2018's message of nineteen images between words (the issue's
script, Claude Code 2.1.319, claude-fable-5-1) ended the interactive
helper "after 13s (exit status 1)" and the client got a 502, while -p
answered. The cause is how the helper saw a paste taken. It looked for
"[Image #N]" and "[Pasted text #N" only in what Claude Code drew after
the paste. Once the prompt runs past a row, Claude Code draws it again
only where it changed and moves the cursor past cells that are already
right. After the 33rd piece the drawing held "\r\x1b[16C\x1b[1B3": one
digit of "[Image #33]". The helper waited out pasteWait (10s) and ended.
Text marks came out in part too ("[Pasted t xt #16"), so several word
pieces each sat out their own 10s before that. There is no limit in
Claude Code's TUI: the same paste is on its screen whole, so no -p
fallback is needed.
Each check now also reads the prompt as the 200x50 screen grid shows
it: the rows between its last two rules, words one space apart (a mark
can wrap onto the next row). The mark that ends it counts (lastMark),
an image's [Image #N] or a whole [Pasted text #N +k lines], numbered
past the piece before, and so do words the prompt ends with. The
stream check stays first.
Run:
- Real, macOS arm64, this Mac, sandbox HOME and CLAUDE_CONFIG_DIR
(token by env, nothing rotated, DISABLE_AUTOUPDATER=1), the issue's
script unchanged, --images 19, Claude Code 2.1.319:
- origin/main a46190e1f: exit 1 after ~32s, stderr as reported.
2.1.316 failed the same way. -p: success, 5.8s.
- This change: exit 0 in 5.3 to 12.1s on 5 runs, subtype success.
The transcript's user row has all 19 image blocks and the words in
order, and the model answered. The script's answer_ok stays false
because the helper's result line has no "result" text (-p's does).
The gateway reads the assistant events, not that field.
- TestShimSeesPastesOnAPromptDrawnInPart feeds the real run's bytes
(testdata/paste-images-2.1.319.bin, folder name replaced at the same
length). Each of the 33 pastes must be seen taken.
- Broken by hand: drop the prompt checks from imageTaken and textTaken
and it goes red on text 12, text 22 and image 33, the pieces whose
marks were drawn in part.
- WSL magpie-desktop (Ubuntu 24.04 amd64, go1.26.8), because mote is
down:
- gofmt -l . is clean.
- go vet -tags nogui ./... and GOOS=windows go vet ./... pass. Plain
vet there lacks gtk4 headers.
- go test ./internal/claudetui/ is ok (120s).
- The darwin build used for the real runs above.
Not tried: Linux arm64 (the reporter's system) with a real account, the
gateway's /v1/messages path end to end with 19 images, and the full
suite (not run at push).
Refs #5654: kept open for the reporter to confirm.
Reported-by: Chapin2018