fix: cli /exit and ctrl-d actually exits

This commit is contained in:
Ting-Wai To 2025-09-08 14:32:47 -07:00
parent 977ab428a4
commit b19acdd30d
4 changed files with 2 additions and 12 deletions

View file

@ -15,7 +15,6 @@ vi.mock("../../session.js", () => ({
describe("useChat clear command", () => {
let mockSetChatHistory: ReturnType<typeof vi.fn>;
let mockExit: ReturnType<typeof vi.fn>;
let mockOnClear: ReturnType<typeof vi.fn>;
beforeEach(() => {
@ -23,7 +22,6 @@ describe("useChat clear command", () => {
vi.clearAllMocks();
mockSetChatHistory = vi.fn();
mockExit = vi.fn();
mockOnClear = vi.fn();
});
@ -44,7 +42,6 @@ describe("useChat clear command", () => {
result,
chatHistory,
setChatHistory: mockSetChatHistory,
exit: mockExit,
onShowConfigSelector: vi.fn(),
onClear: mockOnClear,
});
@ -91,7 +88,6 @@ describe("useChat clear command", () => {
result,
chatHistory,
setChatHistory: mockSetChatHistory,
exit: mockExit,
onShowConfigSelector: vi.fn(),
// onClear is not provided
});
@ -127,7 +123,6 @@ describe("useChat clear command", () => {
result,
chatHistory,
setChatHistory: mockSetChatHistory,
exit: mockExit,
onShowConfigSelector: vi.fn(),
onClear: mockOnClear,
});
@ -149,7 +144,6 @@ describe("useChat clear command", () => {
result,
chatHistory,
setChatHistory: mockSetChatHistory,
exit: mockExit,
onShowConfigSelector: vi.fn(),
onClear: mockOnClear,
});

View file

@ -46,7 +46,6 @@ interface ProcessSlashCommandResultOptions {
result: SlashCommandResult;
chatHistory: ChatHistoryItem[];
setChatHistory: React.Dispatch<React.SetStateAction<ChatHistoryItem[]>>;
exit: () => void;
onShowConfigSelector: () => void;
onShowModelSelector?: () => void;
onShowMCPSelector?: () => void;
@ -61,7 +60,6 @@ export function processSlashCommandResult({
result,
chatHistory,
setChatHistory,
exit,
onShowConfigSelector,
onShowModelSelector,
onShowMCPSelector,
@ -69,8 +67,7 @@ export function processSlashCommandResult({
onClear,
}: ProcessSlashCommandResultOptions): string | null {
if (result.exit) {
exit();
return null;
process.exit(0);
}
if (result.openMcpSelector) {

View file

@ -370,7 +370,6 @@ export function useChat({
result: commandResult,
chatHistory,
setChatHistory,
exit,
onShowConfigSelector,
onShowModelSelector,
onShowMCPSelector,

View file

@ -76,7 +76,7 @@ export function handleControlKeys(options: ControlKeysOptions): boolean {
// Handle Ctrl+D to exit
if (key.ctrl && input === "d") {
exit();
return true;
process.exit(0);
}
// Handle Ctrl+L to refresh screen (clear terminal artifacts)