authoravatarclover caruso<git@paperclover.net>2026-10-23 18:18:08-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-24 19:01:23-07:00
log69ba225c6c6854475eff976b11d59f97cea15983
tree20093f0c9ec070665a418d4528c97cc0bc092468
parent608212cba743fa289f7d666112d5a4fc6e5b4fa9
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

Show VM login username and a hidden-by-default password

The VM Password menu becomes Login, with copyable username and a password revealed on request. CopyField moves to the shared Copy component, and previews attached to a computer may read that VM's access. Assisted-by: claude-opus-5.5

10 files changed, 82 insertions(+), 51 deletions(-)

dashboard/web/components/Copy.css created+25
......@@ -0,0 +1,25 @@
1.copy-field > .copy, .copy-field.masked {
2 display: flex;
3 align-items: center;
4 gap: 10px;
5 width: 100%;
6 min-height: 34px;
7 padding: 6px 10px;
8 border: 2px solid var(--line);
9 border-radius: var(--radius);
10 background: var(--well);
11 color: var(--text);
12 font: 12.5px/1.45 var(--mono);
13 text-align: left;
14 white-space: normal;
15 cursor: copy;
16 transition: border-color 150ms, background-color 150ms;
17}
18.copy-field { flex: 1; min-width: 0; }
19.copy-field .value { flex: 1; min-width: 0; overflow-wrap: anywhere; }
20.copy-field .icon { flex: none; color: var(--muted); transition: color 150ms; }
21.copy-field > .copy:hover { border-color: var(--axis); background: var(--accent-wash); }
22.copy-field > .copy:hover .icon { color: var(--accent); }
23.copy-field.masked { box-sizing: border-box; cursor: default; color: var(--muted); letter-spacing: 0.1em; overflow: hidden; }
24.copy-field.masked .value { overflow-wrap: normal; white-space: nowrap; }
25
dashboard/web/components/Copy.tsx+7-1
......@@ -1,4 +1,10 @@
11import { createSignal, type JSX } from "solid-js";
2import CopyIcon from "lucide-solid/icons/copy";
3import "./Copy.css";
4
5export function CopyField(props: { value: string; label: string }) {
6 return <div class="copy-field"><Copy value={props.value} label={props.label}><span class="value">{props.value}</span><CopyIcon size={14} class="icon" aria-hidden="true" /></Copy></div>;
7}
28
39/**
410 * Text that copies `value` on click; the tooltip turns into the result. Shows `value` unless given children, and
......@@ -12,7 +18,7 @@ export function Copy(props: { value: string; label?: string; children?: JSX.Elem
1218 .then(() => setResult("copied"), () => setResult("Couldn't copy. Select the text instead"));
1319 return (
1420 <>
15 <button type="button" class="copy" data-tip={result() || (props.label ? `copy ${props.label}` : "copy")} onClick={copy}
21 <button type="button" class="copy" aria-label={props.label ? `Copy ${props.label}` : undefined} aria-description={props.label ? props.value : undefined} data-tip={result() || (props.label ? `copy ${props.label}` : "copy")} onClick={copy}
1622 onPointerLeave={() => setResult("")} onBlur={() => setResult("")}>
1723 {props.children ?? props.value}
1824 </button>
dashboard/web/components/VMMenu.tsx+4-3
......@@ -1,14 +1,14 @@
11import { type JSX, onCleanup, onMount } from "solid-js";
22import ChevronDown from "lucide-solid/icons/chevron-down";
33
4export function VMMenu(props: { label: string; children: JSX.Element }) {
4export function VMMenu(props: { label: string; children: JSX.Element; onClose?: () => void }) {
55 let menu!: HTMLDetailsElement;
66 const outside = (event: PointerEvent) => {
77 if (event.target instanceof Node && !menu.contains(event.target)) menu.open = false;
88 };
99 onMount(() => document.addEventListener("pointerdown", outside));
1010 onCleanup(() => document.removeEventListener("pointerdown", outside));
11 return <details ref={menu} class="vm-menu" name="vm-actions" onKeyDown={(event) => {
11 return <details ref={menu} class="vm-menu" name="vm-actions" onToggle={() => { if (!menu.open) props.onClose?.(); }} onKeyDown={(event) => {
1212 if (event.key === "Escape") {
1313 menu.open = false;
1414 menu.querySelector("summary")?.focus();
......@@ -17,7 +17,8 @@ export function VMMenu(props: { label: string; children: JSX.Element }) {
1717 }}>
1818 <summary>{props.label}<ChevronDown size={12} aria-hidden="true" /></summary>
1919 <div role="group" aria-label={`${props.label} actions`} onClick={(event) => {
20 if (event.target instanceof HTMLElement && event.target.closest("button")) menu.open = false;
20 const button = event.target instanceof Element ? event.target.closest("button") : null;
21 if (button?.parentElement === event.currentTarget) menu.open = false;
2122 }}>{props.children}</div>
2223 </details>;
2324}
dashboard/web/pages/AI.tsx+2-7
......@@ -1,19 +1,14 @@
11import { parseResponse } from "hono/client";
2import CopyIcon from "lucide-solid/icons/copy";
32import Download from "lucide-solid/icons/download";
43import EyeOff from "lucide-solid/icons/eye-off";
54import KeyRound from "lucide-solid/icons/key-round";
65import { createResource, createSignal, For, Show } from "solid-js";
76import { api, reason } from "../api.ts";
8import { Copy } from "../components/Copy.tsx";
7import { CopyField } from "../components/Copy.tsx";
98import { Loaded } from "../components/Loaded.tsx";
109import claude from "../../src/claude.svg?raw";
1110import openai from "../../src/openai.svg?raw";
1211
13export function CopyField(props: { value: string; label: string }) {
14 return <div class="mcp-field"><Copy value={props.value} label={props.label}><span class="value">{props.value}</span><CopyIcon size={14} class="icon" /></Copy></div>;
15}
16
1712export function ClientMark(props: { name: string }) {
1813 const logo = () => /claude/i.test(props.name) ? claude : /codex|openai|chatgpt/i.test(props.name) ? openai : "";
1914 return <span class="mcp-client-mark" aria-hidden="true">
......@@ -39,7 +34,7 @@ export function AI(props: { viewing: boolean }) {
3934 <h2 class="mcp-label">API key</h2>
4035 <div class="mcp-key">
4136 <Show when={key()} fallback={<>
42 <span class="mcp-field masked" aria-hidden="true"><span class="value">••••••••••••••••••••••••••••••••</span></span>
37 <span class="copy-field masked" aria-hidden="true"><span class="value">••••••••••••••••••••••••••••••••</span></span>
4338 <button ref={show} class="button" disabled={busy() || props.viewing} aria-busy={busy()}
4439 data-tip={props.viewing ? "Switch back to your account to see the key" : undefined} onClick={async () => {
4540 setBusy(true); setError("");
dashboard/web/pages/MCP.css-26
......@@ -12,32 +12,6 @@
1212.mcp-page .hint, .mcp-approval .hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
1313.mcp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
1414
15/* A value you copy: the whole well is the Copy button. */
16.mcp-field > .copy, .mcp-field.masked {
17 display: flex;
18 align-items: center;
19 gap: 10px;
20 width: 100%;
21 min-height: 34px;
22 padding: 6px 10px;
23 border: 2px solid var(--line);
24 border-radius: var(--radius);
25 background: var(--well);
26 color: var(--text);
27 font: 12.5px/1.45 var(--mono);
28 text-align: left;
29 white-space: normal;
30 cursor: copy;
31 transition: border-color 150ms, background-color 150ms;
32}
33.mcp-field { flex: 1; min-width: 0; }
34.mcp-field .value { flex: 1; min-width: 0; overflow-wrap: anywhere; }
35.mcp-field .icon { flex: none; color: var(--muted); transition: color 150ms; }
36.mcp-field > .copy:hover { border-color: var(--axis); background: var(--accent-wash); }
37.mcp-field > .copy:hover .icon { color: var(--accent); }
38.mcp-field.masked { box-sizing: border-box; cursor: default; color: var(--muted); letter-spacing: 0.1em; overflow: hidden; }
39.mcp-field.masked .value { overflow-wrap: normal; white-space: nowrap; }
40
4115.mcp-key { display: flex; gap: 8px; align-items: stretch; }
4216.mcp-key .button { height: auto; min-height: 34px; }
4317.mcp-section > .mcp-key + .error { margin: 6px 0 0; color: color-mix(in srgb, var(--critical) 80%, var(--text)); font-size: 13px; }
dashboard/web/pages/MCP.tsx+2-1
......@@ -15,7 +15,8 @@ import { Loaded } from "../components/Loaded.tsx";
1515import { StatusLabel } from "../components/Status.tsx";
1616import { TabBar } from "../components/TabBar.tsx";
1717import { toast } from "../components/Toast.tsx";
18import { AI, ClientMark, CopyField } from "./AI.tsx";
18import { AI, ClientMark } from "./AI.tsx";
19import { CopyField } from "../components/Copy.tsx";
1920import { MCPAccess } from "./MCPAccess.tsx";
2021import type { Me } from "../types/model.ts";
2122import type { Access, Catalog, Connections } from "../types/mcp.ts";
dashboard/web/pages/VMs.css+10-2
......@@ -79,8 +79,10 @@
7979.vm-console { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; background: var(--panel); }
8080.vm-console-toolbar { display: flex; flex: none; align-items: center; flex-wrap: wrap; gap: 4px; padding: 6px 12px; border-bottom: 1px solid var(--grid); }
8181.vm-console-status { color: var(--text-2); font-size: 12px; }
82.vm-password { display: grid; gap: 6px; padding: 8px 10px; color: var(--muted); font-size: 11px; }
83.vm-password input { width: 26ch; min-width: 0; padding: 5px 6px; color: var(--text); font: 12px monospace; }
82.vm-credentials { display: grid; gap: 16px; padding: 10px; }
83.vm-credentials h2 { margin: 0 0 6px; color: var(--text-2); font-size: 12px; font-weight: 600; }
84.vm-credential-password { display: flex; gap: 8px; align-items: stretch; }
85.vm-credential-password > .button { height: auto; min-height: 34px; white-space: nowrap; }
8486.vm-console-screen { flex: 1; background: #101014; min-height: 0; position: relative; }
8587.vm-console-screen video { display: block; width: 100%; height: 100%; object-fit: contain; outline: none; touch-action: none; }
8688.vm-screen-canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; background: #101014; }
......@@ -136,6 +138,12 @@
136138.vm-menu summary:hover, .vm-menu[open] summary { background: var(--hover); }
137139.vm-menu > div { position: absolute; top: calc(100% + 6px); left: 0; min-width: 180px; max-width: 300px; z-index: 5; display: flex; flex-direction: column; padding: 4px; border: 1px solid var(--grid); border-radius: 7px; background: var(--panel); box-shadow: 0 6px 24px #0005; }
138140.vm-menu:last-of-type > div { left: auto; right: 0; }
141.vm-menu > div:has(.vm-credentials) { left: auto; right: 0; width: min(380px, calc(100vw - 24px)); max-width: none; }
142@media (max-width: 900px) {
143 .vm-console-toolbar { position: relative; }
144 .vm-menu:has(.vm-credentials) { position: static; }
145 .vm-menu > div:has(.vm-credentials) { right: 12px; }
146}
139147.vm-menu > div > button { display: flex; align-items: center; justify-content: flex-start; gap: 8px; width: 100%; border: 0; border-radius: 4px; background: transparent; color: var(--text); padding: 7px 10px; font: inherit; text-align: left; cursor: pointer; }
140148.vm-menu > div > button svg { flex: none; }
141149.vm-menu > div > button:hover:not(:disabled) { background: var(--hover); }
dashboard/web/pages/VMs.tsx+24-4
......@@ -16,6 +16,7 @@ import Trash from "lucide-solid/icons/trash";
1616import Square from "lucide-solid/icons/square";
1717import Pause from "lucide-solid/icons/pause";
1818import KeyRound from "lucide-solid/icons/key-round";
19import EyeOff from "lucide-solid/icons/eye-off";
1920import Usb from "lucide-solid/icons/usb";
2021import { createEffect, createMemo, createResource, createSignal, For, lazy, onCleanup, Show } from "solid-js";
2122import { LIVE_INTERVAL } from "../types/model.ts";
......@@ -25,7 +26,7 @@ import { DetailedError, parseResponse } from "hono/client";
2526import { api, queries, reason, unconnected } from "../api.ts";
2627import { VMConsole } from "../components/VMConsole.tsx";
2728import { Checkbox } from "../components/Checkbox.tsx";
28import { Copy } from "../components/Copy.tsx";
29import { Copy, CopyField } from "../components/Copy.tsx";
2930import { showConfirmDialog, showTextDialog } from "../components/Dialog.tsx";
3031import { ListPage } from "../components/ListPage.tsx";
3132import { lastGood, Loaded } from "../components/Loaded.tsx";
......@@ -591,6 +592,9 @@ export function VMs() {
591592 }>{(name) => {
592593 const [access] = createResource(() => name, (name) => parseResponse(api.vms[":name"].access.$get({ param: { name } })));
593594 const login = lastGood(access);
595 const [passwordVisible, setPasswordVisible] = createSignal(false);
596 let showPassword!: HTMLButtonElement;
597 let hidePassword!: HTMLButtonElement;
594598 const [consoleOpened, setConsoleOpened] = createSignal(false);
595599 createEffect(() => { if (activeTab() === "console") setConsoleOpened(true); });
596600 return <Show when={latest().domains.find((vm) => vm.name === name)} fallback={
......@@ -627,9 +631,25 @@ export function VMs() {
627631 }}><Disc2 size={14} aria-hidden="true" />Eject ISO</button>
628632 <span class="muted vm-menu-info">{vm().media.find((item) => item.source)?.source ?? "No ISO attached"}</span>
629633 </VMMenu></Show>
630 <Show when={login()}>{(credentials) => <VMMenu label="Password">
631 <label class="vm-password">Guest password<input aria-label="Guest password" value={credentials().password} readOnly spellcheck={false} /></label>
632 <Copy value={credentials().password} label="guest password"><KeyRound size={14} aria-hidden="true" />Copy password</Copy>
634 <Show when={login()}>{(credentials) => <VMMenu label="Login" onClose={() => setPasswordVisible(false)}>
635 <div class="vm-credentials">
636 <div role="group" aria-label="Username">
637 <h2>Username</h2>
638 <CopyField value={credentials().username} label="username" />
639 </div>
640 <div role="group" aria-label="Password">
641 <h2>Password</h2>
642 <div class="vm-credential-password">
643 <Show when={passwordVisible()} fallback={<>
644 <span class="copy-field masked" aria-hidden="true"><span class="value">••••••••••••••••</span></span>
645 <button ref={showPassword} class="button" onClick={() => { setPasswordVisible(true); hidePassword.focus(); }}><KeyRound size={14} aria-hidden="true" />Show password</button>
646 </>}>
647 <CopyField value={credentials().password} label="password" />
648 <button ref={hidePassword} class="button" onClick={() => { setPasswordVisible(false); showPassword.focus(); }}><EyeOff size={14} aria-hidden="true" />Hide</button>
649 </Show>
650 </div>
651 </div>
652 </div>
633653 </VMMenu>}</Show>
634654 </>} />
635655 </section>}</Show>;
tools/dashboard-stage-test.py+5-4
......@@ -35,7 +35,7 @@ class PreviewBoundary(unittest.TestCase):
3535 return json.loads(sent[4:]), host
3636
3737 def test_denies_host_mutations_and_vm_streams_before_dispatch(self):
38 for operation in ["vm.create", "vm.start", "vm.console", "vm.serial", "vm.guest", "vm.upload", "vm.computer", "vm.owner", "storage.destroy", "deploy.start", "deploy.secret.get", "shale.write", "copyparty.manage", []]:
38 for operation in ["vm.create", "vm.start", "vm.console", "vm.serial", "vm.guest", "vm.upload", "vm.computer", "vm.owner", "vm.access", "storage.destroy", "deploy.start", "deploy.secret.get", "shale.write", "copyparty.manage", []]:
3939 with self.subTest(operation=operation):
4040 response, host = self.call({"operation": operation})
4141 self.assertEqual(response["status"], 403)
......@@ -57,7 +57,7 @@ class PreviewBoundary(unittest.TestCase):
5757 def test_attached_computer_cannot_target_another_vm(self):
5858 host = stage.PreviewHost({"clone": "globe/staging/fixture", "computer": "mac-fixture"})
5959 with patch.object(boundary.Host, "handle", return_value={"ok": True}) as call:
60 for operation in ["vm.computer", "vm.owner", "vm.console", "vm.guest"]:
60 for operation in ["vm.computer", "vm.owner", "vm.access", "vm.console", "vm.guest"]:
6161 with self.assertRaises(boundary.dashboard_runs.Error):
6262 host.handle({"operation": operation, "payload": {"name": "personal"}})
6363 call.assert_not_called()
......@@ -100,8 +100,9 @@ class PreviewBoundary(unittest.TestCase):
100100 host.handle(request)
101101 call.assert_called_once_with(request)
102102 with patch.object(boundary.Host, "handle", return_value={"owner": "foreign-id", "ownerOnly": True}):
103 with self.assertRaises(boundary.dashboard_runs.Error):
104 host.handle({"operation": "vm.computer", "payload": {"name": "ai-foreign"}})
103 for operation in ["vm.computer", "vm.access"]:
104 with self.subTest(operation=operation), self.assertRaises(boundary.dashboard_runs.Error):
105 host.handle({"operation": operation, "payload": {"name": "ai-foreign"}})
105106
106107 def test_failed_child_creation_and_repeated_token_revoke_still_clean_parent(self):
107108 identity = "dashboard-preview-12345678"
tools/dashboard-stage.py+3-3
......@@ -38,7 +38,7 @@ class PreviewHost(boundary.Host):
3838 def handle(self, request):
3939 operation = request.get("operation") if isinstance(request, dict) else None
4040 owner = None
41 if self.stage.get("computer") and self.stage.get("mount") and operation in {"vm.computer", "vm.owner", "vm.console", "vm.guest", "vm.domains", "vm.computers", "vm.ai", "vm.act"}:
41 if self.stage.get("computer") and self.stage.get("mount") and operation in {"vm.computer", "vm.owner", "vm.access", "vm.console", "vm.guest", "vm.domains", "vm.computers", "vm.ai", "vm.act"}:
4242 with sqlite3.connect(f"file:{self.stage['mount']}/data/accounts.sqlite?mode=ro", uri=True) as accounts:
4343 owner = accounts.execute("SELECT id FROM users WHERE username='preview'").fetchone()
4444 if not owner:
......@@ -47,7 +47,7 @@ class PreviewHost(boundary.Host):
4747 payload = request.get("payload")
4848 if not owner or not isinstance(payload, dict) or payload.get("owner") != owner[0]:
4949 raise boundary.dashboard_runs.Error(403, "Test VMs must belong to this preview account.")
50 if operation in {"vm.computer", "vm.owner", "vm.act", "vm.console", "vm.guest"}:
50 if operation in {"vm.computer", "vm.owner", "vm.access", "vm.act", "vm.console", "vm.guest"}:
5151 payload = request.get("payload")
5252 if not self.stage.get("computer") or not isinstance(payload, dict):
5353 raise boundary.dashboard_runs.Error(403, "Choose the VM explicitly attached to this preview.")
......@@ -112,7 +112,7 @@ def serve(stage):
112112 if not slots.acquire(blocking=False):
113113 connection.close()
114114 continue
115 operations = OPERATIONS | {"vm.computer", "vm.owner", "vm.ai", "vm.act", "vm.console", "vm.guest"} if saved.get("computer") else OPERATIONS
115 operations = OPERATIONS | {"vm.computer", "vm.owner", "vm.access", "vm.ai", "vm.act", "vm.console", "vm.guest"} if saved.get("computer") else OPERATIONS
116116 work = workers.submit(boundary.serve_connection, connection, host, saved["uid"], operations)
117117 work.add_done_callback(lambda _: slots.release())
118118