Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/types/src/vscode-extension-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export type ExtensionState = Pick<
| "showWorktreesInHomeScreen"
| "disabledTools"
> & {
lockApiConfigAcrossModes?: boolean
version: string
clineMessages: ClineMessage[]
currentTaskItem?: HistoryItem
Expand Down Expand Up @@ -524,6 +525,7 @@ export interface WebviewMessage {
| "searchFiles"
| "toggleApiConfigPin"
| "hasOpenedModeSelector"
| "lockApiConfigAcrossModes"
| "clearCloudAuthSkipModel"
| "cloudButtonClicked"
| "rooCloudSignIn"
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/core/webview/ClineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,8 @@ export class ClineProvider
// Load the saved API config for the restored mode if it exists.
// Skip mode-based profile activation if historyItem.apiConfigName exists,
// since the task's specific provider profile will override it anyway.
if (!historyItem.apiConfigName) {
const lockApiConfigAcrossModes = this.context.workspaceState.get("lockApiConfigAcrossModes", false)
if (!historyItem.apiConfigName && !lockApiConfigAcrossModes) {
const savedConfigId = await this.providerSettingsManager.getModeConfigId(historyItem.mode)
const listApiConfig = await this.providerSettingsManager.listConfig()

Expand Down Expand Up @@ -1316,6 +1317,13 @@ export class ClineProvider

this.emit(RooCodeEventName.ModeChanged, newMode)

// If workspace lock is on, keep the current API config — don't load mode-specific config
const lockApiConfigAcrossModes = this.context.workspaceState.get("lockApiConfigAcrossModes", false)
if (lockApiConfigAcrossModes) {
await this.postStateToWebview()
return
}

// Load the saved API config for the new mode if it exists.
const savedConfigId = await this.providerSettingsManager.getModeConfigId(newMode)
const listApiConfig = await this.providerSettingsManager.listConfig()
Expand Down Expand Up @@ -2081,6 +2089,7 @@ export class ClineProvider
openRouterImageGenerationSelectedModel,
featureRoomoteControlEnabled,
isBrowserSessionActive,
lockApiConfigAcrossModes,
} = await this.getState()

let cloudOrganizations: CloudOrganizationMembership[] = []
Expand Down Expand Up @@ -2229,6 +2238,7 @@ export class ClineProvider
profileThresholds: profileThresholds ?? {},
cloudApiUrl: getRooCodeApiUrl(),
hasOpenedModeSelector: this.getGlobalState("hasOpenedModeSelector") ?? false,
lockApiConfigAcrossModes: lockApiConfigAcrossModes ?? false,
alwaysAllowFollowupQuestions: alwaysAllowFollowupQuestions ?? false,
followupAutoApproveTimeoutMs: followupAutoApproveTimeoutMs ?? 60000,
includeDiagnosticMessages: includeDiagnosticMessages ?? true,
Expand Down Expand Up @@ -2464,6 +2474,7 @@ export class ClineProvider
stateValues.codebaseIndexConfig?.codebaseIndexOpenRouterSpecificProvider,
},
profileThresholds: stateValues.profileThresholds ?? {},
lockApiConfigAcrossModes: this.context.workspaceState.get("lockApiConfigAcrossModes", false),
includeDiagnosticMessages: stateValues.includeDiagnosticMessages ?? true,
maxDiagnosticMessages: stateValues.maxDiagnosticMessages ?? 50,
includeTaskHistoryInEnhance: stateValues.includeTaskHistoryInEnhance ?? true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ describe("ClineProvider - API Handler Rebuild Guard", () => {
store: vi.fn().mockImplementation((key: string, value: string | undefined) => (secrets[key] = value)),
delete: vi.fn().mockImplementation((key: string) => delete secrets[key]),
},
workspaceState: {
get: vi.fn().mockReturnValue(undefined),
update: vi.fn().mockResolvedValue(undefined),
keys: vi.fn().mockReturnValue([]),
},
subscriptions: [],
extension: {
packageJSON: { version: "1.0.0" },
Expand Down
Loading
Loading