fix(ui): Esc cancels delete confirmation instead of confirming it

In the remove-wizard's confirming state, pressing Esc was reflexively
calling removeForwardsCmd — i.e. confirming deletion. The on-screen
help text said 'Esc: Cancel'. Reflexive Esc-to-cancel destroyed data.

Esc now sets confirming=false and resets the cursor; deletion
requires Enter on Yes. Non-confirming Esc behavior (exit wizard with
ClearScreen) is unchanged.

Three regression tests added in handlers_test.go.
This commit is contained in:
2026-05-06 10:45:27 +01:00
parent 7a33e01863
commit 4fe3f6b21f
2 changed files with 104 additions and 7 deletions
+8 -7
View File
@@ -722,14 +722,15 @@ func (m model) handleRemoveWizardKeys(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
case "esc":
if wizard.confirming {
// In confirmation mode, Esc confirms the removal (same as pressing Yes)
selectedForwards := wizard.getSelectedForwards()
return m, removeForwardsCmd(m.ui.mutator, selectedForwards)
} else {
// Not confirming yet - cancel entirely
m.ui.viewMode = ViewModeMain
m.ui.removeWizard = nil
// In confirmation mode, Esc cancels the confirmation (matches help text "Esc: Cancel")
// Returns to selection state without dispatching removal.
wizard.confirming = false
wizard.confirmCursor = 0
return m, nil
}
// Not confirming yet - cancel entirely
m.ui.viewMode = ViewModeMain
m.ui.removeWizard = nil
return m, tea.ClearScreen
case "up", "k":