From 52877abe29cdebd4493f2f19242938e300e217e6 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Fri, 4 Sep 2026 08:24:32 +0100 Subject: [PATCH] fix(maestro): focus the kill button in kill dialogs Enter now confirms the kill the operator just asked for; Escape and the scrim still cancel. --- web/src/killDialog.test.ts | 33 +++++++++++++++++++++++++++++++++ web/src/killDialog.ts | 6 +++--- 2 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 web/src/killDialog.test.ts diff --git a/web/src/killDialog.test.ts b/web/src/killDialog.test.ts new file mode 100644 index 0000000..e3cca27 --- /dev/null +++ b/web/src/killDialog.test.ts @@ -0,0 +1,33 @@ +// @vitest-environment happy-dom +import { beforeEach, describe, expect, it } from "vitest"; +import { + closeForceKillDialog, + openForceKillDialog, + openKillConfirmDialog, +} from "./killDialog.js"; + +describe("kill dialogs", () => { + beforeEach(() => { + closeForceKillDialog(); + document.body.innerHTML = ""; + }); + + it("focuses the kill button, so Enter confirms", () => { + const el = openKillConfirmDialog({ + name: "alpha", + blockers: null, + onKill: () => Promise.resolve(), + }); + expect(document.activeElement).toBe(el.querySelector(".kill-dialog-kill")); + }); + + it("focuses the force button too", () => { + const el = openForceKillDialog({ + name: "alpha", + blockers: null, + reason: "worktree is dirty.", + onForce: () => Promise.resolve(), + }); + expect(document.activeElement).toBe(el.querySelector(".kill-dialog-force")); + }); +}); diff --git a/web/src/killDialog.ts b/web/src/killDialog.ts index 1962be6..b38659c 100644 --- a/web/src/killDialog.ts +++ b/web/src/killDialog.ts @@ -132,9 +132,9 @@ function mount(p: KillDialogSpec): HTMLElement { }; window.addEventListener("keydown", onKeydown, true); open = { el, onKeydown }; - // Cancel takes the focus in both prompts: a kill is never one keystroke - // away from whatever asked for the dialog. - cancel.focus(); + // The acting button takes the focus in both prompts: the operator already + // asked for the kill, so Enter confirms it. Escape and the scrim cancel. + confirm.focus(); return el; }