All checks were successful
React + Vite + TypeScript SPA: scaffold, operations-terminal design system, Bearer-token auth, and the Machines view. - Design system: OKLCH-tinted dark theme (ink-slate + signal-cyan), Hanken Grotesk + JetBrains Mono, status-color language (online/offline/granted/pending/denied/not_required), motion with prefers-reduced-motion honored. - Auth: token in sessionStorage via ref (never React state), protected routes, 401 session teardown, admin-gated per-agent-key UI. - Machines view: data table (sticky header, keyboard-activated rows, skeleton loading, actionable empty/error states), non-blocking detail drawer, delete confirm, admin key management with copy-once reveal. - UI primitives: Modal (focus trap + inert + portal + dialogStack), Drawer, Table, Badge/StatusDot, toast, states. - Typed API client normalizing the two error-envelope shapes. Passed Code Review (no blockers), impeccable critique-and-polish, and local gates (tsc/lint/build green). Dev-only Vite proxy to :3002. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
29 lines
897 B
TypeScript
29 lines
897 B
TypeScript
// A tiny module-level stack so only the topmost open dialog (Modal or Drawer)
|
|
// reacts to Escape and owns the background `inert` toggle. This keeps stacked
|
|
// dialogs (e.g. a confirm on top of a management modal) from all closing at once.
|
|
|
|
const stack: symbol[] = [];
|
|
|
|
/** Push a dialog onto the stack. Returns its token. */
|
|
export function pushDialog(): symbol {
|
|
const token = Symbol("dialog");
|
|
stack.push(token);
|
|
return token;
|
|
}
|
|
|
|
/** Remove a dialog from the stack by token. */
|
|
export function popDialog(token: symbol): void {
|
|
const i = stack.lastIndexOf(token);
|
|
if (i !== -1) stack.splice(i, 1);
|
|
}
|
|
|
|
/** True when `token` is the topmost open dialog. */
|
|
export function isTopDialog(token: symbol): boolean {
|
|
return stack.length > 0 && stack[stack.length - 1] === token;
|
|
}
|
|
|
|
/** True when any dialog is open. */
|
|
export function hasOpenDialog(): boolean {
|
|
return stack.length > 0;
|
|
}
|