feat(ui): implement graceful quit via /quit command and ctrl+c in AppModel

Handle /quit slash command (and aliases /q, /exit) in submitMsg handler by
returning tea.Quit before forwarding to the app layer. Add TODO comment in
cmd/root.go marking where defer appInstance.Close() belongs once app.App
exists (TAS-18).
This commit is contained in:
Ed Zynda
2026-02-26 01:05:27 +03:00
parent 6398b3e637
commit dbf1dd52e1
2 changed files with 8 additions and 0 deletions
+3
View File
@@ -459,6 +459,9 @@ func runNormalMode(ctx context.Context) error {
return fmt.Errorf("failed to create agent: %v", err)
}
defer func() { _ = mcpAgent.Close() }()
// TODO(TAS-18): once app.App is created here, add: defer appInstance.Close()
// app.Close() stops background goroutines and waits for in-flight steps to
// finish before returning — satisfying TAS-14's graceful-quit requirement.
// Initialize hook executor if hooks are configured
// Get model name for display
+5
View File
@@ -265,6 +265,11 @@ func (m *AppModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// ── Input submitted ──────────────────────────────────────────────────────
case submitMsg:
// Handle /quit (and its aliases) before sending to the app layer:
// look up the command and check if it resolves to "/quit".
if cmd := GetCommandByName(msg.Text); cmd != nil && cmd.Name == "/quit" {
return m, tea.Quit
}
if m.appCtrl != nil {
// app.Run() handles queueing internally if a step is in progress.
m.appCtrl.Run(msg.Text)