When opening Cursor a ton of unsaved files from other worktrees are loaded.
I’m assuming I can delete the worktrees but if that is indeed the fix then perhaps it should be built in more intuitively as part of the process of working with worktree generated code
Steps to Reproduce
The files originates from running the Cursor agent towards worktree, often multiple models in parallell
Expected Behavior
I’d expect the files to not be loaded, however it would be useful to be able to see and/or apply the changes from the Agent bar or in the Agent layout
Please confirm the paths for the “unsaved” files - are they directories like ~/.cursor/worktrees/<repo>/…?
Does this happen after Best-of-N (multiple models) or also with a single agent?
Can you record a short screencast of Cursor startup showing the auto-loading of tabs?
Share startup logs: Help > Toggle Developer Tools > Console (screenshot/copy of errors).
Settings values: cursor.worktreeMaxCount and cursor.worktreeCleanupIntervalHours (if changed).
Temporary options:
If old worktrees aren’t needed - you can remove them manually (directories under ~/.cursor/worktrees/<repo>/…) or lower the limit/speed up auto-cleanup: see Worktrees Cleanup Parallel Agents | Cursor Docs
Check if the issue disappears when temporarily disabling restoration of the previous session
Send the data above - this will help speed up the fix. Thanks!
Please confirm the paths for the “unsaved” files - are they directories like ~/.cursor/worktrees/<repo>/…?
Yes! I’m on Windows so the path looks like this C:\Users\{username}\.cursor\worktrees\{repo}\{worktree id - 3 letters}\src\components\TournamentTierTooltip.tsx (see attached image)
Curiously if I right-click the tab, select “Copy relative path” and paste it then I get this path: C:\Users\{username}.cursor\worktrees\{repo}\{worktree id - 3 letters}\src\components\TournamentTierTooltip.tsx. Notice how there’s a missing backslash between username and .cursor folder. Not sure if it’s a coincidence or not, or whether it matters.
Does this happen after Best-of-N (multiple models) or also with a single agent?
It only happens with multiple models
Can you record a short screencast of Cursor startup showing the auto-loading of tabs?
Sure, can I send it to you somehow? Just not to keen to upload it directly here
Share startup logs: Help > Toggle Developer Tools > Console (screenshot/copy of errors).
Sure; I’d say the most immediate errors are until the [Extension host] (node:5896) error. The errors [transport] Connect error in unary AI connect comes slightly after the initial load
Settings values: cursor.worktreeMaxCount and cursor.worktreeCleanupIntervalHours (if changed).
Worktree Max Count: 20 (same as default)
worktreeCleanupIntervalHours: 6 (same as default)
Temporary options:
If old worktrees aren’t needed - you can remove them manually (directories under ~/.cursor/worktrees/<repo>/…) or lower the limit/speed up auto-cleanup: see Worktrees Cleanup Parallel Agents | Cursor Docs
Thanks, I’ll probably delete the ones with the unsaved files, hopefully you have enough info now though.
I enabled git.showCursorWorktrees and can now see worktrees in the Source Control window. What I noticed is that the worktrees with full branch names (not just commit hashes) does not have the problem with unsaved files. The ones with full branch names has a cloud icon with the title “Publish branch” wheras the others have sync icon with the title “$(sync)“. It also seems that the agent entry with the problematic worktrees is unable to load in the Agent Layout bar, it’s stuck at “Loading Chat”. The chat is called “Investigate e2e test timeouts” 2 days ago.
I do have some unfortunate news, it did not fully help to delete the worktrees via the worktrees → delete worktree option. When starting Cursor there is now 44 unsaved files (down from 83 unsaved files). I now only see unsaved files from the following worktrees: zod and ora
I noticed an error when deleting some worktrees but not sure if that was the problem (they were still removed from the UI). Perhaps the worktrees are not fully deleted? git worktree list does not show the problematic worktrees.
The picture shows my current worktrees state and I deleted the problematic worktrees using the shown method.
A comment regarding opening the agent entry containing the problematic unsaved files. At first it was infinitely stuck at loading, but after deleting the worktrees I was able to load the agent entry again, but after restarting Cursor it’s now stuck at loading again.
Yeah it just failed to properly delete the worktrees, I deleted the folders for zodand ora in C:\Users\{username}\.cursor\worktrees\{repo}, discarded the unsaved files and they now no longer appear in Cursor on startup
Opening the agent entry “Investigate e2e test timeouts” now works again.