Changesets · Branches · Tags · Compare
| Changeset | b0e1430b706d75e150ee1c0b2f0e7ead5c9d1e94c0a4367c260ccefda958fb6f |
|---|---|
| Author | Nate <sestinj@gmail.com> · 2025-08-27 21:42 -07:00 |
| Committer | Nate <sestinj@gmail.com> · 2025-08-27 21:42 -07:00 |
| Parents | b2066c2304f5 |
8 files changed
modified extensions/cli/src/compaction.infiniteLoop.test.ts +1 −1
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | import { streamChatResponse } from "./stream/streamChatResponse.js"; |
| 8 | 8 | |
| 9 | 9 | // Mock the dependencies |
| 10 | -vi.mock("./streamChatResponse.js", () => ({ | |
| 10 | +vi.mock("./stream/streamChatResponse.js", () => ({ | |
| 11 | 11 | streamChatResponse: vi.fn(), |
| 12 | 12 | })); |
| 13 | 13 |
modified extensions/cli/src/compaction.test.ts +1 −1
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | import { streamChatResponse } from "./stream/streamChatResponse.js"; |
| 13 | 13 | |
| 14 | 14 | // Mock the streamChatResponse function |
| 15 | -vi.mock("./streamChatResponse.js", () => ({ | |
| 15 | +vi.mock("./stream/streamChatResponse.js", () => ({ | |
| 16 | 16 | streamChatResponse: vi.fn(), |
| 17 | 17 | })); |
| 18 | 18 |
added extensions/cli/src/constants/session.ts +4 −0
| @@ -0,0 +1,4 @@ | ||
| 1 | +/** | |
| 2 | + * Session-related constants | |
| 3 | + */ | |
| 4 | +export const DEFAULT_SESSION_TITLE = "Untitled Session"; |
modified extensions/cli/src/session.ts +7 −6
| @@ -6,11 +6,12 @@ | ||
| 6 | 6 | import historyManager from "core/util/history.js"; |
| 7 | 7 | import { v4 as uuidv4 } from "uuid"; |
| 8 | 8 | |
| 9 | +import { DEFAULT_SESSION_TITLE } from "./constants/session.js"; | |
| 10 | +import { logger } from "./util/logger.js"; | |
| 11 | + | |
| 9 | 12 | // Re-export SessionMetadata for external consumers |
| 10 | 13 | export type { SessionMetadata }; |
| 11 | 14 | |
| 12 | -import { logger } from "./util/logger.js"; | |
| 13 | - | |
| 14 | 15 | // Note: We now use UUID-based session IDs instead of terminal-based IDs. |
| 15 | 16 | // Each new chat session gets a unique UUID. |
| 16 | 17 | // The --resume flag loads the most recent session. |
| @@ -69,7 +70,7 @@ | ||
| 69 | 70 | if (!this.currentSession) { |
| 70 | 71 | this.currentSession = { |
| 71 | 72 | sessionId: uuidv4(), |
| 72 | - title: "Untitled Session", | |
| 73 | + title: DEFAULT_SESSION_TITLE, | |
| 73 | 74 | workspaceDirectory: process.cwd(), |
| 74 | 75 | history: [], |
| 75 | 76 | }; |
| @@ -187,7 +188,7 @@ | ||
| 187 | 188 | export function createSession(history: ChatHistoryItem[] = []): Session { |
| 188 | 189 | const session: Session = { |
| 189 | 190 | sessionId: uuidv4(), |
| 190 | - title: "Untitled Session", | |
| 191 | + title: DEFAULT_SESSION_TITLE, | |
| 191 | 192 | workspaceDirectory: process.cwd(), |
| 192 | 193 | history, |
| 193 | 194 | }; |
| @@ -265,7 +266,7 @@ | ||
| 265 | 266 | |
| 266 | 267 | return { |
| 267 | 268 | sessionId: sessionData.sessionId, |
| 268 | - title: sessionData.title || "Untitled Session", | |
| 269 | + title: sessionData.title || DEFAULT_SESSION_TITLE, | |
| 269 | 270 | dateCreated: stats.birthtime.toISOString(), |
| 270 | 271 | workspaceDirectory: sessionData.workspaceDirectory || "", |
| 271 | 272 | firstUserMessage, |
| @@ -360,7 +361,7 @@ | ||
| 360 | 361 | // Create a new session with a new sessionId |
| 361 | 362 | const newSession: Session = { |
| 362 | 363 | sessionId: uuidv4(), |
| 363 | - title: "Untitled Session", | |
| 364 | + title: DEFAULT_SESSION_TITLE, | |
| 364 | 365 | workspaceDirectory: process.cwd(), |
| 365 | 366 | history, |
| 366 | 367 | }; |
modified extensions/cli/src/stream/streamChatResponse.autoCompaction.test.ts +11 −8
| @@ -5,11 +5,11 @@ | ||
| 5 | 5 | import { handleAutoCompaction } from "./streamChatResponse.autoCompaction.js"; |
| 6 | 6 | |
| 7 | 7 | // Mock dependencies |
| 8 | -vi.mock("./compaction.js", () => ({ | |
| 8 | +vi.mock("../compaction.js", () => ({ | |
| 9 | 9 | compactChatHistory: vi.fn(), |
| 10 | 10 | })); |
| 11 | 11 | |
| 12 | -vi.mock("./session.js", () => ({ | |
| 12 | +vi.mock("../session.js", () => ({ | |
| 13 | 13 | createSession: vi.fn((history) => ({ |
| 14 | 14 | sessionId: "test", |
| 15 | 15 | title: "Test", |
| @@ -20,16 +20,16 @@ | ||
| 20 | 20 | updateSessionHistory: vi.fn(), |
| 21 | 21 | })); |
| 22 | 22 | |
| 23 | -vi.mock("./util/tokenizer.js", () => ({ | |
| 23 | +vi.mock("../util/tokenizer.js", () => ({ | |
| 24 | 24 | shouldAutoCompact: vi.fn(), |
| 25 | 25 | getAutoCompactMessage: vi.fn(), |
| 26 | 26 | })); |
| 27 | 27 | |
| 28 | -vi.mock("./util/formatError.js", () => ({ | |
| 28 | +vi.mock("../util/formatError.js", () => ({ | |
| 29 | 29 | formatError: vi.fn((error) => error.message || String(error)), |
| 30 | 30 | })); |
| 31 | 31 | |
| 32 | -vi.mock("./util/logger.js", () => ({ | |
| 32 | +vi.mock("../util/logger.js", () => ({ | |
| 33 | 33 | logger: { |
| 34 | 34 | info: vi.fn(), |
| 35 | 35 | debug: vi.fn(), |
| @@ -70,7 +70,8 @@ | ||
| 70 | 70 | |
| 71 | 71 | it("should return original history when auto-compaction is not needed", async () => { |
| 72 | 72 | const { shouldAutoCompact } = await import("../util/tokenizer.js"); |
| 73 | - vi.mocked(shouldAutoCompact).mockReturnValue(false); | |
| 73 | + const mockedShouldAutoCompact = shouldAutoCompact as any; | |
| 74 | + mockedShouldAutoCompact.mockReturnValue(false); | |
| 74 | 75 | |
| 75 | 76 | const result = await handleAutoCompaction( |
| 76 | 77 | mockChatHistory, |
| @@ -113,7 +114,8 @@ | ||
| 113 | 114 | compactionContent: "Conversation summary...", |
| 114 | 115 | }; |
| 115 | 116 | |
| 116 | - vi.mocked(compactChatHistory).mockResolvedValue(mockCompactionResult); | |
| 117 | + const mockedCompactChatHistory = compactChatHistory as any; | |
| 118 | + mockedCompactChatHistory.mockResolvedValue(mockCompactionResult); | |
| 117 | 119 | |
| 118 | 120 | const mockCallbacks = { |
| 119 | 121 | onSystemMessage: vi.fn(), |
| @@ -215,7 +217,8 @@ | ||
| 215 | 217 | compactionContent: "Summary", |
| 216 | 218 | }; |
| 217 | 219 | |
| 218 | - vi.mocked(compactChatHistory).mockResolvedValue(mockCompactionResult); | |
| 220 | + const mockedCompactChatHistory = compactChatHistory as any; | |
| 221 | + mockedCompactChatHistory.mockResolvedValue(mockCompactionResult); | |
| 219 | 222 | |
| 220 | 223 | const mockCallbacks = { |
| 221 | 224 | onSystemMessage: vi.fn(), |
modified extensions/cli/src/ui/hooks/useChat.clear.test.ts +3 −0
| @@ -19,6 +19,9 @@ | ||
| 19 | 19 | let mockOnClear: ReturnType<typeof vi.fn>; |
| 20 | 20 | |
| 21 | 21 | beforeEach(() => { |
| 22 | + // Clear all mocks to prevent call history leaking between tests | |
| 23 | + vi.clearAllMocks(); | |
| 24 | + | |
| 22 | 25 | mockSetChatHistory = vi.fn(); |
| 23 | 26 | mockExit = vi.fn(); |
| 24 | 27 | mockOnClear = vi.fn(); |
modified extensions/cli/src/ui/hooks/useChat.helpers.ts +2 −1
| @@ -5,6 +5,7 @@ | ||
| 5 | 5 | import { v4 as uuidv4 } from "uuid"; |
| 6 | 6 | |
| 7 | 7 | import { compactChatHistory } from "../../compaction.js"; |
| 8 | +import { DEFAULT_SESSION_TITLE } from "../../constants/session.js"; | |
| 8 | 9 | import { |
| 9 | 10 | loadSession, |
| 10 | 11 | updateSessionHistory, |
| @@ -422,7 +423,7 @@ | ||
| 422 | 423 | currentSessionTitle?: string, |
| 423 | 424 | ): Promise<string | undefined> { |
| 424 | 425 | // Only generate title for untitled sessions |
| 425 | - if (currentSessionTitle && currentSessionTitle !== "Untitled Session") { | |
| 426 | + if (currentSessionTitle && currentSessionTitle !== DEFAULT_SESSION_TITLE) { | |
| 426 | 427 | return undefined; |
| 427 | 428 | } |
| 428 | 429 |
modified extensions/cli/vitest.setup.ts +3 −0
| @@ -19,6 +19,9 @@ | ||
| 19 | 19 | ), |
| 20 | 20 | })); |
| 21 | 21 | |
| 22 | +// Mock environment for tests | |
| 23 | +process.env.CONTINUE_GLOBAL_DIR = "/tmp/continue-test"; | |
| 24 | + | |
| 22 | 25 | // Set up global afterEach hook to clear all timers and reset console |
| 23 | 26 | afterEach(() => { |
| 24 | 27 | // Clear vitest timers |