Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Devices: a hub-and-groups map with state at a glance, bots on their devices, and details beside the device (#7284)

Milind Soni7f3934bfb653
diff --git a/src/components/devices/DeviceList.tsx b/src/components/devices/DeviceList.tsx
index 69cfc3933c..6179091dfb 100644
--- a/src/components/devices/DeviceList.tsx
+++ b/src/components/devices/DeviceList.tsx
@@ -1,15 +1,10 @@
-import { useEffect, useRef } from "react";
-import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
import { lastSeen } from "@/lib/pairing-time";
-import { deviceGroup, type Device, type DeviceAction, type DeviceGroup } from "@/lib/devices";
-import { SettingsGroup, SettingsRows } from "../SettingsPrimitives";
+import type { Device, DeviceAction } from "@/lib/devices";
import { LendComputerSwitch } from "../LendComputerSwitch";
-import { DOT, KIND_ICON, groupLabel, kindLabel, routeLabel, statusText } from "./device-words";
+import { kindLabel, routeLabel } from "./device-words";
-const GROUPS: readonly DeviceGroup[] = ["computers", "servers", "phones"];
-
-function actionLabel(action: DeviceAction, device: Device): string {
+export function actionLabel(action: DeviceAction, device: Device): string {
switch (action.type) {
case "switch": return t("servers.switch");
case "retry": return t("servers.tryNow");
@@ -24,9 +19,9 @@ function actionLabel(action: DeviceAction, device: Device): string {
}
}
-/** The row's one button beside its name: what it most needs, else Switch. The rest show once it is chosen. */
+/** The card's one button beside its name: what it most needs, else Switch. The rest sit under its details. */
const PRIMARY: ReadonlyArray<DeviceAction["type"]> = ["copy-update", "retry", "pair-again", "switch", "manage"];
-const primaryOf = (device: Device) => PRIMARY.map((type) => device.actions.find((action) => action.type === type)).find(Boolean);
+export const primaryOf = (device: Device) => PRIMARY.map((type) => device.actions.find((action) => action.type === type)).find(Boolean);
function Detail({ label, children }: { label: string; children: React.ReactNode }) {
return (
@@ -37,7 +32,7 @@ function Detail({ label, children }: { label: string; children: React.ReactNode
);
}
-function ActionButton({ device, action, quiet, onAction }: { device: Device; action: DeviceAction; quiet: boolean; onAction: (device: Device, action: DeviceAction) => void }) {
+export function ActionButton({ device, action, quiet, onAction }: { device: Device; action: DeviceAction; quiet: boolean; onAction: (device: Device, action: DeviceAction) => void }) {
return (
<button type="button" data-device-action={action.type} data-danger={action.type === "remove" ? "" : undefined} onClick={() => onAction(device, action)}
aria-label={`${actionLabel(action, device)}: ${device.name}`}
@@ -68,74 +63,3 @@ export function DeviceDetails({ device, actions, onAction, now }: { device: Devi
{actions.length > 0 && <div className="flex flex-wrap items-center gap-x-4 gap-y-2">{actions.map((action) => <ActionButton key={actionKey(action)} device={device} action={action} quiet onAction={onAction} />)}</div>}
</>;
}
-
-/** A device chosen on the map: its line, its one button and its details, right under the map. */
-export function DeviceCard({ device, onAction, onClose, now = Date.now() }: { device: Device; onAction: (device: Device, action: DeviceAction) => void; onClose: () => void; now?: number }) {
- const Icon = KIND_ICON[device.kind];
- const primary = primaryOf(device);
- const card = useRef<HTMLElement>(null);
- useEffect(() => { card.current?.scrollIntoView?.({ block: "nearest" }); }, [device.id]);
- return (
- <section ref={card} data-device-card={device.id} aria-label={device.name} className="flex flex-col gap-3 rounded-xl bg-menu px-4 py-3 shadow-[inset_0_0_0_0.5px_var(--settings-edge)] motion-safe:animate-fade-in">
- <div className="flex items-center gap-3">
- <Icon size={16} aria-hidden="true" className="shrink-0 text-ink-secondary" />
- <div className="flex min-w-0 flex-1 flex-col">
- <span className="truncate text-[14px] font-medium leading-5 text-ink">{device.name}</span>
- <span className={cn("truncate text-[13px] leading-[18px]", device.status === "attention" ? "text-warning" : "text-ink-secondary")}>{statusText(device, now)}</span>
- </div>
- {primary && <ActionButton device={device} action={primary} quiet={false} onAction={onAction} />}
- <button type="button" onClick={onClose} className="settings-quiet shrink-0 cursor-pointer">{t("common.close")}</button>
- </div>
- <div className="flex flex-col gap-3 ps-7"><DeviceDetails device={device} actions={device.actions.filter((action) => action !== primary)} onAction={onAction} now={now} /></div>
- </section>
- );
-}
-
-function DeviceRow({ device, selected, onSelect, onAction, now }: { device: Device; selected: boolean; onSelect: (id: string | null) => void; onAction: (device: Device, action: DeviceAction) => void; now: number }) {
- const Icon = KIND_ICON[device.kind];
- const dot = DOT[device.status];
- const primary = primaryOf(device);
- const rest = device.actions.filter((action) => action !== primary);
- return (
- <div data-device-row={device.id} data-selected={selected ? "" : undefined} className={cn("flex flex-col scroll-mt-4", selected && "bg-ink/[0.04]")}>
- <div className="flex min-h-14 items-center gap-3 px-4 py-2">
- <span className="relative flex size-8 shrink-0 items-center justify-center text-ink-secondary">
- <Icon size={16} aria-hidden="true" />
- {dot && <span aria-hidden="true" className={cn("absolute bottom-1 end-1 size-2 rounded-full", dot)} />}
- </span>
- <button type="button" aria-expanded={selected} onClick={() => onSelect(selected ? null : device.id)}
- className="flex min-w-0 flex-1 cursor-pointer flex-col text-start focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus">
- <span className="truncate text-[14px] leading-5 text-ink">{device.name}</span>
- <span className={cn("truncate text-[13px] leading-[18px]", device.status === "attention" ? "text-warning" : "text-ink-secondary")}>
- {statusText(device, now)}{device.here ? "" : ` · ${routeLabel(device.route)}`}
- </span>
- </button>
- {primary && <ActionButton device={device} action={primary} quiet={false} onAction={onAction} />}
- </div>
- {selected && (
- <div className="flex flex-col gap-3 pb-3 pe-4 ps-[60px]" data-device-details="">
- <DeviceDetails device={device} actions={rest} onAction={onAction} now={now} />
- </div>
- )}
- </div>
- );
-}
-
-/** Under the map: every device by what it is, with the actions that already exist for it. */
-export function DeviceList({ devices, selected, onSelect, onAction, now = Date.now() }: {
- devices: readonly Device[]; selected: string | null; onSelect: (id: string | null) => void; onAction: (device: Device, action: DeviceAction) => void; now?: number;
-}) {
- return <>
- {GROUPS.map((group) => {
- const listed = devices.filter((device) => deviceGroup(device) === group);
- if (listed.length === 0) return null;
- return (
- <SettingsGroup key={group} label={groupLabel(group)} block={`devices-${group}`}>
- <SettingsRows icons>
- {listed.map((device) => <DeviceRow key={device.id} device={device} selected={selected === device.id} onSelect={onSelect} onAction={onAction} now={now} />)}
- </SettingsRows>
- </SettingsGroup>
- );
- })}
- </>;
-}
diff --git a/src/components/devices/DeviceMap.tsx b/src/components/devices/DeviceMap.tsx
index 7257907ebc..11a7f8aa92 100644
--- a/src/components/devices/DeviceMap.tsx
+++ b/src/components/devices/DeviceMap.tsx
@@ -1,135 +1,198 @@
import { Plus } from "lucide-react";
-import type { ReactNode } from "react";
+import { Fragment, useId, useLayoutEffect, useRef, useState, type ReactNode } from "react";
import { cn } from "@/lib/cn";
import { t } from "@/lib/i18n";
-import { groupByRoute, type Device, type DeviceRoute, type PrivateNetwork } from "@/lib/devices";
-import { DOT, KIND_ICON, kindLabel, networkShort, routeLabel, statusText } from "./device-words";
+import { groupByKind, type Device, type DeviceAction, type DeviceGroup, type PrivateNetwork } from "@/lib/devices";
+import { BotFaces, botsLabel, StatusMark, useBotsOn } from "./DeviceTile";
+import { DeviceTile } from "./DeviceTile";
+import { groupLabel, networkShort, statusText } from "./device-words";
-const NODE = "relative flex w-48 min-w-0 cursor-pointer items-center gap-3 rounded-xl bg-menu px-3 py-2 text-start transition-colors hover:bg-ink/[0.06] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus motion-safe:animate-fade-in @max-[480px]/map:w-full";
+/** Under this width the groups stack under one trunk and every tile is a full-width row. */
+export const NARROW_MAP_PX = 520;
-/** One device on the map: its mark with a status dot, its name and one line. Choosing it opens its row below. */
-export function DeviceNode({ device, selected, onSelect, now }: { device: Device; selected: boolean; onSelect: (id: string) => void; now: number }) {
- const Icon = KIND_ICON[device.kind];
- const dot = DOT[device.status];
- const line = statusText(device, now);
+const SOLID = "border-ink-secondary/35";
+const AWAY = "border-dashed border-ink-secondary/35";
+const away = (devices: readonly Device[]) => devices.every((device) => device.status === "offline");
+
+export interface NetworkAction {
+ label: string;
+ run?: () => void;
+ href?: string;
+ busy?: boolean;
+}
+
+const NETWORK_MARK: Partial<Record<PrivateNetwork["state"], Device["status"]>> = { ready: "online", unknown: "unknown" };
+
+/** The private network on this computer: its state in a few words, the whole next step under it, and one button. */
+function NetworkRow({ network, line, action, secondary }: { network: PrivateNetwork; line: string; action: NetworkAction | null; secondary?: ReactNode }) {
return (
- <button type="button" data-device-node={device.id} data-device-status={device.status} aria-pressed={selected} onClick={() => onSelect(device.id)}
- aria-label={`${device.name}, ${kindLabel(device.kind)}, ${line}`} title={device.name}
- className={cn(NODE, selected ? "shadow-[inset_0_0_0_1px_var(--color-ink)]" : "shadow-[inset_0_0_0_0.5px_var(--settings-edge)]")}>
- <span className="relative flex size-5 shrink-0 items-center justify-center text-ink-secondary">
- <Icon size={16} aria-hidden="true" />
- {dot && <span aria-hidden="true" className={cn("absolute -bottom-0.5 -end-0.5 size-2 rounded-full ring-2 ring-(--color-menu)", dot)} />}
- </span>
- <span className="flex w-full min-w-0 flex-col">
- <span className="truncate text-[13px] font-medium leading-[18px] text-ink">{device.name}</span>
- <span className={cn("truncate text-[12px] leading-4", device.status === "attention" ? "text-warning" : "text-ink-secondary")}>{line}</span>
- </span>
- </button>
+ <div data-settings-block="network" data-private-network="" className="flex scroll-mt-4 flex-wrap items-center gap-x-3 gap-y-2 border-t-[0.5px] border-(--settings-edge) px-3 py-2.5">
+ <div className="flex min-w-[min(100%,14rem)] flex-1 flex-col gap-0.5 ps-12">
+ <span className="flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] leading-[18px] text-ink">
+ <span>{t("devicesPage.network.title")}<span className="text-ink-tertiary">{" · Tailscale"}</span></span>
+ <span data-network-state={network.state} className={cn("flex items-center gap-1.5 text-[12px] leading-4", network.state === "ready" || network.state === "unknown" ? "text-ink-secondary" : "text-ink")}>
+ <StatusMark status={NETWORK_MARK[network.state] ?? "attention"} />{networkShort(network)}
+ </span>
+ </span>
+ <span data-network-line={network.state} aria-live="polite" className="text-[12px] leading-4 text-ink-tertiary">{line}</span>
+ </div>
+ {(action || secondary) && (
+ <span className="flex shrink-0 items-center gap-2 ps-12 @min-[520px]/map:ps-0">
+ {secondary}
+ {action && (action.href
+ ? <a href={action.href} target="_blank" rel="noreferrer" className="ui-button ui-button-sm" data-network-action="">{action.label}</a>
+ : <button type="button" className="ui-button ui-button-sm" data-network-action="" disabled={action.busy} onClick={action.run}>{action.label}</button>)}
+ </span>
+ )}
+ </div>
);
}
-/** The root of the map: the place whose Settings these are, with the same mark as the rail and the nav. */
-export function HereNode({ device, mark, selected, onSelect }: { device: Device; mark: ReactNode; selected: boolean; onSelect: (id: string) => void }) {
+/** This place, the hub every line starts from: its mark, the bots on it, Add a device, and on This computer the private network. */
+function Hub({ device, mark, selected, onSelect, onAdd, network }: {
+ device: Device; mark: ReactNode; selected: boolean; onSelect: (id: string) => void; onAdd: () => void; network: ReactNode;
+}) {
+ const bots = useBotsOn(device);
return (
- <button type="button" data-device-node="here" aria-pressed={selected} onClick={() => onSelect(device.id)} title={device.name}
- aria-label={`${device.name}, ${statusText(device)}`}
- className={cn("flex min-w-0 max-w-full cursor-pointer items-center gap-3 rounded-xl bg-menu px-3 py-2 text-start transition-colors hover:bg-ink/[0.06] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus",
- selected ? "shadow-[inset_0_0_0_1px_var(--color-ink)]" : "shadow-[inset_0_0_0_0.5px_var(--settings-edge)]")}>
- <span className="flex size-8 shrink-0 items-center justify-center text-ink-secondary">{mark}</span>
- <span className="flex min-w-0 flex-col">
- <span className="truncate text-[14px] font-medium leading-5 text-ink">{device.name}</span>
- <span className="truncate text-[12px] leading-4 text-ink-secondary">{statusText(device)}</span>
- </span>
- </button>
+ <div data-device-hub="" className={cn("flex flex-col rounded-xl bg-menu", selected ? "shadow-[inset_0_0_0_1px_var(--color-ink)]" : "shadow-[inset_0_0_0_0.5px_var(--settings-edge)]")}>
+ <div className="flex min-w-0 flex-wrap items-center gap-3 px-3 py-3">
+ <button type="button" data-device-node="here" aria-expanded={selected} aria-controls={selected ? "device-card" : undefined} onClick={() => onSelect(device.id)} title={device.name}
+ aria-label={[device.name, statusText(device), botsLabel(bots)].filter(Boolean).join(", ")}
+ className="-m-1.5 flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-lg p-1.5 text-start transition-colors hover:bg-ink/[0.06] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus motion-reduce:transition-none">
+ <span className="flex size-9 shrink-0 items-center justify-center text-ink-secondary">{mark}</span>
+ <span className="flex min-w-0 flex-col">
+ <span className="truncate text-[14px] font-medium leading-5 text-ink">{device.name}</span>
+ <span className="truncate text-[12px] leading-4 text-ink-secondary">{statusText(device)}</span>
+ </span>
+ <span className="ms-auto"><BotFaces bots={bots} size={22} /></span>
+ </button>
+ <button type="button" data-settings-block="add" data-add-device="" onClick={onAdd} className="ui-button ui-button-primary inline-flex shrink-0 scroll-mt-4 items-center gap-1.5">
+ <Plus size={14} aria-hidden="true" />{t("devicesPage.add")}
+ </button>
+ </div>
+ {network}
+ </div>
);
}
-/** A route's branch off the trunk: its name where the line meets it, then its devices. Dashed while none is online. */
-function Branch({ route, last, quiet, label, aside, children, boxed }: { route: DeviceRoute; last: boolean; quiet: boolean; label: ReactNode; aside?: ReactNode; children: ReactNode; boxed?: boolean }) {
- // The stub meets the group's first row: the private network's header, or a plain group's devices (its name sits
- // beside them when the map is wide, above them when it is narrow).
- const stub = boxed ? "top-6" : "top-2 @min-[560px]/map:top-6";
+/** The line from the group's trunk to one tile: solid while it is reachable, dashed while it is away, moving while it is connected now. */
+function Stub({ device, last }: { device: Device; last: boolean }) {
+ const gone = device.status === "offline";
+ return <>
+ <span aria-hidden="true" className={cn("absolute start-2 top-0 border-s", last ? "h-5" : "-bottom-2", SOLID)} />
+ <span aria-hidden="true" data-line={device.live ? "live" : gone ? "away" : "on"} className={cn("absolute start-2 top-5 w-3 border-t", gone ? AWAY : SOLID)} />
+ {device.live && (
+ <svg aria-hidden="true" viewBox="0 0 12 2" className="absolute start-2 top-5 -mt-px h-0.5 w-3 overflow-visible rtl:-scale-x-100">
+ <line x1="0" y1="1" x2="12" y2="1" strokeWidth="1.5" strokeDasharray="2 3" className="animate-link-flow stroke-success" style={{ animationDuration: "2.2s" }} />
+ </svg>
+ )}
+ </>;
+}
+
+function Group({ group, devices, last, selected, onSelect, onAction, panel, now }: {
+ group: DeviceGroup; devices: readonly Device[]; last: boolean; selected: string | null; onSelect: (id: string) => void;
+ onAction: (device: Device, action: DeviceAction) => void; panel: ReactNode; now: number;
+}) {
+ const id = useId();
+ const line = away(devices) ? AWAY : SOLID;
return (
- <li data-device-route={route} className="relative pb-3 ps-6">
- <span aria-hidden="true" className={cn("absolute start-0 top-0 w-0 border-s border-(--settings-edge)", last ? (boxed ? "h-6" : "h-2 @min-[560px]/map:h-6") : "h-full", quiet && "border-dashed")} />
- <span aria-hidden="true" className={cn("absolute start-0 w-5 border-t border-(--settings-edge)", stub, quiet && "border-dashed")} />
- {boxed ? (
- <div className="flex flex-col gap-2 rounded-xl border border-dashed border-(--settings-edge) px-3 py-3" data-private-network="">
- <div className="flex min-h-6 flex-wrap items-center justify-between gap-x-3 gap-y-1">
- <span className="text-[12px] font-medium leading-4 text-ink-secondary">{label}</span>
- {aside}
- </div>
- {children}
- </div>
- ) : (
- <div className="flex flex-col gap-2 @min-[560px]/map:flex-row @min-[560px]/map:items-start">
- <span className="text-[12px] font-medium leading-4 text-ink-secondary @min-[560px]/map:mt-4 @min-[560px]/map:w-28 @min-[560px]/map:shrink-0">{label}</span>
- {children}
- </div>
- )}
- </li>
+ <section data-device-group={group} aria-labelledby={id} className="relative row-span-2 grid min-w-0 grid-cols-[minmax(0,1fr)] grid-rows-subgrid @max-[519px]/map:pb-3">
+ {!last && <span aria-hidden="true" className={cn("absolute start-2 top-0 w-[calc(100%+1rem)] border-t @max-[519px]/map:hidden", line)} />}
+ {!last && <span aria-hidden="true" className={cn("absolute start-2 top-0 bottom-0 hidden border-s @max-[519px]/map:block", SOLID)} />}
+ <h3 id={id} className="relative min-w-0 ps-5 pt-3 pb-2 text-[12px] font-medium leading-4 text-ink-secondary">
+ <span aria-hidden="true" className={cn("absolute start-2 top-0 bottom-0 border-s", line)} />
+ {groupLabel(group)}
+ </h3>
+ <ul className="flex min-w-0 flex-col gap-2 self-start">
+ {devices.map((device, index) => (
+ <Fragment key={device.id}>
+ <li className="relative min-w-0 ps-5">
+ <Stub device={device} last={index === devices.length - 1 && !(panel && selected === device.id)} />
+ <DeviceTile device={device} selected={selected === device.id} onSelect={onSelect} onAction={onAction} now={now} />
+ </li>
+ {panel && selected === device.id && <li className="relative min-w-0 ps-5 pt-1">
+ {index < devices.length - 1 && <span aria-hidden="true" className={cn("absolute start-2 top-0 -bottom-2 border-s", SOLID)} />}
+ {panel}
+ </li>}
+ </Fragment>
+ ))}
+ </ul>
+ </section>
);
}
-export interface NetworkAction {
- label: string;
- run?: () => void;
- href?: string;
- busy?: boolean;
+/** The map's width, for where the chosen device's card goes and where its pointer sits. */
+function useMapLayout(root: React.RefObject<HTMLElement | null>, selected: string | null) {
+ const [width, setWidth] = useState(0);
+ const [caret, setCaret] = useState<number | null>(null);
+ useLayoutEffect(() => {
+ const element = root.current;
+ if (!element || typeof ResizeObserver === "undefined") return;
+ const observer = new ResizeObserver(([entry]) => setWidth(entry?.contentRect.width ?? 0));
+ observer.observe(element);
+ return () => observer.disconnect();
+ }, [root]);
+ useLayoutEffect(() => {
+ const element = root.current;
+ const tile = selected ? element?.querySelector(`[data-device-node="${CSS.escape(selected === "here" ? "here" : selected)}"]`) : null;
+ const card = element?.querySelector("[data-device-card]");
+ if (!tile || !card) { setCaret(null); return; }
+ const at = tile.getBoundingClientRect(), box = card.getBoundingClientRect();
+ const rtl = getComputedStyle(card).direction === "rtl";
+ setCaret(Math.round(Math.max(16, Math.min(box.width - 16, rtl ? box.right - (at.right - 28) : at.left + 28 - box.left))));
+ });
+ return { narrow: width > 0 && width < NARROW_MAP_PX, caret };
}
/**
- * The map: this place at the root, a trunk down its left, and one branch per way devices reach it, named where the line
- * meets it. The private network (Tailscale) is a dashed group of its own, always drawn on This computer, with its state
- * and the one next step. In a narrow window every device becomes a full-width row: the same tree, read as a list.
+ * The map: this place as the hub, with a line down to a few plainly named groups (phones, computers, Clouds and your
+ * own servers), each device a tile that says how it is, how it connects and which bots work on it. The chosen device's
+ * card opens against the map: under the hub, under the groups (pointing at the tile), or in a narrow window right under
+ * the tile. The groups are headed lists of buttons, so the map reads the same to a screen reader and the keyboard.
*/
-export function DeviceMap({ devices, network, networkAction, selected, onSelect, onAdd, here, now = Date.now() }: {
+export function DeviceMap({ devices, mark, network, selected, onSelect, onClose, onAction, onAdd, panel, now = Date.now() }: {
devices: readonly Device[];
- network: PrivateNetwork | null;
- networkAction: NetworkAction | null;
+ mark: ReactNode;
+ network: { network: PrivateNetwork; line: string; action: NetworkAction | null; secondary?: ReactNode } | null;
selected: string | null;
onSelect: (id: string) => void;
+ /** Escape anywhere on the map while a device is chosen closes its card, never all of Settings. */
+ onClose: () => void;
+ onAction: (device: Device, action: DeviceAction) => void;
onAdd: () => void;
- here: ReactNode;
+ /** The chosen device's card, given where its pointer sits. */
+ panel: (caret: number | null) => ReactNode;
now?: number;
}) {
- const groups = groupByRoute(devices);
- const shown = network && !groups.some((group) => group.route === "tailscale") ? [{ route: "tailscale" as const, devices: [] as Device[] }, ...groups] : groups;
- const alone = groups.length === 0;
- const action = networkAction && (networkAction.href
- ? <a href={networkAction.href} target="_blank" rel="noreferrer" className="ui-button ui-button-sm" data-network-action="">{networkAction.label}</a>
- : <button type="button" className="ui-button ui-button-sm" data-network-action="" disabled={networkAction.busy} onClick={networkAction.run}>{networkAction.label}</button>);
+ const root = useRef<HTMLDivElement>(null);
+ const { narrow, caret } = useMapLayout(root, selected);
+ const here = devices.find((device) => device.here)!;
+ const groups = groupByKind(devices);
+ const card = selected ? panel(caret) : null;
+ const inGroups = Boolean(card) && selected !== here.id;
+ const everyoneAway = groups.every((entry) => away(entry.devices));
return (
- <div data-settings-block="map" className="@container/map flex scroll-mt-4 flex-col" role="group" aria-label={t("devicesPage.mapLabel")}>
- <div className="flex flex-wrap items-center justify-between gap-3 pb-2">
- {here}
- <button type="button" data-settings-block="add" data-add-device="" onClick={onAdd} className="ui-button ui-button-primary inline-flex scroll-mt-4 items-center gap-1.5">
- <Plus size={14} aria-hidden="true" />{t("devicesPage.add")}
- </button>
- </div>
- {shown.length > 0 && (
- <ul className="ms-4 flex flex-col" data-device-tree="">
- {shown.map((group, index) => {
- const quiet = group.devices.every((device) => device.status !== "online");
- const isNetwork = group.route === "tailscale" && network;
- return (
- <Branch key={group.route} route={group.route} last={index === shown.length - 1} quiet={quiet} boxed={Boolean(isNetwork)}
- label={isNetwork ? <>{t("devicesPage.network.title")}<span className="font-normal text-ink-tertiary">{" · Tailscale"}</span></> : routeLabel(group.route)}
- aside={isNetwork ? <span className="flex items-center gap-2">
- <span data-network-state={network.state} className={cn("text-[12px] leading-4", network.state === "ready" ? "text-ink-secondary" : network.state === "unknown" ? "text-ink-tertiary" : "text-warning")}>{networkShort(network)}</span>
- {action}
- </span> : undefined}>
- {group.devices.length > 0 && (
- <div className="flex flex-wrap gap-2">
- {group.devices.map((device) => <DeviceNode key={device.id} device={device} selected={selected === device.id} onSelect={onSelect} now={now} />)}
- </div>
- )}
- </Branch>
- );
- })}
- </ul>
+ <div ref={root} data-settings-block="map" data-map-layout={narrow ? "narrow" : "wide"} className="@container/map flex scroll-mt-4 flex-col" role="group" aria-label={t("devicesPage.mapLabel")}
+ onKeyDown={(event) => { if (selected && event.key === "Escape") { event.preventDefault(); event.stopPropagation(); onClose(); } }}>
+ <Hub device={here} mark={mark} selected={selected === here.id} onSelect={onSelect} onAdd={onAdd}
+ network={network && <NetworkRow {...network} />} />
+ {selected === here.id && card && <div className="pt-3">{card}</div>}
+ {groups.length > 0 ? <>
+ <span aria-hidden="true" className={cn("ms-2 h-3 border-s", everyoneAway ? AWAY : SOLID)} />
+ <div data-device-tree="" className="grid gap-x-4 @max-[519px]/map:grid-cols-1" style={narrow ? undefined : { gridTemplateColumns: `repeat(${Math.max(groups.length, 2)}, minmax(0, 1fr))` }}>
+ {groups.map((entry, index) => (
+ <Group key={entry.group} group={entry.group} devices={entry.devices} last={index === groups.length - 1} selected={selected}
+ onSelect={onSelect} onAction={onAction} panel={narrow && inGroups ? card : null} now={now} />
+ ))}
+ </div>
+ {!narrow && inGroups && <div className="pt-4">{card}</div>}
+ </> : (
+ <div className="relative ps-5 pt-3">
+ <span aria-hidden="true" className={cn("absolute start-2 top-0 h-[34px] border-s", AWAY)} />
+ <span aria-hidden="true" className={cn("absolute start-2 top-[34px] w-3 border-t", AWAY)} />
+ <p data-devices-empty="" className="rounded-xl border border-dashed border-(--settings-edge) px-3 py-3 text-[13px] leading-[18px] text-ink-secondary">{t("devicesPage.empty")}</p>
+ </div>
)}
- {alone && <p data-devices-empty="" className="ps-4 pt-1 text-[13px] leading-[18px] text-ink-secondary">{t("devicesPage.empty")}</p>}
</div>
);
}
diff --git a/src/components/devices/DevicePanel.tsx b/src/components/devices/DevicePanel.tsx
new file mode 100644
index 0000000000..c92e29d1f5
--- /dev/null
+++ b/src/components/devices/DevicePanel.tsx
@@ -0,0 +1,61 @@
+import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";
+import { X } from "lucide-react";
+import { BotAvatar } from "@/components/Avatar";
+import type { Device, DeviceAction } from "@/lib/devices";
+import { t } from "@/lib/i18n";
+import { vpsServerId } from "../../../shared/bot-computers";
+import { VpsServerEditor } from "../keys/VpsServerEditor";
+import { ActionButton, DeviceDetails, primaryOf } from "./DeviceList";
+import { StatusLine, useBotsOn } from "./DeviceTile";
+import { KIND_ICON } from "./device-words";
+
+/** A server bots reach over SSH: the id its editor takes. */
+export const vpsOf = (device: Device): string | null => {
+ const source = device.sources.find((one) => one.type === "vps");
+ return source ? vpsServerId(source.id) : null;
+};
+
+/**
+ * The chosen device's card, drawn against the map where it was chosen: its state and its one button, the bots on it,
+ * its details and other actions, and for a server bots reach over SSH its own editor.
+ */
+export function DevicePanel({ device, onAction, onClose, onRemoved, caret, children, now = Date.now() }: {
+ device: Device; onAction: (device: Device, action: DeviceAction) => void; onClose: () => void; onRemoved: (notice: string | null) => void;
+ /** Where the chosen tile sits along the card's top edge, in px from its start; null draws no pointer. */
+ caret: number | null; children?: ReactNode; now?: number;
+}) {
+ const Icon = KIND_ICON[device.kind];
+ const primary = primaryOf(device);
+ const bots = useBotsOn(device);
+ const vps = vpsOf(device);
+ const card = useRef<HTMLElement>(null);
+ useEffect(() => { card.current?.scrollIntoView?.({ block: "nearest" }); }, [device.id]);
+ return (
+ <section ref={card} id="device-card" data-device-card={device.id} aria-label={device.name} style={caret === null ? undefined : { "--caret": `${caret}px` } as CSSProperties}
+ className="relative flex scroll-mt-4 flex-col gap-3 rounded-xl bg-menu px-4 py-3 shadow-[inset_0_0_0_0.5px_var(--settings-edge)] motion-safe:animate-fade-in">
+ {caret !== null && <span aria-hidden="true" className="absolute -top-[5px] start-(--caret) size-2.5 -translate-x-1/2 rotate-45 border-s-[0.5px] border-t-[0.5px] border-(--settings-edge) bg-menu rtl:translate-x-1/2" />}
+ <div className="flex items-center gap-3">
+ <Icon size={16} aria-hidden="true" className="shrink-0 text-ink-secondary" />
+ <div className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="truncate text-[14px] font-medium leading-5 text-ink">{device.name}</span>
+ <StatusLine device={device} now={now} />
+ </div>
+ {primary && <ActionButton device={device} action={primary} quiet={false} onAction={onAction} />}
+ <button type="button" onClick={onClose} aria-label={t("common.close")} title={t("common.close")} className="ui-icon-button shrink-0"><X size={16} aria-hidden="true" /></button>
+ </div>
+ <div className="flex flex-col gap-3 ps-7">
+ {bots.length > 0 && (
+ <div data-device-bot-names="" className="flex flex-col gap-1.5">
+ <span className="text-[12px] leading-4 text-ink-tertiary">{t("devicesPage.bots.title")}</span>
+ <ul className="flex flex-wrap gap-x-3 gap-y-1.5">
+ {bots.map((bot) => <li key={bot.id} className="flex min-w-0 items-center gap-1.5 text-[13px] leading-[18px] text-ink"><BotAvatar bot={bot} size={18} /><span className="truncate">{bot.name}</span></li>)}
+ </ul>
+ </div>
+ )}
+ <DeviceDetails device={device} actions={device.actions.filter((action) => action !== primary)} onAction={onAction} now={now} />
+ {vps && <VpsServerEditor serverId={vps} onRemoved={onRemoved} />}
+ {children}
+ </div>
+ </section>
+ );
+}
diff --git a/src/components/devices/DeviceTile.tsx b/src/components/devices/DeviceTile.tsx
new file mode 100644
index 0000000000..1cc64765cd
--- /dev/null
+++ b/src/components/devices/DeviceTile.tsx
@@ -0,0 +1,99 @@
+import { CircleAlert } from "lucide-react";
+import { BotAvatar } from "@/components/Avatar";
+import { cn } from "@/lib/cn";
+import type { Device, DeviceAction } from "@/lib/devices";
+import { t } from "@/lib/i18n";
+import { useStoreSelector } from "@/state/store-select";
+import { actionLabel } from "./DeviceList";
+import { KIND_ICON, kindLabel, routeLabel, statusText } from "./device-words";
+
+const FACES = 3;
+
+/** How a device is, at a glance: a mark and words, never the colour alone. */
+export function StatusMark({ status }: { status: Device["status"] }) {
+ if (status === "attention") return <CircleAlert size={14} aria-hidden="true" className="shrink-0 text-warning" />;
+ if (status === "online") return <span aria-hidden="true" className="mx-[3px] size-2 shrink-0 rounded-full bg-success" />;
+ if (status === "offline") return <span aria-hidden="true" className="mx-[3px] size-2 shrink-0 rounded-full border border-ink-tertiary" />;
+ return null;
+}
+
+export function StatusLine({ device, now, className }: { device: Device; now: number; className?: string }) {
+ const words = statusText(device, now);
+ if (!words) return null;
+ return (
+ <span data-device-state={device.status} className={cn("flex min-w-0 items-center gap-1.5 text-[12px] leading-4", device.status === "attention" ? "text-ink" : "text-ink-secondary", className)}>
+ <StatusMark status={device.status} />
+ <span className="truncate">{words}</span>
+ </span>
+ );
+}
+
+/** The bots that work on a device, by name, for its label and its card. Bots this window does not know are left out. */
+export function useBotsOn(device: Device) {
+ const bots = useStoreSelector((state) => state.bots);
+ return (device.bots ?? []).flatMap((id) => bots.find((bot) => bot.id === id) ?? []);
+}
+
+/** Up to three faces, overlapping, then the rest as a count. */
+export function BotFaces({ bots, size = 18, ring = "ring-(--color-menu)" }: { bots: ReturnType<typeof useBotsOn>; size?: number; ring?: string }) {
+ if (bots.length === 0) return null;
+ return (
+ <span data-device-bots={bots.length} aria-hidden="true" className="flex shrink-0 items-center -space-x-1.5">
+ {bots.slice(0, FACES).map((bot) => <span key={bot.id} className={cn("rounded-full ring-2", ring)}><BotAvatar bot={bot} size={size} /></span>)}
+ {bots.length > FACES && <span className={cn("flex items-center justify-center rounded-full bg-raised px-1 text-[11px] leading-none text-ink-secondary tabular-nums ring-2", ring)}
+ style={{ minWidth: size, height: size }}>+{bots.length - FACES}</span>}
+ </span>
+ );
+}
+
+export const botsLabel = (bots: ReturnType<typeof useBotsOn>) => (bots.length ? t("devicesPage.bots.on", { names: bots.map((bot) => bot.name).join(", ") }) : "");
+
+/** The one thing a device needs, right on its tile, by what it needs. An update only copies a command, so its button
+ * opens the card that says so. */
+const TILE_ACTION: Partial<Record<NonNullable<Device["note"]>, DeviceAction["type"]>> = { update: "copy-update", "signed-out": "pair-again", insecure: "pair-again", unreachable: "retry" };
+export const tileActionOf = (device: Device) => {
+ const type = device.note && TILE_ACTION[device.note];
+ return type ? device.actions.find((action) => action.type === type) : undefined;
+};
+
+/** One device on the map: what it is, how it is, how it connects and the bots on it. Choosing it opens its card. In a
+ * narrow map the tile is one row, with how it connects and its bots at the end. */
+export function DeviceTile({ device, selected, onSelect, onAction, now }: {
+ device: Device; selected: boolean; onSelect: (id: string) => void; onAction: (device: Device, action: DeviceAction) => void; now: number;
+}) {
+ const Icon = KIND_ICON[device.kind];
+ const bots = useBotsOn(device);
+ const action = tileActionOf(device);
+ const route = device.kind === "cloud" || device.kind === "vm" ? null : routeLabel(device.route);
+ const line = statusText(device, now);
+ const label = [device.name, kindLabel(device.kind), line, route, botsLabel(bots)].filter(Boolean).join(", ");
+ const actionText = action && (action.type === "copy-update" ? t("devicesPage.tile.update") : actionLabel(action, device));
+ return (
+ <div className={cn("relative flex min-w-0 flex-col rounded-xl bg-menu transition-colors hover:bg-ink/[0.06] motion-reduce:transition-none",
+ selected ? "shadow-[inset_0_0_0_1px_var(--color-ink)]" : "shadow-[inset_0_0_0_0.5px_var(--settings-edge)]")}>
+ <button type="button" data-device-node={device.id} data-device-status={device.status} aria-expanded={selected} aria-controls={selected ? "device-card" : undefined}
+ onClick={() => onSelect(device.id)} aria-label={label} title={device.name}
+ className="flex min-w-0 cursor-pointer flex-col gap-1 rounded-xl px-2.5 py-2.5 text-start focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus @max-[519px]/map:flex-row @max-[519px]/map:items-center @max-[519px]/map:gap-3">
+ <span className="flex min-w-0 flex-1 items-start gap-2">
+ <Icon size={16} aria-hidden="true" className="mt-px shrink-0 text-ink-secondary" />
+ <span className="flex min-w-0 flex-1 flex-col gap-0.5">
+ <span className="truncate text-[13px] font-medium leading-[18px] text-ink">{device.name}</span>
+ <StatusLine device={device} now={now} />
+ </span>
+ </span>
+ {(route || bots.length > 0) && (
+ <span className="flex min-h-5 min-w-0 items-center gap-2 ps-6 @max-[519px]/map:max-w-[45%] @max-[519px]/map:shrink-0 @max-[519px]/map:ps-0">
+ {route && <span data-device-route-chip="" className="truncate text-[12px] leading-4 text-ink-tertiary">{route}</span>}
+ <span className="ms-auto"><BotFaces bots={bots} /></span>
+ </span>
+ )}
+ </button>
+ {action && (
+ <span className="flex px-2.5 pb-2.5 ps-[34px]">
+ <button type="button" data-tile-action={action.type} onClick={() => (action.type !== "copy-update" ? onAction(device, action) : selected ? undefined : onSelect(device.id))}
+ aria-label={`${actionText}: ${device.name}`} className="ui-button ui-button-sm max-w-full">{actionText}</button>
+ </span>
+ )}
+ </div>
+ );
+}
diff --git a/src/components/devices/device-words.ts b/src/components/devices/device-words.ts
index 0ebb1c634f..bd3b38e01a 100644
--- a/src/components/devices/device-words.ts
+++ b/src/components/devices/device-words.ts
@@ -9,7 +9,7 @@ export const KIND_ICON: Record<DeviceKind, LucideIcon> = { laptop: Laptop, deskt
const KIND: Record<DeviceKind, LocaleKey> = {
laptop: "devicesPage.kind.laptop", desktop: "devicesPage.kind.desktop", server: "devicesPage.kind.server", cloud: "devicesPage.kind.cloud",
- phone: "devicesPage.kind.phone", vm: "devicesPage.kind.vm",
+ phone: "devicesPage.kind.phone", vm: "devicesPage.kind.cloudDesktop",
};
export const kindLabel = (kind: DeviceKind): string => t(KIND[kind]);
@@ -30,6 +30,7 @@ export function statusText(device: Device, now = Date.now()): string {
if (device.note === "insecure") return t("devicesPage.note.insecure");
if (device.note === "unreachable") return t("devicesPage.note.unreachable");
if (device.note === "reconnecting") return t("devicesPage.note.reconnecting");
+ if (device.kind === "vm") return device.desktop ? t(DESKTOP[device.desktop]) : "";
if (device.status === "online") return t("devicesPage.status.online");
if (device.status === "offline") return device.lastSeen ? t("devicesPage.status.seen", { when: lastSeen(device.lastSeen, now) }) : t("devicesPage.status.offline");
if (device.route === "ssh") return t("devicesPage.status.ssh");
@@ -37,8 +38,9 @@ export function statusText(device: Device, now = Date.now()): string {
return device.home ? t("servers.homeTag") : t("devicesPage.status.unknown");
}
-/** The dot's colour by status; none while nothing says how it is. */
-export const DOT: Record<Device["status"], string | null> = { online: "bg-success", attention: "bg-warning", offline: "bg-ink-tertiary", unknown: null };
+const DESKTOP: Record<NonNullable<Device["desktop"]>, LocaleKey> = {
+ ready: "devicesPage.desktop.ready", asleep: "devicesPage.desktop.asleep", starting: "devicesPage.desktop.starting", unreachable: "devicesPage.note.unreachable",
+};
const NETWORK_SHORT: Record<PrivateNetworkState, LocaleKey> = {
unknown: "devicesPage.network.short.unknown", "not-installed": "devicesPage.network.short.notInstalled", "no-cli": "devicesPage.network.short.noCli",
@@ -62,6 +64,3 @@ export function networkLine(network: PrivateNetwork): string {
case "ready": return network.shared ? t("devicesPage.network.line.ready", { name: network.name ?? "" }) : t("devicesPage.network.line.notShared", { name: network.name ?? "" });
}
}
-
-/** Where to get Tailscale for this computer's system. */
-export const TAILSCALE_DOWNLOAD = "https://tailscale.com/download";
diff --git a/src/components/settings/pages/DevicesPage.dom.test.ts b/src/components/settings/pages/DevicesPage.dom.test.ts
index 482f5f9a8d..839008c924 100644
--- a/src/components/settings/pages/DevicesPage.dom.test.ts
+++ b/src/components/settings/pages/DevicesPage.dom.test.ts
@@ -23,6 +23,8 @@ let session: unknown;
let sessions: Array<{ id: string; label: string; scopes: string[]; lastSeenAt: number }>;
let openCodes: string[];
let requests: string[];
+let botRows: unknown[] | "forbidden";
+let config: Record<string, unknown>;
let bridge: Record<string, ReturnType<typeof vi.fn>>;
let environments: Record<string, ReturnType<typeof vi.fn>>;
let go: ReturnType<typeof vi.fn<SettingsShell["go"]>>;
@@ -62,6 +64,8 @@ beforeEach(() => {
session = { kind: "loopback", trust: "owner" };
sessions = [];
openCodes = ["p1"];
+ botRows = [];
+ config = { profile: { email: "[email protected]" }, managedPolicy: null };
companion = {
enabled: true, keepAwake: false, port: 8810, pairing: null,
devices: [
@@ -80,6 +84,8 @@ beforeEach(() => {
if (path === "/api/auth/pairing" && init?.method === "POST") return Response.json({ id: "p1", code: "7KQ2-M9XD-H4TP", expiresAt: NOW + 600_000, url: null, hint: null });
if (path === "/api/auth/pairing") return Response.json({ pairings: openCodes.map((id) => ({ id })) });
if (path === "/api/phones") return Response.json({ phones: [] });
+ if (path === "/api/computers/bots") return botRows === "forbidden" ? Response.json({ error: "admin only" }, { status: 403 }) : Response.json({ now: NOW, rows: botRows });
+ if (path === "/api/config" && init?.method === "PUT") return Response.json({ notice: "GPU box is no longer used. Its desktops stay on it.", vps: { configured: false, sshAlias: "", servers: [] } });
if (path === "/api/config") return Response.json({ membership: { authority: "local", pairingCodes: true } });
return Response.json({ error: "no route" }, { status: 404 });
}));
@@ -97,35 +103,51 @@ afterEach(() => {
vi.unstubAllGlobals();
});
+const BOTS = [{ id: "b1", name: "Scout", color: "green" }, { id: "b2", name: "Writer", color: "purple" }, { id: "b3", name: "Builder", color: "orange" }];
+const gpu = { configured: true, sshAlias: "", servers: [{ name: "GPU box", sshAlias: "gpu" }] };
const settle = async () => { for (let i = 0; i < 12; i++) await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)); }); };
const $ = <T extends Element = HTMLElement>(selector: string) => document.body.querySelector<T & HTMLElement>(selector);
const click = async (selector: string) => { await act(async () => $(selector)!.click()); await settle(); };
async function render(over: Partial<SettingsShell["ctx"]> = {}) {
const shell: SettingsShell = { ctx: fullContext({ advanced: false, ...over }), place: { name: "This computer", kind: "computer", color: null, named: false }, page: "devices", anchor: null, go };
- const state = { ...initialState, config: { profile: { email: "[email protected]" }, managedPolicy: null } as never };
+ const state = { ...initialState, config: config as never, bots: BOTS as never };
act(() => root.render(createElement(StoreContext.Provider, { value: { state, dispatch: vi.fn() } as never },
createElement(SettingsShellContext.Provider, { value: shell }, createElement(DevicesPage)))));
await settle();
}
describe("the Devices page", () => {
- it("draws this computer at the root and one branch per way in, each device with its state", async () => {
+ it("draws this computer as the hub and the rest in plainly named groups, each tile with its state in a mark and words", async () => {
await render();
- expect($("[data-device-node=here]")?.textContent).toContain("This computer");
- expect([...document.querySelectorAll("[data-device-route]")].map((branch) => branch.getAttribute("data-device-route"))).toEqual(["tailscale", "local", "cloud", "internet"]);
- expect($("[data-device-route=local] [data-device-node='phone:iphone']")?.getAttribute("data-device-status")).toBe("online");
- expect($("[data-device-route=internet] [data-device-node='place:vps']")?.textContent).toContain("Can’t reach it");
- expect($("[data-device-route=cloud] [data-device-node='place:home']")?.textContent).toContain("Home");
- expect($("[data-device-row='phone:pixel']")?.textContent).toContain("Seen");
+ expect($("[data-device-hub] [data-device-node=here]")?.textContent).toContain("This computer");
+ expect([...document.querySelectorAll("[data-device-group]")].map((group) => group.getAttribute("data-device-group"))).toEqual(["phones", "servers"]);
+ expect([...document.querySelectorAll("[data-device-group] h3")].map((heading) => heading.textContent)).toEqual(["Phones", "Clouds and your own servers"]);
+ const iphone = $("[data-device-group=phones] [data-device-node='phone:iphone']")!;
+ expect(iphone.getAttribute("data-device-status")).toBe("online");
+ expect(iphone.querySelector("[data-device-state]")?.textContent).toBe("Online");
+ expect(iphone.querySelector("[data-device-route-chip]")?.textContent).toBe("Same network");
+ expect(iphone.closest("li")?.querySelector("[data-line]")?.getAttribute("data-line")).toBe("live");
+ const pixel = $("[data-device-node='phone:pixel']")!;
+ expect(pixel.textContent).toContain("Seen");
+ expect(pixel.closest("li")?.querySelector("[data-line]")?.getAttribute("data-line")).toBe("away");
+ expect($("[data-device-group=servers] [data-device-node='place:vps']")?.textContent).toContain("Can’t reach it");
+ expect($("[data-device-group=servers] [data-device-node='place:home']")?.textContent).toContain("Home");
+ expect($("[data-device-row]")).toBeNull();
});
- it("opens a chosen device's card, whose buttons call the actions that already exist", async () => {
+ it("puts the one thing a device needs on its tile", async () => {
await render();
- await click("[data-device-node='place:vps']");
- expect($("[data-device-card='place:vps']")).not.toBeNull();
- await click("[data-device-card='place:vps'] [data-device-action=retry]");
+ await click("[data-device-node='place:vps'] ~ * [data-tile-action=retry]");
expect(environments.retry).toHaveBeenCalledWith("vps");
+ expect($("[data-device-node='phone:iphone'] ~ * [data-tile-action]")).toBeNull();
+ });
+
+ it("opens a chosen device's card against the map, whose buttons call the actions that already exist, and closes on Escape", async () => {
+ await render();
+ await click("[data-device-node='place:vps']");
+ expect($("[data-device-node='place:vps']")?.getAttribute("aria-expanded")).toBe("true");
+ expect($("[data-device-map], [data-settings-block=map]")?.contains($("[data-device-card='place:vps']"))).toBe(true);
await click("[data-device-card='place:vps'] [data-device-action=remove]");
expect(environments.forget).toHaveBeenCalledWith("vps");
await click("[data-device-node='phone:pixel']");
@@ -135,6 +157,85 @@ describe("the Devices page", () => {
await click("[data-device-node='phone:iphone']");
await click("[data-device-card='phone:iphone'] [data-device-action=manage]");
expect(go).toHaveBeenCalledWith("phone", "paired");
+ // Settings closes on an Escape that reaches the window unhandled: the map's Escape closes only the card.
+ const reached: boolean[] = [];
+ const onWindow = (event: KeyboardEvent) => reached.push(!event.defaultPrevented);
+ window.addEventListener("keydown", onWindow);
+ act(() => { $("[data-device-card='phone:iphone'] button")!.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })); });
+ await settle();
+ expect($("[data-device-card]")).toBeNull();
+ await click("[data-device-node='place:vps']");
+ act(() => { $("[data-device-node='place:vps']")!.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true })); });
+ await settle();
+ window.removeEventListener("keydown", onWindow);
+ expect($("[data-device-card]")).toBeNull();
+ expect(reached.filter(Boolean)).toEqual([]);
+ });
+
+ it("opens the card from a tile's Update…, and never closes it from there", async () => {
+ environments.state.mockResolvedValue({ localOrigin: "http://127.0.0.1:8799", remote: false, packaged: true, activeId: "local", environments: [
+ { id: "local", kind: "local", name: "This computer" }, { id: "mini", kind: "remote", name: "Studio Mac mini", origin: "http://mini.tail1.ts.net:8799" },
+ ] });
+ environments.status.mockResolvedValue([{ id: "mini", state: "connected", since: NOW, version: "0.1.170", behind: true, install: "global" }]);
+ await render();
+ await click("[data-device-node='place:mini'] ~ * [data-tile-action=copy-update]");
+ expect($("[data-device-card='place:mini'] [data-device-action=copy-update]")?.textContent).toBe("Copy update command");
+ await click("[data-device-node='place:mini'] ~ * [data-tile-action=copy-update]");
+ expect($("[data-device-card='place:mini']")).not.toBeNull();
+ });
+
+ it("is a set of headed lists of buttons, so the keyboard and a screen reader reach every device", async () => {
+ await render();
+ const nodes = [...document.querySelectorAll<HTMLElement>("[data-device-node]")];
+ expect(nodes.map((node) => node.tagName)).toEqual(nodes.map(() => "BUTTON"));
+ expect(nodes.every((node) => node.tabIndex === 0 && node.getAttribute("aria-label"))).toBe(true);
+ for (const group of document.querySelectorAll("[data-device-group]")) {
+ expect(document.getElementById(group.getAttribute("aria-labelledby")!)?.tagName).toBe("H3");
+ expect(group.querySelector("ul > li [data-device-node]")).not.toBeNull();
+ }
+ });
+
+ it("shows which bots work where, the cloud desktops among the devices, and their names on the card", async () => {
+ config = { ...config, vps: gpu };
+ botRows = [
+ { botId: "b1", kind: "local", computerId: "local", name: null, state: "ready", stateAt: NOW },
+ { botId: "b2", kind: "cloud", computerId: "cloud:b2", name: null, state: "asleep", stateAt: NOW },
+ { botId: "b3", kind: "vps", computerId: "vps:gpu/omb-b3", name: "GPU box", state: "ready", stateAt: NOW, vps: { serverId: "vps:gpu", alias: "gpu", container: "omb-b3" } },
+ ];
+ await render();
+ expect(requests).toContain("GET /api/computers/bots");
+ expect($("[data-device-node=here]")?.getAttribute("aria-label")).toContain("Bots here: Scout");
+ expect($("[data-device-node=here] [data-device-bots]")?.getAttribute("data-device-bots")).toBe("1");
+ const desktop = $("[data-device-group=servers] [data-device-node='cloud:b2']")!;
+ expect(desktop.textContent).toContain("Writer’s cloud desktop");
+ expect(desktop.querySelector("[data-device-state]")?.textContent).toBe("Asleep");
+ await click("[data-device-node='vps:gpu']");
+ expect($("[data-device-card='vps:gpu'] [data-device-bot-names]")?.textContent).toContain("Builder");
+ });
+
+ it("draws no state at all for a cloud desktop whose state nothing knows", async () => {
+ botRows = [{ botId: "b2", kind: "cloud", computerId: "cloud:b2", name: null, state: "unknown", stateAt: null }];
+ await render();
+ expect($("[data-device-node='cloud:b2']")).not.toBeNull();
+ expect($("[data-device-node='cloud:b2'] [data-device-state]")).toBeNull();
+ });
+
+ it("draws no bots when the list is refused", async () => {
+ botRows = "forbidden";
+ await render();
+ expect(document.querySelector("[data-device-bots]")).toBeNull();
+ expect($("[data-device-node='phone:iphone']")).not.toBeNull();
+ });
+
+ it("opens a server bots reach over SSH straight in its editor, and closes with the server's notice once it is removed", async () => {
+ config = { ...config, vps: gpu };
+ await render();
+ await click("[data-device-node='vps:gpu']");
+ expect($<HTMLInputElement>("[data-device-card='vps:gpu'] [data-vps-server=gpu] input")?.value).toBe("GPU box");
+ await click("[data-device-card='vps:gpu'] [data-vps-server=gpu] button[aria-label^='Remove']");
+ expect(requests).toContain("PUT /api/config");
+ expect($("[data-device-card]")).toBeNull();
+ expect($("[role=status]")?.textContent).toContain("GPU box is no longer used");
});
it("never asks Tailscale on its own, and shows the check's answer and its next step after Set up", async () => {
@@ -157,7 +258,8 @@ describe("the Devices page", () => {
};
await render();
expect($("[data-network-state]")?.textContent).toBe("On");
- expect($("[data-private-network] [data-device-node='phone:tab']")).not.toBeNull();
+ expect($("[data-device-group=phones] [data-device-node='phone:tab'] [data-device-route-chip]")?.textContent).toBe("Private network");
+ expect($("[data-private-network][data-settings-block=network]")).not.toBeNull();
expect($("[data-network-line]")?.textContent).toContain("ada.tail1.ts.net");
expect(bridge.setTailscaleComputers).not.toHaveBeenCalled();
});
@@ -240,6 +342,7 @@ describe("the Devices page", () => {
expect(requests).not.toContain("GET /api/auth/sessions");
expect(requests).not.toContain("GET /api/phones");
expect(document.querySelector("[data-device-action=remove]")).toBeNull();
+ expect(requests).not.toContain("GET /api/computers/bots");
});
it("gives a new server one line to run, the sign-in included", async () => {
@@ -251,10 +354,19 @@ describe("the Devices page", () => {
]);
});
- it("reads as a list in a narrow window: every device a full-width row", async () => {
+ it("reads as one column in a narrow window, with the chosen device's card right under its tile", async () => {
+ vi.stubGlobal("ResizeObserver", class {
+ constructor(private readonly report: ResizeObserverCallback) {}
+ observe() { this.report([{ contentRect: { width: 380 } } as ResizeObserverEntry], this as never); }
+ disconnect() {}
+ });
await render();
- expect($("[data-device-tree]")?.tagName).toBe("UL");
- expect($("[data-device-node='phone:iphone']")?.className).toContain("@max-[480px]/map:w-full");
+ expect($("[data-map-layout]")?.getAttribute("data-map-layout")).toBe("narrow");
+ expect($("[data-device-tree]")?.getAttribute("style")).toBeNull();
+ await click("[data-device-node='phone:iphone']");
+ const card = $("[data-device-card='phone:iphone']")!;
+ expect(card.closest("[data-device-group=phones]")).not.toBeNull();
+ expect(card.closest("li")?.previousElementSibling?.querySelector("[data-device-node='phone:iphone']")).not.toBeNull();
});
});
diff --git a/src/components/settings/pages/DevicesPage.tsx b/src/components/settings/pages/DevicesPage.tsx
index 9289a68d7e..83aba8403f 100644
--- a/src/components/settings/pages/DevicesPage.tsx
+++ b/src/components/settings/pages/DevicesPage.tsx
@@ -9,14 +9,13 @@ import type { CompanionState } from "@/lib/companion-types";
import { api } from "@/state/api";
import { useStoreDispatch, useStoreSelector } from "@/state/store-select";
import { AddDeviceDialog, type AddKind } from "../../devices/AddDeviceDialog";
-import { DeviceCard, DeviceList } from "../../devices/DeviceList";
-import { DeviceMap, HereNode, type NetworkAction } from "../../devices/DeviceMap";
+import { DeviceMap, type NetworkAction } from "../../devices/DeviceMap";
+import { DevicePanel } from "../../devices/DevicePanel";
import { networkLine } from "../../devices/device-words";
import { PairDeviceDialog } from "../../PhoneDevicesSection";
import { usePhoneSetupController } from "../../PhoneSetupFlow";
import { OwnServerLink, RailSheet } from "../../PlaceAddSheet";
import { updateCommand } from "../../ServerList";
-import { SettingRow, SettingsGroup, SettingsRows } from "../../SettingsPrimitives";
import { PlaceBadge } from "../SettingsNav";
import { useSettingsShell } from "../settings-shell";
@@ -48,14 +47,15 @@ export function DevicesPage() {
const { ctx, place, go } = useSettingsShell();
const dispatch = useStoreDispatch();
const config = useStoreSelector((state) => state.config);
- const { devices, companion, loaded, refresh } = useDevices({ here: ctx.here, client: ctx.client, name: place.name, kind: place.kind });
+ const { devices, companion, refresh } = useDevices({ here: ctx.here, client: ctx.client, name: place.name, kind: place.kind });
const c = usePhoneSetupController(config?.profile?.email);
- const [selected, setSelected] = useState<{ id: string; from: "map" | "list" } | null>(null);
+ const [selected, setSelected] = useState<string | null>(null);
const [adding, setAdding] = useState<AddKind | null | false>(false);
const [pairingPhone, setPairingPhone] = useState(false);
const [sheet, setSheet] = useState<Sheet>(null);
const [problem, setProblem] = useState<CompanionState["tailscaleProblem"] | null>(null);
const [failure, setFailure] = useState<string | null>(null);
+ const [notice, setNotice] = useState<string | null>(null);
const asked = useRef(0);
const blocked = config?.managedPolicy?.remoteAccess === false ? t("policy.managedBy", { organization: config.managedPolicy.organizationName }) : null;
const network = ctx.here ? privateNetwork(companion, problem) : null;
@@ -101,7 +101,7 @@ export function DevicesPage() {
else if (source.type === "phone") await c.act((bridge) => bridge.revoke(source.id));
else if (source.type === "phone-app") await api(phoneRemovePath(source.id), { method: "DELETE" });
else if (source.type === "session") await api(`/api/auth/sessions/${encodeURIComponent(source.id)}`, { method: "DELETE" });
- if (selected?.id === device.id) setSelected(null);
+ if (selected === device.id) setSelected(null);
break;
}
}
@@ -111,33 +111,27 @@ export function DevicesPage() {
refresh();
};
- const here = devices[0]!;
- const workspaces = ctx.here ? window.ogb?.workspaces : undefined;
const mark = place.kind === "computer" ? <Laptop size={20} aria-hidden="true" /> : <PlaceBadge place={place} size={24} />;
- const others = devices.length > 1;
- const pick = (id: string) => setSelected((now) => (now?.id === id && now.from === "map" ? null : { id, from: "map" }));
- const chosen = selected?.from === "map" ? devices.find((device) => device.id === selected.id) : undefined;
+ const workspaces = ctx.here ? window.ogb?.workspaces : undefined;
+ const chosen = selected ? devices.find((device) => device.id === selected) : undefined;
+ const close = () => {
+ const id = selected;
+ setSelected(null);
+ if (id) window.requestAnimationFrame(() => document.querySelector<HTMLElement>(`[data-device-node="${CSS.escape(id)}"]`)?.focus());
+ };
+ const shared = network?.state === "ready" && network.shared;
+ const secondary = network && (networkAction?.href
+ ? <button type="button" className="settings-quiet cursor-pointer" disabled={c.busy} onClick={() => void check()}>{c.busy ? t("common.checking") : t("remote.checkAgain")}</button>
+ : shared ? <button type="button" className="settings-quiet cursor-pointer" onClick={() => go("phone", "computers")}>{t("devicesPage.action.manage")}</button> : null);
return <>
- <DeviceMap devices={devices} network={network} networkAction={networkAction} selected={selected?.from === "map" ? selected.id : null} onSelect={pick}
- onAdd={() => setAdding(null)} here={<HereNode device={here} mark={mark} selected={chosen?.id === here.id} onSelect={pick} />} />
- {chosen && <DeviceCard device={chosen} onAction={(device, action) => void act(device, action)} onClose={() => setSelected(null)} />}
+ <DeviceMap devices={devices} mark={mark} selected={chosen ? chosen.id : null} onSelect={(id) => { setNotice(null); setSelected((now) => (now === id ? null : id)); }} onClose={close}
+ onAction={(device, action) => void act(device, action)} onAdd={() => setAdding(null)}
+ network={network && { network, line: blocked ?? networkLine(network), action: networkAction, secondary }}
+ panel={(caret) => chosen && <DevicePanel device={chosen} caret={caret} onAction={(device, action) => void act(device, action)} onClose={close}
+ onRemoved={(text) => { setSelected(null); setNotice(text); refresh(); }} />} />
{failure && <p role="alert" className="px-4 text-[12px] leading-4 text-danger">{failure}</p>}
- {network && (
- <SettingsGroup label={t("devicesPage.network.title")} block="network">
- <SettingsRows>
- <SettingRow title="Tailscale" subtitle={<span data-network-line={network.state} aria-live="polite">{blocked ?? networkLine(network)}</span>}>
- {networkAction?.href && <>
- <button type="button" className="settings-quiet cursor-pointer" disabled={c.busy} onClick={() => void check()}>{c.busy ? t("common.checking") : t("remote.checkAgain")}</button>
- <a href={networkAction.href} target="_blank" rel="noreferrer" className="ui-button">{networkAction.label}</a>
- </>}
- {networkAction?.run && !(network.state === "ready" && network.shared) && <button type="button" className="ui-button" disabled={networkAction.busy} onClick={networkAction.run}>{networkAction.label}</button>}
- {network.state === "ready" && network.shared && <button type="button" className="ui-button" onClick={() => go("phone", "computers")}>{t("devicesPage.action.manage")}</button>}
- </SettingRow>
- </SettingsRows>
- </SettingsGroup>
- )}
- {loaded && others && <DeviceList devices={devices} selected={selected?.from === "list" ? selected.id : null} onSelect={(id) => setSelected(id ? { id, from: "list" } : null)} onAction={(device, action) => void act(device, action)} />}
+ {notice && <p role="status" className="px-4 text-[12px] leading-4 text-ink-secondary">{notice}</p>}
{adding !== false && (
<AddDeviceDialog here={ctx.here} cloud={ctx.cloud} network={network} networkAction={networkAction} tailnetAddress={companion?.tailnetShare?.origin ?? null} places={places} start={adding}
onClose={() => { setAdding(false); refresh(); }} onConnected={refresh}
diff --git a/src/devices-preview.tsx b/src/devices-preview.tsx
index 7315c7d7fc..520e471a81 100644
--- a/src/devices-preview.tsx
+++ b/src/devices-preview.tsx
@@ -1,6 +1,6 @@
// Dev-only gallery of Settings → Devices, served at /devices-preview.html; not in the packaged app. It mounts the real
// Settings window over a fake desktop bridge and answers every /api request itself, so nothing reaches a server.
-// ?place=computer|cloud&devices=full|none&tailscale=unknown|not-installed|no-cli|signed-out|needs-approval|magicdns|ready|unshared
+// ?place=computer|cloud&devices=full|none|one|ten&bots=full|none|unknown|forbidden&tailscale=unknown|not-installed|no-cli|signed-out|needs-approval|magicdns|ready|unshared
// &check=1 (presses the private network's button once loaded) &select=<device id> &add=choose|phone|computer|server
// &skin=midnight|daylight&advanced=1
import { StrictMode } from "react";
@@ -15,7 +15,9 @@ import "./styles.css";
const params = new URLSearchParams(location.search);
const place = params.get("place") === "cloud" ? "cloud" : "computer";
-const full = params.get("devices") !== "none";
+const shown = params.get("devices") ?? "full";
+const full = shown === "full" || shown === "ten";
+const ten = shown === "ten";
const tailscale = params.get("tailscale") ?? (full ? "ready" : "unknown");
const skin = params.get("skin") ?? "midnight";
applySkinChoice(SKIN_IDS.includes(skin as SkinId) ? (skin as SkinId) : "midnight");
@@ -31,8 +33,12 @@ let companion: CompanionState = {
devices: full ? [
{ id: "iphone", name: "Ada’s iPhone 16", createdAt: now - 9e8, lastSeenAt: now - MIN, cloudDesktopAccess: false, e2eAt: now - 5e8, routes: "any", route: "wifi" },
{ id: "pixel", name: "Pixel 9", createdAt: now - 9e8, lastSeenAt: now - 26 * 60 * MIN, cloudDesktopAccess: false, e2eAt: now - 5e8, routes: "any", route: null },
- ] : [],
- connectedDeviceIds: full ? ["iphone"] : [],
+ ...(ten ? [
+ { id: "ipad", name: "Ada’s iPad Pro", createdAt: now - 9e8, lastSeenAt: now - MIN, cloudDesktopAccess: false, e2eAt: now - 5e8, routes: "any" as const, route: "tailscale" as const },
+ { id: "kid", name: "Theo’s Galaxy A54 with a very long name", createdAt: now - 9e8, lastSeenAt: now - 3 * 24 * 60 * MIN, cloudDesktopAccess: false, e2eAt: now - 5e8, routes: "local" as const, route: null },
+ ] : []),
+ ] : shown === "one" ? [{ id: "iphone", name: "Ada’s iPhone 16", createdAt: now - 9e8, lastSeenAt: now - MIN, cloudDesktopAccess: false, e2eAt: now - 5e8, routes: "any", route: "wifi" }] : [],
+ connectedDeviceIds: full ? ["iphone", ...(ten ? ["ipad"] : [])] : shown === "one" ? ["iphone"] : [],
routes: { wifi: { on: full, since: now - 9e8 }, relay: { on: full, since: now - 9e8 }, tailscale: tailRoute, https: { on: false, since: null } },
tailnetShare: ready && tailscale !== "unshared" ? { on: true, origin: "http://ada-macbook.tail4c2e.ts.net:8799", https: false, problem: null } : undefined,
};
@@ -50,6 +56,7 @@ const environments = full ? [
{ id: "home", kind: "remote" as const, name: "Ada’s Cloud", origin: "https://ada.mausbot.cloud", home: true, color: "violet" },
{ id: "mini", kind: "remote" as const, name: "Studio Mac mini", origin: "http://studio-mini.tail4c2e.ts.net:8799" },
{ id: "vps", kind: "remote" as const, name: "Hetzner box", origin: "https://maus.example.com" },
+ ...(ten ? [{ id: "lan", kind: "remote" as const, name: "Office NUC", origin: "http://192.168.1.40:8799" }] : []),
] : [{ id: "local", kind: "local" as const, name: "This computer" }];
const statuses = full ? [
{ id: "mini", state: "connected", since: now - 9e8, version: "0.1.171", behind: true, install: "global" },
@@ -81,7 +88,21 @@ const sessions = full ? [
{ id: "s-air", label: "Ada’s MacBook Air", scopes: ["admin", "client"], createdAt: now - 9e8, lastSeenAt: now - 3 * 60 * MIN, expiresAt: now + 9e8 },
...(place === "cloud" ? [{ id: "s-phone", label: "Safari on iPhone", scopes: ["admin", "client"], createdAt: now - 9e8, lastSeenAt: now - MIN, expiresAt: now + 9e8 }] : []),
] : [];
+const BOTS = [
+ { id: "b1", name: "Scout", color: "green" }, { id: "b2", name: "Writer", color: "purple" }, { id: "b3", name: "Builder", color: "orange" },
+ { id: "b4", name: "Ledger", color: "blue" }, { id: "b5", name: "Helper", color: "pink" },
+];
+const row = (botId: string, kind: string, computerId: string | null, state: string, extra: object = {}) => ({ botId, kind, computerId, name: null, state, stateAt: state === "unknown" ? null : now - MIN, ...extra });
+const botMode = params.get("bots") ?? "full";
+const botRows = !full || botMode === "none" ? [] : botMode === "unknown" ? [
+ row("b1", "cloud", "cloud:b1", "unknown"), row("b2", "vps", "vps:gpu/omb-b2", "unknown", { vps: { serverId: "vps:gpu", alias: "gpu", container: "omb-b2" } }),
+] : [
+ row("b1", "local", "local", "ready"), row("b2", "local", "local", "ready"), row("b3", "cloud", "cloud:b3", "asleep"),
+ row("b4", "vps", "vps:gpu/omb-b4", "ready", { vps: { serverId: "vps:gpu", alias: "gpu", container: "omb-b4" } }), row("b5", "browser", null, "unknown"),
+ ...(ten ? [row("b5", "cloud", "cloud:b5", "ready")] : []),
+];
const ANSWERS: Record<string, unknown> = {
+ "/api/computers/bots": { now, rows: botRows },
"/api/auth/session": { kind: "loopback", trust: "owner" },
"/api/auth/sessions": { sessions, current: null },
"/api/phones": { phones: full ? [{ key: "k1", registration: { installId: "i1", name: "Ada’s iPhone 16", platform: "ios", appVersion: "2.4.0", timeZone: "UTC", capabilities: {} }, registeredAt: now - 9e8, seen: now - MIN, lastUsedAt: null, online: true, busy: false }] : [] },
@@ -89,7 +110,7 @@ const ANSWERS: Record<string, unknown> = {
};
const config = {
profile: { name: "Ada", email: "[email protected]" }, membership: { authority: "local", pairingCodes: true }, managedPolicy: null,
- vps: { configured: full, sshAlias: "", servers: full ? [{ name: "GPU box", sshAlias: "gpu" }] : [] },
+ vps: { configured: full, sshAlias: "", servers: full ? [{ name: "GPU box", sshAlias: "gpu" }, ...(ten ? [{ name: "Render farm", sshAlias: "farm" }] : [])] : [] },
...(place === "cloud" ? { cloudHome: true } : {}),
};
ANSWERS["/api/config"] = config;
@@ -98,11 +119,12 @@ globalThis.fetch = async (input: RequestInfo | URL) => {
if (path === "/api/shared-computers" && place === "cloud" && full) {
return Response.json({ computers: [], known: [{ id: "l1", name: "Ada’s MacBook Pro", platform: "darwin", online: true, busy: false, lent: true, lastSeenAt: now, lastUsedAt: null, scopes: { folders: 1, terminal: true, screen: true, internet: false, chrome: false } }] });
}
+ if (path === "/api/computers/bots" && botMode === "forbidden") return Response.json({ error: "forbidden" }, { status: 403 });
if (path in ANSWERS) return Response.json(ANSWERS[path]);
return Response.json({ error: "not in the preview" }, { status: 404 });
};
-const state = { ...initialState, config: config as never, appSettingsOpen: true, appSettingsSection: "devices" as const };
+const state = { ...initialState, bots: BOTS as never, config: config as never, appSettingsOpen: true, appSettingsSection: "devices" as const };
createRoot(document.getElementById("root")!).render(
<StrictMode>
<StoreContext.Provider value={{ state, dispatch: () => {} } as never}>
diff --git a/src/lib/device-bots.ts b/src/lib/device-bots.ts
new file mode 100644
index 0000000000..324954d590
--- /dev/null
+++ b/src/lib/device-bots.ts
@@ -0,0 +1,54 @@
+import { vpsServerId, type BotComputerKind, type BotComputerRow } from "../../shared/bot-computers";
+import type { Device, DeviceSources } from "./devices";
+import { t } from "./i18n";
+
+type Kind = Exclude<BotComputerKind, "auto">;
+
+const kindOf = (row: BotComputerRow): Kind | undefined => (row.kind === "auto" ? row.autoKind : row.kind);
+
+function cloudDesktop(computerId: string, rows: readonly BotComputerRow[], botName: (botId: string) => string | null): Device {
+ const latest = rows.reduce((best, row) => ((row.stateAt ?? -1) > (best.stateAt ?? -1) ? row : best));
+ const owner = botName(computerId.slice("cloud:".length));
+ const name = latest.name ?? (owner ? t("devicesPage.desktopOf", { name: owner }) : t("devicesPage.kind.cloudDesktop"));
+ const state = latest.state;
+ const shown = state === "none" || state === "unknown" ? {} : { desktop: state };
+ const status = state === "ready" ? "online" : state === "asleep" || state === "unreachable" ? "offline" : "unknown";
+ return {
+ id: computerId, kind: "vm", name, status, ...(state === "unreachable" ? { note: "unreachable" as const } : {}), ...shown,
+ route: "cloud", routes: ["cloud"], sources: [{ type: "desktop", id: computerId }], canRunBots: false, canHostComputer: true, actions: [],
+ };
+}
+
+/**
+ * The bots on each device, from what the server last knew. This place gets the bots on its own private desktop (and on
+ * This computer, the ones that work on it); a server bots reach over SSH gets its own; each cloud desktop becomes a
+ * device of its own. Rows with no computer (the browser alone, no screen, an Auto not yet settled) are left out.
+ */
+export function withBots(devices: readonly Device[], rows: readonly BotComputerRow[] | null | undefined, here: DeviceSources["here"]["kind"],
+ botName: (botId: string) => string | null): Device[] {
+ if (!rows?.length) return [...devices];
+ const onDevice = new Map<string, string[]>();
+ const desktops = new Map<string, BotComputerRow[]>();
+ const add = (deviceId: string, botId: string) => {
+ const bots = onDevice.get(deviceId) ?? [];
+ if (!bots.includes(botId)) onDevice.set(deviceId, [...bots, botId]);
+ };
+ const vpsDevice = (serverId: string) => devices.find((device) => device.sources.some((source) => source.type === "vps" && vpsServerId(source.id) === serverId));
+ for (const row of rows) {
+ const kind = kindOf(row);
+ if (!kind || !row.computerId) continue;
+ if (kind === "vm" || (kind === "local" && here === "computer")) add("here", row.botId);
+ else if (kind === "vps" && row.vps) {
+ const device = vpsDevice(row.vps.serverId);
+ if (device) add(device.id, row.botId);
+ } else if (kind === "cloud") {
+ desktops.set(row.computerId, [...(desktops.get(row.computerId) ?? []), row]);
+ add(row.computerId, row.botId);
+ }
+ }
+ const made = [...desktops].map(([computerId, list]) => cloudDesktop(computerId, list, botName));
+ return [...devices, ...made].map((device) => {
+ const bots = onDevice.get(device.id);
+ return bots ? { ...device, bots } : device;
+ });
+}
diff --git a/src/lib/devices.test.ts b/src/lib/devices.test.ts
index 3df8e88c6e..93acb776e1 100644
--- a/src/lib/devices.test.ts
+++ b/src/lib/devices.test.ts
@@ -1,7 +1,10 @@
import { describe, expect, it } from "vitest";
import type { ServerStatus } from "../../electron/server-status.mjs";
import type { CompanionState, PhoneDevice } from "./companion-types";
-import { buildDevices, groupByRoute, kindFromLabel, nameKey, privateNetwork, type DeviceSources } from "./devices";
+import { vpsServerId, type BotComputerRow } from "../../shared/bot-computers";
+import { withBots } from "./device-bots";
+import { buildDevices, groupByKind, kindFromLabel, nameKey, privateNetwork, type DeviceSources } from "./devices";
+import { setLocale } from "./i18n";
import type { PublicPhone } from "./phones";
const NOW = 1_800_000_000_000;
@@ -128,20 +131,69 @@ describe("the device list", () => {
lent: [{ id: "l1", name: "Ada's MacBook", platform: "darwin", online: true, lent: true, lastSeenAt: NOW }, { id: "l2", name: "Old", platform: "linux", online: false, lent: false, lastSeenAt: 0 }],
vps: [{ alias: "my-vps" }, { alias: "my-vps", name: "Again" }, { alias: "gpu", name: "GPU box" }],
});
- expect(devices.map((device) => device.id)).toEqual(["here", "lent:l1", "vps:my-vps", "vps:gpu"]);
+ expect(devices.map((device) => device.id)).toEqual(["here", "lent:l1", vpsServerId("my-vps"), vpsServerId("gpu")]);
expect(devices[3]!.name).toBe("GPU box");
expect(devices[1]).toMatchObject({ route: "cloud", canHostComputer: true, canRunBots: false, status: "online" });
- expect(devices[2]).toMatchObject({ kind: "server", route: "ssh", status: "unknown", canHostComputer: true });
+ expect(devices[2]).toMatchObject({ kind: "server", route: "ssh", status: "unknown", canHostComputer: true, actions: [] });
+ expect(devices[1]!.live).toBe(true);
});
- it("groups the map by route in one fixed order, this place apart", () => {
+ it("marks live only what is connected at this moment: a phone on its link, a place this app is connected to", () => {
const devices = build({
- places: places([{ id: "home", kind: "remote", name: "My Cloud", origin: "https://a.mausbot.cloud", home: true }, { id: "mini", kind: "remote", name: "mini", origin: "http://mini.tail1.ts.net:8799" }]),
+ places: places([{ id: "a", kind: "remote", name: "A", origin: "https://a.example.com" }, { id: "b", kind: "remote", name: "B", origin: "https://b.example.com" }]),
+ statuses: [status("a"), status("b", { behind: true })],
+ companion: { devices: [phone("on", "On"), phone("off", "Off")], connectedDeviceIds: ["on"] },
+ sessions: { current: null, sessions: [{ id: "s", label: "Chrome on Windows", scopes: ["admin"], lastSeenAt: NOW - 60_000 }] },
+ });
+ const live = Object.fromEntries(devices.map((device) => [device.id, Boolean(device.live)]));
+ expect(live).toMatchObject({ "place:a": true, "place:b": false, "phone:on": true, "phone:off": false, "session:s": false });
+ });
+
+ it("groups the map by what each device is, in one fixed order, this place apart", () => {
+ const devices = build({
+ places: places([{ id: "home", kind: "remote", name: "My Cloud", origin: "https://a.mausbot.cloud", home: true }, { id: "mini", kind: "remote", name: "Mac mini", origin: "http://mini.tail1.ts.net:8799" }]),
companion: { devices: [phone("a", "Phone", { route: "wifi" })], connectedDeviceIds: ["a"] },
+ vps: [{ alias: "gpu" }],
});
- expect(groupByRoute(devices).map((group) => [group.route, group.devices.map((device) => device.id)])).toEqual([
- ["tailscale", ["place:mini"]], ["local", ["phone:a"]], ["cloud", ["place:home"]],
+ expect(groupByKind(devices).map((group) => [group.group, group.devices.map((device) => device.id)])).toEqual([
+ ["phones", ["phone:a"]], ["computers", ["place:mini"]], ["servers", ["place:home", "vps:gpu"]],
]);
+ expect(groupByKind(build({}))).toEqual([]);
+ });
+});
+
+describe("the bots on each device", () => {
+ const row = (botId: string, kind: BotComputerRow["kind"], computerId: string | null, state: BotComputerRow["state"], over: Partial<BotComputerRow> = {}): BotComputerRow =>
+ ({ botId, kind, computerId, name: null, state, stateAt: state === "unknown" ? null : NOW, ...over });
+ const names: Record<string, string> = { b1: "Scout", b2: "Writer", b3: "Builder" };
+ const named = (id: string) => names[id] ?? null;
+ const devices = () => build({ vps: [{ alias: "gpu", name: "GPU box" }] });
+ setLocale("en");
+
+ it("puts each bot on the device it works on, once, and makes a device of each cloud desktop", () => {
+ const out = withBots(devices(), [
+ row("b1", "local", "local", "ready"), row("b1", "local", "local", "ready", { threadId: "t1" }), row("b2", "vm", "vm:b2", "asleep"),
+ row("b3", "vps", "vps:gpu/omb-b3", "ready", { vps: { serverId: vpsServerId("gpu"), alias: "gpu", container: "omb-b3" } }),
+ row("b2", "cloud", "cloud:b2", "asleep"), row("b3", "browser", null, "unknown"), row("b1", "auto", null, "unknown"),
+ ], "computer", named);
+ expect(Object.fromEntries(out.map((device) => [device.id, device.bots ?? []]))).toEqual({ here: ["b1", "b2"], "vps:gpu": ["b3"], "cloud:b2": ["b2"] });
+ expect(out.at(-1)).toMatchObject({ kind: "vm", name: "Writer’s cloud desktop", status: "offline", desktop: "asleep", route: "cloud" });
+ });
+
+ it("shows no state for a cloud desktop nothing knows about, and no device for a computer the server cannot name", () => {
+ const out = withBots(devices(), [row("b1", "cloud", "cloud:team-1", "unknown", { name: "Team desktop" }), row("b2", "cloud", "cloud:b2", "none"), row("b3", "auto", null, "unknown")], "computer", () => null);
+ expect(out.slice(-2).map((device) => [device.name, device.status, device.desktop])).toEqual([["Team desktop", "unknown", undefined], ["Cloud desktop", "unknown", undefined]]);
+ });
+
+ it("follows Auto to the place it settled on, and leaves a bot on this computer out on a Cloud's page", () => {
+ const out = withBots(devices(), [row("b1", "auto", "local", "ready", { autoKind: "local" }), row("b2", "local", "local", "ready")], "cloud", named);
+ expect(out.find((device) => device.here)?.bots).toBeUndefined();
+ expect(withBots(devices(), [row("b1", "auto", "local", "ready", { autoKind: "local" })], "computer", named)[0]!.bots).toEqual(["b1"]);
+ });
+
+ it("draws nothing extra when the list is empty, refused or missing", () => {
+ expect(withBots(devices(), [], "computer", named)).toEqual(devices());
+ expect(withBots(devices(), null, "computer", named)).toEqual(devices());
});
});
diff --git a/src/lib/devices.ts b/src/lib/devices.ts
index 2214753279..3681d97244 100644
--- a/src/lib/devices.ts
+++ b/src/lib/devices.ts
@@ -1,9 +1,10 @@
import { serverTransport } from "../../electron/server-address.mjs";
+import { vpsServerId, type BotComputerState } from "../../shared/bot-computers";
import type { ServerInstall, ServerStatus } from "../../electron/server-status.mjs";
import type { CompanionState, PhoneDevice } from "./companion-types";
import type { PublicPhone } from "./phones";
-/** What a device is, for its icon and its group in the list. `vm` is a bot's own computer. */
+/** What a device is, for its icon and its group on the map. `vm` is a bot's cloud desktop. */
export type DeviceKind = "laptop" | "desktop" | "server" | "cloud" | "phone" | "vm";
/** `unknown`: nothing says how it is right now (a Cloud the Admin runs, a server bots reach over SSH). */
export type DeviceStatus = "online" | "offline" | "attention" | "unknown";
@@ -20,7 +21,8 @@ export type DeviceSource =
| { type: "phone-app"; id: string }
| { type: "session"; id: string }
| { type: "lent"; id: string }
- | { type: "vps"; id: string };
+ | { type: "vps"; id: string }
+ | { type: "desktop"; id: string };
export type DeviceAction =
| { type: "switch"; placeId: string }
@@ -55,6 +57,12 @@ export interface Device {
home?: true;
/** This desktop lets that place's bots use it (Share this computer is on). */
usesThisComputer?: boolean;
+ /** Connected at this moment (a phone on its link now, a place this app is connected to), not merely seen lately. */
+ live?: true;
+ /** The bots that work on it, by id, from `GET /api/computers/bots`. */
+ bots?: string[];
+ /** A cloud desktop's last-known state; absent while nothing says. */
+ desktop?: Exclude<BotComputerState, "none" | "unknown">;
actions: DeviceAction[];
}
@@ -157,7 +165,7 @@ function fromPlace(entry: SavedPlace, status: ServerStatus | undefined, lends: b
id: `place:${entry.id}`, kind: entry.home || entry.cloud ? "cloud" : MINI_LABEL.test(entry.name) ? "desktop" : "server", name: entry.name, ...state, route, routes: [route],
...(hand && status?.version ? { version: status.version } : {}), ...(hand && entry.origin ? { address: entry.origin } : {}),
sources: [{ type: "place", id: entry.id }], canRunBots: true, canHostComputer: false, ...(entry.home ? { home: true as const } : {}),
- ...(lends ? { usesThisComputer: true } : {}), actions,
+ ...(lends ? { usesThisComputer: true } : {}), ...(state.status === "online" ? { live: true as const } : {}), actions,
};
}
@@ -170,8 +178,9 @@ function phoneRoute(device: PhoneDevice, routes: CompanionState["routes"] | unde
function fromPhone(device: PhoneDevice, connected: ReadonlySet<string>, routes: CompanionState["routes"] | undefined): Device {
const route = phoneRoute(device, routes);
+ const now = connected.has(device.id) || Boolean(device.route);
return {
- id: `phone:${device.id}`, kind: "phone", name: device.name, status: connected.has(device.id) || device.route ? "online" : "offline",
+ id: `phone:${device.id}`, kind: "phone", name: device.name, status: now ? "online" : "offline", ...(now ? { live: true as const } : {}),
route, routes: [route], lastSeen: device.lastSeenAt, sources: [{ type: "phone", id: device.id }], canRunBots: false, canHostComputer: false,
actions: [{ type: "remove", source: { type: "phone", id: device.id } }, { type: "manage", page: "phone", anchor: "paired" }],
};
@@ -179,7 +188,8 @@ function fromPhone(device: PhoneDevice, connected: ReadonlySet<string>, routes:
function fromPhoneApp(phone: PublicPhone): Device {
return {
- id: `phone-app:${phone.key}`, kind: "phone", name: phone.registration.name, status: phone.online ? "online" : "offline", route: "paired", routes: ["paired"],
+ id: `phone-app:${phone.key}`, kind: "phone", name: phone.registration.name, status: phone.online ? "online" : "offline", ...(phone.online ? { live: true as const } : {}),
+ route: "paired", routes: ["paired"],
lastSeen: phone.seen, version: phone.registration.appVersion, sources: [{ type: "phone-app", id: phone.key }], canRunBots: false, canHostComputer: false,
actions: [{ type: "remove", source: { type: "phone-app", id: phone.key } }],
};
@@ -196,15 +206,15 @@ function fromSession(session: SignedInDevice, route: DeviceRoute, now: number):
function fromLent(computer: LentDevice, route: DeviceRoute): Device {
return {
- id: `lent:${computer.id}`, kind: "laptop", name: computer.name, status: computer.online ? "online" : "offline", route, routes: [route],
+ id: `lent:${computer.id}`, kind: "laptop", name: computer.name, status: computer.online ? "online" : "offline", ...(computer.online ? { live: true as const } : {}), route, routes: [route],
lastSeen: computer.lastSeenAt, sources: [{ type: "lent", id: computer.id }], canRunBots: false, canHostComputer: true, actions: [],
};
}
function fromVps({ alias, name }: { alias: string; name?: string }): Device {
return {
- id: `vps:${alias}`, kind: "server", name: name?.trim() || alias, status: "unknown", route: "ssh", routes: ["ssh"], sources: [{ type: "vps", id: alias }],
- canRunBots: false, canHostComputer: true, actions: [{ type: "manage", page: "ai", anchor: "ai-keys" }],
+ id: vpsServerId(alias), kind: "server", name: name?.trim() || alias, status: "unknown", route: "ssh", routes: ["ssh"], sources: [{ type: "vps", id: alias }],
+ canRunBots: false, canHostComputer: true, actions: [],
};
}
@@ -218,6 +228,7 @@ function join(into: Device, other: Device): Device {
const seen = Math.max(into.lastSeen ?? 0, other.lastSeen ?? 0);
return {
...into, status, note: status === into.status ? into.note : other.note, routes: [...new Set([...into.routes, ...other.routes])],
+ ...(into.live || other.live ? { live: true as const } : {}),
...(seen ? { lastSeen: seen } : {}), version: into.version ?? other.version, address: into.address ?? other.address,
sources: [...into.sources, ...other.sources], canRunBots: into.canRunBots || other.canRunBots, canHostComputer: into.canHostComputer || other.canHostComputer,
actions: [...into.actions, ...other.actions.filter((action) => action.type === "remove" || !into.actions.some((mine) => mine.type === action.type))],
@@ -301,18 +312,14 @@ export function privateNetwork(companion: Pick<CompanionState, "routes" | "tailn
return { state: "ready", name: route.name, shared };
}
-/** A device inside the private network's group on the map: on it now, or reached over it. */
-export const onPrivateNetwork = (device: Device): boolean => device.route === "tailscale";
-
-/** The groups the map draws below this place, in a fixed order, each with its devices; empty groups are left out. */
-export const ROUTE_ORDER: readonly DeviceRoute[] = ["tailscale", "local", "relay", "cloud", "internet", "paired", "ssh"];
-
-export function groupByRoute(devices: readonly Device[]): Array<{ route: DeviceRoute; devices: Device[] }> {
- return ROUTE_ORDER.map((route) => ({ route, devices: devices.filter((device) => !device.here && device.route === route) }))
- .filter((group) => group.devices.length > 0);
-}
-
-/** The list's groups under the map: what a person calls them. */
+/** The map's groups, by what a person calls each device. */
export type DeviceGroup = "computers" | "servers" | "phones";
+export const GROUP_ORDER: readonly DeviceGroup[] = ["phones", "computers", "servers"];
export const deviceGroup = (device: Device): DeviceGroup =>
device.kind === "phone" ? "phones" : device.kind === "laptop" || device.kind === "desktop" ? "computers" : "servers";
+
+/** The groups the map draws around this place, in a fixed order; empty groups are left out. */
+export function groupByKind(devices: readonly Device[]): Array<{ group: DeviceGroup; devices: Device[] }> {
+ return GROUP_ORDER.map((group) => ({ group, devices: devices.filter((device) => !device.here && deviceGroup(device) === group) }))
+ .filter((entry) => entry.devices.length > 0);
+}
diff --git a/src/lib/use-devices.ts b/src/lib/use-devices.ts
index 8d5e1d9c9b..23ad0235ab 100644
--- a/src/lib/use-devices.ts
+++ b/src/lib/use-devices.ts
@@ -3,8 +3,10 @@ import type { ServerStatus } from "../../electron/server-status.mjs";
import { api } from "@/state/api";
import { useStoreSelector } from "@/state/store-select";
import { desktopAppVersion } from "./app-links";
+import { fetchBotComputers, type BotComputerRow } from "./bot-computers";
import { companionBridge } from "./companion-bridge";
import type { CompanionState } from "./companion-types";
+import { withBots } from "./device-bots";
import { buildDevices, type Device, type DeviceSources, type LentDevice, type SignedInDevice } from "./devices";
import type { PublicPhone } from "./phones";
import { isOwnerOrAdmin } from "./session";
@@ -29,6 +31,7 @@ export interface DevicesView {
* link live. `client`: this app drives another computer, which lists its own devices. */
export function useDevices({ here, client, name, kind }: { here: boolean; client: boolean; name: string; kind: DeviceSources["here"]["kind"] }): DevicesView {
const vpsConfig = useStoreSelector((state) => state.config?.vps);
+ const bots = useStoreSelector((state) => state.bots);
const [places, setPlaces] = useState<Places | null>(null);
const [statuses, setStatuses] = useState<ServerStatus[]>([]);
const [lending, setLending] = useState<DeviceSources["lending"]>(null);
@@ -36,6 +39,7 @@ export function useDevices({ here, client, name, kind }: { here: boolean; client
const [phoneApps, setPhoneApps] = useState<PublicPhone[] | null>(null);
const [sessions, setSessions] = useState<DeviceSources["sessions"]>(null);
const [lent, setLent] = useState<LentDevice[] | null>(null);
+ const [botRows, setBotRows] = useState<BotComputerRow[] | null>(null);
const [answered, setAnswered] = useState(false);
const alive = useRef(true);
@@ -54,6 +58,9 @@ export function useDevices({ here, client, name, kind }: { here: boolean; client
admin ? api<{ phones?: PublicPhone[] }>("/api/phones", { background: true }).then((body) => { if (alive.current) setPhoneApps(body.phones ?? []); }) : undefined,
admin ? api<{ sessions?: SignedInDevice[]; current?: string | null }>("/api/auth/sessions", { background: true })
.then((body) => { if (alive.current) setSessions({ sessions: Array.isArray(body.sessions) ? body.sessions : [], current: typeof body.current === "string" ? body.current : null }); }) : undefined,
+ // Which computer each bot works on: an admin route too, read in the background so a sleeping Cloud stays asleep.
+ admin ? fetchBotComputers({ background: true })
+ .then((body) => { if (alive.current) setBotRows(Array.isArray(body.rows) ? body.rows : null); }, () => { if (alive.current) setBotRows(null); }) : undefined,
// A 404 is a place that lends no computers (the family is off for this request).
api<{ known?: LentDevice[] }>("/api/shared-computers", { background: true })
.then((body) => { if (alive.current) setLent(Array.isArray(body.known) ? body.known : []); }, () => { if (alive.current) setLent(null); }),
@@ -75,10 +82,10 @@ export function useDevices({ here, client, name, kind }: { here: boolean; client
return [...(alias ? [{ alias }] : []), ...servers.map((server) => ({ alias: server.sshAlias, name: server.name }))];
}, [vpsConfig]);
- const devices = useMemo(() => buildDevices({
+ const devices = useMemo(() => withBots(buildDevices({
here: { name, kind, version: desktopAppVersion(), desktop: typeof window !== "undefined" && Boolean(window.ogb) },
places, statuses, lending, companion, phoneApps, sessions, lent, vps,
- }), [name, kind, places, statuses, lending, companion, phoneApps, sessions, lent, vps]);
+ }), botRows, kind, (botId) => bots.find((bot) => bot.id === botId)?.name ?? null), [name, kind, places, statuses, lending, companion, phoneApps, sessions, lent, vps, botRows, bots]);
return { devices, companion, loaded: answered, refresh: () => void read() };
}
diff --git a/src/locales/de.json b/src/locales/de.json
index ec554e7efb..0e815eb6e6 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -3707,7 +3707,6 @@
"devicesPage.kind.server": "Dein eigener Server",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Telefon",
- "devicesPage.kind.vm": "Computer des Bots",
"devicesPage.group.computers": "Computer",
"devicesPage.group.servers": "Clouds und eigene Server",
"devicesPage.group.phones": "Telefone",
diff --git a/src/locales/en.json b/src/locales/en.json
index 9fd29fd621..79e7df989a 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -11054,6 +11054,13 @@
"devicesPage.status.seen": "Seen {when}",
"devicesPage.status.ssh": "Bots work on it",
"devicesPage.status.unknown": "Not checked",
+ "devicesPage.desktopOf": "{name}’s cloud desktop",
+ "devicesPage.desktop.ready": "Awake",
+ "devicesPage.desktop.asleep": "Asleep",
+ "devicesPage.desktop.starting": "Starting…",
+ "devicesPage.bots.on": "Bots here: {names}",
+ "devicesPage.bots.title": "Bots that work here",
+ "devicesPage.tile.update": "Update…",
"devicesPage.note.update": "Update it",
"devicesPage.note.signedOut": "Pair it again",
"devicesPage.note.insecure": "Needs a safe address",
@@ -11072,7 +11079,7 @@
"devicesPage.kind.server": "Your own server",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Phone",
- "devicesPage.kind.vm": "Bot’s computer",
+ "devicesPage.kind.cloudDesktop": "Cloud desktop",
"devicesPage.group.computers": "Computers",
"devicesPage.group.servers": "Clouds and your own servers",
"devicesPage.group.phones": "Phones",
diff --git a/src/locales/es.json b/src/locales/es.json
index e79cb3e695..45189c10bd 100644
--- a/src/locales/es.json
+++ b/src/locales/es.json
@@ -6100,7 +6100,6 @@
"devicesPage.kind.server": "Tu propio servidor",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Teléfono",
- "devicesPage.kind.vm": "Ordenador del bot",
"devicesPage.group.computers": "Ordenadores",
"devicesPage.group.servers": "Clouds y tus propios servidores",
"devicesPage.group.phones": "Teléfonos",
diff --git a/src/locales/fr.json b/src/locales/fr.json
index ff7d1a6628..aab8d608e5 100644
--- a/src/locales/fr.json
+++ b/src/locales/fr.json
@@ -3444,7 +3444,6 @@
"devicesPage.kind.server": "Votre propre serveur",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Téléphone",
- "devicesPage.kind.vm": "Ordinateur du bot",
"devicesPage.group.computers": "Ordinateurs",
"devicesPage.group.servers": "Clouds et vos propres serveurs",
"devicesPage.group.phones": "Téléphones",
diff --git a/src/locales/hi.json b/src/locales/hi.json
index c6c640445d..b63f5c071e 100644
--- a/src/locales/hi.json
+++ b/src/locales/hi.json
@@ -3295,7 +3295,6 @@
"devicesPage.kind.server": "आपका अपना सर्वर",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "फ़ोन",
- "devicesPage.kind.vm": "बॉट का कंप्यूटर",
"devicesPage.group.computers": "कंप्यूटर",
"devicesPage.group.servers": "Cloud और आपके अपने सर्वर",
"devicesPage.group.phones": "फ़ोन",
diff --git a/src/locales/it.json b/src/locales/it.json
index 17506182b5..95bf9b2b78 100644
--- a/src/locales/it.json
+++ b/src/locales/it.json
@@ -10883,7 +10883,6 @@
"devicesPage.kind.server": "Il tuo server",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Telefono",
- "devicesPage.kind.vm": "Computer del bot",
"devicesPage.group.computers": "Computer",
"devicesPage.group.servers": "Cloud e i tuoi server",
"devicesPage.group.phones": "Telefoni",
diff --git a/src/locales/ja.json b/src/locales/ja.json
index bab907ff6f..c5921751b5 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -7699,7 +7699,6 @@
"devicesPage.kind.server": "自分のサーバー",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "スマホ",
- "devicesPage.kind.vm": "ボットのコンピューター",
"devicesPage.group.computers": "コンピューター",
"devicesPage.group.servers": "Cloud と自分のサーバー",
"devicesPage.group.phones": "スマホ",
diff --git a/src/locales/ko.json b/src/locales/ko.json
index 13ca184e63..1a94c5fe9e 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -7372,7 +7372,6 @@
"devicesPage.kind.server": "내 서버",
"devicesPage.kind.cloud": "클라우드",
"devicesPage.kind.phone": "휴대폰",
- "devicesPage.kind.vm": "봇의 컴퓨터",
"devicesPage.group.computers": "컴퓨터",
"devicesPage.group.servers": "클라우드 및 내 서버",
"devicesPage.group.phones": "휴대폰",
diff --git a/src/locales/pl.json b/src/locales/pl.json
index bf2d8f227f..ea40e910c4 100644
--- a/src/locales/pl.json
+++ b/src/locales/pl.json
@@ -6794,7 +6794,6 @@
"devicesPage.kind.server": "Własny serwer",
"devicesPage.kind.cloud": "Chmura",
"devicesPage.kind.phone": "Telefon",
- "devicesPage.kind.vm": "Komputer bota",
"devicesPage.group.computers": "Komputery",
"devicesPage.group.servers": "Chmury i własne serwery",
"devicesPage.group.phones": "Telefony",
diff --git a/src/locales/pt-br.json b/src/locales/pt-br.json
index 5f3f82e0e3..be0d3a051d 100644
--- a/src/locales/pt-br.json
+++ b/src/locales/pt-br.json
@@ -10980,6 +10980,13 @@
"devicesPage.status.seen": "Visto {when}",
"devicesPage.status.ssh": "Os bots trabalham nele",
"devicesPage.status.unknown": "Não verificado",
+ "devicesPage.desktopOf": "Desktop na nuvem de {name}",
+ "devicesPage.desktop.ready": "Ativo",
+ "devicesPage.desktop.asleep": "Em repouso",
+ "devicesPage.desktop.starting": "Iniciando…",
+ "devicesPage.bots.on": "Bots aqui: {names}",
+ "devicesPage.bots.title": "Bots que trabalham aqui",
+ "devicesPage.tile.update": "Atualizar…",
"devicesPage.note.update": "Atualize",
"devicesPage.note.signedOut": "Pareie de novo",
"devicesPage.note.insecure": "Precisa de um endereço seguro",
@@ -10998,7 +11005,7 @@
"devicesPage.kind.server": "Seu próprio servidor",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Celular",
- "devicesPage.kind.vm": "Computador do bot",
+ "devicesPage.kind.cloudDesktop": "Desktop na nuvem",
"devicesPage.group.computers": "Computadores",
"devicesPage.group.servers": "Clouds e seus próprios servidores",
"devicesPage.group.phones": "Celulares",
diff --git a/src/locales/ru.json b/src/locales/ru.json
index 6d10c73305..5d9964c1b5 100644
--- a/src/locales/ru.json
+++ b/src/locales/ru.json
@@ -6855,7 +6855,6 @@
"devicesPage.kind.server": "Свой сервер",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Телефон",
- "devicesPage.kind.vm": "Компьютер бота",
"devicesPage.group.computers": "Компьютеры",
"devicesPage.group.servers": "Cloud и свои серверы",
"devicesPage.group.phones": "Телефоны",
diff --git a/src/locales/tr.json b/src/locales/tr.json
index aa7c872e91..36f5a3db2d 100644
--- a/src/locales/tr.json
+++ b/src/locales/tr.json
@@ -5592,7 +5592,6 @@
"devicesPage.kind.server": "Kendi sunucunuz",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Telefon",
- "devicesPage.kind.vm": "Botun bilgisayarı",
"devicesPage.group.computers": "Bilgisayarlar",
"devicesPage.group.servers": "Cloud'lar ve kendi sunucularınız",
"devicesPage.group.phones": "Telefonlar",
diff --git a/src/locales/uk.json b/src/locales/uk.json
index 12a537a8f7..75fa43f94b 100644
--- a/src/locales/uk.json
+++ b/src/locales/uk.json
@@ -3730,7 +3730,6 @@
"devicesPage.kind.server": "Власний сервер",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Телефон",
- "devicesPage.kind.vm": "Комп’ютер бота",
"devicesPage.group.computers": "Комп’ютери",
"devicesPage.group.servers": "Cloud і власні сервери",
"devicesPage.group.phones": "Телефони",
diff --git a/src/locales/vi.json b/src/locales/vi.json
index 5c78decbc9..c4df7eb23c 100644
--- a/src/locales/vi.json
+++ b/src/locales/vi.json
@@ -5592,7 +5592,6 @@
"devicesPage.kind.server": "Máy chủ của riêng bạn",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "Điện thoại",
- "devicesPage.kind.vm": "Máy tính của bot",
"devicesPage.group.computers": "Máy tính",
"devicesPage.group.servers": "Cloud và máy chủ của riêng bạn",
"devicesPage.group.phones": "Điện thoại",
diff --git a/src/locales/zh-tw.json b/src/locales/zh-tw.json
index d67bc17253..a7933dfbff 100644
--- a/src/locales/zh-tw.json
+++ b/src/locales/zh-tw.json
@@ -9935,7 +9935,6 @@
"devicesPage.kind.server": "你自己的伺服器",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "手機",
- "devicesPage.kind.vm": "機器人的電腦",
"devicesPage.group.computers": "電腦",
"devicesPage.group.servers": "Cloud 和你自己的伺服器",
"devicesPage.group.phones": "手機",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 90df794353..95586f04fa 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -8240,7 +8240,6 @@
"devicesPage.kind.server": "你自己的服务器",
"devicesPage.kind.cloud": "Cloud",
"devicesPage.kind.phone": "手机",
- "devicesPage.kind.vm": "机器人的电脑",
"devicesPage.group.computers": "电脑",
"devicesPage.group.servers": "Cloud 和你自己的服务器",
"devicesPage.group.phones": "手机",
diff --git a/src/styles.css b/src/styles.css
index f1104deb46..8995e57076 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -2615,6 +2615,7 @@ html[data-cloud-intent-morph] [data-tour="composer"] { view-transition-name: clo
without touching system settings; the welcome flow also reads it to skip
its view transitions. Mirrors the media block above for its own classes. */
:root[data-reduced-motion="true"] .animate-rise,
+:root[data-reduced-motion="true"] .animate-link-flow,
:root[data-reduced-motion="true"] .animate-spot-in,
:root[data-reduced-motion="true"] .animate-pop-in,
:root[data-reduced-motion="true"] .animate-pop-out,