Cursor IDE (single-folder workspace) + language servers (reproduced with Metals / Scala)
Describe the Bug
In a single-folder workspace (only one project folder), with no visible editor tabs for other projects, Cursor still feeds the language server document sync (textDocument/didOpen or equivalent) for many source files under sibling directories outside the workspace folder.
Those out-of-workspace documents survive Reload Window and language-server cache wipes. Language servers that react to opened docs (Metals) then compile them as orphans (Scala CLI BSP), flooding Problems and spawning many helper processes.
Agent/chat history appears implicated: User/globalStorage/state.vscdb table cursorDiskKV retains large numbers of agentKv / bubbleId / composerData entries that reference those out-of-workspace paths from prior agent sessions in the same workspace.
Steps to Reproduce
Open a single project folder (not the parent monorepo root), e.g. ~/projects/fun/zipx.
Run Agent in that window such that it reads/edits files in sibling repos under ~/projects/fun/….
Close all editor tabs (UI shows no open files).
Developer: Reload Window.
Language server log shows workspace folder = zipx only, then immediately processes many paths under sibling repos.
Problems panel fills with diagnostics for those foreign files.
Expected Behavior
Do not sync out-of-workspace files to LSPs unless the user opens them (or explicitly attaches them).
Agent restore must not silently rehydrate out-of-workspace documents into the LSP document set.
Empty editor group + Reload should leave LSPs with only in-workspace documents.
Operating System
macOS
Version Information
Cursor 3.13.10 (Metals client id Cursor 1.128.0)
Does this stop you from using Cursor
No, but it badly breaks Problems / CPU for Scala workspaces next to sibling repos after agent sessions.
Related Metals issue
Steps to Reproduce
Steps to Reproduce
On disk, have several sibling Scala/sbt repos under one parent, e.g. ~/projects/fun/{zipx,Anode,specular,ascent,…}.
In Cursor, open only one folder as the workspace: ~/projects/fun/zipx (single-folder, not a multi-root workspace of fun/).
In that zipx window, use Agent so it reads/edits files in sibling repos outside the workspace (e.g. ~/projects/fun/Anode/..., ~/projects/fun/specular/...). This leaves out-of-workspace paths in Cursor agent/chat state (User/globalStorage/state.vscdb → cursorDiskKV: agentKv / bubbleId / composerData).
Close all editor tabs. Confirm the UI shows no open files.
Command Palette → Developer: Reload Window.
With Metals (or watch any LSP that reacts to didOpen):
Metals starts correctly for zipx only: Started … in folders '…/zipx'
Within ~1s the Metals log shows many out-of-workspace paths, e.g.:
no build target found for …/Anode/.../ProgressiveWebApp.scala
Scala CLI started for …/Anode/... / …/specular/... / etc.
Problems fills with diagnostics for those foreign files
ps shows many scala-cli … bsp processes
Optional confirmation that this is not Metals DB restore:
Same out-of-workspace didOpen / Scala CLI storm returns
Expected
Empty editor group + single-folder workspace ⇒ LSPs only see in-workspace documents. Agent history must not silently rehydrate sibling-repo files into LSP document sync.
Hey, thanks for the detailed report. The repro steps, logs, and the confirmation that the state survives Reload Window and clearing the Metals cache really helped. I also looked at the Metals log screenshot.
This is a confirmed bug on our side. Unresolved agent changes not accepted or rejected are persisted across sessions and, after a window reload, they get sent through LSP again, including files from sibling repos outside the current workspace. That’s why Metals starts picking up other .scala files as orphan files. I’ve filed this internally, but I can’t share an ETA for the fix yet.
Workaround that should stop the storm:
In the affected workspace, go through the agent’s pending changes and click Keep All or Undo All in the review bar to accept or reject everything. This clears the saved diff state that keeps feeding Metals, and after the next Reload Window it shouldn’t rehydrate.
If Keep All or Undo All gets stuck or the diffs don’t go away, which can happen with phantom diffs, try closing the specific chat that created those changes. The review state is tied to the chat, and closing it usually resets the related diffs.
Going forward, if the agent needs to work with sibling repos, start the session from that repo’s own folder, or open the common parent as a multi-root workspace. That way those paths won’t leak into the other project’s LSP.
One note: files the agent opens during an active session will still be reported to LSP. That’s current behavior. The bug is specifically that the state comes back after reload. If the storm still comes back after these steps, let me know and we’ll dig deeper.