|
|
@@ -201,10 +201,13 @@ describe("ClineProvider - Sticky Provider Profile", () => {
|
|
|
let mockOutputChannel: vscode.OutputChannel
|
|
|
let mockWebviewView: vscode.WebviewView
|
|
|
let mockPostMessage: any
|
|
|
+ let originalRooCliRuntimeEnv: string | undefined
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
vi.clearAllMocks()
|
|
|
taskIdCounter = 0
|
|
|
+ originalRooCliRuntimeEnv = process.env.ROO_CLI_RUNTIME
|
|
|
+ delete process.env.ROO_CLI_RUNTIME
|
|
|
|
|
|
if (!TelemetryService.hasInstance()) {
|
|
|
TelemetryService.createInstance([])
|
|
|
@@ -293,6 +296,14 @@ describe("ClineProvider - Sticky Provider Profile", () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+ afterEach(() => {
|
|
|
+ if (originalRooCliRuntimeEnv === undefined) {
|
|
|
+ delete process.env.ROO_CLI_RUNTIME
|
|
|
+ } else {
|
|
|
+ process.env.ROO_CLI_RUNTIME = originalRooCliRuntimeEnv
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
describe("activateProviderProfile", () => {
|
|
|
beforeEach(async () => {
|
|
|
await provider.resolveWebviewView(mockWebviewView)
|
|
|
@@ -457,7 +468,7 @@ describe("ClineProvider - Sticky Provider Profile", () => {
|
|
|
})
|
|
|
|
|
|
describe("createTaskWithHistoryItem", () => {
|
|
|
- it("should restore provider profile from history item when reopening task", async () => {
|
|
|
+ it("should restore provider profile from history item when reopening task outside CLI runtime", async () => {
|
|
|
await provider.resolveWebviewView(mockWebviewView)
|
|
|
|
|
|
// Create a history item with saved provider profile
|
|
|
@@ -495,6 +506,71 @@ describe("ClineProvider - Sticky Provider Profile", () => {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ it("should skip restoring task apiConfigName from history in CLI runtime", async () => {
|
|
|
+ await provider.resolveWebviewView(mockWebviewView)
|
|
|
+ process.env.ROO_CLI_RUNTIME = "1"
|
|
|
+
|
|
|
+ const historyItem: HistoryItem = {
|
|
|
+ id: "test-task-id",
|
|
|
+ number: 1,
|
|
|
+ ts: Date.now(),
|
|
|
+ task: "Test task",
|
|
|
+ tokensIn: 100,
|
|
|
+ tokensOut: 200,
|
|
|
+ cacheWrites: 0,
|
|
|
+ cacheReads: 0,
|
|
|
+ totalCost: 0.001,
|
|
|
+ apiConfigName: "saved-profile",
|
|
|
+ }
|
|
|
+
|
|
|
+ const activateProviderProfileSpy = vi
|
|
|
+ .spyOn(provider, "activateProviderProfile")
|
|
|
+ .mockResolvedValue(undefined)
|
|
|
+ const logSpy = vi.spyOn(provider, "log")
|
|
|
+
|
|
|
+ vi.spyOn(provider.providerSettingsManager, "listConfig").mockResolvedValue([
|
|
|
+ { name: "saved-profile", id: "saved-profile-id", apiProvider: "anthropic" },
|
|
|
+ ])
|
|
|
+
|
|
|
+ await provider.createTaskWithHistoryItem(historyItem)
|
|
|
+
|
|
|
+ expect(activateProviderProfileSpy).not.toHaveBeenCalledWith({ name: "saved-profile" }, expect.anything())
|
|
|
+ expect(logSpy).toHaveBeenCalledWith(
|
|
|
+ expect.stringContaining("Skipping restore of provider profile 'saved-profile'"),
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it("should skip restoring mode-based provider config from history in CLI runtime", async () => {
|
|
|
+ await provider.resolveWebviewView(mockWebviewView)
|
|
|
+ process.env.ROO_CLI_RUNTIME = "1"
|
|
|
+
|
|
|
+ const historyItem: HistoryItem = {
|
|
|
+ id: "test-task-id",
|
|
|
+ number: 1,
|
|
|
+ ts: Date.now(),
|
|
|
+ task: "Test task",
|
|
|
+ tokensIn: 100,
|
|
|
+ tokensOut: 200,
|
|
|
+ cacheWrites: 0,
|
|
|
+ cacheReads: 0,
|
|
|
+ totalCost: 0.001,
|
|
|
+ mode: "code",
|
|
|
+ }
|
|
|
+
|
|
|
+ const activateProviderProfileSpy = vi
|
|
|
+ .spyOn(provider, "activateProviderProfile")
|
|
|
+ .mockResolvedValue(undefined)
|
|
|
+
|
|
|
+ vi.spyOn(provider.providerSettingsManager, "getModeConfigId").mockResolvedValue("mode-config-id")
|
|
|
+ vi.spyOn(provider.providerSettingsManager, "listConfig").mockResolvedValue([
|
|
|
+ { name: "mode-profile", id: "mode-config-id", apiProvider: "anthropic" },
|
|
|
+ ])
|
|
|
+
|
|
|
+ await provider.createTaskWithHistoryItem(historyItem)
|
|
|
+
|
|
|
+ expect(activateProviderProfileSpy).not.toHaveBeenCalled()
|
|
|
+ })
|
|
|
+
|
|
|
it("should use current profile if history item has no saved apiConfigName", async () => {
|
|
|
await provider.resolveWebviewView(mockWebviewView)
|
|
|
|