From 035706d51aac7aab1639efc3619aee4ed7989efa Mon Sep 17 00:00:00 2001 From: Nate Date: Sun, 31 Aug 2025 16:02:43 -0700 Subject: [PATCH] chore: format --- extensions/cli/src/slashCommands.ts | 2 +- .../cli/src/stream/streamChatResponse.ts | 2 +- extensions/cli/src/ui/UserInput.tsx | 6 ++-- .../TUIChat.interruption.minimal.test.tsx | 29 +++++++++---------- extensions/cli/src/ui/hooks/useChat.ts | 22 +++++++++----- package-lock.json | 1 + 6 files changed, 33 insertions(+), 29 deletions(-) diff --git a/extensions/cli/src/slashCommands.ts b/extensions/cli/src/slashCommands.ts index a739cc450..9c8b172a8 100644 --- a/extensions/cli/src/slashCommands.ts +++ b/extensions/cli/src/slashCommands.ts @@ -186,7 +186,7 @@ async function handleInfo() { const currentSession = getCurrentSession(); infoLines.push(` Title: ${chalk.green(currentSession.title)}`); infoLines.push(` ID: ${chalk.gray(currentSession.sessionId)}`); - + const sessionFilePath = getSessionFilePath(); infoLines.push(` File: ${chalk.blue(sessionFilePath)}`); } catch { diff --git a/extensions/cli/src/stream/streamChatResponse.ts b/extensions/cli/src/stream/streamChatResponse.ts index 1c3803e66..300ea5b24 100644 --- a/extensions/cli/src/stream/streamChatResponse.ts +++ b/extensions/cli/src/stream/streamChatResponse.ts @@ -341,7 +341,7 @@ export async function streamChatResponse( isHeadless, tools, }); - + if (abortController?.signal.aborted) { return finalResponse || content || fullResponse; } diff --git a/extensions/cli/src/ui/UserInput.tsx b/extensions/cli/src/ui/UserInput.tsx index 86c2f1874..7e48b56ad 100644 --- a/extensions/cli/src/ui/UserInput.tsx +++ b/extensions/cli/src/ui/UserInput.tsx @@ -413,12 +413,12 @@ const UserInput: React.FC = ({ // Expand all paste blocks before submitting textBuffer.expandAllPasteBlocks(); const submittedText = textBuffer.text.trim(); - + // Only add to history if there's actual text (not when resuming) if (submittedText) { inputHistory.addEntry(submittedText); } - + // Send empty string when resuming, actual text otherwise onSubmit(submittedText); textBuffer.clear(); @@ -654,7 +654,7 @@ const UserInput: React.FC = ({ )} - + {/* Input box */} { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: false, // Initially false - }) + }), ); try { @@ -43,7 +43,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: true, // Now true - }) + }), ); // Should show interruption message @@ -51,7 +51,6 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { expect(frame).toBeDefined(); expect(frame).toContain("⚠ Interrupted by user"); expect(frame).toContain("Press enter to resume"); - } finally { unmount(); } @@ -68,7 +67,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: true, // Initially true - }) + }), ); try { @@ -86,7 +85,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: false, // Now false - }) + }), ); // Should not show interruption message @@ -94,7 +93,6 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { expect(frame).toBeDefined(); expect(frame).not.toContain("⚠ Interrupted by user"); expect(frame).not.toContain("Press enter to resume"); - } finally { unmount(); } @@ -111,7 +109,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: true, // Interrupted state - }) + }), ); try { @@ -120,7 +118,6 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { // Should call onSubmit with empty string (for resume) expect(mockOnSubmit).toHaveBeenCalledWith(""); - } finally { unmount(); } @@ -137,7 +134,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: true, // Interrupted state - }) + }), ); try { @@ -146,8 +143,9 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { stdin.write("\r"); // Should call onSubmit with the typed content - expect(mockOnSubmit).toHaveBeenCalledWith("New message after interruption"); - + expect(mockOnSubmit).toHaveBeenCalledWith( + "New message after interruption", + ); } finally { unmount(); } @@ -164,7 +162,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { inputMode: true, onInterrupt: mockOnInterrupt, wasInterrupted: true, - }) + }), ); try { @@ -172,8 +170,8 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { expect(frame).toBeDefined(); // The interruption message should appear before the input box - const frameLines = frame?.split('\n') || []; - + const frameLines = frame?.split("\n") || []; + let foundInterruptionLine = -1; let foundInputBoxLine = -1; @@ -190,9 +188,8 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => { expect(foundInterruptionLine).toBeGreaterThan(-1); expect(foundInputBoxLine).toBeGreaterThan(-1); expect(foundInterruptionLine).toBeLessThan(foundInputBoxLine); - } finally { unmount(); } }); -}); \ No newline at end of file +}); diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index d360635e3..8109d1991 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -259,26 +259,29 @@ export function useChat({ // Find the index of the last user or tool message to resume from let lastUserOrToolIndex = -1; for (let i = chatHistory.length - 1; i >= 0; i--) { - if (chatHistory[i].message.role === "user" || !!chatHistory[i].toolCallStates?.length) { + if ( + chatHistory[i].message.role === "user" || + !!chatHistory[i].toolCallStates?.length + ) { lastUserOrToolIndex = i; break; } } - + if (lastUserOrToolIndex >= 0) { // Truncate history to include up to and including the user/tool message const truncatedHistory = chatHistory.slice(0, lastUserOrToolIndex + 1); setChatHistory(truncatedHistory); - + // Clear the interrupted state and resume setWasInterrupted(false); - + // Re-execute streaming with the truncated history await executeStreamingResponse(truncatedHistory, compactionIndex); return; } } - + // Clear interrupted state if user types a new message if (wasInterrupted && message !== "") { setWasInterrupted(false); @@ -400,16 +403,19 @@ export function useChat({ // Local mode: abort the controller if (abortController && isWaitingForResponse) { abortController.abort(); - + // Remove the last message if it's from assistant (partial response) setChatHistory((current) => { const lastMessage = current[current.length - 1]; - if (lastMessage?.message.role === "assistant" && !lastMessage.toolCallStates?.length) { + if ( + lastMessage?.message.role === "assistant" && + !lastMessage.toolCallStates?.length + ) { return current.slice(0, -1); } return current; }); - + setWasInterrupted(true); setIsWaitingForResponse(false); setResponseStartTime(null); diff --git a/package-lock.json b/package-lock.json index b4289d422..b3ddaef8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,7 @@ "requires": true, "packages": { "": { + "name": "continue", "devDependencies": { "@typescript-eslint/parser": "^7.8.0", "concurrently": "^9.1.2",