| author | |
| committer | |
| log | 9083401435daed119d178d7b48c0e452d41da6c1 |
| tree | ea85c9cdfcb0f29afb08480d5323c828e6137b1a |
| parent | 3bbd5d1b55104fc08e88d1cfb7c141b5525bfdc3 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
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-astra6 files changed, 193 insertions(+), 200 deletions(-)
dashboard/web/components/Dialog.tsx+2-3| ... | ... | @@ -42,7 +42,6 @@ const SHAKE = [0, -8, 8, -8, 8, -8, 8, 0].map((x) => ({ transform: `translateX($ |
| 42 | 42 | const reduced = matchMedia("(prefers-reduced-motion: reduce)"); |
| 43 | 43 | let dialogs = 0; |
| 44 | 44 | |
| 45 | /** Destructive confirmations focus back; fields with autofocus take precedence. */ | |
| 46 | 45 | export const showConfirmDialog = (options: DialogOptions) => open(options); |
| 47 | 46 | |
| 48 | 47 | /** Like showConfirmDialog with a text field; Enter submits once `validateInput` passes. */ |
| ... | ... | @@ -119,10 +118,10 @@ function open(options: DialogOptions, field?: TextDialogOptions) { |
| 119 | 118 | <Show when={options.body}><fieldset disabled={pending()}>{body}</fieldset></Show> |
| 120 | 119 | <Show when={error()}><p class="error" role="alert">{error()}</p></Show> |
| 121 | 120 | <div class="actions"> |
| 122 | <button type="button" class="button" disabled={pending()} autofocus={options.destructive} onClick={close}>back<kbd aria-hidden="true">esc</kbd></button> | |
| 121 | <button type="button" class="button" disabled={pending()} onClick={close}>back<kbd aria-hidden="true">esc</kbd></button> | |
| 123 | 122 | {/* aria-disabled rather than disabled while pending, so focus stays put for a retry. */} |
| 124 | 123 | <button type="submit" class="button primary" classList={{ danger: options.destructive }} |
| 125 | autofocus={!field && !options.destructive} disabled={!valid()} aria-disabled={pending()} aria-busy={pending()}> | |
| 124 | autofocus={!field} disabled={!valid()} aria-disabled={pending()} aria-busy={pending()}> | |
| 126 | 125 | {options.confirmLabel}<kbd aria-hidden="true">enter</kbd> |
| 127 | 126 | </button> |
| 128 | 127 | </div> |
dashboard/web/components/Meter.tsx+2-2| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | import { Show } from "solid-js"; |
| 2 | 2 | |
| 3 | 3 | /** A thin progress bar; `failed` stacks a critical segment after the done one. */ |
| 4 | export function Meter(props: { value: number; max?: number; failed?: number }) { | |
| 4 | export function Meter(props: { value: number; max?: number; failed?: number; label?: string }) { | |
| 5 | 5 | const width = (part: number) => `${(part / (props.max || 1)) * 100}%`; |
| 6 | 6 | return ( |
| 7 | <div class="meter" role="progressbar" aria-valuemin="0" aria-valuemax={props.max ?? 1} aria-valuenow={props.value}> | |
| 7 | <div class="meter" role="progressbar" aria-label={props.label} aria-valuemin="0" aria-valuemax={props.max ?? 1} aria-valuenow={props.value}> | |
| 8 | 8 | <span style={{ width: width(props.value) }} /> |
| 9 | 9 | <Show when={props.failed}>{(failed) => <span class="failed" style={{ width: width(failed()) }} />}</Show> |
| 10 | 10 | </div> |
dashboard/web/components/VMConsole.tsx+58-13| ... | ... | @@ -17,9 +17,21 @@ type WindowSurface = { |
| 17 | 17 | }; |
| 18 | 18 | type WindowFrame = { windows: WindowSurface[]; rtpTimestamp: number }; |
| 19 | 19 | |
| 20 | export function VMConsole(props: { name: string; platform: Domain["platform"]; enabled: boolean; active: boolean; setup?: Domain["setup"]; unavailable?: string; clipboard?: (text: string) => Promise<void>; toolbar: JSX.Element; content: (toolbar: HTMLDivElement) => JSX.Element }) { | |
| 20 | 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<void>; toolbar: JSX.Element; content: (toolbar: HTMLDivElement) => JSX.Element }) { | |
| 21 | 21 | const enabled = createMemo(() => props.enabled); |
| 22 | const preparing = () => !!props.setup && props.setup !== "ready"; | |
| 22 | const [bootScreen, setBootScreen] = createSignal(false); | |
| 23 | const preparing = () => !bootScreen() && (!!props.setup && props.setup !== "ready" || props.booting || state() === "Connecting…"); | |
| 24 | const [now, setNow] = createSignal(Date.now()); | |
| 25 | createEffect(() => { | |
| 26 | if (!preparing() || !props.active) return; | |
| 27 | setNow(Date.now()); | |
| 28 | const timer = window.setInterval(() => setNow(Date.now()), 1000); | |
| 29 | onCleanup(() => clearInterval(timer)); | |
| 30 | }); | |
| 31 | const elapsed = () => { | |
| 32 | const seconds = Math.max(0, Math.floor(now() / 1000 - (props.startedAt ?? now() / 1000))); | |
| 33 | return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`; | |
| 34 | }; | |
| 23 | 35 | let reconnectTimer: number | undefined; |
| 24 | 36 | let retryDelay = 1000; |
| 25 | 37 | let attempt = 0; |
| ... | ... | @@ -72,6 +84,7 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e |
| 72 | 84 | }; |
| 73 | 85 | const [state, setState] = createSignal<"Connecting…" | "Connected" | "Disconnected">("Connecting…"); |
| 74 | 86 | const connected = () => state() === "Connected"; |
| 87 | const acceptsInput = () => props.active && connected() && !preparing(); | |
| 75 | 88 | const [problem, setProblem] = createSignal(""); |
| 76 | 89 | const [clipboard, setClipboard] = createSignal(""); |
| 77 | 90 | const [sendingClipboard, setSendingClipboard] = createSignal(false); |
| ... | ... | @@ -126,7 +139,7 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e |
| 126 | 139 | const socket = new WebSocket(url.href, ["binary"]); |
| 127 | 140 | socket.binaryType = "arraybuffer"; |
| 128 | 141 | const keyboard = new RemoteKeyboard(video); |
| 129 | const focus = () => { if (input?.readyState === "open") keyboard.grab(); }; | |
| 142 | const focus = () => { if (acceptsInput() && input?.readyState === "open") keyboard.grab(); }; | |
| 130 | 143 | const blur = () => { keyboard.ungrab(); release(); }; |
| 131 | 144 | const releaseKeyboard = (event: KeyboardEvent) => { |
| 132 | 145 | if (event.key !== "Escape" || !event.ctrlKey || !event.altKey) return; |
| ... | ... | @@ -243,7 +256,7 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e |
| 243 | 256 | if (codecs?.length) transceiver.setCodecPreferences(codecs); |
| 244 | 257 | input = peer.createDataChannel("input"); |
| 245 | 258 | movement = peer.createDataChannel("pointer", { ordered: false, maxRetransmits: 0 }); |
| 246 | keyboard.onkeyevent = (key, _code, down) => send({ type: "key", key, down }); | |
| 259 | keyboard.onkeyevent = (key, _code, down) => { if (acceptsInput()) send({ type: "key", key, down }); }; | |
| 247 | 260 | input.onopen = () => { |
| 248 | 261 | ready(); |
| 249 | 262 | if (document.activeElement === video) focus(); |
| ... | ... | @@ -355,13 +368,41 @@ export function VMConsole(props: { name: string; platform: Domain["platform"]; e |
| 355 | 368 | setProblem(""); |
| 356 | 369 | } |
| 357 | 370 | }); |
| 358 | createEffect(() => { if (!props.active || !connected() || preparing()) release(); }); | |
| 371 | createEffect(() => { | |
| 372 | if (acceptsInput()) return; | |
| 373 | release(); | |
| 374 | if (document.activeElement === video) { | |
| 375 | video.blur(); | |
| 376 | if (props.active) tools()?.querySelector<HTMLElement>("summary")?.focus(); | |
| 377 | } | |
| 378 | }); | |
| 359 | 379 | createEffect(on(() => props.setup, setup => { |
| 360 | 380 | if (setup === "ready" && enabled() && state() === "Disconnected") void connect(); |
| 361 | 381 | }, { defer: true })); |
| 362 | onCleanup(() => { disposed = true; disconnect(); }); | |
| 382 | let playbackFrame: number | undefined; | |
| 383 | const resumeVideo = () => { | |
| 384 | if (playbackFrame !== undefined) cancelAnimationFrame(playbackFrame); | |
| 385 | const current = attempt; | |
| 386 | playbackFrame = requestAnimationFrame(() => { | |
| 387 | if (disposed || current !== attempt || !props.active || !enabled() || document.hidden || !video.srcObject) return; | |
| 388 | void video.play().catch(() => { | |
| 389 | if (!disposed && current === attempt && props.active && enabled() && !document.hidden && video.srcObject) { | |
| 390 | setProblem("The browser couldn't play the screen. Reconnect to try again."); | |
| 391 | } | |
| 392 | }); | |
| 393 | }); | |
| 394 | }; | |
| 395 | createEffect(on(() => [props.active, enabled(), preparing()], resumeVideo)); | |
| 396 | createEffect(on(() => props.startedAt, () => setBootScreen(false))); | |
| 397 | document.addEventListener("visibilitychange", resumeVideo); | |
| 398 | onCleanup(() => { | |
| 399 | disposed = true; | |
| 400 | if (playbackFrame !== undefined) cancelAnimationFrame(playbackFrame); | |
| 401 | document.removeEventListener("visibilitychange", resumeVideo); | |
| 402 | disconnect(); | |
| 403 | }); | |
| 363 | 404 | const pointer = (event: PointerEvent | WheelEvent, mask = buttons) => { |
| 364 | if (!connected() || !width || !height) return; | |
| 405 | if (!connected() || preparing() || !width || !height) return; | |
| 365 | 406 | const rect = video.getBoundingClientRect(); |
| 366 | 407 | const scale = Math.min(rect.width / width, rect.height / height); |
| 367 | 408 | 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 |
| 436 | 477 | </div> |
| 437 | 478 | </div> |
| 438 | 479 | </Show> |
| 439 | <Show when={props.active && props.enabled && preparing()}> | |
| 440 | <div class="empty vm-setup" role={props.setup === "failed" ? "alert" : "status"}> | |
| 441 | <StatusLabel health={props.setup === "failed" ? "down" : "starting"}>{VM_SETUP[props.setup!]}</StatusLabel> | |
| 442 | <p>{props.setup === "failed" ? "Restart this VM from the Machine menu to retry." : "Your desktop opens here when setup finishes."}</p> | |
| 480 | <div class="vm-console-screen" hidden={!props.active || !props.enabled}> | |
| 481 | <Show when={preparing()}> | |
| 482 | <div class="empty vm-setup"> | |
| 483 | <div role={props.setup === "failed" ? "alert" : "status"}> | |
| 484 | <StatusLabel health={props.setup === "failed" ? "down" : "starting"}>{props.setup && props.setup !== "ready" ? VM_SETUP[props.setup] : props.booting ? "Starting your VM…" : "Connecting to screen…"}</StatusLabel> | |
| 485 | <p>{props.setup === "failed" ? "Restart this VM from the Machine menu to retry." : !props.booting ? "Waiting for the screen connection." : props.arch === "aarch64" ? "This preset can take several minutes to boot." : "This preset takes about 1 minute to boot."}</p> | |
| 486 | </div> | |
| 487 | <Show when={props.startedAt !== null}><span class="vm-setup-elapsed" role="timer" aria-live="off">{elapsed()} elapsed</span></Show> | |
| 488 | <button class="button small" onClick={() => setBootScreen(true)}>View boot screen</button> | |
| 443 | 489 | </div> |
| 444 | 490 | </Show> |
| 445 | <div class="vm-console-screen" hidden={!props.active || !props.enabled || preparing()}> | |
| 446 | 491 | <canvas ref={canvas} class="vm-window-canvas" hidden aria-hidden="true" /> |
| 447 | <video ref={video} autoplay muted playsinline tabindex="0" aria-label="VM screen" aria-describedby={`keyboard-release-${props.name}`} | |
| 492 | <video ref={video} autoplay muted playsinline tabindex={preparing() ? -1 : 0} aria-hidden={preparing()} aria-label="VM screen" aria-describedby={`keyboard-release-${props.name}`} | |
| 448 | 493 | onContextMenu={(event) => event.preventDefault()} |
| 449 | 494 | onPointerMove={pointer} |
| 450 | 495 | onPointerLeave={() => { cursorInside = false; drawCursor(); }} |
dashboard/web/pages/VMs.css+35-43| ... | ... | @@ -1,23 +1,19 @@ |
| 1 | 1 | .vms-list th:not(:first-child), .vms-list tr.top > td:not(.title) { width: 1%; white-space: nowrap; } |
| 2 | .vm-setup { flex: 1; display: grid; align-content: center; justify-items: center; gap: 12px; } | |
| 2 | .vm-setup { position: absolute; inset: 0; z-index: 2; background: var(--panel); display: grid; align-content: center; justify-items: center; gap: 12px; margin: 0; } | |
| 3 | 3 | .vms-list .row-skeleton { height: 36px; margin: 14px var(--gutter); } |
| 4 | 4 | |
| 5 | 5 | .vms-list tbody.vm tr { cursor: pointer; } |
| 6 | 6 | .vms-list tbody.vm tr > td { transition: background-color 150ms; } |
| 7 | 7 | .vms-list tbody.vm:has(tr:hover) tr > td { background: var(--hover); } |
| 8 | .vms-list tr.top > td { padding-top: 8px; padding-bottom: 0; } | |
| 9 | .vms-list tr.bottom > td { padding-top: 2px; padding-bottom: 8px; font-size: 12px; color: var(--muted); } | |
| 10 | .vms-list tbody.off tr.bottom > td.num { color: var(--text-2); } | |
| 11 | .vms .vms-list table.data tbody.vm tr.bottom > td:last-child { padding-right: 8px; } | |
| 12 | /* A row-spanning cell loses its collapsed bottom border to the next row, so each VM's rule is drawn as a shadow. */ | |
| 13 | .vms-list tbody.vm td { border-bottom: 0; } | |
| 14 | .vms-list tbody.vm :is(tr.bottom > td, td.actions) { box-shadow: inset 0 -1px var(--grid); } | |
| 8 | .vms-list tr.top > td { padding-top: 8px; padding-bottom: 8px; vertical-align: top; } | |
| 9 | .vm-resource-usage { display: block; margin-top: 0; color: var(--muted); font-size: 12px; } | |
| 15 | 10 | .vms-list td:focus-visible { outline-offset: -2px; } |
| 16 | 11 | |
| 17 | 12 | .vms-list td.title { min-width: 220px; max-width: 0; } |
| 18 | 13 | .vms-list td.title button { |
| 19 | 14 | display: flex; |
| 20 | align-items: baseline; | |
| 15 | align-items: center; | |
| 16 | min-height: 36px; | |
| 21 | 17 | gap: 8px; |
| 22 | 18 | width: 100%; |
| 23 | 19 | padding: 0; |
| ... | ... | @@ -30,44 +26,37 @@ |
| 30 | 26 | cursor: pointer; |
| 31 | 27 | } |
| 32 | 28 | .vms-list td.title button:focus-visible { outline-offset: 2px; } |
| 33 | .vm-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; } | |
| 29 | .vm-name { min-width: 0; max-width: 100%; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; } | |
| 34 | 30 | .vms-list tbody.off .vm-name { color: var(--text-2); } |
| 35 | 31 | .vms-list .for { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); } |
| 36 | .vms-list td.specs { max-width: 0; } | |
| 37 | .vms-list td.specs > div { display: flex; flex-wrap: wrap; gap: 2px 12px; cursor: default; } | |
| 38 | .vms-list td.specs span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; } | |
| 39 | .vms-list td.specs svg { flex: none; } | |
| 40 | .vms-list td.specs .mono { color: var(--text-2); } | |
| 32 | .vms-list .specs { display: flex; flex-wrap: wrap; gap: 3px 12px; margin-top: 0; color: var(--muted); font-size: 12px; cursor: default; } | |
| 33 | .vms-list .specs span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; } | |
| 34 | .vms-list .specs svg { flex: none; } | |
| 35 | .vms-list .specs .mono { color: var(--text-2); } | |
| 41 | 36 | |
| 42 | 37 | |
| 43 | .vm-detail { display: grid; align-content: start; gap: 16px; } | |
| 38 | .vm-detail { display: grid; align-content: start; gap: 28px; } | |
| 39 | .vm-detail h2 { margin: 0; font-size: 18px; overflow-wrap: anywhere; } | |
| 40 | .vm-detail h3 { margin: 0 0 14px; font-size: 13px; font-weight: 600; } | |
| 44 | 41 | .vm-detail .off-hour { margin: 0; color: var(--muted); font-size: 12px; } |
| 45 | 42 | .vm-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; } |
| 46 | 43 | .vm-charts .skeleton { height: 104px; } |
| 47 | .vm-detail .facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 16px 28px; } | |
| 48 | .vm-detail .kv { align-content: start; } | |
| 49 | .vm-detail .settings { display: grid; gap: 12px; align-content: start; } | |
| 50 | .vm-detail .describe { | |
| 51 | margin: 0 -4px; | |
| 52 | padding: 0 4px; | |
| 53 | border: 0; | |
| 54 | border-radius: 4px; | |
| 55 | background: none; | |
| 56 | color: inherit; | |
| 57 | font: inherit; | |
| 58 | text-align: left; | |
| 59 | cursor: text; | |
| 60 | transition: background-color 150ms; | |
| 61 | } | |
| 62 | .vm-detail .describe:hover { background: var(--hover); } | |
| 63 | .vm-detail .describe.empty { color: var(--accent); cursor: pointer; } | |
| 64 | .vm-detail .lines { display: grid; gap: 4px 10px; align-items: center; } | |
| 65 | .vm-detail .lines > div { display: contents; } | |
| 66 | .vm-detail .lines.disks { grid-template-columns: auto minmax(0, 1fr) 72px auto; } | |
| 67 | .vm-detail .lines.disks .meter { min-width: 0; height: 5px; } | |
| 68 | .vm-detail .lines.nics { grid-template-columns: auto auto minmax(0, 1fr); } | |
| 69 | .vm-detail .lines.devices { grid-template-columns: auto minmax(0, 1fr); } | |
| 70 | .vm-detail .lines .source { overflow-wrap: anywhere; } | |
| 44 | .vm-detail .facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px 48px; } | |
| 45 | .vm-detail .kv { align-content: start; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 24px; } | |
| 46 | .vm-detail .kv dd { min-width: 0; overflow-wrap: anywhere; } | |
| 47 | .vm-detail .source { min-width: 0; overflow-wrap: anywhere; } | |
| 48 | .vm-devices { display: grid; align-content: start; gap: 28px; } | |
| 49 | .vm-device-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; } | |
| 50 | .vm-device-line > svg { flex: none; align-self: center; color: var(--muted); } | |
| 51 | .vm-device-line .num { margin-left: auto; white-space: nowrap; } | |
| 52 | .vm-disk { display: grid; gap: 8px; font-size: 13px; } | |
| 53 | .vm-disk + .vm-disk { margin-top: 16px; } | |
| 54 | .vm-disk .meter { width: 100%; height: 5px; } | |
| 55 | .vm-disk > .muted { font-size: 12px; } | |
| 56 | .vm-firmware { margin-top: 16px; } | |
| 57 | .vm-nic + .vm-nic { margin-top: 18px; } | |
| 58 | .vm-nic > .kv { margin-top: 12px; font-size: 12px; } | |
| 59 | .vm-usage { padding-top: 4px; } | |
| 71 | 60 | |
| 72 | 61 | .vms-empty { display: grid; justify-items: center; gap: 8px; } |
| 73 | 62 | .vms-empty p { margin: 0; } |
| ... | ... | @@ -85,8 +74,6 @@ |
| 85 | 74 | .vm-resource-scale { color: var(--muted); font-size: 11px; } |
| 86 | 75 | .vm-hardware summary { cursor: pointer; font-size: 13px; color: var(--text-2); } |
| 87 | 76 | .vm-hardware .row { margin-top: 12px; } |
| 88 | .vm-media { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--grid); border-radius: 6px; font-size: 12px; } | |
| 89 | .vm-media .source { overflow-wrap: anywhere; min-width: 0; } | |
| 90 | 77 | .vm-upload-progress { display: grid; gap: 8px; } |
| 91 | 78 | .vm-upload-progress progress { width: 100%; accent-color: var(--accent); } |
| 92 | 79 | .vm-console { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; background: var(--panel); } |
| ... | ... | @@ -105,7 +92,6 @@ |
| 105 | 92 | .vm-clipboard { display: grid; gap: 8px; padding: 12px; } |
| 106 | 93 | @media (max-width: 640px) { |
| 107 | 94 | .vm-detail .facts, .vm-charts { grid-template-columns: 1fr; } |
| 108 | .vm-media { flex-wrap: wrap; } | |
| 109 | 95 | } |
| 110 | 96 | |
| 111 | 97 | .vm-workspace { min-width: 0; } |
| ... | ... | @@ -164,3 +150,9 @@ |
| 164 | 150 | .vm-serial-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); font-size: 13px; pointer-events: none; } |
| 165 | 151 | .vm-serial-empty button { pointer-events: auto; } |
| 166 | 152 | .vm-serial-terminal { flex: 1; min-height: 0; --clo-term-bg: var(--page); --clo-term-fg: var(--text); --clo-term-cursor: var(--accent); } |
| 153 | ||
| 154 | .vm-setup-elapsed { display: block; font-variant-numeric: tabular-nums; margin-bottom: 16px; color: var(--muted); } | |
| 155 | ||
| 156 | .vms-list td.state .status-label { min-height: 36px; } | |
| 157 | .vms-list td.num > div { display: flex; align-items: center; justify-content: flex-end; height: 36px; } | |
| 158 | .vms-list td.actions > div { height: 36px; } |
dashboard/web/pages/VMs.tsx+95-139| ... | ... | @@ -61,7 +61,7 @@ function status(vm: Domain): [StatusKind, string, tip?: string] { |
| 61 | 61 | if (vm.startedAt === null) return ["healthy", "up"]; |
| 62 | 62 | const up = Date.now() / 1000 - vm.startedAt!; |
| 63 | 63 | const started = `started ${datetime(vm.startedAt!)}`; |
| 64 | if (vm.agent !== "disconnected") return ["healthy", `up ${duration(up)}`, started]; | |
| 64 | if (vm.setup === "ready" || vm.agent !== "disconnected") return ["healthy", `up ${duration(up)}`, started]; | |
| 65 | 65 | if (up < STARTING) return ["starting", "starting", started]; |
| 66 | 66 | return ["healthy", `up ${duration(up)}`, `${started}, guest agent not answering`]; |
| 67 | 67 | } |
| ... | ... | @@ -135,18 +135,6 @@ const forceOff = (vm: Domain, refetch: () => unknown) => showConfirmDialog({ |
| 135 | 135 | onConfirm: () => act(vm, "destroy", refetch), |
| 136 | 136 | }); |
| 137 | 137 | |
| 138 | const describe = (vm: Domain, refetch: () => unknown) => showTextDialog({ | |
| 139 | title: `Describe ${vm.name}`, | |
| 140 | label: "what it's for", | |
| 141 | placeholder: "game streaming to the TV…", | |
| 142 | initialValue: vm.description, | |
| 143 | validateInput: () => true, | |
| 144 | confirmLabel: "save", | |
| 145 | onConfirm: async (description) => { | |
| 146 | await parseResponse(api.vms[":name"].$patch({ param: { name: vm.name }, json: { description } })); | |
| 147 | await refetch(); | |
| 148 | }, | |
| 149 | }); | |
| 150 | 138 | |
| 151 | 139 | function remove(vm: Domain, refetch: () => unknown) { |
| 152 | 140 | const volumes = vm.disks.filter((disk) => disk.pool); |
| ... | ... | @@ -351,111 +339,79 @@ function Hardware(props: { vm: Domain; refetch: () => unknown; username?: string |
| 351 | 339 | setSaving(false); |
| 352 | 340 | } |
| 353 | 341 | }; |
| 354 | return ( | |
| 355 | <div class="vm-detail"> | |
| 356 | <Show when={props.vm.capabilities.includes("media")}><div class="vm-media"> | |
| 357 | <span class="muted">CD drive</span> | |
| 358 | <span class="source">{props.vm.media.find((item) => item.source)?.source ?? "No ISO attached"}</span> | |
| 359 | <span class="spacer" /><span class="muted">{props.vm.firmware === "uefi" ? "UEFI" : "Legacy BIOS"}</span> | |
| 360 | </div></Show> | |
| 361 | <Loaded data={history} what="usage history" retry={refetch} skeleton={ | |
| 362 | <div class="vm-charts"><div class="skeleton" /><div class="skeleton" /></div> | |
| 363 | }> | |
| 364 | {(latest) => { | |
| 365 | const samples = () => latest().domains[props.vm.name]; | |
| 366 | return ( | |
| 367 | <Show when={samples()?.cpu.some((v) => v !== null)} fallback={<p class="off-hour">No usage samples in the last hour</p>}> | |
| 368 | <div class="vm-charts"> | |
| 369 | <TimeChart series={[{ name: "cpu", t: latest().t, v: samples()!.cpu }]} format={percent} max={100} | |
| 370 | colors={["var(--series-1)"]} height={104} inline sync={`vm-${props.vm.name}`} /> | |
| 371 | <TimeChart series={[{ name: "memory", t: latest().t, v: samples()!.memory }]} format={bytes} max={props.vm.memory ?? undefined} | |
| 372 | colors={["var(--series-2)"]} height={104} inline sync={`vm-${props.vm.name}`} /> | |
| 373 | </div> | |
| 374 | </Show> | |
| 375 | ); | |
| 376 | }} | |
| 377 | </Loaded> | |
| 378 | <div class="facts"> | |
| 379 | <div class="settings"> | |
| 380 | <dl class="kv"> | |
| 381 | <dt>host</dt><dd>{props.vm.host}</dd> | |
| 382 | <dt>architecture</dt><dd>{props.vm.arch}</dd> | |
| 383 | <Show when={props.username}><dt>guest user</dt><dd>{props.username}</dd></Show> | |
| 384 | <Show when={props.hostname}>{(hostname) => <><dt>hostname</dt><dd><Copy value={hostname()} /></dd></>}</Show> | |
| 385 | <dt>for</dt> | |
| 386 | <dd> | |
| 387 | <Show when={props.vm.capabilities.includes("edit")} fallback={props.vm.description}> | |
| 388 | <button class="describe" classList={{ empty: !props.vm.description }} data-tip="edit" | |
| 389 | onClick={() => describe(props.vm, props.refetch)}> | |
| 390 | {props.vm.description || "add a description"} | |
| 391 | </button> | |
| 392 | </Show> | |
| 393 | </dd> | |
| 394 | <Show when={props.vm.capabilities.includes("edit")}> | |
| 395 | <dt>autostart</dt> | |
| 396 | <dd> | |
| 397 | <Checkbox checked={props.vm.autostart} disabled={saving()} onChange={setAutostart}>start with the host</Checkbox> | |
| 398 | </dd> | |
| 399 | </Show> | |
| 400 | <dt>cpu</dt> | |
| 401 | <dd>{props.vm.pinned ? `pinned to threads ${threads(props.vm.pinned)}` : "floats over all threads"}</dd> | |
| 402 | </dl> | |
| 403 | </div> | |
| 342 | return <div class="vm-detail"> | |
| 343 | <h2>{props.vm.name}</h2> | |
| 344 | <div class="facts"> | |
| 345 | <section> | |
| 346 | <h3>Hardware</h3> | |
| 404 | 347 | <dl class="kv"> |
| 405 | <dt>disks</dt> | |
| 406 | <dd class="lines disks"> | |
| 407 | <For each={props.vm.disks}> | |
| 408 | {(disk) => ( | |
| 409 | <div> | |
| 410 | <span class="muted mono">{disk.target}</span> | |
| 411 | <span class="source" classList={{ mono: !!disk.pool }}> | |
| 412 | <Copy value={disk.source} label={disk.pool ? "volume name" : "device path"}> | |
| 413 | {disk.pool ? disk.source : drive(disk.source)} | |
| 414 | </Copy> | |
| 415 | </span> | |
| 416 | <Show when={disk.pool} fallback={<span class="muted used">whole drive</span>}> | |
| 417 | <span class="used" data-tip={`${bytes(disk.allocation)} / ${bytes(disk.capacity)} (${percent((disk.allocation / disk.capacity) * 100)})`}> | |
| 418 | <Meter value={disk.allocation} max={disk.capacity} /> | |
| 419 | </span> | |
| 420 | </Show> | |
| 421 | <span class="num">{bytes(disk.capacity)}</span> | |
| 422 | </div> | |
| 423 | )} | |
| 424 | </For> | |
| 425 | </dd> | |
| 426 | <dt>network</dt> | |
| 427 | <dd class="lines nics"> | |
| 428 | <For each={props.vm.interfaces}> | |
| 429 | {(nic) => ( | |
| 430 | <div> | |
| 431 | <span class="muted mono">{nic.source}</span> | |
| 432 | <span class="mono"> | |
| 433 | <Show when={nic.addresses[0]} fallback={<span class="muted">{running(props.vm) ? "no address" : ""}</span>}> | |
| 434 | {(address) => <Copy value={address()} />} | |
| 435 | </Show> | |
| 436 | </span> | |
| 437 | <span class="mono muted"><Copy value={nic.mac} label="MAC address" /></span> | |
| 438 | </div> | |
| 439 | )} | |
| 440 | </For> | |
| 348 | <dt>host</dt><dd>{props.vm.host}</dd> | |
| 349 | <dt>operating system</dt><dd>{props.vm.os}</dd> | |
| 350 | <dt>architecture</dt><dd>{props.vm.arch}</dd> | |
| 351 | <dt>processor</dt><dd>{props.vm.vcpus === null ? "—" : plural(props.vm.vcpus, "vcpu")} | |
| 352 | <Show when={props.vm.pinned}>{(pinned) => <span class="vm-resource-usage">Pinned to threads {threads(pinned())}</span>}</Show> | |
| 441 | 353 | </dd> |
| 442 | <Show when={props.vm.hostdevs.length}> | |
| 443 | <dt>passthrough</dt> | |
| 444 | <dd class="lines devices"> | |
| 445 | <For each={props.vm.hostdevs}> | |
| 446 | {(dev) => ( | |
| 447 | <div> | |
| 448 | <span class="mono muted"><Copy value={dev.address}>{dev.address.replace(/^0000:/, "")}</Copy></span> | |
| 449 | <span>{dev.name}</span> | |
| 450 | </div> | |
| 451 | )} | |
| 452 | </For> | |
| 453 | </dd> | |
| 354 | <dt>memory</dt><dd>{allocated(props.vm)}</dd> | |
| 355 | <Show when={props.username}><dt>guest user</dt><dd>{props.username}</dd></Show> | |
| 356 | <Show when={props.hostname}>{(hostname) => <><dt>hostname</dt><dd><Copy value={hostname()} /></dd></>}</Show> | |
| 357 | <Show when={props.vm.capabilities.includes("edit")}> | |
| 358 | <dt>autostart</dt><dd><Checkbox checked={props.vm.autostart} disabled={saving()} onChange={setAutostart}>start with the host</Checkbox></dd> | |
| 454 | 359 | </Show> |
| 455 | 360 | </dl> |
| 361 | </section> | |
| 362 | <div class="vm-devices"> | |
| 363 | <section> | |
| 364 | <h3>Storage</h3> | |
| 365 | <For each={props.vm.disks}>{(disk) => <div class="vm-disk"> | |
| 366 | <div class="vm-device-line"> | |
| 367 | <HardDrive size={15} aria-hidden="true" /> | |
| 368 | <span class="source"><Copy value={disk.source} label={disk.pool ? "volume name" : "device path"}>{disk.pool ? disk.source : drive(disk.source)}</Copy></span> | |
| 369 | <span class="num">{bytes(disk.capacity)}</span> | |
| 370 | </div> | |
| 371 | <Show when={disk.pool} fallback={<span class="muted">Whole drive</span>}> | |
| 372 | <Meter value={disk.allocation} max={disk.capacity} label={`${disk.source} allocated storage`} /> | |
| 373 | <span class="muted">{bytes(disk.allocation)} allocated</span> | |
| 374 | </Show> | |
| 375 | </div>}</For> | |
| 376 | <Show when={props.vm.capabilities.includes("media")}> | |
| 377 | <dl class="kv vm-firmware"><dt>CD drive</dt><dd class="source">{props.vm.media.find((item) => item.source)?.source ?? "No ISO attached"}</dd> | |
| 378 | <dt>firmware</dt><dd>{props.vm.firmware === "uefi" ? "UEFI" : "Legacy BIOS"}</dd></dl> | |
| 379 | </Show> | |
| 380 | </section> | |
| 381 | <section> | |
| 382 | <h3>Network</h3> | |
| 383 | <For each={props.vm.interfaces}>{(nic) => <div class="vm-nic"> | |
| 384 | <div class="vm-device-line"><Network size={15} aria-hidden="true" /><span>{nic.source}</span></div> | |
| 385 | <dl class="kv"><dt>IP address</dt><dd><Show when={nic.addresses.length} fallback={<span class="muted">Address unavailable</span>}> | |
| 386 | <For each={nic.addresses}>{(address) => <Copy value={address} />}</For> | |
| 387 | </Show></dd><dt>MAC address</dt><dd class="mono"><Copy value={nic.mac} label="MAC address" /></dd></dl> | |
| 388 | </div>}</For> | |
| 389 | </section> | |
| 390 | <Show when={props.vm.hostdevs.length}><section> | |
| 391 | <h3>Passthrough</h3> | |
| 392 | <For each={props.vm.hostdevs}>{(dev) => <div class="vm-device-line"> | |
| 393 | <span class="mono muted"><Copy value={dev.address}>{dev.address.replace(/^0000:/, "")}</Copy></span><span>{dev.name}</span> | |
| 394 | </div>}</For> | |
| 395 | </section></Show> | |
| 456 | 396 | </div> |
| 457 | 397 | </div> |
| 458 | ); | |
| 398 | <section class="vm-usage"> | |
| 399 | <h3>Usage</h3> | |
| 400 | <Loaded data={history} what="usage history" retry={refetch} skeleton={<div class="vm-charts"><div class="skeleton" /><div class="skeleton" /></div>}> | |
| 401 | {(latest) => { | |
| 402 | const samples = () => latest().domains[props.vm.name]; | |
| 403 | return <Show when={samples()?.cpu.some((v) => v !== null)} fallback={<p class="off-hour">No usage samples in the last hour</p>}> | |
| 404 | <div class="vm-charts"> | |
| 405 | <TimeChart series={[{ name: "cpu", t: latest().t, v: samples()!.cpu }]} format={percent} max={100} | |
| 406 | colors={["var(--series-1)"]} height={104} inline sync={`vm-${props.vm.name}`} /> | |
| 407 | <TimeChart series={[{ name: "memory", t: latest().t, v: samples()!.memory }]} format={bytes} max={props.vm.memory ?? undefined} | |
| 408 | colors={["var(--series-2)"]} height={104} inline sync={`vm-${props.vm.name}`} /> | |
| 409 | </div> | |
| 410 | </Show>; | |
| 411 | }} | |
| 412 | </Loaded> | |
| 413 | </section> | |
| 414 | </div>; | |
| 459 | 415 | } |
| 460 | 416 | |
| 461 | 417 | function PowerControls(props: { vm: Domain; refetch: () => unknown }) { |
| ... | ... | @@ -495,13 +451,13 @@ function Row(props: { |
| 495 | 451 | const state = () => status(props.vm); |
| 496 | 452 | const pinned = () => props.vm.pinned && `pinned to threads ${threads(props.vm.pinned)}`; |
| 497 | 453 | const cpuTip = () => { |
| 498 | if (!props.vm.usage || props.vm.vcpus === null) return pinned() || undefined; | |
| 454 | if (!running(props.vm) || !props.vm.usage || props.vm.vcpus === null) return pinned() || undefined; | |
| 499 | 455 | const busy = (props.vm.usage.cpu / 100) * props.vm.vcpus; |
| 500 | 456 | return [`${busy.toFixed(1)} of ${props.vm.vcpus} vcpus busy, ${percent((busy / props.hostCpus) * 100)} of the host`, pinned()] |
| 501 | 457 | .filter(Boolean).join(", "); |
| 502 | 458 | }; |
| 503 | 459 | const memoryTip = () => { |
| 504 | const used = props.vm.usage?.memory; | |
| 460 | const used = running(props.vm) ? props.vm.usage?.memory : undefined; | |
| 505 | 461 | if (props.vm.balloon === null || props.vm.memory === null) return undefined; |
| 506 | 462 | const grows = props.vm.balloon < props.vm.memory && `can grow to ${bytes(props.vm.memory)}`; |
| 507 | 463 | if (used === undefined) return grows ? `boots with ${bytes(props.vm.balloon)}, ${grows}` : undefined; |
| ... | ... | @@ -516,28 +472,7 @@ function Row(props: { |
| 516 | 472 | <span class="vm-name">{props.vm.name}</span> |
| 517 | 473 | <Show when={props.vm.description}><span class="for">{props.vm.description}</span></Show> |
| 518 | 474 | </button> |
| 519 | </td> | |
| 520 | <td class="state" tabindex={state()[2] ? 0 : undefined} data-tip={state()[2]}> | |
| 521 | <StatusLabel health={state()[0]}>{state()[1]}</StatusLabel> | |
| 522 | </td> | |
| 523 | <td class="num" data-tip={cpuTip()}>{props.vm.usage && percent(props.vm.usage.cpu)}</td> | |
| 524 | <td class="num" data-tip={memoryTip()}>{props.vm.usage && bytes(props.vm.usage.memory)}</td> | |
| 525 | <td class="actions" rowspan="2" onClick={(event) => event.stopPropagation()}> | |
| 526 | <div> | |
| 527 | <Show when={running(props.vm) && props.vm.console}><button onClick={props.onOpen}>screen</button></Show> | |
| 528 | <Show when={running(props.vm) && props.vm.interfaces.flatMap((nic) => nic.addresses)[0]}> | |
| 529 | {(value) => { | |
| 530 | const target = () => remote(props.vm.os, value()); | |
| 531 | return <a href={target()[0]} target="_blank" rel="noreferrer">{target()[1]}</a>; | |
| 532 | }} | |
| 533 | </Show> | |
| 534 | <PowerControls vm={props.vm} refetch={props.refetch} /> | |
| 535 | </div> | |
| 536 | </td> | |
| 537 | </tr> | |
| 538 | <tr class="bottom"> | |
| 539 | <td class="specs" colspan="2"> | |
| 540 | <div onClick={(event) => event.stopPropagation()}> | |
| 475 | <div class="specs" onClick={(event) => event.stopPropagation()}> | |
| 541 | 476 | <span>{props.vm.os}</span> |
| 542 | 477 | <span>{props.vm.host}</span> |
| 543 | 478 | <For each={props.vm.interfaces}> |
| ... | ... | @@ -572,8 +507,29 @@ function Row(props: { |
| 572 | 507 | <Show when={props.vm.autostart}><span><Power size={12} aria-hidden="true" />autostart</span></Show> |
| 573 | 508 | </div> |
| 574 | 509 | </td> |
| 575 | <td class="num" tabindex={cpuTip() ? 0 : undefined} data-tip={cpuTip()}>{props.vm.vcpus === null ? "—" : plural(props.vm.vcpus, "vcpu")}</td> | |
| 576 | <td class="num" tabindex={memoryTip() ? 0 : undefined} data-tip={memoryTip()}>{allocated(props.vm)}</td> | |
| 510 | <td class="state" tabindex={state()[2] ? 0 : undefined} data-tip={state()[2]}> | |
| 511 | <StatusLabel health={state()[0]}>{state()[1]}</StatusLabel> | |
| 512 | </td> | |
| 513 | <td class="num" tabindex={cpuTip() ? 0 : undefined} data-tip={cpuTip()}> | |
| 514 | <div>{props.vm.vcpus === null ? "—" : plural(props.vm.vcpus, "vcpu")}</div> | |
| 515 | <Show when={running(props.vm) && props.vm.usage}>{(usage) => <span class="vm-resource-usage">{percent(usage().cpu)} busy</span>}</Show> | |
| 516 | </td> | |
| 517 | <td class="num" tabindex={memoryTip() ? 0 : undefined} data-tip={memoryTip()}> | |
| 518 | <div>{allocated(props.vm)}</div> | |
| 519 | <Show when={running(props.vm) && props.vm.usage}>{(usage) => <span class="vm-resource-usage">{bytes(usage().memory)} used</span>}</Show> | |
| 520 | </td> | |
| 521 | <td class="actions" onClick={(event) => event.stopPropagation()}> | |
| 522 | <div> | |
| 523 | <Show when={running(props.vm) && props.vm.console}><button onClick={props.onOpen}>screen</button></Show> | |
| 524 | <Show when={running(props.vm) && props.vm.interfaces.flatMap((nic) => nic.addresses)[0]}> | |
| 525 | {(value) => { | |
| 526 | const target = () => remote(props.vm.os, value()); | |
| 527 | return <a href={target()[0]} target="_blank" rel="noreferrer">{target()[1]}</a>; | |
| 528 | }} | |
| 529 | </Show> | |
| 530 | <PowerControls vm={props.vm} refetch={props.refetch} /> | |
| 531 | </div> | |
| 532 | </td> | |
| 577 | 533 | </tr> |
| 578 | 534 | |
| 579 | 535 | </tbody> |
| ... | ... | @@ -641,7 +597,7 @@ export function VMs() { |
| 641 | 597 | <div class="empty vms-empty"><p>This VM isn't in your account.</p><button class="button" onClick={() => setParams({ vm: undefined, tab: undefined })}>VM home</button></div> |
| 642 | 598 | }>{(vm) => <section class="vm-workspace" aria-label={`${name} workspace`}> |
| 643 | 599 | <h1 class="sr-only">{name}</h1> |
| 644 | <VMConsole name={name} platform={vm().platform} enabled={running(vm()) || vm().state === "paused"} active={activeTab() === "screen"} setup={vm().setup} | |
| 600 | <VMConsole name={name} platform={vm().platform} enabled={running(vm()) || vm().state === "paused"} active={activeTab() === "screen"} setup={vm().setup} booting={status(vm())[0] === "starting"} startedAt={vm().startedAt} arch={vm().arch} | |
| 645 | 601 | unavailable={vm().state === "unreachable" ? `${vm().host} is unreachable. Check its power and network.` : vm().state === "pmsuspended" ? "The VM is suspended. Resume it from the Machine menu." : undefined} |
| 646 | 602 | clipboard={vm().capabilities.includes("clipboard") ? async (text) => { await parseResponse(api.vms[":name"].clipboard.$post({ param: { name }, json: { text } })); } : undefined} |
| 647 | 603 | content={(toolbar) => <> |
dashboard/web/types/vms.ts+1| ... | ... | @@ -26,6 +26,7 @@ type Platform = "linux" | "windows" | "macos"; |
| 26 | 26 | export const VM_SETUP = { |
| 27 | 27 | starting: "Starting Windows…", |
| 28 | 28 | personalizing: "Preparing your account…", |
| 29 | signingIn: "Signing in…", | |
| 29 | 30 | restarting: "Restarting to finish setup…", |
| 30 | 31 | ready: "Ready", |
| 31 | 32 | failed: "Setup stopped", |