// docs/SIDEBAR.md "Killing a session": every kill confirms first, and the // confirmation names what the card last saw in the way — the daemon refuses an // unforced kill over such a tree, and saying so beforehand is cheaper than the // refusal. Cancel holds the focus so a stray Enter kills nothing. import { useEffect, useRef } from "react"; import { createPortal } from "react-dom"; import type { InTheWay } from "../../types.js"; import { formatInTheWay } from "../../types.js"; export interface KillConfirmProps { name: string; blockers: InTheWay | null; /** Set when the daemon already refused an unforced kill: this pass forces. */ force?: boolean; onConfirm(): void; onCancel(): void; } export function KillConfirm(props: KillConfirmProps) { const cancel = useRef(null); useEffect(() => cancel.current?.focus(), []); return createPortal(
{ if (e.key === "Escape") props.onCancel(); }} >

{props.force ? "Force kill" : "Kill"} {props.name}?

{props.blockers && (

{formatInTheWay(props.blockers)}

)}
, document.body, ); }