IntelliJ Plugin: Diff tab automatically steals focus, causing accidental approvals
IntelliJ Plugin: Diff Tab Automatically Steals Focus
Problem Description
The Claude Code IntelliJ IDEA plugin opens diff approvals as new editor tabs and IntelliJ automatically switches to and focuses those tabs. This creates a dangerous UX issue: if the user is typing in the editor when the diff tab opens, their keystrokes are redirected to the diff editor, potentially causing accidental approval, rejection, or typing garbage into the diff without the user realizing they've lost context.
This issue occurs even with a single IntelliJ window, affecting any workflow where the user continues working while waiting for Claude Code responses.
Impact
Severity: High - Risk of approving code changes without review
- User types in editor while waiting for Claude Code response
- Diff tab suddenly opens and automatically receives focus
- User's keypresses are now going to the diff tab instead of their code editor
- User might accidentally approve/reject the diff without seeing it
- User might inadvertently type into the diff, corrupting the review
- Complete loss of context - user must remember what they were typing and where
This is particularly problematic during:
- Active coding sessions with rapid back-and-forth interactions
- Asynchronous workflows where the user continues working while waiting for responses
- Any multi-tasking scenario where the user doesn't expect the tab switch
Steps to Reproduce
- Open IntelliJ IDEA with a project
- Start a Claude Code session and request a code change that requires diff approval
- Continue typing in your current editor while waiting for the response
- When the diff tab opens, observe that:
- IntelliJ automatically switches to the new diff tab
- The diff tab immediately receives keyboard focus
- Your keypresses are now captured by the diff tab instead of your code editor
- No visual/audio warning before focus transfer
- Your typing context is completely lost
Expected Behavior
The diff tab should open without automatically switching focus:
- Diff opens in a background tab (visible but not focused)
- User maintains focus in their current editor
- Visual indicator (tab highlight, notification badge) shows diff awaits review
- User must explicitly click the tab or use a dedicated shortcut to review
- Alternatively: Show a non-intrusive notification that doesn't steal focus
Proposed Solutions
Option 1: Background Tab Opening (Recommended)
Open diff tabs in the background without switching focus:
FileEditorManager.getInstance(project).openFile(
virtualFile,
/* focusEditor = */ false, // Don't switch to the tab
/* searchForOpen = */ true
);
- Diff tab opens but remains in background
- Current editor retains focus
- Tab highlight or notification indicator shows diff is ready
- User explicitly switches to review when ready
Option 2: Non-Intrusive Notification First
Show a notification before opening the diff:
- Display sticky notification: "Diff ready for review"
- Notification includes "Review" button
- Clicking button opens diff tab with focus
- Diff doesn't open automatically until user clicks
Option 3: Split View Without Focus Change
Open diff in a split pane without changing editor focus:
- Diff appears in split view or dedicated tool window
- Current editor maintains keyboard focus
- User can glance at diff without losing context
- Requires explicit click to interact with diff
Option 4: Input Delay Protection
If focus stealing is unavoidable, add protection:
- Ignore keyboard input for first 500-1000ms after diff opens
- Display countdown/warning banner during delay period
- Show "Diff loading... input disabled" message
- Prevents accidental keypresses during transition
Option 5: Configuration Option
Add user preferences:
Settings → Tools → Claude Code → Diff Approval Behavior
[x] Open diffs in background tabs (don't auto-switch)
[ ] Show notification before opening diff
[ ] Delay keyboard input after diff opens (ms): [500]
Workarounds Attempted (All Failed)
The following configuration changes were attempted but did not prevent the focus stealing:
- IntelliJ Advanced Settings:
ide.disable.autofocus.dialogs= trueide.disable.dialog.focus.stealing= true- No effect on editor tab focus behavior
- IntelliJ VM Options (
idea64.vmoptions):
-Djava.awt.Window.locationByPlatform=false-Dawt.nativeDoubleBuffering=true-Dsun.java2d.xr.deferred=false- No effect on tab switching behavior
- Diff Settings (
diff.xml):
- Modified various diff component settings
- No setting controls whether new tabs steal focus
- Window Manager Settings:
- Attempted Mutter/Muffin focus prevention
- Window manager doesn't control IntelliJ's internal tab behavior
Conclusion: IntelliJ's tab focus behavior is controlled by the plugin's file opening API calls, not by user-configurable settings. This requires a plugin code change.
Current Workaround (Manual)
Until fixed, the only reliable workaround is:
- Stop typing immediately when you send a Claude Code request
- Wait for the diff tab to appear before continuing work
- This defeats the purpose of asynchronous operation
Technical Details
Environment:
- IntelliJ IDEA Community 2025.2
- Linux (Mutter/Muffin window manager)
- Claude Code plugin (latest version)
Root Cause:
The plugin likely uses FileEditorManager.openFile() with focusEditor=true or requestFocus(), causing IntelliJ to automatically switch to and focus the new diff tab.
Affected Component:
The code that opens the diff view for approval (likely in the plugin's diff/review handler)
Related Issues
This is similar to focus-stealing issues in other IDE plugins that open files for review:
- GitHub Copilot's diff review behavior
- Git conflict resolution tool window behavior
- General IntelliJ tab switching on file open
Additional Context
The CLI version of Claude Code doesn't have this issue since:
- It operates in a terminal without automatic tab switching
- Diffs are displayed inline without context switching
- User explicitly chooses when to review
This is specific to the IntelliJ plugin implementation and how it opens diff editor tabs.
---
Suggested Priority: High
Category: UX/Safety
Affected Component: IntelliJ IDEA Plugin - Diff Tab Opening/Focus Management
21 Comments
Found 1 possible duplicate issue:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Update: Workarounds Cause Side Effects
The VM options workarounds mentioned in this issue:
Not only did these workarounds fail to prevent the focus stealing, but they also caused significant rendering issues:
Side Effects Observed:
Resolution:
Removing these VM options immediately resolved all blinking/flickering issues and restored normal IDE rendering.
Recommendation: Do not use these VM options as workarounds. They introduce worse problems than the original focus-stealing issue.
The focus-stealing problem still requires a proper fix in the plugin code (using
focusEditor=falsein file opening calls).This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
This is still happening. Commenting to keep issue open. Thank you 👍 :)
still happening , Anthropic we pay you enough money for you to make the plugin stable as it is on vs code
Same issue here.
if we opened up the diff and without taking focus, then it can get really difficult for the user to find the diff tab if they have a lot of tabs open (which is common).
if you are actively working on the editor, it could be helpful to run auto-accept-edits permission mode and then check back on what's edited afterwards!
@hackyon-anthropic, I would think there has to be another way to make it where the user doesn't lose the diff tab.
Maybe you could add a "link" in the console that says click here to view diff in IDE?
The thing that really makes this hard to work with is when I am working on two projects and all of a sudden I get thrown between projects due to the auto focus changing.
At the very least I would like a way to turn off the opening of the editor tab at all. I have been using the plugin for the send to claude integration, but I would rather not have the IDE diff open ever then run on auto-accept-edits.
@Kacy-Luker - would you be comfortable enabling auto-accept mode? you can cycle through modes using shift+tab
I’m not the original poster, but I’m not comfortable with that either. Auto-accept is actually the opposite of what I need. Because I work on multiple projects simultaneously, I need more manual control to avoid accidental approvals, not more automation. Just give me the choice to toggle autofocus off entirely so I can find the tab myself.
@hackyon-anthropic
I do not want to be forced to use auto-accept as a workaround for a UX issue. If we cannot find a general way to link a Claude Code Suggestion to the diff opened in the IDE, at the very least I would appreciate a setting so I can make the diffs open in the background or even not at all.
When I have multiple claude instances working on multiple projects they will fight over focus and it is incredibly jarring when I am being forced between projects when each agent just happens to want to make a set of changes at the same time. Auto-accept doesn't address this since I still want the ability to work with the agent (changes, suggestions, corrections).
I have used auto-accept before and it is very powerful for some workflows, but to use that as a workaround here is going to force me to not be able to collaborate with the agents and I think that is a huge loss of functionality.
There is a
Diff toolsetting in/configyou can use to keep the diff in the terminal instead of a popping up in the editor.You do not understand. I want diff in Idea, but not focused.
Just adding a comment that I am bothered by the focus stealing too.
A lot of mistypes and I don't like waiting. I might just be changing a character and then I have half a prompt in my code.
Any news on this ? I have same issue. Impossible to work with multiple projects
Closed as not planned is one of the saddest things I've read. This is an absolute disaster bug. Power users don't just sit and wait for a single instance of claude-code to think and then make a diff, we have multiple sessions going at once, which is a fantastic and very productive workflow.
Note: my experience of this is with the IDE integration with Jetbrains (phpstorm in particular), but it's the exact same issue.
Yeah this is by far the most annoying UX bugs in my entire workflow as a developer. I have uninstalled the claude plugin in all my intellij products as it is unusable in its current state. Sad for such a great product (Claude) to be just made inferior to other offerings on the market due to a broken integration and refusal to address the issue. How hard can it be to add a toggle in the settings?
I understand the frustration, and sorry I can't get this fixed for you. The JetBrains Plugin API just doesn't give us the ability to show a diff without taking focus (their openFile API for focus doesn't work with diff files), so unfortunately this isn't a trivial fix. If you can convince them to add this to the API, we can add this to our end too.
For those that don't want to steal focus, we recommend
/rewind(double-esc)! The auto-accept edits still require permissions for any dangerous bash commands though. Many power users do this already.Diff tool settingin/configto terminal, to keep the diff in the terminal and it won't take focusHave you (Anthropic) made any attempt to work with Jetbrains on API changes? Much more likely to listen to you all over some random devleoper..
Thank you for this context! Happy to go apply pressure there if I can find where/how to most appropriately do that. If anyone has the time, a link from this thread to that would be great!
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.