[BUG] Terminal focus automatically shifts to open file after sending Claude Code prompts in PyCharm

Resolved 💬 5 comments Opened May 23, 2025 by kaybeudeker Closed May 28, 2025

Environment

  • Platform:
  • [x] Anthropic API
  • Claude CLI version: 1.0.2 (Claude Code)
  • Operating System: macOS Sequoia 15.5
  • Terminal: PyCharm's internal 'Reworked 2025 (BETA)' and 'classic' (PyCharm: 2025.1.1.1)

Bug Description

When using Claude Code in PyCharm's terminal with files open in the editor, the cursor/focus automatically shifts from the terminal to the open file after pressing Enter to send a prompt. This makes it impossible to use ESC or any other terminal commands to interrupt Claude Code operations, despite following the official troubleshooting guide.

The core issue is focus management, not specifically the ESC key functionality.

Video demonstration:

https://github.com/user-attachments/assets/29989062-b87c-4d91-b2e4-8abe73a1bce6

Expected Behavior

  • After sending a prompt to Claude Code, focus should remain in the terminal
  • User should be able to immediately use ESC, Ctrl+C, or other terminal commands without manually clicking back into the terminal
  • Terminal should maintain focus throughout the entire Claude Code session

Actual Behavior

  • Focus automatically shifts to the open file after pressing Enter on any Claude Code prompt
  • ESC key presses are captured by the file editor instead of Claude Code terminal
  • User must manually click back into terminal to regain control
  • This behavior occurs consistently when files are open in the editor
  • Works correctly only when no files are open (focus stays in terminal)
  • This behavior persists across both "Reworked 2025 (BETA)" and "classic" terminal modes

Additional Context

  • Potentially related to #664, but occurs even after following all official troubleshooting steps

View original on GitHub ↗

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