diff --git a/internal/app/commands.go b/internal/app/commands.go index 3cb0938..581a1b7 100644 --- a/internal/app/commands.go +++ b/internal/app/commands.go @@ -22,7 +22,7 @@ func (a *Application) handleCommand(input string) { switch parts[0] { case "/model": a.cmdModel(parts[1:]) - case "/exit": + case "/exit", "/quit": a.cmdExit() case "/compact": a.cmdCompact() @@ -367,6 +367,7 @@ func (a *Application) cmdHelp() { /permission [tool] [level] Manage tool permissions /yolo Toggle auto-approve mode /exit Exit the application + /quit Exit the application /compact Compact conversation context to save tokens /clear Clear chat history /help Show this help message diff --git a/internal/app/commands_exit_test.go b/internal/app/commands_exit_test.go new file mode 100644 index 0000000..7e41732 --- /dev/null +++ b/internal/app/commands_exit_test.go @@ -0,0 +1,20 @@ +package app + +import ( + "testing" + "time" + + "github.com/vigo999/ms-cli/ui/model" +) + +func TestProcessInputQuitTriggersExit(t *testing.T) { + app := newTestApp() + + app.processInput("/quit") + + _ = drainUntil(t, app, model.AgentReply, 2*time.Second) + done := drainUntil(t, app, model.Done, 2*time.Second) + if done.Type != model.Done { + t.Fatalf("expected done event, got %s", done.Type) + } +} diff --git a/ui/slash/commands.go b/ui/slash/commands.go index 0b861f2..5c638f8 100644 --- a/ui/slash/commands.go +++ b/ui/slash/commands.go @@ -122,6 +122,12 @@ func (r *Registry) registerDefaults() { Usage: "/exit", }) + r.Register(Command{ + Name: "/quit", + Description: "Exit the application", + Usage: "/quit", + }) + r.Register(Command{ Name: "/compact", Description: "Compact conversation context", diff --git a/ui/slash/commands_test.go b/ui/slash/commands_test.go new file mode 100644 index 0000000..8b863a5 --- /dev/null +++ b/ui/slash/commands_test.go @@ -0,0 +1,29 @@ +package slash + +import "testing" + +func TestDefaultRegistryIncludesQuit(t *testing.T) { + r := NewRegistry() + + if _, ok := r.Get("/quit"); !ok { + t.Fatal("expected /quit command to be registered") + } +} + +func TestSuggestionsIncludesQuitPrefix(t *testing.T) { + r := NewRegistry() + + suggestions := r.Suggestions("/q") + if !contains(suggestions, "/quit") { + t.Fatalf("expected /quit in suggestions for /q, got %v", suggestions) + } +} + +func contains(items []string, target string) bool { + for _, item := range items { + if item == target { + return true + } + } + return false +}