[BUG] Terminal focus automatically shifts to open file after sending Claude Code prompts in PyCharm
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
Thanks for the report, Kay.
We've had an issue with keeping focus for the Esc button with PyCharm 2025.1.1.1, and rolled out a fix in the 0.1.5-beta version of the plugin. Mind giving the new version a spin to see if it fixes the problem?
Works like a charm in 0.1.5-beta. Great work! Focus now stays properly in terminal when files are open.
This same issue occurs in vscode, related to the bug I wrote #1278
Please open a separate bug with repro if there's editor focus issues in VSCode. Thanks!
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.