From 772ec18d9daada014ddd095269b76ded22bdee05 Mon Sep 17 00:00:00 2001 From: Nicolas Varrot Date: Tue, 3 Mar 2026 09:01:51 +0000 Subject: [PATCH] fix: slash commands without args now submit immediately on selection When selecting a slash command without arguments (e.g. /new, /status, /help) from the autocomplete menu, the command now executes immediately instead of getting stuck in a loop where the menu kept intercepting Enter keypresses. Fixes #17 --- src/components/ChatInput.tsx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/components/ChatInput.tsx b/src/components/ChatInput.tsx index 49130c8..c765ba2 100644 --- a/src/components/ChatInput.tsx +++ b/src/components/ChatInput.tsx @@ -270,7 +270,35 @@ export function ChatInput({ onSend, onNewSession, onAbort, isGenerating, disable { setText(cmd); setShowSlash(shouldShowSlashMenu(cmd)); textareaRef.current?.focus(); }} + onSelect={(cmd) => { + // Commands without args (no trailing space) should submit immediately + if (!cmd.endsWith(' ')) { + setText(cmd); + setShowSlash(false); + // Submit directly — need to call onSend/onNewSession inline since setState is async + if ((cmd === '/new') && onNewSession) { + void onNewSession(); + setText(''); + setFiles([]); + onCancelReply?.(); + if (sessionKey) draftsRef.current.delete(sessionKey); + } else { + // For other no-arg commands (e.g. /status, /help), send as text + const finalText = replyTo?.preview + ? `> ${replyTo.preview.split('\n')[0].slice(0, 80)}\n\n${cmd}` + : cmd; + onSend(finalText); + setText(''); + setFiles([]); + onCancelReply?.(); + if (sessionKey) draftsRef.current.delete(sessionKey); + } + } else { + setText(cmd); + setShowSlash(shouldShowSlashMenu(cmd)); + textareaRef.current?.focus(); + } + }} onClose={() => setShowSlash(false)} /> {/* Reply context banner */}