fix(tui): confirm a kill with y, and make the dialog say what it would kill

Killing demanded the session's NAME typed out in full. That is the right
ceremony for dropping a production database and the wrong one for closing a
pane you are looking at; the beta tester's verdict was "thats stupid, just make
me type Y to confirm". `x` then `y` is already two deliberate keystrokes on a
row the user selected, and the conversation lives in its transcript, which a
kill does not touch.

Everything that is not `y` CANCELS rather than being ignored, so a stray key
closes the dialog instead of leaving a destructive prompt armed and waiting for
whatever gets typed next. Enter cancels too: it is the key most likely to be
hit by reflex, and this is the one dialog that destroys something.

⚠️ Found while verifying the new dialog: it did not name the session. The label
was computed as `row.session.name ?? id.slice(0, 8)`, and `??` falls back only
on null or undefined, so every session the server left with an EMPTY name — all
of them, until the TUI started naming its own — sailed through and the box read
"Kill ?". A destructive prompt that cannot say what it will destroy is worse
than no prompt, and it is now a single keystroke. The caller passes the same
label the LIST shows, so the dialog names the row in front of the user.

The typed-name machinery goes with it: TuiConfirmState.typed, setConfirmInput(),
confirmAccepts() and the 'typing'/'reject' steps are all removed rather than
left as unreachable branches.
This commit is contained in:
Codeman maintainer
2026-08-22 14:13:58 +02:00
parent 7b1150ca4f
commit b2ac6c1bd9
8 changed files with 75 additions and 84 deletions
+2 -3
View File
@@ -614,7 +614,7 @@ const FOOTER_KEYS: Record<string, (glyphs: TuiGlyphSet) => string> = {
'q quit',
].join(` ${g.separator} `),
help: (g) => `esc ${g.separator} ? close`,
'confirm-kill': (g) => `type the name ${g.separator} ${g.enter} confirm ${g.separator} esc cancel`,
'confirm-kill': (g) => `y kill ${g.separator} any other key cancels`,
message: () => 'esc dismiss',
prompt: (g) => `${g.enter} send ${g.separator} esc cancel`,
search: (g) => `${g.updown} results ${g.separator} ${g.enter} open ${g.separator} esc close`,
@@ -805,10 +805,9 @@ function overlayContent(
}
case 'confirm-kill': {
if (!model.confirm) return null;
const { name, typed } = model.confirm;
return {
title: 'Kill session',
lines: [`Kill ${name}?`, '', 'Type the name to confirm:', ` ${typed}_`],
lines: [`Kill ${model.confirm.name}?`, '', 'press y to kill, any other key cancels'],
};
}
case 'message':