Skip to content

Add workspace scanning to oak_scan and wire it to the LSP#1244

Open
lionel- wants to merge 9 commits into
oak/salsa-11-scan-libraryfrom
oak/salsa-12-scan-workspace
Open

Add workspace scanning to oak_scan and wire it to the LSP#1244
lionel- wants to merge 9 commits into
oak/salsa-11-scan-libraryfrom
oak/salsa-12-scan-workspace

Conversation

@lionel-
Copy link
Copy Markdown
Contributor

@lionel- lionel- commented May 29, 2026

Branched from #1243
Progress towards #1212

This PR adds workspace scanning to oak_scan and wires it into the LSP. The scanner walks a workspace folder, finds packages (any DESCRIPTION file in the tree with a Package field, honoring .gitignore) and top-level R scripts, and registers them under a Root in oak_db.

The LSP feeds three event types into the scanner:

  • initialize and didChangeWorkspaceFolders update workspace roots in the DB.
  • didChangeWatchedFiles applies surgical updates for single R files. When a change to a DESCRIPTION file is detected, this triggers a full rescan of the containing root (package files might be demoted to scripts).

Editor-owned URLs (files the editor has open) get special handling because we ignore disk state for those. The editor contents are the source of truth. When a workspace is removed, these files survive and get placed in OrphanRoot. This way analysis keeps working when a user closes a workspace folder while a buffer from it is still open.

Files that leave a live workspace (folder removed, file deleted, buffer closed) route to StaleRoot. We keep them there for as long as they remain deleted, and we bring them back if they are added again. This allows reusing the File inputs without creating new ones. Salsa inputs are never garbage collected so reusing them (based on their URL key) avoids unbounded memory growth when e.g. switching git branches, which can delete and bring back many files at a time.

Workspace scans run synchronously in the main loop of the LSP in this PR. Since these operations are too heavy to be run synchronously, and would stall requests from user interactions, the next PR moves
them off the main loop.

@lionel- lionel- force-pushed the oak/salsa-12-scan-workspace branch from 48eb900 to a29744e Compare May 29, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant