Skip to content

feat(workspace): add rootResolution setting for multi-root workspaces#538

Open
simurg79 wants to merge 1 commit into
Zoo-Code-Org:mainfrom
simurg79:feat/workspace-root-resolution
Open

feat(workspace): add rootResolution setting for multi-root workspaces#538
simurg79 wants to merge 1 commit into
Zoo-Code-Org:mainfrom
simurg79:feat/workspace-root-resolution

Conversation

@simurg79

@simurg79 simurg79 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports the workspace root resolution feature from simurg79/Roo-Code (commit d89c1ff) into Zoo-Code.

Introduces a new zoo-code.workspace.rootResolution VS Code setting that controls how Zoo resolves the "project root" in a multi-root workspace (used to locate .roomodes, .roo/mcp.json, .roo/rules/, and other project-scoped configuration):

Value Behavior
activeEditor (default) Prefer the workspace folder containing the active editor; fall back to workspaceFolders[0]. Preserves legacy behavior.
firstFolder Always use workspaceFolders[0]. Deterministic — independent of which file is focused.

The default preserves today's behavior exactly, so this is a non-breaking, opt-in change.

Motivation

The historic active-editor heuristic is convenient but non-deterministic: switching the focused file between roots silently changes which project config is picked up, and it can disagree with the marketplace installers (which always target workspaceFolders[0]). firstFolder gives a stable root for CI/automation and multi-root setups where only one folder is the real project.

Changes

Port notes

  • Settings namespace adapted from the fork's roo-cline.* to Zoo-Code's zoo-code.*.
  • The test reads the shared vscode mock via resolve.alias (mutation-based) to match Zoo-Code's src/vitest.config.ts.

Testing

cd src && npx vitest run utils/__tests__/path.spec.ts30 passed. Both modified JSON files validated as parseable. Pre-commit lint hooks passed.

Summary by CodeRabbit

  • New Features

    • Added zoo-code.workspace.rootResolution setting to control how workspace root is detected: activeEditor (default, legacy behavior) or firstFolder (deterministic mode for multi-root workspaces).
  • Documentation

    • Added specification for workspace root resolution behavior and configuration options.

Introduces a new zoo-code.workspace.rootResolution VS Code setting with two strategies:

- activeEditor (default): legacy behavior - prefer the workspace folder containing the active editor, fall back to workspaceFolders[0].

- firstFolder: deterministic - always use workspaceFolders[0], independent of the focused file.

Updates getWorkspacePath() and getWorkspacePathForContext() in src/utils/path.ts to honor the setting, registers it in src/package.json with localized strings in src/package.nls.json, expands src/utils/__tests__/path.spec.ts with focused unit tests for both strategies, and adds a design doc at docs/design/workspace-root-resolution.md.

Ported from simurg79/Roo-Code commit d89c1ff (settings namespace adapted roo-cline -> zoo-code).
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1029a2c6-8416-4fda-8810-884a5dc550c8

📥 Commits

Reviewing files that changed from the base of the PR and between c7f1d19 and b8f5058.

📒 Files selected for processing (5)
  • docs/design/workspace-root-resolution.md
  • src/package.json
  • src/package.nls.json
  • src/utils/__tests__/path.spec.ts
  • src/utils/path.ts

📝 Walkthrough

Walkthrough

This PR introduces a zoo-code.workspace.rootResolution configuration setting for multi-root workspaces. Users can now choose between activeEditor mode (default, uses the active editor's folder) and firstFolder mode (deterministic, always uses the first workspace folder). The change includes design documentation, VS Code extension configuration, core resolver implementation, and comprehensive tests.

Changes

Workspace Root Resolution Feature

Layer / File(s) Summary
Design specification
docs/design/workspace-root-resolution.md
Design document specifying the new zoo-code.workspace.rootResolution setting with activeEditor and firstFolder modes, exception-safe config reading, behavior matrices for multi-root and edge cases, documented non-effects (tasks, global config, subfolder rules), usage guidance, and test coverage expectations.
Configuration schema and localization
src/package.json, src/package.nls.json
VS Code extension config declares zoo-code.workspace.rootResolution as a string enum with activeEditor (default) and firstFolder choices; localization file provides descriptions for the setting and both modes.
Workspace resolution implementation
src/utils/path.ts
Exports WorkspaceRootResolution type; introduces getRootResolutionStrategy() to safely read the config setting with try/catch fallback; updates getWorkspacePath() to deterministically choose folder based on strategy (first folder in firstFolder mode, else prefer active editor's folder); updates getWorkspacePathForContext() to short-circuit in firstFolder mode, bypassing context-path lookup.
Test coverage and helpers
src/utils/__tests__/path.spec.ts
Refactors mocking from inline vi.mock to imported shared mock; adds typed helpers (setRootResolution, withWorkspaceMock) to mutate/restore mock state per test; covers both resolution modes, workspace folder selection, fallback when folders/editor missing, config read exceptions, and validates getWorkspaceFolder call patterns.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • taltas
  • navedmerchant
  • hannesrudolph
  • edelauna

Poem

🐰 A rabbit hops through multi-root lands,
Where workspace paths now bend to commands,
First folder sure, or editor's lead—
Both modes dance well, deterministic indeed!
The resolution is clear, no more chance,
Zoo-Code's workspace takes its rightful stance. 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: introducing a rootResolution setting for multi-root workspace handling.
Description check ✅ Passed The PR description is comprehensive, covering summary, motivation, changes, port notes, and testing details; matches template intent despite using custom structure.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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