[BUG] Session orchestration pauses in unfocused terminal tabs/panes until user interaction
Preflight
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code sessions running multi-agent orchestration workflows (subagents via the Agent tool) stop progressing when the terminal tab or split pane doesn't have keyboard focus. The session remains visibly "Idle" for 30+ minutes despite a background agent having already returned results. The moment the user clicks into the pane (or presses any key), the session instantly resumes — processing the already-completed agent result and continuing the workflow.
This is not a rendering-only issue. The workflow state machine itself does not advance. The status transitions from "Idle" → "Ebbing... (2s)" immediately upon interaction, confirming the agent result was available in memory but the orchestration logic hadn't processed it.
Reproduction Steps
- Open iTerm2 (or any terminal) with multiple tabs or split panes
- In one pane, run a Claude Code session with a multi-phase workflow that dispatches background agents (e.g., a conductor skill that spawns Agent tool calls)
- While that session is running, click into a different tab/pane and actively work there
- The unfocused session will reach a point where an agent completes, but instead of proceeding to the next phase, it shows "Idle" indefinitely
- Click into the paused session — it immediately resumes, processing the already-returned agent result
Expected Behavior
The orchestration state machine should process agent completion events and advance to the next workflow phase regardless of whether the terminal pane has keyboard focus. Agent result polling and workflow progression should not depend on render cycles or terminal focus state.
Actual Behavior
The session pauses at agent completion boundaries until the user interacts with the pane. The process is not suspended (it responds instantly to input), but workflow state transitions do not fire until a render cycle is triggered by user interaction.
Environment
- Claude Code Version: 2.1.80
- OS: macOS 26.0.1 (Darwin 25.0.0, arm64)
- Terminal: iTerm2 (also expected to occur in Ghostty and other GPU-accelerated terminals)
- Shell: zsh
Investigation & Root Cause Hypothesis
Extensive testing ruled out:
| Hypothesis | Tested | Result |
|-----------|--------|--------|
| macOS App Nap | Disabled via defaults write + Activity Monitor verification | Still occurs |
| iTerm2 focus reporting (DECSET 1004) | Disabled in Advanced settings | Still occurs |
| iTerm2 adaptive frame rate | Unrelated (setting not exposed) | Still occurs |
| caffeinate -i claude wrapper | Tested | Made it worse — session required keystroke even when focused (stdin ownership conflict with Ink) |
| iTerm2 split panes specifically | Tested with separate tabs | Same behavior with tabs |
Likely root cause: Claude Code uses Ink (React for CLI) for its TUI. Modern GPU-accelerated terminals (iTerm2, Ghostty) deprioritize rendering for unfocused surfaces — Ghostty explicitly documents this: "sets non-focused rendering threads as QoS background" and "uses an adaptive frame rate depending on whether a window is focused."
If Ink's React reconciliation cycle (which drives useState/useEffect hooks) is coupled to terminal write/render completion, then deprioritized rendering would stall the React state updates that drive workflow orchestration. The agent result sits in memory, but the effect that processes it never fires because no render cycle occurs.
Evidence: the status label transitions from "Idle" to "Ebbing... (2s)" instantly on click — the 2-second timer started the moment the pane received focus, not when the agent completed. This means the agent completion event was queued but unprocessed.
Related Issues
- #22127 — Same pattern in Claude Desktop (MCP results available but UI doesn't progress until click). Was confirmed as a UI state management bug and fixed.
- #32050 — Session idle timeout during background tasks (different: full disconnect vs. pause)
- #17540 — Session freezes with multiple background agents (different: permanent freeze vs. resumable pause)
- #11391 — Focus reporting escape sequences per-pane (fixed, but demonstrates per-pane focus events exist)
Suggested Fix
Decouple agent result polling and workflow state machine progression from Ink's render cycle. Use a setInterval-based polling loop or Node.js EventEmitter pattern that fires independently of React's rendering, ensuring orchestration advances even when the terminal deprioritizes rendering for unfocused surfaces.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗