From 9083401435daed119d178d7b48c0e452d41da6c1 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Tue, 20 Oct 2026 16:08:43 -0700 Subject: [PATCH] Align VM details and show timed startup progress Give every console a startup surface, elapsed time, and a boot-screen escape. Keep video laid out beneath the overlay and resume playback when revealed. Release keyboard capture while covered. Align VM rows, group hardware facts, and focus the confirmation action so Enter matches its shortcut. Verified responsive light/dark layouts and confirmation keyboard behavior. Native Safari control remains unavailable, so its playback fix is unverified. Assisted-by: gpt-6-astra --- dashboard/web/components/Dialog.tsx | 5 +- dashboard/web/components/Meter.tsx | 4 +- dashboard/web/components/VMConsole.tsx | 71 ++++++-- dashboard/web/pages/VMs.css | 78 ++++----- dashboard/web/pages/VMs.tsx | 234 ++++++++++--------------- dashboard/web/types/vms.ts | 1 + 6 files changed, 193 insertions(+), 200 deletions(-) diff --git a/dashboard/web/components/Dialog.tsx b/dashboard/web/components/Dialog.tsx index 1ac56ccf9cef5e62af16f3c00698af6999334adf..afb375a4f4ae14bbe89028402c1d93f16a1bca09 100644 --- a/dashboard/web/components/Dialog.tsx +++ b/dashboard/web/components/Dialog.tsx @@ -42,7 +42,6 @@ const SHAKE = [0, -8, 8, -8, 8, -8, 8, 0].map((x) => ({ transform: `translateX($ const reduced = matchMedia("(prefers-reduced-motion: reduce)"); let dialogs = 0; -/** Destructive confirmations focus back; fields with autofocus take precedence. */ export const showConfirmDialog = (options: DialogOptions) => open(options); /** Like showConfirmDialog with a text field; Enter submits once `validateInput` passes. */ @@ -119,10 +118,10 @@ function open(options: DialogOptions, field?: TextDialogOptions) {
{body}
- + {/* aria-disabled rather than disabled while pending, so focus stays put for a retry. */}
diff --git a/dashboard/web/components/Meter.tsx b/dashboard/web/components/Meter.tsx index f5d54066d6ef0b7d92d6df6fe1fa724c4a935511..ad761837c626f58139c74ed7f01dc5b4ef5e062c 100644 --- a/dashboard/web/components/Meter.tsx +++ b/dashboard/web/components/Meter.tsx @@ -1,10 +1,10 @@ import { Show } from "solid-js"; /** A thin progress bar; `failed` stacks a critical segment after the done one. */ -export function Meter(props: { value: number; max?: number; failed?: number }) { +export function Meter(props: { value: number; max?: number; failed?: number; label?: string }) { const width = (part: number) => `${(part / (props.max || 1)) * 100}%`; return ( -
+
{(failed) => }
diff --git a/dashboard/web/components/VMConsole.tsx b/dashboard/web/components/VMConsole.tsx index d53aa23255135ddc8436eda7f212e483af6e84b2..962fd36f3181a00387e44a26a49f6b89992421f9 100644 --- a/dashboard/web/components/VMConsole.tsx +++ b/dashboard/web/components/VMConsole.tsx @@ -17,9 +17,21 @@ type WindowSurface = { }; type WindowFrame = { windows: WindowSurface[]; rtpTimestamp: number }; -export function VMConsole(props: { name: string; platform: Domain["platform"]; enabled: boolean; active: boolean; setup?: Domain["setup"]; unavailable?: string; clipboard?: (text: string) => Promise; toolbar: JSX.Element; content: (toolbar: HTMLDivElement) => JSX.Element }) { +export function VMConsole(props: { name: string; platform: Domain["platform"]; enabled: boolean; active: boolean; setup?: Domain["setup"]; booting: boolean; startedAt: number | null; arch: string; unavailable?: string; clipboard?: (text: string) => Promise; toolbar: JSX.Element; content: (toolbar: HTMLDivElement) => JSX.Element }) { const enabled = createMemo(() => props.enabled); - const preparing = () => !!props.setup && props.setup !== "ready"; + const [bootScreen, setBootScreen] = createSignal(false); + const preparing = () => !bootScreen() && (!!props.setup && props.setup !== "ready" || props.booting || state() === "Connecting…"); + const [now, setNow] = createSignal(Date.now()); + createEffect(() => { + if (!preparing() || !props.active) return; + setNow(Date.now()); + const timer = window.setInterval(() => setNow(Date.now()), 1000); + onCleanup(() => clearInterval(timer)); + }); + const elapsed = () => { + const seconds = Math.max(0, Math.floor(now() / 1000 - (props.startedAt ?? now() / 1000))); + return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`; + }; let reconnectTimer: number | undefined; let retryDelay = 1000; let attempt = 0; @@ -72,6 +84,7 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e }; const [state, setState] = createSignal<"Connecting…" | "Connected" | "Disconnected">("Connecting…"); const connected = () => state() === "Connected"; + const acceptsInput = () => props.active && connected() && !preparing(); const [problem, setProblem] = createSignal(""); const [clipboard, setClipboard] = createSignal(""); const [sendingClipboard, setSendingClipboard] = createSignal(false); @@ -126,7 +139,7 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e const socket = new WebSocket(url.href, ["binary"]); socket.binaryType = "arraybuffer"; const keyboard = new RemoteKeyboard(video); - const focus = () => { if (input?.readyState === "open") keyboard.grab(); }; + const focus = () => { if (acceptsInput() && input?.readyState === "open") keyboard.grab(); }; const blur = () => { keyboard.ungrab(); release(); }; const releaseKeyboard = (event: KeyboardEvent) => { if (event.key !== "Escape" || !event.ctrlKey || !event.altKey) return; @@ -243,7 +256,7 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e if (codecs?.length) transceiver.setCodecPreferences(codecs); input = peer.createDataChannel("input"); movement = peer.createDataChannel("pointer", { ordered: false, maxRetransmits: 0 }); - keyboard.onkeyevent = (key, _code, down) => send({ type: "key", key, down }); + keyboard.onkeyevent = (key, _code, down) => { if (acceptsInput()) send({ type: "key", key, down }); }; input.onopen = () => { ready(); if (document.activeElement === video) focus(); @@ -355,13 +368,41 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e setProblem(""); } }); - createEffect(() => { if (!props.active || !connected() || preparing()) release(); }); + createEffect(() => { + if (acceptsInput()) return; + release(); + if (document.activeElement === video) { + video.blur(); + if (props.active) tools()?.querySelector("summary")?.focus(); + } + }); createEffect(on(() => props.setup, setup => { if (setup === "ready" && enabled() && state() === "Disconnected") void connect(); }, { defer: true })); - onCleanup(() => { disposed = true; disconnect(); }); + let playbackFrame: number | undefined; + const resumeVideo = () => { + if (playbackFrame !== undefined) cancelAnimationFrame(playbackFrame); + const current = attempt; + playbackFrame = requestAnimationFrame(() => { + if (disposed || current !== attempt || !props.active || !enabled() || document.hidden || !video.srcObject) return; + void video.play().catch(() => { + if (!disposed && current === attempt && props.active && enabled() && !document.hidden && video.srcObject) { + setProblem("The browser couldn't play the screen. Reconnect to try again."); + } + }); + }); + }; + createEffect(on(() => [props.active, enabled(), preparing()], resumeVideo)); + createEffect(on(() => props.startedAt, () => setBootScreen(false))); + document.addEventListener("visibilitychange", resumeVideo); + onCleanup(() => { + disposed = true; + if (playbackFrame !== undefined) cancelAnimationFrame(playbackFrame); + document.removeEventListener("visibilitychange", resumeVideo); + disconnect(); + }); const pointer = (event: PointerEvent | WheelEvent, mask = buttons) => { - if (!connected() || !width || !height) return; + if (!connected() || preparing() || !width || !height) return; const rect = video.getBoundingClientRect(); const scale = Math.min(rect.width / width, rect.height / height); const x = Math.floor((event.clientX - rect.left - (rect.width - width * scale) / 2) / scale); @@ -436,15 +477,19 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e
- -
- {VM_SETUP[props.setup!]} -

{props.setup === "failed" ? "Restart this VM from the Machine menu to retry." : "Your desktop opens here when setup finishes."}

+