Skip to content

fix: don't prompt when all workspace folders share one Bazel workspace#666

Open
omri-steinmetz wants to merge 1 commit into
bazel-contrib:masterfrom
omri-steinmetz:multi-root-single-bazel-workspace
Open

fix: don't prompt when all workspace folders share one Bazel workspace#666
omri-steinmetz wants to merge 1 commit into
bazel-contrib:masterfrom
omri-steinmetz:multi-root-single-bazel-workspace

Conversation

@omri-steinmetz

Copy link
Copy Markdown

Problem

In a multi-root VS Code workspace, BazelWorkspaceInfo.fromWorkspaceFolders() unconditionally calls vscode.window.showWorkspaceFolderPick(). When it runs without a user gesture — e.g. the Bazel target completion-provider refresh right after activation — the pick resolves to undefined and the extension logs:

[error] Failed to find a Bazel workspace

This happens even when every workspace folder belongs to the same Bazel workspace (a common monorepo layout: a root folder plus per-package/per-service subfolders in a .code-workspace). There is nothing for the user to disambiguate, and no setting to suppress the error.

Related: #446 covers the non-Bazel-repo case; this covers the multi-root single-Bazel-workspace case.

Fix

Resolve each workspace folder to its Bazel workspace root first (via the existing fromWorkspaceFolder), then:

Testing

  • npm run typecheck, eslint, prettier --check, and npm run build pass.
  • xvfb-run -a npm run test:unit: 123 passing, 1 failing — the same pre-existing lcov parser / function coverage details failure occurs on unpatched master in the same environment (Rust demangling difference), unrelated to this change.
  • Manually verified against a 20-folder multi-root workspace whose folders all resolve to one Bazel workspace root: the activation-time error no longer fires, and target queries use the shared root.

🤖 Generated with Claude Code

In a multi-root VS Code workspace, fromWorkspaceFolders() always showed
a workspace-folder quick pick. When it ran without a user gesture (e.g.
the target-completion refresh at activation), the pick resolved to
undefined and the extension logged "Failed to find a Bazel workspace"
even though every folder belonged to the same Bazel workspace.

Resolve each folder to its Bazel workspace first: if none qualify,
return undefined silently; if they all map to a single Bazel workspace
root, use it without prompting; only show the picker when the folders
span multiple distinct Bazel workspaces.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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