VSCode Extension Steals Focus When Maximizing Terminal Panel

Resolved 💬 3 comments Opened Dec 21, 2025 by gurdiga Closed Dec 21, 2025

Environment

  • OS: macOS 26.2 (25C56) - Darwin 25.2.0
  • Architecture: arm64 (Apple Silicon)
  • VSCode Version: 1.107.1 (994fd12f8d3a5aa16f17d42c041e5809167e845a)
  • Claude Code Extension Version: 2.0.75-darwin-arm64
  • Shell: zsh (macOS default)

Summary

When the Claude Code panel is open in VSCode, clicking the "Maximize Panel Size" button to maximize the terminal panel (or using the keyboard shortcut) causes Claude Code's input field to steal focus instead of the intended action occurring.

Steps to Reproduce

  1. Open VSCode with Claude Code extension installed
  2. Open the Claude Code panel (appears in the bottom panel area)
  3. Also have a terminal open in the same panel area
  4. Click the "Maximize Panel Size" button (up arrow icon) in the terminal panel header
  • OR use the keyboard shortcut to maximize the panel (typically Cmd+J on Mac)

Expected behavior: Terminal panel should maximize/restore to fill the editor area

Actual behavior: Claude Code's input field receives focus, and the terminal panel maximize action does not complete

Investigation

After investigating the extension code (using Claude Code itself to explore the codebase), the issue appears to be in the webview JavaScript:

File: ~/.vscode/extensions/anthropic.claude-code-2.0.75-darwin-arm64/webview/index.js

Line 1117 (approximately):

u.current&&document.hasFocus()?(d(0),e.safeFocus(u.current))

Line 1121 contains the focus event listeners:

function Nkt(){
  let[n,e]=(0,Ki.useState)(document.hasFocus());
  return(0,Ki.useEffect)(()=>{
    function t(){e(!0)}
    function i(){e(!1)}
    return window.addEventListener("focus",t),
           window.addEventListener("blur",i),
           ()=>{window.removeEventListener("focus",t),
                window.removeEventListener("blur",i)
           }
  },[]),n
}

Potential Cause

  1. When you maximize/restore the terminal panel in VSCode, the layout changes
  2. This layout change appears to trigger a window focus event (even though focus didn't truly leave/return to the window)
  3. The Claude Code extension's global window focus listener seems to catch this event
  4. The extension then appears to call safeFocus() on its input field, stealing focus from the user's intended action

This happens with both the button click and keyboard shortcut because both trigger the same panel resize operation.

Impact

  • Severity: Medium - Disrupts normal VSCode workflow
  • Frequency: Every time when Claude Code panel is open and terminal panel is maximized/minimized
  • Workaround: None identified that doesn't involve temporarily closing Claude Code panel

Additional Notes

  • The issue occurs regardless of whether the user clicks the button or uses the keyboard shortcut
  • The focus handler appears to be checking document.hasFocus() but may not distinguish between:
  • Genuine window focus changes (user switching between applications)
  • Internal VSCode layout changes that trigger spurious focus events

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗