Skip to content

Commit 1922745

Browse files
committed
fix(webview): sync flat provider settings to local state
1 parent a75d707 commit 1922745

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

src/core/webview/ClineProvider.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import {
5050
DEFAULT_CHECKPOINT_TIMEOUT_SECONDS,
5151
getModelId,
5252
isRetiredProvider,
53+
PROVIDER_SETTINGS_KEYS,
5354
} from "@roo-code/types"
5455
import { RateLimitClock, createRateLimitClock } from "../task/RateLimitClock"
5556
import { aggregateTaskCostsRecursive, type AggregatedCosts } from "./aggregateTaskCosts"
@@ -3043,6 +3044,19 @@ export class ClineProvider
30433044
} else {
30443045
this.viewLocalState.apiConfiguration = val
30453046
}
3047+
} else if (PROVIDER_SETTINGS_KEYS.some((key) => key in values)) {
3048+
const providerSettingsUpdate = PROVIDER_SETTINGS_KEYS.reduce((acc, key) => {
3049+
if (key in values) {
3050+
return { ...acc, [key]: values[key as keyof RooCodeSettings] }
3051+
}
3052+
3053+
return acc
3054+
}, {} as ProviderSettings)
3055+
3056+
this.viewLocalState.apiConfiguration = {
3057+
...(this.viewLocalState.apiConfiguration ?? {}),
3058+
...providerSettingsUpdate,
3059+
}
30463060
}
30473061
}
30483062

src/core/webview/__tests__/ClineProvider.parallelMode.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,6 +1294,33 @@ describe("ClineProvider - Parallel Mode Support", () => {
12941294

12951295
await provider.dispose()
12961296
})
1297+
1298+
it("should update viewLocalState apiConfiguration when setValues receives flat provider settings", async () => {
1299+
const provider = new ClineProvider(mockContext, mockOutputChannel, "sidebar", new ContextProxy(mockContext))
1300+
1301+
await (provider as any).saveViewState("apiConfiguration", {
1302+
apiProvider: "openrouter",
1303+
openRouterModelId: "openrouter/old-model",
1304+
})
1305+
1306+
await provider.setValues({
1307+
apiProvider: "bedrock",
1308+
awsUseApiKey: true,
1309+
awsApiKey: "mock-key",
1310+
awsRegion: "us-east-1",
1311+
apiModelId: "anthropic.claude-opus-4-8-20261215-v1:0",
1312+
awsBedrockEndpoint: "http://127.0.0.1:4567",
1313+
awsBedrockEndpointEnabled: true,
1314+
})
1315+
1316+
const state = await provider.getState()
1317+
1318+
expect(state.apiConfiguration.apiProvider).toBe("bedrock")
1319+
expect(state.apiConfiguration.awsBedrockEndpoint).toBe("http://127.0.0.1:4567")
1320+
expect((provider as any).viewLocalState.apiConfiguration.apiProvider).toBe("bedrock")
1321+
1322+
await provider.dispose()
1323+
})
12971324
})
12981325

12991326
describe("multi-instance isolation", () => {

0 commit comments

Comments
 (0)