diff --git a/desktop/src/components/chat/ChatInput.test.tsx b/desktop/src/components/chat/ChatInput.test.tsx
index a482110b..d95a66cb 100644
--- a/desktop/src/components/chat/ChatInput.test.tsx
+++ b/desktop/src/components/chat/ChatInput.test.tsx
@@ -1101,4 +1101,54 @@ describe('ChatInput file mentions', () => {
expect(input).toHaveValue('/agent debugger ')
})
+
+ it('selects a highlighted agent entry from /agent without sending until the configured send shortcut is used', async () => {
+ useSettingsStore.setState({
+ chatSendBehavior: 'modifierEnter',
+ })
+ mocks.listAgents.mockResolvedValue({
+ activeAgents: [
+ {
+ agentType: 'debugger',
+ description: 'Debug failures',
+ modelDisplay: 'OPUS',
+ source: 'userSettings',
+ isActive: true,
+ },
+ ],
+ allAgents: [],
+ })
+
+ render()
+
+ await waitFor(() => {
+ expect(mocks.listAgents).toHaveBeenCalledWith('/repo')
+ })
+
+ const input = screen.getByRole('textbox') as HTMLTextAreaElement
+ fireEvent.change(input, {
+ target: { value: '/agent', selectionStart: 6 },
+ })
+
+ await screen.findByText('/agent debugger')
+ fireEvent.keyDown(input, { key: 'ArrowDown' })
+ fireEvent.keyDown(input, { key: 'Enter' })
+
+ expect(input).toHaveValue('/agent debugger ')
+ expect(mocks.wsSend).not.toHaveBeenCalled()
+
+ const prompt = '/agent debugger investigate this failure'
+ fireEvent.change(input, {
+ target: { value: prompt, selectionStart: prompt.length },
+ })
+ fireEvent.keyDown(input, { key: 'Enter' })
+ expect(mocks.wsSend).not.toHaveBeenCalled()
+
+ fireEvent.keyDown(input, { key: 'Enter', ctrlKey: true })
+ expect(mocks.wsSend).toHaveBeenCalledWith(sessionId, {
+ type: 'user_message',
+ content: prompt,
+ attachments: [],
+ })
+ })
})
diff --git a/desktop/src/components/chat/ChatInput.tsx b/desktop/src/components/chat/ChatInput.tsx
index 54fa73bb..a17c7d99 100644
--- a/desktop/src/components/chat/ChatInput.tsx
+++ b/desktop/src/components/chat/ChatInput.tsx
@@ -737,8 +737,10 @@ export function ChatInput({ variant = 'default', compact = false }: ChatInputPro
return
}
if (event.key === 'Enter') {
+ const selected = filteredCommands[slashSelectedIndex]
if (
exactSlashCommand &&
+ selected?.name.toLowerCase() === exactSlashCommand.name.toLowerCase() &&
slashFilter.trim().toLowerCase() === exactSlashCommand.name.toLowerCase() &&
shouldSubmitOnEnter(event, chatSendBehavior)
) {
@@ -747,7 +749,6 @@ export function ChatInput({ variant = 'default', compact = false }: ChatInputPro
return
}
event.preventDefault()
- const selected = filteredCommands[slashSelectedIndex]
if (selected) selectSlashCommand(selected.name)
return
}
diff --git a/desktop/src/pages/EmptySession.test.tsx b/desktop/src/pages/EmptySession.test.tsx
index 7f19ee76..0926f8bd 100644
--- a/desktop/src/pages/EmptySession.test.tsx
+++ b/desktop/src/pages/EmptySession.test.tsx
@@ -353,6 +353,43 @@ describe('EmptySession', () => {
expect(input).toHaveValue('/agent debugger ')
})
+ it('selects a highlighted agent entry from /agent without creating a session', async () => {
+ useSettingsStore.setState({
+ chatSendBehavior: 'enter',
+ })
+ mocks.listAgents.mockResolvedValue({
+ activeAgents: [
+ {
+ agentType: 'debugger',
+ description: 'Debug failures',
+ modelDisplay: 'OPUS',
+ source: 'userSettings',
+ isActive: true,
+ },
+ ],
+ allAgents: [],
+ })
+
+ render()
+
+ await waitFor(() => {
+ expect(mocks.listAgents).toHaveBeenCalledWith(undefined)
+ })
+
+ const input = screen.getByRole('textbox') as HTMLTextAreaElement
+ fireEvent.change(input, {
+ target: { value: '/agent', selectionStart: 6 },
+ })
+
+ await screen.findByText('/agent debugger')
+ fireEvent.keyDown(input, { key: 'ArrowDown' })
+ fireEvent.keyDown(input, { key: 'Enter' })
+
+ expect(input).toHaveValue('/agent debugger ')
+ expect(mocks.createSession).not.toHaveBeenCalled()
+ expect(mocks.wsSend).not.toHaveBeenCalled()
+ })
+
it('integrates repository launch controls into the desktop composer panel', async () => {
render()
diff --git a/desktop/src/pages/EmptySession.tsx b/desktop/src/pages/EmptySession.tsx
index e733a348..92482e1d 100644
--- a/desktop/src/pages/EmptySession.tsx
+++ b/desktop/src/pages/EmptySession.tsx
@@ -415,9 +415,11 @@ export function EmptySession() {
return
}
if (event.key === 'Enter' || event.key === 'Tab') {
+ const selected = filteredCommands[slashSelectedIndex]
if (
event.key === 'Enter' &&
exactSlashCommand &&
+ selected?.name.toLowerCase() === exactSlashCommand.name.toLowerCase() &&
slashFilter.trim().toLowerCase() === exactSlashCommand.name.toLowerCase() &&
shouldSubmitOnEnter(event, chatSendBehavior)
) {
@@ -426,7 +428,6 @@ export function EmptySession() {
return
}
event.preventDefault()
- const selected = filteredCommands[slashSelectedIndex]
if (selected) selectSlashCommand(selected.name)
return
}