chore: format

This commit is contained in:
Nate 2025-08-31 16:02:43 -07:00
parent 38eb3ece2d
commit 035706d51a
6 changed files with 33 additions and 29 deletions

View file

@ -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 {

View file

@ -341,7 +341,7 @@ export async function streamChatResponse(
isHeadless,
tools,
});
if (abortController?.signal.aborted) {
return finalResponse || content || fullResponse;
}

View file

@ -413,12 +413,12 @@ const UserInput: React.FC<UserInputProps> = ({
// 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<UserInputProps> = ({
</Text>
</Box>
)}
{/* Input box */}
<Box
borderStyle="round"

View file

@ -25,7 +25,7 @@ describe("TUIChat - Interruption UI (Minimal Test)", () => {
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();
}
});
});
});

View file

@ -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);

1
package-lock.json generated
View file

@ -4,6 +4,7 @@
"requires": true,
"packages": {
"": {
"name": "continue",
"devDependencies": {
"@typescript-eslint/parser": "^7.8.0",
"concurrently": "^9.1.2",