Skip to content

Commit 40d3598

Browse files
Merge pull request #1442 from stanislavHamara/fix-commands-and-the-queue
## Fix: Predefined slash commands work correctly while agent is working
2 parents 6229043 + 8041d4e commit 40d3598

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

pkg/tui/page/chat/chat.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,14 @@ func (p *chatPage) cancelStream(showCancelMessage bool) tea.Cmd {
611611
// handleSendMsg handles incoming messages from the editor, either processing
612612
// them immediately or queuing them if the agent is busy.
613613
func (p *chatPage) handleSendMsg(msg msgtypes.SendMsg) (layout.Model, tea.Cmd) {
614+
// Predefined slash commands (e.g., /yolo, /exit, /compact) execute immediately
615+
// even while the agent is working - they're UI commands that don't interrupt the stream.
616+
// Custom agent commands (defined in config) should still be queued.
617+
if commands.ParseSlashCommand(msg.Content) != nil {
618+
cmd := p.processMessage(msg)
619+
return p, cmd
620+
}
621+
614622
// If not working, process immediately
615623
if !p.working {
616624
cmd := p.processMessage(msg)
@@ -691,6 +699,12 @@ func (p *chatPage) syncQueueToSidebar() {
691699

692700
// processMessage processes a message with the runtime
693701
func (p *chatPage) processMessage(msg msgtypes.SendMsg) tea.Cmd {
702+
// Handle slash commands (e.g., /eval, /compact, /exit) BEFORE cancelling any ongoing stream.
703+
// These are UI commands that shouldn't interrupt the running agent.
704+
if cmd := commands.ParseSlashCommand(msg.Content); cmd != nil {
705+
return cmd
706+
}
707+
694708
if p.msgCancel != nil {
695709
p.msgCancel()
696710
}
@@ -705,11 +719,6 @@ func (p *chatPage) processMessage(msg msgtypes.SendMsg) tea.Cmd {
705719
return p.messages.ScrollToBottom()
706720
}
707721

708-
// Handle slash commands (e.g., /eval, /compact, /exit)
709-
if cmd := commands.ParseSlashCommand(msg.Content); cmd != nil {
710-
return cmd
711-
}
712-
713722
// Start working state immediately to show the user something is happening.
714723
// This provides visual feedback while the runtime loads tools and prepares the stream.
715724
// The spinner will be visible in the resize handle area.

0 commit comments

Comments
 (0)