TUI: add quit confirmation

This commit is contained in:
Moira Daniella A Sebastian
2026-03-20 13:55:00 +01:00
parent 6a91abc13f
commit 6d72c9195b
10 changed files with 151 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/LazyBachelor/LazyPM/pkg/tui/components"
"github.com/LazyBachelor/LazyPM/pkg/tui/issues"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/key"
tea "github.com/charmbracelet/bubbletea"
)
@@ -323,6 +324,29 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
})
case tea.KeyMsg:
// Always allow quit with q/ctrl+c, even when in inputs or other modals
if !m.confirmingQuit && (key.Matches(msg, m.keyMap.Quit) || msg.String() == "q" || msg.String() == "ctrl+c") {
m.cancelAllModals()
m.startConfirmQuit()
m.logAction("tui quit requested")
return m, nil
}
if m.confirmingQuit {
switch msg.String() {
case "y", "Y", "ctrl+c":
m.logAction("tui confirmed quit")
m.confirmingQuit = false
return m, tea.Quit
case "n", "N", "esc":
m.logAction("tui canceled quit")
m.confirmingQuit = false
return m, nil
default:
return m, nil
}
}
if m.confirmingDelete {
switch msg.String() {
case "y", "Y":