diff --git a/extensions/cli/src/compaction.infiniteLoop.test.ts b/extensions/cli/src/compaction.infiniteLoop.test.ts index 4fe565660..c0f1127cd 100644 --- a/extensions/cli/src/compaction.infiniteLoop.test.ts +++ b/extensions/cli/src/compaction.infiniteLoop.test.ts @@ -1,7 +1,7 @@ -import { ChatCompletionMessageParam } from "openai/resources.mjs"; -import { describe, it, expect, vi } from "vitest"; import { ModelConfig } from "@continuedev/config-yaml"; import { BaseLlmApi } from "@continuedev/openai-adapters"; +import { ChatCompletionMessageParam } from "openai/resources.mjs"; +import { describe, it, expect, vi } from "vitest"; import { compactChatHistory } from "./compaction.js"; import { streamChatResponse } from "./streamChatResponse.js"; @@ -43,7 +43,7 @@ describe("compaction infinite loop prevention", () => { mockStreamResponse.mockImplementation( async (history, model, api, controller, callbacks) => { callbacks?.onContent?.("Summary"); - callbacks?.onContentComplete?.(); + callbacks?.onContentComplete?.("Summary"); return "Summary"; }, ); @@ -54,7 +54,7 @@ describe("compaction infinite loop prevention", () => { ]; // This should not hang - it should break out of the loop - const result = await compactChatHistory(history, mockModel, mockLlmApi); + const result = await compactChatHistory(history, mockModel, mockLlmApi, {}); // Should complete successfully even though token count is still too high expect(result.compactedHistory).toBeDefined(); @@ -75,7 +75,7 @@ describe("compaction infinite loop prevention", () => { mockStreamResponse.mockImplementation( async (history, model, api, controller, callbacks) => { callbacks?.onContent?.("Summary"); - callbacks?.onContentComplete?.(); + callbacks?.onContentComplete?.("Summary"); return "Summary"; }, ); @@ -88,7 +88,7 @@ describe("compaction infinite loop prevention", () => { ]; // This should not hang - const result = await compactChatHistory(history, mockModel, mockLlmApi); + const result = await compactChatHistory(history, mockModel, mockLlmApi, {}); expect(result.compactedHistory).toBeDefined(); }); @@ -116,7 +116,7 @@ describe("compaction infinite loop prevention", () => { mockStreamResponse.mockImplementation( async (history, model, api, controller, callbacks) => { callbacks?.onContent?.("Summary"); - callbacks?.onContentComplete?.(); + callbacks?.onContentComplete?.("Summary"); return "Summary"; }, ); @@ -129,7 +129,7 @@ describe("compaction infinite loop prevention", () => { { role: "user", content: "Another question" }, ]; - const result = await compactChatHistory(history, mockModel, mockLlmApi); + const result = await compactChatHistory(history, mockModel, mockLlmApi, {}); expect(result.compactedHistory).toBeDefined(); // The function will call countTokens multiple times during the process diff --git a/extensions/cli/src/test-helpers/ui-test-context.ts b/extensions/cli/src/test-helpers/ui-test-context.ts index 5eeda611d..a8eae59f3 100644 --- a/extensions/cli/src/test-helpers/ui-test-context.ts +++ b/extensions/cli/src/test-helpers/ui-test-context.ts @@ -72,7 +72,7 @@ export function createUITestContext( responseStartTime: null, inputMode: true, attachedFiles: [], - handleUserMessage: vi.fn(), + handleUserMessage: vi.fn().mockResolvedValue(undefined), handleInterrupt: vi.fn(), handleFileAttached: vi.fn(), resetChatHistory: vi.fn(), diff --git a/extensions/cli/src/ui/hooks/useChat.helpers.ts b/extensions/cli/src/ui/hooks/useChat.helpers.ts index 2b1113bc9..b8d77e028 100644 --- a/extensions/cli/src/ui/hooks/useChat.helpers.ts +++ b/extensions/cli/src/ui/hooks/useChat.helpers.ts @@ -291,10 +291,6 @@ export async function handleAutoCompaction({ currentChatHistory: ChatCompletionMessageParam[]; currentCompactionIndex: number | null; }> { - if (!llmApi) { - throw new Error("LLM API is not available for auto-compaction"); - } - const { handleAutoCompaction: coreAutoCompaction } = await import( "../../streamChatResponse.autoCompaction.js" );