Skip to content

Commit 968b489

Browse files
committed
fix(task): persist selected provider profile on task
1 parent c39a473 commit 968b489

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/core/task/Task.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
15401540
// Update this task's API configuration to match the new profile
15411541
// This ensures the parser state is synchronized with the selected model
15421542
const newState = await provider.getState()
1543+
this.setTaskApiConfigName(newState?.currentApiConfigName ?? providerProfile)
15431544
if (newState?.apiConfiguration) {
15441545
this.updateApiConfiguration(newState.apiConfiguration)
15451546
}

src/core/task/__tests__/Task.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,30 @@ describe("Cline", () => {
17911791
expect(requireDefined(createMessage.mock.calls[0])[2]?.mode).toBe("code")
17921792
})
17931793

1794+
it("stores a provider profile selected through submitUserMessage", async () => {
1795+
const selectedConfiguration: ProviderSettings = {
1796+
...mockApiConfig,
1797+
apiModelId: "selected-model",
1798+
}
1799+
const task = new Task({
1800+
provider: mockProvider,
1801+
apiConfiguration: mockApiConfig,
1802+
task: "initial task",
1803+
startTask: false,
1804+
})
1805+
task.setTaskApiConfigName("previous-profile")
1806+
vi.spyOn(mockProvider, "setProviderProfile").mockResolvedValue(undefined)
1807+
vi.spyOn(mockProvider, "getState").mockResolvedValue({
1808+
currentApiConfigName: "selected-profile",
1809+
apiConfiguration: selectedConfiguration,
1810+
})
1811+
vi.spyOn(task, "handleWebviewAskResponse").mockImplementation(() => {})
1812+
1813+
await task.submitUserMessage("switch profiles", undefined, undefined, "selected-profile")
1814+
1815+
expect(task.taskApiConfigName).toBe("selected-profile")
1816+
})
1817+
17941818
it("should handle empty messages gracefully", async () => {
17951819
const task = new Task({
17961820
provider: mockProvider,

0 commit comments

Comments
 (0)