Skip to content
This repository was archived by the owner on Jul 7, 2026. It is now read-only.

Commit 1ed75f3

Browse files
authored
fix: insert slash commands without auto-sending (#84)
fix: insert slash commands without auto-sending When selecting a slash command from suggestions (via Tab, Enter, or click), the command is now inserted into the input field instead of being sent immediately. This allows users to add arguments after the command before sending. State-changing commands (/clear, /plan, /agent, /compact) still execute immediately as they don't require additional input.
1 parent a0ba1dd commit 1ed75f3

2 files changed

Lines changed: 18 additions & 61 deletions

File tree

src/renderer/features/agents/main/chat-input-area.tsx

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
import { trpc } from "../../../lib/trpc"
4040
import { cn } from "../../../lib/utils"
4141
import { isPlanModeAtom, lastSelectedModelIdAtom, type SubChatFileChange } from "../atoms"
42-
import { AgentsSlashCommand, COMMAND_PROMPTS, type SlashCommandOption } from "../commands"
42+
import { AgentsSlashCommand, type SlashCommandOption } from "../commands"
4343
import { AgentSendButton } from "../components/agent-send-button"
4444
import type { UploadedFile, UploadedImage } from "../hooks/use-agents-file-upload"
4545
import {
@@ -540,59 +540,37 @@ export const ChatInputArea = memo(function ChatInputArea({
540540
editorRef.current?.clearSlashCommand()
541541
setShowSlashDropdown(false)
542542

543-
// Handle builtin commands
543+
// Handle builtin commands that change app state (no text input needed)
544544
if (command.category === "builtin") {
545545
switch (command.name) {
546546
case "clear":
547547
// Create a new sub-chat (fresh conversation)
548548
if (onCreateNewSubChat) {
549549
onCreateNewSubChat()
550550
}
551-
break
551+
return
552552
case "plan":
553553
if (!isPlanMode) {
554554
setIsPlanMode(true)
555555
}
556-
break
556+
return
557557
case "agent":
558558
if (isPlanMode) {
559559
setIsPlanMode(false)
560560
}
561-
break
561+
return
562562
case "compact":
563563
// Trigger context compaction
564564
onCompact()
565-
break
566-
// Prompt-based commands - auto-send to agent
567-
case "review":
568-
case "pr-comments":
569-
case "release-notes":
570-
case "security-review":
571-
case "commit": {
572-
const prompt =
573-
COMMAND_PROMPTS[command.name as keyof typeof COMMAND_PROMPTS]
574-
if (prompt) {
575-
editorRef.current?.setValue(prompt)
576-
// Auto-send the prompt to agent
577-
setTimeout(() => onSend(), 0)
578-
}
579-
break
580-
}
565+
return
581566
}
582-
return
583567
}
584568

585-
// Handle custom commands
586-
if (command.argumentHint) {
587-
// Command expects arguments - insert command and let user add args
588-
editorRef.current?.setValue(`/${command.name} `)
589-
} else if (command.prompt) {
590-
// Command without arguments - send immediately
591-
editorRef.current?.setValue(command.prompt)
592-
setTimeout(() => onSend(), 0)
593-
}
569+
// For all other commands (builtin prompts and custom):
570+
// insert the command and let user add arguments or press Enter to send
571+
editorRef.current?.setValue(`/${command.name} `)
594572
},
595-
[isPlanMode, setIsPlanMode, onSend, onCreateNewSubChat, onCompact, editorRef],
573+
[isPlanMode, setIsPlanMode, onCreateNewSubChat, onCompact, editorRef],
596574
)
597575

598576
// Paste handler for images, plain text, and large text (saved as files)

src/renderer/features/agents/main/new-chat-form.tsx

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,51 +1001,30 @@ export function NewChatForm({
10011001
editorRef.current?.clearSlashCommand()
10021002
setShowSlashDropdown(false)
10031003

1004-
// Handle builtin commands
1004+
// Handle builtin commands that change app state (no text input needed)
10051005
if (command.category === "builtin") {
10061006
switch (command.name) {
10071007
case "clear":
10081008
editorRef.current?.clear()
1009-
break
1009+
return
10101010
case "plan":
10111011
if (!isPlanMode) {
10121012
setIsPlanMode(true)
10131013
}
1014-
break
1014+
return
10151015
case "agent":
10161016
if (isPlanMode) {
10171017
setIsPlanMode(false)
10181018
}
1019-
break
1020-
// Prompt-based commands - auto-send to agent
1021-
case "review":
1022-
case "pr-comments":
1023-
case "release-notes":
1024-
case "security-review": {
1025-
const prompt =
1026-
COMMAND_PROMPTS[command.name as keyof typeof COMMAND_PROMPTS]
1027-
if (prompt) {
1028-
editorRef.current?.setValue(prompt)
1029-
// Auto-send the prompt to agent
1030-
setTimeout(() => handleSend(), 0)
1031-
}
1032-
break
1033-
}
1019+
return
10341020
}
1035-
return
10361021
}
10371022

1038-
// Handle custom commands
1039-
if (command.argumentHint) {
1040-
// Command expects arguments - insert command and let user add args
1041-
editorRef.current?.setValue(`/${command.name} `)
1042-
} else if (command.prompt) {
1043-
// Command without arguments - send immediately
1044-
editorRef.current?.setValue(command.prompt)
1045-
setTimeout(() => handleSend(), 0)
1046-
}
1023+
// For all other commands (builtin prompts and custom):
1024+
// insert the command and let user add arguments or press Enter to send
1025+
editorRef.current?.setValue(`/${command.name} `)
10471026
},
1048-
[isPlanMode, setIsPlanMode, handleSend],
1027+
[isPlanMode, setIsPlanMode],
10491028
)
10501029

10511030
// Paste handler for images, plain text, and large text (saved as files)

0 commit comments

Comments
 (0)