TUI switches to different layout (dashboard vs compact) on terminal focus/blur events
Description
Claude Code's TUI switches between two completely different UI layouts based on terminal focus state. When the terminal loses focus, it shows an expanded "dashboard" view. When focus returns, it switches back to a compact view. This causes a jarring visual experience and is disruptive to the user.
Visual Evidence
Focused State (Compact View)
When the terminal has focus, Claude Code shows a minimal header:
- Small mascot icon
- Version info ("Claude Code v2.1.27")
- Model info ("Opus 4.5 · Claude Max")
- Current directory
- Conversation history starts immediately below
Unfocused State (Dashboard/Welcome View)
When the terminal loses focus, the entire UI changes to show:
- Large decorative box with colored border
- "Welcome back" greeting
- Larger centered mascot
- "Recent activity" panel on the right (showing recent sessions)
- "What's new" panel (showing changelog)
- Organization name displayed prominently
- Takes up approximately 50% of the visible terminal
Reproduction Steps
- Start Claude Code in any terminal (Windows Terminal, xterm.js-based terminals, etc.)
- Observe the compact working view
- Click outside the terminal window (or switch to another application)
- Result: The entire UI transforms into the expanded dashboard view
- Click back into the terminal
- Result: The UI switches back to the compact view
Why This Is Problematic
- Jarring visual experience: The entire screen content shifts when switching focus
- Loss of context: Users may lose their place in the conversation when the layout changes
- Unnecessary redraws: The full UI redraw on every focus change wastes resources
- Repeated triggers: In some terminal emulators (especially those with complex window hierarchies), this can trigger multiple times per focus change
- Distracting: Users who frequently switch between windows experience constant UI shifting
Expected Behavior
The UI layout should remain stable regardless of terminal focus state. If there's a need to indicate focus/unfocus status, it should be done with:
- A subtle visual indicator (border color change, icon change, etc.)
- NOT a complete UI layout transformation
Other TUI applications (vim, htop, lazygit, etc.) do not change their layout based on focus - they maintain visual stability.
Technical Context
From investigating the code, Claude Code:
- Enables DEC Private Mode 1004 (
CSI ? 1004 h) for focus event reporting - Receives
ESC[I(focus in) andESC[O(focus out) sequences from the terminal - Updates
isTerminalFocusedstate in a React context - Conditionally renders different components based on this state (dashboard vs compact view)
Suggested Fix
- Remove the focus-dependent layout switching entirely - Show the same UI regardless of focus
- Or make it configurable - Add a setting like
--no-focus-dashboardor in the config file - At minimum, debounce the focus events - Prevent rapid switching when focus changes quickly
Environment
- Claude Code version: 2.1.27
- Observed in: Windows Terminal (shown in screenshots), also affects xterm.js-based terminals
- OS: Windows 11 (also reported on macOS and Linux)
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗