Skip to content

Commit 210899f

Browse files
committed
fix(api): route setConfiguration through ClineProvider.setValues
Route the CS API setConfiguration write through ClineProvider.setValues instead of the raw context proxy so the view-local subset stays in sync with the sidebar view's state. A direct context-proxy write leaves the view-local apiConfiguration stale; the mode-switch / profile-activation paths re-apply the current provider settings to the focused task on every user message, so a task started after an API setConfiguration runs with the stale configuration (wrong model / reasoning flags / endpoint). That is the deterministic 13-test e2e provider-suite failure (72/13) on this head: the provider suites configure the provider via setConfiguration and the mock serves fixtures by the model the request actually carries. Ported from the F5 head (vps2 F5) where the e2e provider suites pass; includes the unit spec asserting the routing. Upstream: #982 (vps2 F3)
1 parent fe0dfd1 commit 210899f

2 files changed

Lines changed: 56 additions & 1 deletion

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { describe, expect, it, vi } from "vitest"
2+
3+
import { providerIdentifiers } from "@roo-code/types"
4+
5+
import { API } from "../api"
6+
import type { ClineProvider } from "../../core/webview/ClineProvider"
7+
import type { OutputChannel } from "vscode"
8+
9+
vi.mock("@roo-code/ipc", () => ({
10+
IpcServer: class {},
11+
}))
12+
13+
vi.mock("../../integrations/terminal/Terminal", () => ({
14+
Terminal: {
15+
getTerminalProfile: vi.fn(),
16+
setTerminalProfile: vi.fn(),
17+
},
18+
}))
19+
20+
vi.mock("../../integrations/terminal/TerminalRegistry", () => ({
21+
TerminalRegistry: {
22+
closeIdleTerminals: vi.fn(),
23+
},
24+
}))
25+
26+
describe("API.setConfiguration", () => {
27+
it("routes configuration through ClineProvider.setValues so view-local state stays in sync", async () => {
28+
const provider = {
29+
context: {},
30+
on: vi.fn(),
31+
setValues: vi.fn().mockResolvedValue(undefined),
32+
contextProxy: {
33+
setValues: vi.fn().mockResolvedValue(undefined),
34+
},
35+
providerSettingsManager: {
36+
saveConfig: vi.fn().mockResolvedValue("default-id"),
37+
},
38+
postStateToWebview: vi.fn().mockResolvedValue(undefined),
39+
} as unknown as ClineProvider
40+
const api = new API({ appendLine: vi.fn() } as unknown as OutputChannel, provider)
41+
const configuration = {
42+
apiProvider: providerIdentifiers.bedrock,
43+
currentApiConfigName: "default",
44+
awsRegion: "us-east-1",
45+
apiModelId: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
46+
}
47+
48+
await api.setConfiguration(configuration)
49+
50+
expect(provider.setValues).toHaveBeenCalledWith(configuration)
51+
expect(provider.contextProxy.setValues).not.toHaveBeenCalled()
52+
expect(provider.providerSettingsManager.saveConfig).toHaveBeenCalledWith("default", configuration)
53+
expect(provider.postStateToWebview).toHaveBeenCalled()
54+
})
55+
})

‎src/extension/api.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
565565
}
566566

567567
public async setConfiguration(values: RooCodeSettings) {
568-
await this.sidebarProvider.contextProxy.setValues(values)
568+
await this.sidebarProvider.setValues(values)
569569
await this.sidebarProvider.providerSettingsManager.saveConfig(values.currentApiConfigName || "default", values)
570570
if (values.modeApiConfigs) {
571571
await Promise.all(

0 commit comments

Comments
 (0)