Skip to content

Commit 0f2fc76

Browse files
authored
Merge pull request #2152 from trungutt/support-exit-keyword
feat: support "exit" as a keyword to quit the session
2 parents ed55e9f + 5813e3b commit 0f2fc76

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

pkg/tui/commands/commands.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,26 @@ func builtInSessionCommands() []Item {
107107
return core.CmdHandler(messages.ExitSessionMsg{})
108108
},
109109
},
110+
{
111+
ID: "session.quit",
112+
Label: "Quit",
113+
SlashCommand: "/quit",
114+
Description: "Quit the application (alias for /exit)",
115+
Category: "Session",
116+
Execute: func(string) tea.Cmd {
117+
return core.CmdHandler(messages.ExitSessionMsg{})
118+
},
119+
},
120+
{
121+
ID: "session.q",
122+
Label: "Quit (short)",
123+
SlashCommand: "/q",
124+
Description: "Quit the application (alias for /exit)",
125+
Category: "Session",
126+
Execute: func(string) tea.Cmd {
127+
return core.CmdHandler(messages.ExitSessionMsg{})
128+
},
129+
},
110130
{
111131
ID: "session.export",
112132
Label: "Export",

pkg/tui/page/chat/chat.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,13 @@ func (p *chatPage) cancelStream(showCancelMessage bool) tea.Cmd {
624624
// handleSendMsg handles incoming messages from the editor, either processing
625625
// them immediately or queuing them if the agent is busy.
626626
func (p *chatPage) handleSendMsg(msg msgtypes.SendMsg) (layout.Model, tea.Cmd) {
627+
// Handle "exit", "quit", and ":q" as special keywords to quit the session
628+
// immediately, equivalent to the /exit slash command.
629+
switch strings.TrimSpace(msg.Content) {
630+
case "exit", "quit", ":q":
631+
return p, core.CmdHandler(msgtypes.ExitSessionMsg{})
632+
}
633+
627634
// Predefined slash commands (e.g., /yolo, /exit, /compact) execute immediately
628635
// even while the agent is working - they're UI commands that don't interrupt the stream.
629636
// Custom agent commands (defined in config) should still be queued.

0 commit comments

Comments
 (0)