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
Subsystem design references
These pages describe current responsibilities, runtime paths, state, and contracts. Start with the subsystem relevant to your task, then follow its source links to verify the implementation you change.
| Subsystem | Reference |
|---|---|
| Built-in subscriptions moving to plugins | Provider and plugin ownership |
| Built-in plugins: registry, lifecycle, plugins.yml, presets, settings schemas, the window's kernel (slots, error boundary, kit) | Plugin runtime |
| Plugins that run on the gateway's requests and replies | Gateway middleware |
| Tools that plugins give, offered to every agent as an MCP server | Plugin tools |
| Plugins that await context recall and observe completed replies | Asynchronous gateway request hooks |
| Claude subscription turns across Claude Code runs | Claude subscription bridge |
| How the gateway picks a provider, key or account, and falls back | Gateway routing and fallback |
| Gateway Session Aggregation | Gateway Session Aggregation |
| Connecting an agent's config to the gateway, drift, disconnect, WSL twins | Agent wiring |
| Providers, keys, subscription accounts, refresh and allowance | Providers and accounts |
| Instructions, MCP servers, skills and RTK written into agents | Library |
| One MCP server, magpie, given to every agent in place of the Library's servers | MCP router |
Tray, panel, window, magpie web and the page's JSON API |
GUI app shell |
| Encrypted backups and setup synchronization over WebDAV, S3 or GitHub | Sync and backup |
A subsystem can span several packages or repositories. Its reference describes the behavior those parts provide together; it does not need to list every function.
Maintain a reference
Update the owning reference in the same PR when a change alters a documented responsibility, interface, state transition, runtime path, compatibility rule, or failure behavior. An internal refactor that preserves these contracts does not require a prose change.
Keep each fact in one reference and link to it from agent instructions or other pages. Link to source files and named symbols rather than copying implementation details that change frequently. Explain field meanings and constraints that signatures alone do not express.
For a new reference, include the responsibilities and boundaries, source of truth, main runtime paths, state transitions, important constraints, and existing verification commands. Include failure and compatibility behavior where relevant. Document current behavior separately from proposed changes; the proposal belongs in its issue or PR.
Describe a PR's semantic changes
For each affected subsystem, explain the observable change with its trigger and before/after behavior. Include changes to interfaces, state, compatibility, and failure behavior when relevant. Link the affected reference, implementation, and verification evidence. State when a refactor preserves the documented behavior.
For example, a change to plugin adoption should explain which migration state and account condition trigger it, which implementation handles requests before and after adoption, and which test exercises that transition.
This is an author-provided explanation that a reviewer verifies against the diff and surrounding code. It is not an automatically proven compatibility verdict.
Review a change
- Identify the affected subsystem and the actual runtime path, including plugin or built-in ownership.
- Compare the claimed before/after behavior with the base and head implementation. Trace relevant callers and state transitions beyond the changed lines.
- Check that changed contracts appear in the owning reference and that source links still resolve.
- Check that the cited tests or runtime evidence exercise the claimed behavior. Report checks that were not run.
A documentation update alone does not prove the implementation. Existing tests and runtime evidence remain necessary for behavior changes.