Skip to content

Commit aa07009

Browse files
committed
fix(task): persist selected provider profile on task
1 parent bf2cea1 commit aa07009

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
@@ -1513,6 +1513,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
15131513
// Update this task's API configuration to match the new profile
15141514
// This ensures the parser state is synchronized with the selected model
15151515
const newState = await provider.getState()
1516+
this.setTaskApiConfigName(newState?.currentApiConfigName ?? providerProfile)
15161517
if (newState?.apiConfiguration) {
15171518
this.updateApiConfiguration(newState.apiConfiguration)
15181519
}

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

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

1711+
it("stores a provider profile selected through submitUserMessage", async () => {
1712+
const selectedConfiguration: ProviderSettings = {
1713+
...mockApiConfig,
1714+
apiModelId: "selected-model",
1715+
}
1716+
const task = new Task({
1717+
provider: mockProvider,
1718+
apiConfiguration: mockApiConfig,
1719+
task: "initial task",
1720+
startTask: false,
1721+
})
1722+
task.setTaskApiConfigName("previous-profile")
1723+
vi.spyOn(mockProvider, "setProviderProfile").mockResolvedValue(undefined)
1724+
vi.spyOn(mockProvider, "getState").mockResolvedValue({
1725+
currentApiConfigName: "selected-profile",
1726+
apiConfiguration: selectedConfiguration,
1727+
})
1728+
vi.spyOn(task, "handleWebviewAskResponse").mockImplementation(() => {})
1729+
1730+
await task.submitUserMessage("switch profiles", undefined, undefined, "selected-profile")
1731+
1732+
expect(task.taskApiConfigName).toBe("selected-profile")
1733+
})
1734+
17111735
it("should handle empty messages gracefully", async () => {
17121736
const task = new Task({
17131737
provider: mockProvider,

0 commit comments

Comments
 (0)