Skip to content

feat: add per-workspace API profile selection#11612

Draft
roomote[bot] wants to merge 1 commit intomainfrom
feat/workspace-api-profiles
Draft

feat: add per-workspace API profile selection#11612
roomote[bot] wants to merge 1 commit intomainfrom
feat/workspace-api-profiles

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 19, 2026

Related GitHub Issue

Closes: #8010

Description

This PR attempts to address Issue #8010 by adding per-workspace API profile selection. The branch was created by @ruben-benaco and has been rebased onto the latest main.

Key implementation details:

  • Workspace-scoped configuration storage: Uses VS Code's workspaceState to store workspace-specific API profile overrides via a new WorkspaceOverrides schema in ProviderSettingsManager.
  • Scope toggle in UI: The ApiConfigSelector component gains a scope toggle button (Global / Workspace) that lets users choose whether a profile selection applies globally or only to the current workspace.
  • Visual indicator: A [W] badge appears next to the profile name when workspace scope is active.
  • ContextProxy.setLocalValue(): A new method that updates the in-memory cache without persisting to globalState, preventing workspace-scoped values from leaking to other VS Code windows.
  • Fallback behavior: When no workspace override exists, the global profile is used (preserving existing behavior by default).
  • Mode-aware workspace overrides: Workspace overrides support per-mode API config mappings.

Test Procedure

  • All 61 tests in ProviderSettingsManager.spec.ts pass (covering workspace override CRUD, scope toggling, fallback behavior, and profile activation with scope).
  • All 93 tests in ClineProvider.spec.ts pass (87 passed, 6 skipped).
  • Full type checking passes across all 14 monorepo packages.
  • Manual testing: Open two VS Code windows with different workspaces, select different API profiles with workspace scope in each, verify they remain independent.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: I have considered if my changes require documentation updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.
  • Yes, documentation updates are required. The new workspace scope toggle and [W] indicator should be documented in user-facing docs.

Additional Notes

This PR is based on the existing feat/workspace-api-profiles branch (per @ruben-benaco's request in #8010). It has been rebased onto the latest main to resolve any drift. Feedback and guidance are welcome.

Files changed (11):

  • packages/types/src/vscode-extension-host.ts - Added currentConfigScope to ExtensionState and scope to WebviewMessage
  • src/core/config/ContextProxy.ts - Added setLocalValue() method for in-memory-only cache updates
  • src/core/config/ProviderSettingsManager.ts - Added workspace override storage, scope-aware profile activation, and active profile resolution
  • src/core/config/__tests__/ProviderSettingsManager.spec.ts - Comprehensive tests for workspace override functionality
  • src/core/webview/ClineProvider.ts - Wired scope through to profile activation and state
  • src/core/webview/__tests__/ClineProvider.spec.ts - Updated tests for scope support
  • src/core/webview/webviewMessageHandler.ts - Pass scope from webview messages to profile activation
  • webview-ui/src/components/chat/ApiConfigSelector.tsx - Added scope toggle UI with Global/Workspace button
  • webview-ui/src/components/chat/ChatTextArea.tsx - Wired scope state and handlers to ApiConfigSelector
  • webview-ui/src/i18n/locales/en/prompts.json - Added scope/global/workspace translation strings
  • src/core/webview/__tests__/ClineProvider.apiHandlerRebuild.spec.ts - Minor test update

Start a new Roo Code Cloud session on this branch

Implements per-workspace API profile selection as requested in #8010.
Addresses critical issues from review by @daniel-lxs:

1. Fix: Workspace selection no longer overwrites global config across windows.
   When scope="workspace", only the local cache is updated via setLocalValue(),
   avoiding leaking currentApiConfigName to other windows via shared globalState.

2. Fix: Toggling scope back to Global now clears workspace overrides via
   clearWorkspaceOverrides(), preventing stale workspace state from keeping
   the scope stuck on "workspace".

Backend changes:
- Add ConfigScope type and WorkspaceOverrides schema to ProviderSettingsManager
- Add workspace override methods (getWorkspaceOverrides, storeWorkspaceOverrides,
  clearWorkspaceOverrides, getConfigScope, getActiveProfileName)
- Modify activateProfile and setModeConfig to accept scope parameter
- Modify getModeConfigId to check workspace overrides first
- Add setLocalValue to ContextProxy for cache-only state updates
- Add scope field to WebviewMessage and currentConfigScope to ExtensionState

Frontend changes:
- Add scope toggle UI to ApiConfigSelector with [W] indicator
- Wire scope through ChatTextArea to pass with config changes
- Add i18n translation keys for scope UI elements

Testing:
- Add comprehensive workspace-scoped tests to ProviderSettingsManager.spec.ts
- Update ClineProvider test mocks with getConfigScope method
- All tests passing (175 across 5 test files)

Fixes #8010
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.

[ENHANCEMENT] Per-workspace API profile selection (sticky across restarts)

1 participant

Comments