fix: guard terminal deferred quit state

This commit is contained in:
proxyctl coordinator
2026-07-17 10:40:52 +08:00
parent eb8932a319
commit e92a4788ba
2 changed files with 94 additions and 5 deletions
+8 -1
View File
@@ -77,7 +77,7 @@ func (m Model) Init() tea.Cmd { return nil }
// operation start checks it, so a completion can only belong to the one current
// operation rather than racing another operation for shared model state.
func (m Model) busy() bool {
return m.operationInFlight() || m.pendingActivation.Kind != 0
return m.quitRequested || m.operationInFlight() || m.pendingActivation.Kind != 0
}
func (m Model) operationInFlight() bool {
@@ -85,6 +85,13 @@ func (m Model) operationInFlight() bool {
}
func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) {
// A deferred tea.Quit is queued only after the in-flight completion has
// been consumed. Until Bubble Tea processes that QuitMsg, keep the model
// terminal so intervening input cannot cancel a confirmation or start a
// second mutation.
if m.quitRequested && !m.operationInFlight() {
return m, nil
}
if key, ok := message.(tea.KeyMsg); ok && m.operationInFlight() && isQuitKey(key) {
m.quitRequested = true
return m, nil