Add terminal.claudeResumeMode to auto-answer Claude Code's resume prompt
Summary
What? Adds a terminal.claudeResumeMode setting (ask | full | summary, default ask) that lets cmux answer Claude Code's compacted-session resume prompt for you when it auto-resumes an agent.
Why? When cmux auto-resumes a compacted Claude Code session (claude --resume <id>), Claude shows an interactive menu:
Resuming the full session will consume a substantial portion of your usage limits. We recommend resuming from a summary.
❯ 1. Resume from summary (recommended)
2. Resume full session as-is
3. Don't ask me again
There is no Claude Code CLI flag or config to skip this (verified against the current Claude Code release), so today you have to hand-pick an option every time cmux restores your panes. This adds a cmux-side setting to drive that menu — the natural home, since cmux owns the pane and already auto-resumes the session.
Behavior
ask(default) — unchanged: the prompt is left for you. This is a complete no-op; nothing is armed.full— cmux selects Resume full session as-is.summary— cmux selects Resume from summary.
How it works:
- Armed only from
Workspace.createPanelwhen a Claude agent is being auto-resumed (restorableAgent.kind == .claudeand a resume command/input will run) and the mode isn't.ask. - A short, hibernation-style poll (
ClaudeResumeAutoResponderController, modeled onAgentHibernationController) reads the pane's rendered text via the existingTerminalSurface.readTextand, when the menu appears, sends the keys via the existingTerminalSurface.sendNamedKey(so libghostty encodes the right sequence for the pane's cursor mode). - One-shot and bounded: it fires at most once per resume, then disarms; if the menu never appears (session wasn't compacted) it gives up after a short watch window.
Design
- Pure logic, unit-tested:
ClaudeResumeMode(SettingCodableenum, mirrorsWorkspaceGroupNewPlacement) andClaudeResumePrompt(detection + keystroke planning) live inCmuxSettingswith no AppKit/ghostty deps. Detection is label-based; selection is option-order independent (it finds the target row and the currently-highlighted row by pointer glyph, then moves to it), so it keeps working if the menu is reordered, and falls back to "first row highlighted" when no glyph is rendered. - Thin integration: the controller + the one-line arm in
createPanelare the only app-side glue. - Fail-safe: detection requires Claude's specific option labels, so if a future Claude release changes that wording the responder simply never fires and the prompt stays interactive — no wrong key is sent. Default
askmeans zero behavior change unless opted in.
Wired through the usual surfaces: Settings → Terminal Picker (CmuxSettingsUI), settings search index + curated entry, cmux.json schema + template + JSON-path support, and the file-store parser.
Testing
- Added
CmuxSettingsTests/ClaudeResumeModeTests.swiftcovering: tolerant raw-string parsing + UserDefaults/JSON round-trips; prompt detection (present/absent); keystroke planning for the default menu, a reordered menu, and a no-pointer menu; and the one-shot responder (waits for the menu, fires once, never double-fires, inert inask). - The detection/keystroke logic was exercised directly and all assertions pass.
Checklist
- Added tests for the behavior change (
CmuxSettingsTests) - Default (
ask) preserves existing behavior - Swift file-length budget updated for the touched files
- Demo video — N/A (a setting + a menu responder; covered by unit tests)
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.
Summary by cubic
Adds terminal.claudeResumeMode (ask | full | summary) to auto-answer Claude Code’s compacted-session resume menu when cmux auto-resumes a Claude agent. Default is ask; the responder is one‑shot, retries until keys are accepted, and ignores stale menu text.
-
New Features
- Terminal setting/picker for
terminal.claudeResumeMode; searchable and localized; added to schema (withdescriptionKey), template, JSON‑path, and file‑store parsing. Strict enum parsing (ask/full/summaryonly); non‑string or invalid values are logged. - Auto-responder for Claude auto-resumes (restorable snapshots and agent‑hook resume bindings): detection requires all three option labels; uses the latest contiguous menu block and ignores stale blocks; pointer-aware and option‑order independent. Bounded round‑robin polling with capped reads; pending responders are bounded until a pane goes live, then watched briefly; retries until keystrokes are accepted, then disarms; one‑shot; safe no‑op if the menu never appears. Wired into
Workspace.createPanel. - Unit tests cover strict parsing, prompt detection (all labels, stale‑block handling), keystroke planning (default, reordered, no‑pointer), and one‑shot with delivery confirmation.
- Terminal setting/picker for
-
Migration
- No action needed; default is
ask. - To auto-select, set
terminal.claudeResumeModetofullorsummaryin Settings → Terminal or incmux.json.
- No action needed; default is
Summary by CodeRabbit
- New Features
- Added a new “Claude Resume Prompt” Terminal setting to control how cmux handles Claude Code’s compacted-session resume prompt during restore/auto-resume.
- Includes modes: Ask, Full, and Summary.
- UI / Configuration
- Exposed in settings with searchable indexing, persisted as
terminal.claudeResumeMode, and included in the default template and configuration schema.
- Exposed in settings with searchable indexing, persisted as
- Automation
- When set to Full or Summary, cmux can automatically select the appropriate resume option once.
- Tests
- Added tests for mode parsing, prompt detection/keystroke selection, and one-shot responder behavior.