Skip to content

Import a VS Code .code-workspace file's folders into a project - #8086

Open
ymichael wants to merge 2 commits into
mainfrom
bb/code-workspace-import-thr_psx98pzvux
Open

ymichael wants to merge 2 commits into
mainfrom
bb/code-workspace-import-thr_psx98pzvux

Conversation

@ymichael

@ymichael ymichael commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

#2181 asks to bring a VS Code multi-root workspace into bb. Since #8007 a project's checkout on a machine can carry extra folders that its threads there can read and write, but each folder had to be added one at a time. A .code-workspace file already lists them, and there was no way to use it.

What changed

Following timurkhakhalev's proposal on #2181 (one project with several folders), importing a .code-workspace fills the folders of the project's checkout on one machine.

Server.

  • POST /projects/:id/sources/:sourceId/folders/import with { path }. It reads the file on the checkout's machine with host.read_file, so no daemon change and no protocol bump.
  • code-workspace.ts parses VS Code's lenient JSON (comments, trailing commas, BOM) with strip-json-comments, which the server already installs through pino-pretty; the lockfile only adds the direct link. It reads folders[].path, and folders[].uri when it is a file: URI (local host only); other URI schemes (vscode-remote://, …) are reported, not added.
  • Relative paths resolve against the file's directory.
  • Each folder goes through tryAddProjectSourceFolder, the same path as bb project folder add and update. It returns the folder or a typed problem (main_folder, inside_main_folder, contains_main_folder, duplicate, not_found, limit, …) from workspaceFolderPathProblem; add/update turn it into the same HTTP errors as before, and import maps it straight to a skip reason.
  • The main folder and folders inside it are skipped, not errors: threads can already use them.
  • The result lists added folders and skipped folders, each with a reason (main_folder, inside_main_folder, duplicate, not_found, limit, invalid, unsupported_uri) and a message.
  • A malformed folders entry (for example "path": 42) is skipped as invalid under its index (folders[5]); the rest of the file still imports.
  • A file that is not a workspace returns 400. A missing file returns 404.

SDK and CLI.

App. Each machine's folder list in project settings gains an "Import .code-workspace" action next to "Add folder", shown while the machine is online. It opens a dialog with the machine's folder browser, starting at the main folder. RemotePathBrowser gained an optional fileSelection prop, so clicking a .code-workspace file fills the path; the path can also be typed. The dialog then shows what was added and what was skipped and why.

Compared with T3 (WorkspaceFolders.ts: decodeCodeWorkspace, scanFolders):

  • T3 looks for a .code-workspace in a scanned folder's root. Here the user names the file, so one anywhere on the machine works.
  • T3 ignores uri entries and drops missing folders silently. Here file: URIs are imported, and every folder that is not added is reported with its reason.
  • T3 deduplicates by real path; here duplicates are matched on the canonical path, the same as adding a folder by hand. A symlink to an already listed folder is added as its own entry.

How you verified

Live (pnpm start:worktree, real host daemon). The project's main folder was ws-demo/app, and ws-demo/app/app.code-workspace listed ., packages/ui, ../api, an absolute …/ws-demo/docs-site, ../not-cloned-yet and a vscode-remote:// URI, with comments and trailing commas:

$ bb project folder import proj_2t863s9r8e …/ws-demo/app/app.code-workspace
Added    ws-demo/api
Added    ws-demo/docs-site
Skipped  Folder ws-demo/app is the main folder
Skipped  Folder ws-demo/app/packages/ui is inside the main folder, which threads can already use
Skipped  Folder ws-demo/not-cloned-yet does not exist on this machine
Skipped  vscode-remote://ssh-remote+devbox/home/me/infra is not a folder on this machine
  • Running it again reports api and docs-site as already listed.
  • A missing file gives HTTP 404: Path does not exist, and a non-workspace file gives is not a VS Code workspace file.
  • In the settings UI, picking app.code-workspace in the dialog's folder browser filled the path, and the import added both folders, the folder list updated, and the dialog listed the four skipped folders with their reasons. Checked at desktop and mobile sizes, including the pending state.

Tests:

  • code-workspace.test.ts: comments, trailing commas, BOM, // inside strings, file: URIs (including Windows drive paths and localhost), other schemes, malformed entries reported per entry, and non-workspace input.
  • public-project-source-folders.test.ts: one import covering added, main, inside, duplicate, missing, contains-the-main-folder, malformed-entry and URI folders; a broken file; a relative file path; a missing file.
  • Ran pnpm exec turbo run typecheck lint --filter='...[origin/main]' and the @bb/server, @bb/app, @bb/cli, @bb/sdk, @bb/server-contract and @bb/templates suites.
  • After the follow-up commit: pnpm exec turbo run typecheck lint test --filter=@bb/server --filter=@bb/app --filter=@bb/templates (17/17 tasks), plus a live re-run of the CLI import and the dialog at desktop and phone widths.
  • The only local failures were install-machine-script and timeline-guard-coverage, under load average ~100. Both also fail on other branches and don't touch this code.

Fixes #2181

AGENT GENERATED

🤖 Generated with Claude Code

ymichael added a commit that referenced this pull request Nov 24, 2026
Squashed rebase of #8086 onto main. The import action sits next to
"Add folder" as a SettingsListAction in the machine row that #8112
introduced. Plugin SDK 0.6.200.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael force-pushed the bb/code-workspace-import-thr_psx98pzvux branch from 5497cf2 to b571634 Compare November 24, 2026 22:41
Squashed rebase of #8086 onto main. The import action sits next to
"Add folder" as a SettingsListAction in the machine row that #8112
introduced. Plugin SDK 0.6.203.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael force-pushed the bb/code-workspace-import-thr_psx98pzvux branch from b571634 to 78f5678 Compare November 25, 2026 01:00
- Folder checks return a typed problem kind. add, update and import share
  one tryAddProjectSourceFolder path, so import maps the kind to a skip
  reason instead of re-checking the main folder and reading HTTP codes.
- The import dialog embeds the remote path browser, which can now select
  files; clicking a .code-workspace file fills the path.
- Parse JSONC with strip-json-comments (already installed via pino-pretty)
  instead of a hand-written stripper, and report a malformed folders entry
  as invalid instead of rejecting the whole file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

Feature request: import a VS Code multi-root workspace (.code-workspace) into bb

1 participant