[BUG] `claude --resume` exits at startup under tmux — probe replies read as input
Summary
Launching claude --resume <session> (or --continue) inside a freshly-created tmux pane makes Claude quit during startup, before the TUI is usable, to a bare exit (code 1). It fails every time in the affected setup and does not recover on retry.
On startup Claude emits terminal-capability probes (DA1/DA2, XTVERSION, OSC 10/11 fg/bg, colour-scheme DSR 996). Under tmux those get answered — by the outer terminal (round-trip) when the pane is attached, or by tmux from its cache when detached — and Claude then reads the replies to its own probes as keyboard input during the resume-transcript load and exits. When it exits early, the un-consumed replies spill onto the shell prompt (see Evidence).
Environment split (deterministic, not flaky)
| Invocation | Result |
|---|---|
| claude --resume <s> directly (no tmux) | ✅ works |
| bare claude (no resume) inside tmux | ✅ works |
| claude --resume <s> inside a fresh tmux pane | ❌ exits at startup, every time |
The variation is by environment, not run-to-run. Bare claude survives because by the time replies arrive its input handler is settled and treats them as terminal responses; a cold --resume is still loading the transcript when they land.
Repro
Terminal that answers capability queries (Ghostty 1.3.1), with tmux:
tmux new-session "claude --resume <a-cold-session-name>"
Claude quits at startup and the probe replies appear at the next shell prompt.
Evidence
The bytes that spill to the shell after the exit (Claude's probe replies):
ESC[?997;1n # colour-scheme (DSR 996) reply
ESC[?62;22;52c # DA1
ESC[>1;10;0c # DA2
ESC P >|ghostty 1.3.1 ESC\ # XTVERSION
ESC]10;rgb:dcdc/dcdc/dcdc ESC\ # OSC 10 (default fg)
ESC]11;rgb:1515/1919/1f1f ESC\ # OSC 11 (default bg)
What I ruled out (no client-side workaround holds)
--debug/--debug-filemakes it disappear — the added latency shifts the timing. (So debug can't be used to capture the failing run.)- Pre-launch
sleep(0.5s–3s) doesn't help — it delays the probes and the transcript load equally, so the relative race is unchanged. - Starting the session detached (
tmux new-session -d … ; attach) makes Claude exit faster — tmux answers the probes from cache immediately. - Explicit
theme(dark) doesn't stop the OSC 10/11 / colour-scheme probes.
Expected
Claude should not consume the replies to its own terminal-capability probes as user input, and should not accept prompt/dialog input, until its input parser is initialized and the probe round-trip is drained — regardless of how long the resume transcript takes to load.
Environment
- Claude Code 2.1.258 (also seen on 2.x)
- macOS (Darwin 25.6)
- tmux with
extended-keys always,extended-keys-format csi-u,terminal-features 'xterm*:extkeys' - Ghostty 1.3.1