Elffuss BraidHub

kikocis/continue public

fix: linting and address feedback
Changesetb0e1430b706d75e150ee1c0b2f0e7ead5c9d1e94c0a4367c260ccefda958fb6f
AuthorNate <sestinj@gmail.com> · 2025-08-27 21:42 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-27 21:42 -07:00
Parentsb2066c2304f5

Browse the files at this changeset

8 files changed

modified extensions/cli/src/compaction.infiniteLoop.test.ts +1 −1
@@ -7,7 +7,7 @@
77 import { streamChatResponse } from "./stream/streamChatResponse.js";
88
99 // Mock the dependencies
10-vi.mock("./streamChatResponse.js", () => ({
10+vi.mock("./stream/streamChatResponse.js", () => ({
1111 streamChatResponse: vi.fn(),
1212 }));
1313
modified extensions/cli/src/compaction.test.ts +1 −1
@@ -12,7 +12,7 @@
1212 import { streamChatResponse } from "./stream/streamChatResponse.js";
1313
1414 // Mock the streamChatResponse function
15-vi.mock("./streamChatResponse.js", () => ({
15+vi.mock("./stream/streamChatResponse.js", () => ({
1616 streamChatResponse: vi.fn(),
1717 }));
1818
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 @@
66 import historyManager from "core/util/history.js";
77 import { v4 as uuidv4 } from "uuid";
88
9+import { DEFAULT_SESSION_TITLE } from "./constants/session.js";
10+import { logger } from "./util/logger.js";
11+
912 // Re-export SessionMetadata for external consumers
1013 export type { SessionMetadata };
1114
12-import { logger } from "./util/logger.js";
13-
1415 // Note: We now use UUID-based session IDs instead of terminal-based IDs.
1516 // Each new chat session gets a unique UUID.
1617 // The --resume flag loads the most recent session.
@@ -69,7 +70,7 @@
6970 if (!this.currentSession) {
7071 this.currentSession = {
7172 sessionId: uuidv4(),
72- title: "Untitled Session",
73+ title: DEFAULT_SESSION_TITLE,
7374 workspaceDirectory: process.cwd(),
7475 history: [],
7576 };
@@ -187,7 +188,7 @@
187188 export function createSession(history: ChatHistoryItem[] = []): Session {
188189 const session: Session = {
189190 sessionId: uuidv4(),
190- title: "Untitled Session",
191+ title: DEFAULT_SESSION_TITLE,
191192 workspaceDirectory: process.cwd(),
192193 history,
193194 };
@@ -265,7 +266,7 @@
265266
266267 return {
267268 sessionId: sessionData.sessionId,
268- title: sessionData.title || "Untitled Session",
269+ title: sessionData.title || DEFAULT_SESSION_TITLE,
269270 dateCreated: stats.birthtime.toISOString(),
270271 workspaceDirectory: sessionData.workspaceDirectory || "",
271272 firstUserMessage,
@@ -360,7 +361,7 @@
360361 // Create a new session with a new sessionId
361362 const newSession: Session = {
362363 sessionId: uuidv4(),
363- title: "Untitled Session",
364+ title: DEFAULT_SESSION_TITLE,
364365 workspaceDirectory: process.cwd(),
365366 history,
366367 };
modified extensions/cli/src/stream/streamChatResponse.autoCompaction.test.ts +11 −8
@@ -5,11 +5,11 @@
55 import { handleAutoCompaction } from "./streamChatResponse.autoCompaction.js";
66
77 // Mock dependencies
8-vi.mock("./compaction.js", () => ({
8+vi.mock("../compaction.js", () => ({
99 compactChatHistory: vi.fn(),
1010 }));
1111
12-vi.mock("./session.js", () => ({
12+vi.mock("../session.js", () => ({
1313 createSession: vi.fn((history) => ({
1414 sessionId: "test",
1515 title: "Test",
@@ -20,16 +20,16 @@
2020 updateSessionHistory: vi.fn(),
2121 }));
2222
23-vi.mock("./util/tokenizer.js", () => ({
23+vi.mock("../util/tokenizer.js", () => ({
2424 shouldAutoCompact: vi.fn(),
2525 getAutoCompactMessage: vi.fn(),
2626 }));
2727
28-vi.mock("./util/formatError.js", () => ({
28+vi.mock("../util/formatError.js", () => ({
2929 formatError: vi.fn((error) => error.message || String(error)),
3030 }));
3131
32-vi.mock("./util/logger.js", () => ({
32+vi.mock("../util/logger.js", () => ({
3333 logger: {
3434 info: vi.fn(),
3535 debug: vi.fn(),
@@ -70,7 +70,8 @@
7070
7171 it("should return original history when auto-compaction is not needed", async () => {
7272 const { shouldAutoCompact } = await import("../util/tokenizer.js");
73- vi.mocked(shouldAutoCompact).mockReturnValue(false);
73+ const mockedShouldAutoCompact = shouldAutoCompact as any;
74+ mockedShouldAutoCompact.mockReturnValue(false);
7475
7576 const result = await handleAutoCompaction(
7677 mockChatHistory,
@@ -113,7 +114,8 @@
113114 compactionContent: "Conversation summary...",
114115 };
115116
116- vi.mocked(compactChatHistory).mockResolvedValue(mockCompactionResult);
117+ const mockedCompactChatHistory = compactChatHistory as any;
118+ mockedCompactChatHistory.mockResolvedValue(mockCompactionResult);
117119
118120 const mockCallbacks = {
119121 onSystemMessage: vi.fn(),
@@ -215,7 +217,8 @@
215217 compactionContent: "Summary",
216218 };
217219
218- vi.mocked(compactChatHistory).mockResolvedValue(mockCompactionResult);
220+ const mockedCompactChatHistory = compactChatHistory as any;
221+ mockedCompactChatHistory.mockResolvedValue(mockCompactionResult);
219222
220223 const mockCallbacks = {
221224 onSystemMessage: vi.fn(),
modified extensions/cli/src/ui/hooks/useChat.clear.test.ts +3 −0
@@ -19,6 +19,9 @@
1919 let mockOnClear: ReturnType<typeof vi.fn>;
2020
2121 beforeEach(() => {
22+ // Clear all mocks to prevent call history leaking between tests
23+ vi.clearAllMocks();
24+
2225 mockSetChatHistory = vi.fn();
2326 mockExit = vi.fn();
2427 mockOnClear = vi.fn();
modified extensions/cli/src/ui/hooks/useChat.helpers.ts +2 −1
@@ -5,6 +5,7 @@
55 import { v4 as uuidv4 } from "uuid";
66
77 import { compactChatHistory } from "../../compaction.js";
8+import { DEFAULT_SESSION_TITLE } from "../../constants/session.js";
89 import {
910 loadSession,
1011 updateSessionHistory,
@@ -422,7 +423,7 @@
422423 currentSessionTitle?: string,
423424 ): Promise<string | undefined> {
424425 // Only generate title for untitled sessions
425- if (currentSessionTitle && currentSessionTitle !== "Untitled Session") {
426+ if (currentSessionTitle && currentSessionTitle !== DEFAULT_SESSION_TITLE) {
426427 return undefined;
427428 }
428429
modified extensions/cli/vitest.setup.ts +3 −0
@@ -19,6 +19,9 @@
1919 ),
2020 }));
2121
22+// Mock environment for tests
23+process.env.CONTINUE_GLOBAL_DIR = "/tmp/continue-test";
24+
2225 // Set up global afterEach hook to clear all timers and reset console
2326 afterEach(() => {
2427 // Clear vitest timers