Skip to content

Commit f3fd7b5

Browse files
fix: don't chat with subagent when selecting from /agent menu, just @-mention it (#266)
Co-authored-by: Codebuff <noreply@codebuff.com>
1 parent d2352a9 commit f3fd7b5

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

npm-app/src/cli-handlers/agents.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { getAllTsFiles } from '../agents/agent-utils'
1717
import { CLI, getLocalAgentInfo } from '../cli'
1818
import { createExampleAgentFiles } from './init-agents'
1919
import { getProjectRoot } from '../project-files'
20-
import { Spinner } from '../utils/spinner'
2120
import {
2221
ENTER_ALT_BUFFER,
2322
EXIT_ALT_BUFFER,
@@ -504,7 +503,7 @@ function setupAgentsKeyHandler(rl: any, onExit: () => void) {
504503
return
505504
}
506505

507-
// Handle Enter - switch to selected agent, create new, or edit
506+
// Handle Enter - add @<agent-name> to input field or create new agent
508507
if (key && key.name === 'return') {
509508
if (agentList.length > 0 && selectedIndex < agentList.length) {
510509
const selectedAgent = agentList[selectedIndex]
@@ -523,21 +522,10 @@ function setupAgentsKeyHandler(rl: any, onExit: () => void) {
523522
startDirectAgentCreation(onExit)
524523
} else {
525524
exitAgentsBuffer(rl)
526-
// Start spinner for agent switching
527-
Spinner.get().start(`Switching to agent: ${selectedAgent.name}...`)
528-
529-
// Use resetAgent to switch to the selected agent
525+
// Instead of switching agents, add @<agent-name> to the input field
530526
const cliInstance = CLI.getInstance()
531-
cliInstance
532-
.resetAgent(selectedAgent.id)
533-
.then(() => {
534-
cliInstance.freshPrompt()
535-
})
536-
.catch((error: any) => {
537-
Spinner.get().stop()
538-
console.error(red('Error switching to agent:'), error)
539-
onExit()
540-
})
527+
const agentName = selectedAgent.name.replace(/\s*\(.*\)$/, '') // Remove any (id) suffix
528+
cliInstance.freshPrompt(`@${agentName} `)
541529
}
542530
}
543531
return

0 commit comments

Comments
 (0)