Cursor stealing window focus on source code change

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

When I update the source code by using source control cli (e.g. git checkout), the main cursor Window steals focus from my terminal. This is a Cursor terminal popped out into a separate window.

Steps to Reproduce

It doesn’t happen 100% of the time, but often. Try just asking the AI to read some source code, then git checkout to a version that has edits to that code.

Expected Behavior

I should be able to continue using my terminal rather than having to alt-tab back to it.

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.1.36 (user setup)
VSCode Version: 1.105.1
Commit: 9cd7c8b6cebcbccc1242df211dee45a4b6fe15e0
Date: 2025-11-26T03:43:48.079Z
Electron: 37.7.0
Chromium: 138.0.7204.251
Node.js: 22.20.0
V8: 13.8.258.32-electron.0
OS: Windows_NT x64 10.0.26100

Additional Information

Cursor stack trace with a break point set on window.focus:

onElementFocus (workbench.desktop.main.js:6399)
e.HTMLElement.focus (workbench.desktop.main.js:6399)
le (workbench.desktop.main.js:2808)
await in le
(anonymous) (workbench.desktop.main.js:2808)
(anonymous) (workbench.desktop.main.js:441)
yo (workbench.desktop.main.js:276)
ya (workbench.desktop.main.js:441)
(anonymous) (workbench.desktop.main.js:2808)
Uht (workbench.desktop.main.js:2808)
(anonymous) (workbench.desktop.main.js:276)
yo (workbench.desktop.main.js:276)
$ (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:7139)
_1f (workbench.desktop.main.js:7139)
(anonymous) (workbench.desktop.main.js:276)
yo (workbench.desktop.main.js:276)
$ (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:7139)
get children (workbench.desktop.main.js:6105)
(anonymous) (workbench.desktop.main.js:276)
m4a (workbench.desktop.main.js:276)
wst (workbench.desktop.main.js:276)
xe (workbench.desktop.main.js:276)
jE (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
yo (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
m4a (workbench.desktop.main.js:276)
wst (workbench.desktop.main.js:276)
St (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
yo (workbench.desktop.main.js:276)
$ (workbench.desktop.main.js:276)
get children (workbench.desktop.main.js:6105)
(anonymous) (workbench.desktop.main.js:276)
m4a (workbench.desktop.main.js:276)
wst (workbench.desktop.main.js:276)
xe (workbench.desktop.main.js:276)
jE (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
yo (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
m4a (workbench.desktop.main.js:276)
wst (workbench.desktop.main.js:276)
St (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:276)
yo (workbench.desktop.main.js:276)
$ (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:6105)
d4a (workbench.desktop.main.js:276)
(anonymous) (workbench.desktop.main.js:6105)
(anonymous) (workbench.desktop.main.js:441)
a (workbench.desktop.main.js:276)
nz (workbench.desktop.main.js:276)
hP (workbench.desktop.main.js:276)
k$n (workbench.desktop.main.js:441)
(anonymous) (workbench.desktop.main.js:6105)
invokeFunction (workbench.desktop.main.js:7389)
Vv (workbench.desktop.main.js:6105)
C1f (workbench.desktop.main.js:7139)
createProvidedContext (workbench.desktop.main.js:7139)
onContextChanged (workbench.desktop.main.js:7139)
await in onContextChanged
(anonymous) (workbench.desktop.main.js:7139)
_deliver (workbench.desktop.main.js:49)
_deliverQueue (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
refresh (workbench.desktop.main.js:2967)
await in refresh
onDidFilesChange (workbench.desktop.main.js:2967)
(anonymous) (workbench.desktop.main.js:2967)
_deliver (workbench.desktop.main.js:49)
_deliverQueue (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
(anonymous) (workbench.desktop.main.js:8929)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
(anonymous) (workbench.desktop.main.js:8084)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
u (workbench.desktop.main.js:6316)
onResponse (workbench.desktop.main.js:6316)
onBuffer (workbench.desktop.main.js:6316)
(anonymous) (workbench.desktop.main.js:6315)
_deliver (workbench.desktop.main.js:49)
_deliverQueue (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:6316)
_receiveMessage (workbench.desktop.main.js:6316)
(anonymous) (workbench.desktop.main.js:6316)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
acceptChunk (workbench.desktop.main.js:6316)
(anonymous) (workbench.desktop.main.js:6316)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
(anonymous) (workbench.desktop.main.js:6321)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
$onDidManagedSocketHaveData (workbench.desktop.main.js:6321)
_doInvokeHandler (workbench.desktop.main.js:6948)
_invokeHandler (workbench.desktop.main.js:6948)
_receiveRequest (workbench.desktop.main.js:6948)
_receiveOneMessage (workbench.desktop.main.js:6948)
(anonymous) (workbench.desktop.main.js:6948)
_deliver (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:49)
fire (workbench.desktop.main.js:6316)
(anonymous) (workbench.desktop.main.js:8973)

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, thanks for the report.

This seems to be a real bug where Cursor’s file watcher programmatically calls window.focus() when external file changes are detected. The stack trace clearly shows the chain from onDidFilesChange → refresh → context updates → window.focus.

I’ll pass this to the team for investigation. In the meantime, the only workaround is to alt-tab back to your terminal after a git checkout.

Thanks for taking the time to debug and report this!

Yeah no worries! I figured out what causes it to happen 100% of the time. It’s when the source code update affects anything in .cursor/rules/*. We have this directory checked in because we have a monorepo and a shared set of rules that make sense for everybody in the org to have. Anyway, if you have a commit that updates a rule file, and you checkout to before and after it, it does the focus steal every time.

1 Like

Thanks for the update - the tip with .cursor/rules/* is very useful.

While there’s no fix yet, temporary workaround - return to the terminal via Alt+Tab.

Could you please:

  • attach a short screen recording
  • confirm if this reproduces when the terminal isn’t in a separate window, but opened inside the main Cursor window

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.