Skip to content

Commit 613d31a

Browse files
committed
fix(api): sync setConfiguration view-local state
1 parent a0405d2 commit 613d31a

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

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

src/extension/api.ts

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

505505
public async setConfiguration(values: RooCodeSettings) {
506-
await this.sidebarProvider.contextProxy.setValues(values)
506+
await this.sidebarProvider.setValues(values)
507507
await this.sidebarProvider.providerSettingsManager.saveConfig(values.currentApiConfigName || "default", values)
508508
await this.sidebarProvider.postStateToWebview()
509509
}

0 commit comments

Comments
 (0)