mirror of
https://github.com/mark3labs/kit.git
synced 2026-06-14 03:30:26 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user