Skip to content

fix: default lockApiConfigAcrossModes to true to prevent silent profile switching#12246

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/lock-api-config-default-true
Draft

fix: default lockApiConfigAcrossModes to true to prevent silent profile switching#12246
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/lock-api-config-default-true

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented Apr 30, 2026

Related GitHub Issue

Closes: #12222
Also related: #12237

Description

This PR attempts to address Issue #12222 (and the related #12237) by changing the default value of lockApiConfigAcrossModes from false to true.

The core problem: When users switch modes (code, architect, debug, etc.) -- whether manually or via AI-triggered switch_mode tool calls -- the extension silently changes the active API configuration/model. This is unexpected and causes billing confusion for users with multiple API profiles.

What this PR does:

  1. Changes the default of lockApiConfigAcrossModes from false to true across all code paths (backend state reads, frontend initial state). This means by default, mode switches will no longer change the active API configuration. Users who want per-mode API configs can still unlock this via the lock/unlock icon in the API config selector popover.

  2. Guards the cloud profile sync path (syncCloudProfiles) to also respect the lock setting, preventing background cloud sync from silently switching the active profile when the user has it locked.

  3. Adds a test verifying that the default behavior (no explicit setting) keeps the API config locked across mode switches.

Files changed:

  • src/core/webview/ClineProvider.ts -- default value changed from false to true in 4 places; cloud sync guarded
  • webview-ui/src/context/ExtensionStateContext.tsx -- frontend initial state default changed
  • src/core/webview/__tests__/ClineProvider.lockApiConfig.spec.ts -- new test for default behavior
  • src/core/webview/__tests__/ClineProvider.spec.ts -- existing tests explicitly set unlock for mode-specific config tests

Feedback and guidance are welcome.

Test Procedure

  • Ran all related test suites, all passing:
    • ClineProvider.lockApiConfig.spec.ts (3 tests)
    • ClineProvider.spec.ts (87 tests)
    • ClineProvider.sticky-mode.spec.ts (19 tests)
    • ClineProvider.sticky-profile.spec.ts (14 tests)
    • webviewMessageHandler.lockApiConfig.spec.ts (2 tests)
    • ChatTextArea.lockApiConfig.spec.tsx (5 tests)
  • Full monorepo lint and type-check passed

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 (if applicable).
  • Documentation Impact: No documentation updates needed -- this changes a default value for an existing setting.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Interactively review PR in Roo Code Cloud

…le switching

Changes the default value of lockApiConfigAcrossModes from false to true,
so that by default, switching modes (whether user-initiated or AI-triggered)
will NOT change the active API configuration/model.

Users who want per-mode API configs can still unlock this via the lock icon
in the API config selector popover.

Also guards the cloud profile sync path to respect the lock setting,
preventing silent profile changes from background cloud sync.

Addresses #12222 and #12237.
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.

[BUG] Intermittent switching of API profiles

1 participant