When starting Cursor a lot of unsaved files from other worktrees are loaded

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

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

Screenshots / Screen Recordings

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.1.46 (user setup)
VSCode Version: 1.105.1
Commit: ab326d0767c02fb9847b342c43ea58275c4b1680
Date: 2025-12-02T03:59:29.283Z
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.26200

For AI issues: which model did you use?

Model name: Sonnet 4.5, Gemini-3-pro-preview, Opus 4.5

For AI issues: add Request ID with privacy disabled

Request ID: 81ab7a38-34cf-4bfd-bae5-a8c5950af564

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hey, thanks for the report. This seems unusual.

We need a bit more details to reproduce:

  • 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)
      Skjermbilde 2025-12-04 211611
    • 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.
  • Check if the issue disappears when temporarily disabling restoration of the previous session

    • I enabled these which indeed made the repo not open on start-up, but when opening the repo the unsaved files reappeared
      • "window.restoreWindows": "none",
        "files.hotExit": "off",
        "workbench.startupEditor": "newUntitledFile",
        "workbench.editor.restoreViewState": false,
        "terminal.integrated.enablePersistentSessions": false
        

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 :slight_smile:

Opening the agent entry “Investigate e2e test timeouts” now works again.

I got the same problem