Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/devtui/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const (
keyCtrlC = "ctrl+c"
keyDown = "down"
keyEnter = "enter"
keyEsc = "esc"
keyUp = "up"
keyTab = "tab"
keyShiftTab = "shift+tab"
Expand Down
3 changes: 3 additions & 0 deletions internal/devtui/overlay_stop_confirm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ func (sc *stopConfirm) Update(msg tea.Msg) (Modal, tea.Cmd) {
}
case keyTab:
sc.selected = (sc.selected + 1) % count
case keyEsc:
return nil, emit(stopConfirmResultMsg{Cancel: true})
case keyEnter:
switch sc.selected {
case stopConfirmCancel:
Expand All @@ -71,6 +73,7 @@ func (sc *stopConfirm) View(width, height int) string {
footerHint := tui.ShortcutBar(
tui.Shortcut{Key: "←/→", Label: "Select"},
tui.Shortcut{Key: "enter", Label: "Confirm"},
tui.Shortcut{Key: "esc", Label: "Cancel"},
)
return renderPhaseLayout(tui.RenderPhaseCard(card.String()), width, height, footerHint)
}
16 changes: 9 additions & 7 deletions internal/devtui/overlay_stop_confirm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ func TestStopConfirm_HAndLKeysMoveSelection(t *testing.T) {
assert.Equal(t, stopConfirmStop, sc.selected, "'h' should move the selection back")
}

func TestStopConfirm_EscIsNoop(t *testing.T) {
// NOTE: stopConfirm.Update does not handle Esc — pressing it leaves the
// modal in place and emits no command. The model-level update layer is
// responsible for any global Esc handling.
func TestStopConfirm_EscEmitsCancel(t *testing.T) {
sc := newStopConfirm()

next, cmd := sc.Update(tea.KeyPressMsg(tea.Key{Code: tea.KeyEsc}))
assert.Same(t, sc, next)
assert.Nil(t, cmd)
assert.Equal(t, stopConfirmStop, sc.selected, "esc must not mutate the selection")
assert.Nil(t, next, "esc should dismiss the modal")
assert.NotNil(t, cmd)

res, ok := cmd().(stopConfirmResultMsg)
assert.True(t, ok, "expected stopConfirmResultMsg, got %T", cmd())
assert.True(t, res.Cancel, "esc should emit a cancel result")
assert.False(t, res.Stop)
}

func TestStopConfirm_NonKeyMsgIsIgnored(t *testing.T) {
Expand Down
Loading