From b19acdd30d5a5c5a8bbe61cac0ab8dda86643d99 Mon Sep 17 00:00:00 2001 From: Ting-Wai To <40179554+tingwai@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:32:47 -0700 Subject: [PATCH] fix: cli /exit and ctrl-d actually exits --- extensions/cli/src/ui/hooks/useChat.clear.test.ts | 6 ------ extensions/cli/src/ui/hooks/useChat.helpers.ts | 5 +---- extensions/cli/src/ui/hooks/useChat.ts | 1 - extensions/cli/src/ui/hooks/useUserInput.ts | 2 +- 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/extensions/cli/src/ui/hooks/useChat.clear.test.ts b/extensions/cli/src/ui/hooks/useChat.clear.test.ts index 1c0a7341e..7056a62b6 100644 --- a/extensions/cli/src/ui/hooks/useChat.clear.test.ts +++ b/extensions/cli/src/ui/hooks/useChat.clear.test.ts @@ -15,7 +15,6 @@ vi.mock("../../session.js", () => ({ describe("useChat clear command", () => { let mockSetChatHistory: ReturnType; - let mockExit: ReturnType; let mockOnClear: ReturnType; 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, }); diff --git a/extensions/cli/src/ui/hooks/useChat.helpers.ts b/extensions/cli/src/ui/hooks/useChat.helpers.ts index 17aa450fb..1c289e5c7 100644 --- a/extensions/cli/src/ui/hooks/useChat.helpers.ts +++ b/extensions/cli/src/ui/hooks/useChat.helpers.ts @@ -46,7 +46,6 @@ interface ProcessSlashCommandResultOptions { result: SlashCommandResult; chatHistory: ChatHistoryItem[]; setChatHistory: React.Dispatch>; - 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) { diff --git a/extensions/cli/src/ui/hooks/useChat.ts b/extensions/cli/src/ui/hooks/useChat.ts index c2f1e0130..9b9cc5871 100644 --- a/extensions/cli/src/ui/hooks/useChat.ts +++ b/extensions/cli/src/ui/hooks/useChat.ts @@ -370,7 +370,6 @@ export function useChat({ result: commandResult, chatHistory, setChatHistory, - exit, onShowConfigSelector, onShowModelSelector, onShowMCPSelector, diff --git a/extensions/cli/src/ui/hooks/useUserInput.ts b/extensions/cli/src/ui/hooks/useUserInput.ts index b8a48cd04..c5945bbf3 100644 --- a/extensions/cli/src/ui/hooks/useUserInput.ts +++ b/extensions/cli/src/ui/hooks/useUserInput.ts @@ -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)