Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Console devices: Settings → Devices cards, device page in the design's cards, device wording

Massimo Cairo8e9851b18a9a
diff --git a/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts b/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts
index 7ba81fe77..2deaf6f26 100644
--- a/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts
+++ b/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts
@@ -5,7 +5,6 @@ import { chatView } from '@renderer/features/chats/chat-view';
import { connectorsView } from '@renderer/features/connectors/connectors-view';
import { locationView } from '@renderer/features/locations/view';
import { machineView } from '@renderer/features/machines/machine-view';
-import { machinesView } from '@renderer/features/machines/machines-view';
import { managedAgentView } from '@renderer/features/managed-agents/managed-agent-view';
import { remoteHostView } from '@renderer/features/remote-hosts/views/remote-host-view';
import { remoteHostsView } from '@renderer/features/remote-hosts/views/remote-hosts-view';
@@ -40,7 +39,6 @@ export const views = {
server: serverView,
managedServer: managedServerView,
serverAgents: serverAgentsView,
- machines: machinesView,
machine: machineView,
connectors: connectorsView,
serverRooms: serverRoomsView,
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/add-machine-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/add-machine-modal.tsx
index a17b58542..dcaa68a76 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/add-machine-modal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/add-machine-modal.tsx
@@ -50,7 +50,7 @@ export function AddMachineModal({ serverId, onClose }: Props) {
return (
<>
<DialogHeader>
- <DialogTitle>Add a machine</DialogTitle>
+ <DialogTitle>Add a device</DialogTitle>
</DialogHeader>
<DialogContentArea className="space-y-4 pt-0">
<DialogDescription>
@@ -73,7 +73,7 @@ export function AddMachineModal({ serverId, onClose }: Props) {
<Input
value={name}
onChange={(e) => setName(e.target.value)}
- placeholder="Defaults to the machine's host name"
+ placeholder="Defaults to the device's host name"
/>
{nameTooLong && (
<p className="mt-1 text-xs text-destructive">
@@ -99,7 +99,7 @@ export function AddMachineModal({ serverId, onClose }: Props) {
{issued.loopback && (
<p className="rounded-md border border-border bg-background-1 px-3 py-2 text-xs text-foreground-muted">
This server is at {issued.serverUrl}, which only this computer can reach. Another
- machine needs an address it can reach Switch at: change <code>--server</code> to
+ device needs an address it can reach Switch at: change <code>--server</code> to
that.
</p>
)}
@@ -113,7 +113,7 @@ export function AddMachineModal({ serverId, onClose }: Props) {
<CommandBlock
title="Install, enroll and start"
command={installCommand(issued.serverUrl, issued.code, machine)}
- note="Installs the newest controller with npm, enrolls the machine, and runs the controller as a service of your user."
+ note="Installs the newest controller with npm, enrolls the device, and runs the controller as a service of your user."
/>
<CommandBlock
title="Already installed"
@@ -125,8 +125,8 @@ export function AddMachineModal({ serverId, onClose }: Props) {
<p className="text-xs text-foreground-muted">
The code is single use and valid until{' '}
- {new Date(issued.expiresAt).toLocaleTimeString()}. The machine shows up in Your
- Machines once its controller reports; if it does not, run{' '}
+ {new Date(issued.expiresAt).toLocaleTimeString()}. The device shows up in Settings →
+ Devices once its controller reports; if it does not, run{' '}
<code>switch-agent-controller doctor</code> on it. A computer you reach over SSH can
also join without this: create an agent on it, and Switch Console sets its controller
up.
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/collapsible-section.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/collapsible-section.tsx
deleted file mode 100644
index ebafe6749..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/collapsible-section.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import { ChevronRightIcon } from 'lucide-react';
-import { type ReactNode, useId, useState } from 'react';
-import { cn } from '@renderer/utils/utils';
-
-/**
- * A section of a machine's page that folds away under its title, with the
- * caret beside the title as the chat's thinking line has it.
- */
-export function CollapsibleSection({
- title,
- defaultOpen,
- children,
-}: {
- title: string;
- /** Whether it starts open. */
- defaultOpen: boolean;
- children: ReactNode;
-}) {
- const [open, setOpen] = useState(defaultOpen);
- const contentId = useId();
- return (
- <section>
- <h3 className="text-[11.5px] text-[#8A8A8A]">
- <button
- type="button"
- aria-expanded={open}
- aria-controls={contentId}
- onClick={() => setOpen((shown) => !shown)}
- className="focus-visible:ring-ring -mx-1 inline-flex cursor-pointer items-center gap-1 rounded px-1 transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:outline-none"
- >
- {title}
- <ChevronRightIcon
- aria-hidden
- className={cn(
- 'size-3 shrink-0 transition-transform motion-reduce:transition-none',
- open && 'rotate-90'
- )}
- />
- </button>
- </h3>
- <div id={contentId} hidden={!open}>
- {children}
- </div>
- </section>
- );
-}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/detail-card.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/detail-card.tsx
new file mode 100644
index 000000000..6b443f625
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/detail-card.tsx
@@ -0,0 +1,22 @@
+import { cn } from '@renderer/utils/utils';
+
+/** One titled card of a device's page. */
+export function Card({
+ title,
+ subtitle,
+ children,
+ className,
+}: {
+ title: React.ReactNode;
+ subtitle?: React.ReactNode;
+ children: React.ReactNode;
+ className?: string;
+}) {
+ return (
+ <section className={cn('rounded-[10px] border border-border bg-background p-4', className)}>
+ <h3 className="text-[13px] font-semibold text-foreground">{title}</h3>
+ {subtitle && <p className="text-[12px] text-[var(--fg-dim)]">{subtitle}</p>}
+ <div className="mt-3">{children}</div>
+ </section>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/devices-settings-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/devices-settings-page.tsx
new file mode 100644
index 000000000..faf8d2d0b
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/devices-settings-page.tsx
@@ -0,0 +1,273 @@
+import { MoreVertical, Pencil, Plus, Trash2 } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useState } from 'react';
+import { useManagedAgents } from '@renderer/features/managed-agents/use-managed-agents';
+import { isFrozenServer } from '@renderer/features/switch-servers/managed-server-state';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';
+import { PageHeader } from '@renderer/lib/components/page-header';
+import { failureText } from '@renderer/lib/errors/describe-failure';
+import { useNavigate } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { Button } from '@renderer/lib/ui/button';
+import { DisclosureRow } from '@renderer/lib/ui/disclosure-row';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@renderer/lib/ui/dropdown-menu';
+import { Spinner } from '@renderer/lib/ui/spinner';
+import { ToggleGroup, ToggleGroupItem } from '@renderer/lib/ui/toggle-group';
+import { cn } from '@renderer/utils/utils';
+import type { MachineDetail } from '@shared/core/managed-agents/managed-agents';
+import { MachineIcon, TONE_DOT } from './machine-marks';
+import {
+ arrangeMachines,
+ controllerRelease,
+ MACHINE_CATEGORY_LABELS,
+ type MachineCategory,
+ machineCategory,
+ machineConnection,
+} from './machine-state';
+import { useDeviceActions } from './use-device-actions';
+import { useMachineDetails } from './use-machines';
+
+type Filter = 'all' | MachineCategory;
+
+/**
+ * Settings → Devices: the computers that run the signed-in person's managed
+ * agents on the server the window is on, one card each, opening its page.
+ * The server returns the whole list in one response, unpaged, and only this
+ * person's own devices.
+ */
+export const DevicesSettingsPage = observer(function DevicesSettingsPage() {
+ const serverId = workspacesStore.activeServerId;
+ const server = switchServersStore.servers.find((s) => s.id === serverId);
+ const [filter, setFilter] = useState<Filter>('all');
+ const showAddMachineModal = useShowModal('addMachineModal');
+
+ return (
+ <>
+ <PageHeader
+ sticky
+ title="Devices"
+ description={`The devices that host your agents on ${server?.name ?? 'this server'}.`}
+ >
+ <div className="flex items-center justify-between gap-2">
+ <ToggleGroup
+ multiple={false}
+ value={[filter]}
+ onValueChange={([value]) => {
+ if (value) setFilter(value as Filter);
+ }}
+ >
+ <ToggleGroupItem value="all">All</ToggleGroupItem>
+ {(Object.keys(MACHINE_CATEGORY_LABELS) as MachineCategory[]).map((category) => (
+ <ToggleGroupItem key={category} value={category}>
+ {MACHINE_CATEGORY_LABELS[category]}
+ </ToggleGroupItem>
+ ))}
+ </ToggleGroup>
+ {serverId && (
+ <Button variant="outline" onClick={() => showAddMachineModal({ serverId })}>
+ <Plus className="size-4" />
+ Add device
+ </Button>
+ )}
+ </div>
+ </PageHeader>
+ {serverId === null ? (
+ <p className="pt-4 text-sm text-foreground-muted">Pick a workspace to see its devices.</p>
+ ) : (
+ <DevicesBody
+ serverId={serverId}
+ filter={filter}
+ frozen={!!server && isFrozenServer(server)}
+ />
+ )}
+ </>
+ );
+});
+
+function DevicesBody({
+ serverId,
+ filter,
+ frozen,
+}: {
+ serverId: string;
+ filter: Filter;
+ frozen: boolean;
+}) {
+ const machines = useMachineDetails(serverId);
+ const managed = useManagedAgents(serverId);
+ const [showRemoved, setShowRemoved] = useState(false);
+
+ if (machines.error && !frozen)
+ return (
+ <p role="alert" className="pt-4 text-sm text-destructive">
+ {failureText(machines.error, 'Could not load your devices.')}
+ </p>
+ );
+ if (machines.data === undefined) return <Spinner className="mt-4" />;
+ if (machines.data === null)
+ return (
+ <p className="pt-4 text-sm text-foreground-muted">
+ This server does not have agent management turned on.
+ </p>
+ );
+
+ const arranged = arrangeMachines(machines.data);
+ const shown = (list: MachineDetail[]) =>
+ filter === 'all' ? list : list.filter((machine) => machineCategory(machine) === filter);
+ const live = shown(arranged.live);
+ const removed = shown(arranged.removed);
+ const agentsOn = (machine: MachineDetail) =>
+ (managed.data ?? []).filter((agent) => agent.machine?.id === machine.id).length;
+
+ return (
+ <div className="flex flex-col gap-6 pt-4 pb-10">
+ {live.length === 0 ? (
+ <p className="text-sm text-foreground-muted">
+ {machines.data.length === 0
+ ? 'No devices yet. This computer joins when you run a managed agent on it, and so does an SSH host; a standalone machine joins once it is enrolled.'
+ : `No ${filter === 'all' ? '' : `${MACHINE_CATEGORY_LABELS[filter as MachineCategory].toLowerCase()} `}devices.`}
+ </p>
+ ) : (
+ <div className="grid grid-cols-2 gap-3">
+ {live.map((machine) => (
+ <DeviceCard
+ key={machine.id}
+ serverId={serverId}
+ machine={machine}
+ agentCount={agentsOn(machine)}
+ />
+ ))}
+ </div>
+ )}
+ {removed.length > 0 && (
+ <div>
+ <DisclosureRow
+ open={showRemoved}
+ title="Removed"
+ summary="Devices removed from Switch"
+ meta={removed.length}
+ onToggle={() => setShowRemoved((open) => !open)}
+ />
+ {showRemoved && (
+ <div className="mt-3 grid grid-cols-2 gap-3">
+ {removed.map((machine) => (
+ <DeviceCard
+ key={machine.id}
+ serverId={serverId}
+ machine={machine}
+ agentCount={agentsOn(machine)}
+ />
+ ))}
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
+
+/** One device: what it is, whether it is connected, its name, and what runs on it. */
+function DeviceCard({
+ serverId,
+ machine,
+ agentCount,
+}: {
+ serverId: string;
+ machine: MachineDetail;
+ agentCount: number;
+}) {
+ const { navigate } = useNavigate();
+ const connection = machineConnection(machine);
+ const badge = machine.state === 'revoked' ? null : controllerRelease(machine).badge;
+ const actions = useDeviceActions(serverId, machine, agentCount);
+ const open = () => navigate('machine', { serverId, machineId: machine.id, name: machine.name });
+
+ return (
+ <div
+ role="button"
+ tabIndex={0}
+ onClick={open}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' || e.key === ' ') {
+ e.preventDefault();
+ open();
+ }
+ }}
+ className="flex min-w-0 cursor-pointer flex-col gap-3 rounded-[10px] border border-border bg-background p-4 text-left transition-colors hover:bg-[var(--fill)]"
+ >
+ <div className="flex items-center gap-2">
+ <MachineIcon machine={machine} className="size-6 border-0 bg-transparent" />
+ <span
+ title={`${connection.label}: ${connection.title}`}
+ aria-label={connection.label}
+ className={cn('size-1.5 rounded-full', TONE_DOT[connection.tone])}
+ />
+ {badge && (
+ <span
+ title={controllerRelease(machine).title}
+ className="text-[11px] text-foreground-warning"
+ >
+ {badge.label}
+ </span>
+ )}
+ <span className="flex-1" />
+ {(actions.renamable || actions.removable) && (
+ // A click on the menu is not a click on the card.
+ <span onClick={(e) => e.stopPropagation()} onKeyDown={(e) => e.stopPropagation()}>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="sm"
+ className="size-7 p-0"
+ aria-label={`${machine.name} actions`}
+ >
+ <MoreVertical className="size-4" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
+ {actions.renamable && (
+ <DropdownMenuItem onClick={actions.rename}>
+ <Pencil className="size-4" />
+ Rename
+ </DropdownMenuItem>
+ )}
+ {actions.removable && (
+ <DropdownMenuItem variant="destructive" onClick={actions.remove}>
+ <Trash2 className="size-4" />
+ Remove…
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </span>
+ )}
+ </div>
+ <div className="min-w-0">
+ <div className="truncate text-sm text-foreground">
+ {machine.local?.kind === 'this-computer'
+ ? `${machine.name} (this computer)`
+ : machine.name}
+ </div>
+ <div className="truncate text-sm text-foreground-muted">
+ {agentCount === 0
+ ? 'No agents'
+ : `${agentCount} ${agentCount === 1 ? 'agent' : 'agents'}`}
+ </div>
+ </div>
+ {actions.error && (
+ <p role="alert" className="text-xs text-destructive">
+ {actions.error}
+ </p>
+ )}
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-details.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-details.tsx
index 58e2078c9..f94d2920b 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-details.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-details.tsx
@@ -1,6 +1,5 @@
-import { useQueryClient } from '@tanstack/react-query';
-import { Pencil, Plus, Trash2 } from 'lucide-react';
-import { useState } from 'react';
+import { format } from 'date-fns';
+import { ExternalLink, MoreHorizontal, Pencil, Plus, Trash2 } from 'lucide-react';
import { CopyButton } from '@renderer/features/admin/copy-button';
import { CloudMachineCard } from '@renderer/features/cloud-agents/cloud-machine-card';
import { useCloudMachines } from '@renderer/features/cloud-agents/use-cloud-agents';
@@ -8,21 +7,27 @@ import {
managedAgentLabel,
managedAgentState,
} from '@renderer/features/managed-agents/managed-agent-state';
-import { MANAGED_AGENTS_KEY } from '@renderer/features/managed-agents/use-managed-agents';
import type { ManagedTone } from '@renderer/features/switch-servers/managed-server-state';
-import { MessageBox, SectionLabel } from '@renderer/features/switch-servers/server-page-ui';
-import { agoLabel, sinceLabel } from '@renderer/features/switch-servers/server-times';
+import { MessageBox } from '@renderer/features/switch-servers/server-page-ui';
+import { agoLabel } from '@renderer/features/switch-servers/server-times';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
import { AgentAvatar } from '@renderer/lib/components/agent-avatar';
import { failureText } from '@renderer/lib/errors/describe-failure';
-import { rpc } from '@renderer/lib/ipc';
import { useNavigate } from '@renderer/lib/layout/navigation-provider';
import { useShowModal } from '@renderer/lib/modal/modal-provider';
import { Button } from '@renderer/lib/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@renderer/lib/ui/dropdown-menu';
+import { Progress } from '@renderer/lib/ui/progress';
import { formatBytes } from '@renderer/utils/formatBytes';
import { cn } from '@renderer/utils/utils';
import type { MachineDetail, ManagedAgentView } from '@shared/core/managed-agents/managed-agents';
import { providerDisplayName } from '@shared/core/providers/agent-provider-registry';
-import { CollapsibleSection } from './collapsible-section';
+import { Card } from './detail-card';
import { MachineIcon, TONE_DOT, TonePill } from './machine-marks';
import { MachineProviders } from './machine-providers';
import {
@@ -33,9 +38,8 @@ import {
machineNotices,
type MachineTone,
platformLabel,
- resourceLabel,
- sessionsLabel,
} from './machine-state';
+import { useDeviceActions } from './use-device-actions';
/** A notice's box, in the server page's hues. */
const NOTICE_TONE: Record<MachineTone, ManagedTone> = {
@@ -69,10 +73,9 @@ const PROCESS_TONE: Record<string, MachineTone> = {
};
/**
- * One machine's page: what it is and whether it is connected, anything that
- * needs doing about it, what it last reported, and the agents on it. Built
- * from the local server's status page pieces, the other page about one
- * computer.
+ * One device's page: what it is and whether it is connected, anything that
+ * needs doing about it, then its details, connection, system and software,
+ * the agents on it and its AI providers, each in a card.
*/
export function MachineDetails({
serverId,
@@ -85,100 +88,69 @@ export function MachineDetails({
placed: ManagedAgentView[];
}) {
const connection = machineConnection(machine);
- const platform = platformLabel(machine.platform);
const notices = machineNotices(machine);
const removed = machine.state === 'revoked';
const showAddAgentModal = useShowModal('addAgentModal');
- const showRenameModal = useShowModal('renameMachineModal');
- const showConfirm = useShowModal('confirmActionModal');
- const queryClient = useQueryClient();
- const [removeError, setRemoveError] = useState<string | null>(null);
- // Switch names the cloud machine; this computer and SSH hosts are this
- // Console's own to take away, which it does elsewhere.
- const renamable = !removed && !machine.cloud;
- const removable = !removed && !machine.cloud && machine.local === null;
-
- const confirmRemove = () =>
- showConfirm({
- title: `Remove ${machine.name}?`,
- description:
- placed.length === 0
- ? `${machine.name} stops running agents for you and cannot reconnect. To use it again, enroll it again.`
- : `${machine.name} stops running agents for you and cannot reconnect. The ${placed.length === 1 ? 'agent' : `${placed.length} agents`} on it stay placed on it and do not run until you move them.`,
- confirmLabel: 'Remove',
- onSuccess: () => {
- setRemoveError(null);
- rpc.managedAgents
- .removeMachine({ serverId, machineId: machine.id })
- .then(() => queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, serverId] }))
- .catch((error: unknown) =>
- setRemoveError(failureText(error, `Could not remove ${machine.name}.`))
- );
- },
- });
+ const actions = useDeviceActions(serverId, machine, placed.length);
+ const owner = switchServersStore.statusFor(serverId)?.user?.name ?? null;
return (
- <div className="space-y-[18px]">
- <header className="flex items-center gap-3">
- <MachineIcon machine={machine} className="rounded-[10px] border-0 bg-[var(--fill)]" />
+ <div className="space-y-4">
+ <header className="flex items-start gap-3">
+ <MachineIcon machine={machine} className="size-10 rounded-[10px]" />
<div className="min-w-0 flex-1">
<div className="flex min-w-0 items-center gap-2">
- <h2 className="truncate font-mono text-[17px] font-semibold text-foreground">
- {machine.name}
- </h2>
+ <h2 className="truncate text-[20px] font-semibold text-foreground">{machine.name}</h2>
+ <TonePill tone="idle" dot={false} label={machineKindLabel(machine)} />
<TonePill tone={connection.tone} label={connection.label} title={connection.title} />
</div>
<p className="truncate text-[13px] text-[var(--fg-dim)]">
- {[machineKindLabel(machine), platform].filter(Boolean).join(' · ')}
+ {[owner, machine.description].filter(Boolean).join(' · ')}
</p>
</div>
- {renamable && (
- <Button
- size="sm"
- variant="outline"
- onClick={() =>
- showRenameModal({
- serverId,
- machineId: machine.id,
- currentName: machine.name,
- currentDescription: machine.description,
- })
- }
- >
- <Pencil className="size-3.5" />
- Rename
- </Button>
- )}
- {removable && (
- <Button size="sm" variant="outline" onClick={confirmRemove}>
- <Trash2 className="size-3.5" />
- Remove
- </Button>
- )}
- {!removed && (
- <Button
- size="sm"
- variant="outline"
- // The new agent form lists an offline machine but cannot place an agent on it.
- disabled={machine.state !== 'online'}
- title={
- machine.state === 'online' ? undefined : 'It can take a new agent once it is online.'
- }
- onClick={() => showAddAgentModal({ entryPoint: 'machine_page', machineId: machine.id })}
- >
- <Plus className="size-4" />
- New agent
- </Button>
- )}
+ <div className="flex shrink-0 items-center gap-2">
+ {actions.renamable && (
+ <Button size="sm" variant="outline" onClick={actions.rename}>
+ <Pencil className="size-3.5" />
+ Rename
+ </Button>
+ )}
+ {!removed && (
+ <Button
+ size="sm"
+ variant="outline"
+ // The new agent form lists an offline device but cannot place an agent on it.
+ disabled={machine.state !== 'online'}
+ title={
+ machine.state === 'online'
+ ? undefined
+ : 'It can take a new agent once it is online.'
+ }
+ onClick={() =>
+ showAddAgentModal({ entryPoint: 'machine_page', machineId: machine.id })
+ }
+ >
+ <Plus className="size-4" />
+ New agent
+ </Button>
+ )}
+ {actions.removable && (
+ <Button
+ size="sm"
+ variant="outline"
+ className="text-foreground-error"
+ onClick={actions.remove}
+ >
+ <Trash2 className="size-3.5" />
+ Remove
+ </Button>
+ )}
+ </div>
</header>
- {machine.description && (
- <p className="text-[13px] whitespace-pre-line text-foreground">{machine.description}</p>
- )}
-
- {removeError && (
+ {actions.error && (
<p role="alert" className="text-sm text-destructive">
- {removeError}
+ {actions.error}
</p>
)}
@@ -188,15 +160,184 @@ export function MachineDetails({
</MessageBox>
))}
- <DetailsSection machine={machine} />
+ <DetailsCard machine={machine} owner={owner} />
+ {!removed && (
+ <div className="grid grid-cols-3 gap-4">
+ <ConnectionCard machine={machine} />
+ <SystemCard machine={machine} />
+ <SoftwareCard machine={machine} />
+ </div>
+ )}
{machine.cloud && !removed && <CloudMachineSection serverId={serverId} machine={machine} />}
+ {/* Kept on a removed device: its agents stay placed on it until they are moved. */}
+ <AgentsCard machine={machine} placed={placed} />
{!removed && <MachineProviders serverId={serverId} machine={machine} />}
- {/* Kept on a removed machine: its agents stay placed on it until they are moved. */}
- <AgentsSection machine={machine} placed={placed} />
</div>
);
}
+/** A label and its value side by side, as the Connection, System and Software cards list them. */
+function Row({ label, children }: { label: string; children: React.ReactNode }) {
+ return (
+ <div className="grid grid-cols-[110px_1fr] items-start gap-2 py-1 text-[13px]">
+ <dt className="text-[var(--fg-dim)]">{label}</dt>
+ <dd className="min-w-0 text-foreground">{children}</dd>
+ </div>
+ );
+}
+
+function DetailsCard({ machine, owner }: { machine: MachineDetail; owner: string | null }) {
+ const removedAt = machine.revokedAt ? format(new Date(machine.revokedAt), 'd MMM yyyy') : null;
+ return (
+ <Card title="Details">
+ <dl className="grid grid-cols-5 gap-4 text-[13px]">
+ <Fact label="Name">{machine.name}</Fact>
+ <Fact label="Description">{machine.description ?? '—'}</Fact>
+ <Fact label="Owner">{owner ?? '—'}</Fact>
+ <Fact label="Device type">{machineKindLabel(machine)}</Fact>
+ {removedAt ? (
+ <Fact label="Removed">{removedAt}</Fact>
+ ) : (
+ <Fact label="Added">
+ {machine.createdAt ? format(new Date(machine.createdAt), 'd MMM yyyy') : '—'}
+ </Fact>
+ )}
+ </dl>
+ </Card>
+ );
+}
+
+function Fact({ label, children }: { label: string; children: React.ReactNode }) {
+ return (
+ <div className="min-w-0">
+ <dt className="text-[12px] text-[var(--fg-dim)]">{label}</dt>
+ <dd className="mt-0.5 break-words text-foreground">{children}</dd>
+ </div>
+ );
+}
+
+function ConnectionCard({ machine }: { machine: MachineDetail }) {
+ const connection = machineConnection(machine);
+ const contact = lastContact(machine, new Date());
+ return (
+ <Card title="Connection">
+ <dl>
+ <Row label="State">
+ <TonePill tone={connection.tone} label={connection.label} title={connection.title} />
+ </Row>
+ <Row label="Last seen">
+ {machine.state === 'online' ? 'Now' : contact ? agoLabel(contact, new Date()) : 'Never'}
+ </Row>
+ {machine.local?.kind === 'ssh-host' && (
+ <Row label="SSH as">
+ <span className="break-all">{machine.local.sshHost}</span>
+ </Row>
+ )}
+ <Row label="Console sign-ins">
+ <TonePill
+ tone={machine.acceptsLogins ? 'ok' : 'idle'}
+ dot={false}
+ label={machine.acceptsLogins ? 'Yes' : 'No'}
+ />
+ </Row>
+ </dl>
+ {!machine.acceptsLogins && (
+ <p className="mt-2 text-[12px] text-[var(--fg-dim)]">
+ {machine.local?.kind === 'this-computer'
+ ? "It uses this computer's own provider sign-ins."
+ : 'Its controller has no key to take a sign-in with: providers sign in on the device itself.'}
+ </p>
+ )}
+ </Card>
+ );
+}
+
+function Usage({ free, total }: { free: number; total: number }) {
+ if (total <= 0) return <>—</>;
+ return (
+ <div>
+ {formatBytes(free)} free of {formatBytes(total)}
+ <Progress
+ value={Math.round(((total - free) / total) * 100)}
+ aria-label="Used"
+ className="mt-1.5"
+ />
+ </div>
+ );
+}
+
+function SystemCard({ machine }: { machine: MachineDetail }) {
+ const resources = machine.resources;
+ const platform = machine.platform;
+ return (
+ <Card title="System">
+ {!platform && !resources ? (
+ <p className="text-[13px] text-[var(--fg-dim)]">Not reported yet.</p>
+ ) : (
+ <dl>
+ {platform && (
+ <>
+ <Row label="Operating system">{platformLabel({ ...platform, arch: '' })}</Row>
+ <Row label="CPU">{platform.arch}</Row>
+ </>
+ )}
+ {resources && (
+ <>
+ <Row label="Disk">
+ <Usage free={resources.diskFreeBytes} total={resources.diskTotalBytes} />
+ </Row>
+ <Row label="Memory">
+ <Usage free={resources.memFreeBytes} total={resources.memTotalBytes} />
+ </Row>
+ <Row label="Sessions">
+ {resources.sessionsMax > 0
+ ? `${resources.sessionsRunning} of ${resources.sessionsMax} running`
+ : `${resources.sessionsRunning} running now`}
+ </Row>
+ </>
+ )}
+ </dl>
+ )}
+ </Card>
+ );
+}
+
+function SoftwareCard({ machine }: { machine: MachineDetail }) {
+ const release = controllerRelease(machine);
+ return (
+ <Card title="Software">
+ <dl>
+ <Row label="Version">
+ <span title={release.title} className="flex flex-wrap items-center gap-1.5">
+ {machine.version ?? 'Not reported'}
+ {release.badge && (
+ <TonePill tone={release.badge.tone} dot={false} label={release.badge.label} />
+ )}
+ </span>
+ </Row>
+ {machine.updatedBy && (
+ <Row label="Updates">
+ {machine.updatedBy === 'console' ? 'Updated with Switch Console' : 'Updates itself'}
+ </Row>
+ )}
+ {machine.workspacesDir && (
+ <Row label="Workspaces">
+ <span className="flex items-start gap-1">
+ <code
+ className="min-w-0 truncate font-[Menlo,ui-monospace,monospace] text-[11.5px] [direction:rtl]"
+ title={machine.workspacesDir}
+ >
+ <bdi>{machine.workspacesDir}</bdi>
+ </code>
+ <CopyButton value={machine.workspacesDir} />
+ </span>
+ </Row>
+ )}
+ </dl>
+ </Card>
+ );
+}
+
/**
* The Switch cloud machine's power and disk, and starting and stopping it, as
* Your Agents shows them: the cloud machine as Switch runs it, beside the
@@ -216,16 +357,11 @@ function CloudMachineSection({ serverId, machine }: { serverId: string; machine:
}
/**
- * The agents on the machine: those placed on it, each opening its page, and
- * any others it reports running, which this person cannot open.
+ * The agents on the device: those placed on it, each opening its page and
+ * movable to another device, and any others it reports running, which this
+ * person cannot open.
*/
-function AgentsSection({
- machine,
- placed,
-}: {
- machine: MachineDetail;
- placed: ManagedAgentView[];
-}) {
+function AgentsCard({ machine, placed }: { machine: MachineDetail; placed: ManagedAgentView[] }) {
const { navigate } = useNavigate();
const showMoveModal = useShowModal('moveAgentModal');
const unlisted = machine.agents.filter(
@@ -233,91 +369,135 @@ function AgentsSection({
);
const count = placed.length + unlisted.length;
return (
- <CollapsibleSection title={count === 0 ? 'Agents' : `Agents · ${count}`} defaultOpen>
- <div className="mt-1">
- {count === 0 && (
- <p className="py-[9px] text-[13px] text-[var(--fg-dim)]">No agents placed on it.</p>
- )}
- {placed.map((agent) => {
- const label = managedAgentLabel(agent);
- const state = managedAgentState(agent);
- const tone = AGENT_TONE[state.tone];
- const sessions =
- machine.agents.find((report) => report.agentId === agent.agentId)?.activeSessions ?? 0;
- const folder = agent.status?.directory ?? agent.definition.directory;
- return (
- <div
- key={agent.agentId}
- className="-mx-2 flex items-center gap-2 rounded-md border-b-[0.5px] border-[var(--hair-soft)] px-2 py-[5px] text-[13px] transition-colors hover:bg-[var(--sel-soft)]"
- >
- <button
- type="button"
- onClick={() =>
- navigate('managedAgent', {
- serverId: agent.serverId,
- agentId: agent.agentId,
- name: label,
- })
- }
- className="flex min-w-0 flex-1 cursor-pointer items-center gap-2.5 py-0.5 text-left"
- >
- <AgentAvatar
- name={label}
- iconUrl={agent.iconUrl}
- serverId={agent.serverId}
- size={20}
- />
- <span className="w-40 min-w-0 shrink-0 truncate text-foreground">{label}</span>
- <span
- className="min-w-0 flex-1 truncate font-[Menlo,ui-monospace,monospace] text-[11.5px] text-[var(--fg-dim)]"
- title={folder ?? undefined}
- >
- {folder ? shortFolder(folder, machine.workspacesDir) : ''}
- </span>
- <span className="shrink-0 text-[var(--fg-dim)]">
- {providerDisplayName(agent.definition.provider) ?? agent.definition.provider}
- {sessions > 0 && ` · ${sessions} ${sessions === 1 ? 'session' : 'sessions'}`}
- </span>
- <StateText tone={tone} label={state.label} title={state.detail ?? undefined} />
- </button>
- <Button
- size="sm"
- variant="ghost"
- className="shrink-0"
- onClick={() => showMoveModal({ agent })}
+ <Card
+ title={count === 0 ? 'Agents' : `Agents · ${count}`}
+ subtitle={
+ machine.local?.kind === 'this-computer'
+ ? 'Agents here only run while this computer is awake and Switch Console is open.'
+ : undefined
+ }
+ >
+ {count === 0 ? (
+ <p className="text-[13px] text-[var(--fg-dim)]">No agents on it.</p>
+ ) : (
+ <table className="w-full table-fixed text-[13px]">
+ <thead>
+ <tr className="text-left text-[12px] text-[var(--fg-dim)]">
+ <th className="w-[30%] pb-2 font-normal">Agent</th>
+ <th className="w-[14%] pb-2 font-normal">Status</th>
+ <th className="pb-2 font-normal">Working folder</th>
+ <th className="w-[16%] pb-2 font-normal">Provider</th>
+ <th className="w-[112px] pb-2" />
+ </tr>
+ </thead>
+ <tbody>
+ {placed.map((agent) => {
+ const label = managedAgentLabel(agent);
+ const state = managedAgentState(agent);
+ const folder = agent.status?.directory ?? agent.definition.directory;
+ const open = () =>
+ navigate('managedAgent', {
+ serverId: agent.serverId,
+ agentId: agent.agentId,
+ name: label,
+ });
+ return (
+ <tr key={agent.agentId} className="border-t-[0.5px] border-[var(--hair-soft)]">
+ <td className="py-1.5">
+ <button
+ type="button"
+ onClick={open}
+ className="flex max-w-full cursor-pointer items-center gap-2.5 text-left text-foreground underline-offset-2 hover:underline"
+ >
+ <AgentAvatar
+ name={label}
+ iconUrl={agent.iconUrl}
+ serverId={agent.serverId}
+ size={20}
+ />
+ <span className="truncate">{label}</span>
+ </button>
+ </td>
+ <td className="py-1.5">
+ <StateText
+ tone={AGENT_TONE[state.tone]}
+ label={state.label}
+ title={state.detail ?? undefined}
+ />
+ </td>
+ <td
+ className="truncate py-1.5 font-[Menlo,ui-monospace,monospace] text-[11.5px] text-[var(--fg-dim)]"
+ title={folder ?? undefined}
+ >
+ {folder ? shortFolder(folder, machine.workspacesDir) : '—'}
+ </td>
+ <td className="truncate py-1.5 text-foreground">
+ {providerDisplayName(agent.definition.provider) ?? agent.definition.provider}
+ </td>
+ <td className="py-1.5">
+ <div className="flex items-center justify-end gap-1">
+ <Button size="sm" variant="outline" onClick={() => showMoveModal({ agent })}>
+ Move…
+ </Button>
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="outline"
+ size="sm"
+ className="size-7 p-0"
+ aria-label={`${label} actions`}
+ >
+ <MoreHorizontal className="size-4" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={open}>
+ <ExternalLink className="size-4" />
+ Open agent
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => showMoveModal({ agent })}>
+ Move to another device…
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </td>
+ </tr>
+ );
+ })}
+ {unlisted.map((report) => (
+ <tr
+ key={report.agentId}
+ className="border-t-[0.5px] border-[var(--hair-soft)]"
+ title="Runs here, but is not one of the agents you can open."
>
- Move…
- </Button>
- </div>
- );
- })}
- {unlisted.map((report) => (
- <div
- key={report.agentId}
- className="flex items-center gap-2.5 border-b-[0.5px] border-[var(--hair-soft)] py-[7px] text-[13px]"
- title="Runs here, but is not one of the agents you can open."
- >
- <span className="min-w-0 flex-1 truncate font-mono text-[11.5px] text-[var(--fg-dim)]">
- {report.agentId}
- </span>
- <StateText
- tone={PROCESS_TONE[report.process] ?? 'idle'}
- label={report.process}
- title={[report.reason, report.detail].filter(Boolean).join(': ') || undefined}
- />
- </div>
- ))}
- </div>
- </CollapsibleSection>
+ <td className="truncate py-1.5 font-mono text-[11.5px] text-[var(--fg-dim)]">
+ {report.agentId}
+ </td>
+ <td className="py-1.5">
+ <StateText
+ tone={PROCESS_TONE[report.process] ?? 'idle'}
+ label={report.process}
+ title={[report.reason, report.detail].filter(Boolean).join(': ') || undefined}
+ />
+ </td>
+ <td />
+ <td />
+ <td />
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ )}
+ </Card>
);
}
function StateText({ tone, label, title }: { tone: MachineTone; label: string; title?: string }) {
return (
- <span
- title={title}
- className={cn('flex w-24 shrink-0 items-center justify-end gap-1.5', STATE_TEXT[tone])}
- >
+ <span title={title} className={cn('flex items-center gap-1.5', STATE_TEXT[tone])}>
<span aria-hidden className={cn('size-1.5 shrink-0 rounded-full', TONE_DOT[tone])} />
<span className="truncate">{label}</span>
</span>
@@ -325,99 +505,8 @@ function StateText({ tone, label, title }: { tone: MachineTone; label: string; t
}
/**
- * What the machine last reported about itself, and when it was added and last
- * heard from: the short facts in a grid, then its workspaces folder, the one
- * value too long for one.
- */
-function DetailsSection({ machine }: { machine: MachineDetail }) {
- const now = new Date();
- const release = controllerRelease(machine);
- const contact = lastContact(machine, now);
- const resources = machine.resources;
- const memory = resources
- ? resourceLabel(resources.memFreeBytes, resources.memTotalBytes, formatBytes)
- : null;
- const disk = resources
- ? resourceLabel(resources.diskFreeBytes, resources.diskTotalBytes, formatBytes)
- : null;
- const removed = machine.state === 'revoked';
-
- return (
- <>
- {/* Label above value, so each sits next to its own: these values are
- short, and across a full-width row the eye loses which is which. */}
- <dl className="grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-x-6 gap-y-4">
- <Fact label="Controller">
- <span title={release.title}>
- {machine.version ?? 'Not reported'}
- {release.badge
- ? ` · ${release.badge.label.toLowerCase()}`
- : machine.release?.current
- ? ' · up to date'
- : ''}
- </span>
- </Fact>
- {removed ? (
- machine.revokedAt && <Fact label="Removed">{sinceLabel(machine.revokedAt, now)}</Fact>
- ) : machine.state === 'online' && machine.connection ? (
- <Fact label="Connected since">{sinceLabel(machine.connection.connectedAt, now)}</Fact>
- ) : (
- <Fact label="Last seen">{contact ? agoLabel(contact, now) : 'Never'}</Fact>
- )}
- {!removed && resources && (
- <>
- <Fact label="Sessions running">{sessionsLabel(resources)}</Fact>
- {memory && <Fact label="Memory">{memory}</Fact>}
- {disk && <Fact label="Disk">{disk}</Fact>}
- </>
- )}
- {machine.createdAt && <Fact label="Added">{sinceLabel(machine.createdAt, now)}</Fact>}
- {!removed && machine.updatedBy && (
- <Fact label="Updates">
- {machine.updatedBy === 'console' ? 'Updated with Switch Console' : 'Updates itself'}
- </Fact>
- )}
- {!removed && (
- <Fact label="Console sign-ins">
- <span
- title={
- machine.acceptsLogins
- ? 'Switch Console can give it a provider sign-in.'
- : 'Its controller has no key to take a sign-in with: providers sign in on the machine itself.'
- }
- >
- {machine.acceptsLogins ? 'Yes' : 'No'}
- </span>
- </Fact>
- )}
- </dl>
- {machine.workspacesDir && (
- <section>
- <SectionLabel>Workspaces folder</SectionLabel>
- <div className="mt-1 flex items-start gap-1">
- <code className="min-w-0 pt-px font-[Menlo,ui-monospace,monospace] text-[11.5px] break-all text-foreground">
- {machine.workspacesDir}
- </code>
- <CopyButton value={machine.workspacesDir} />
- </div>
- </section>
- )}
- </>
- );
-}
-
-function Fact({ label, children }: { label: string; children: React.ReactNode }) {
- return (
- <div className="min-w-0">
- <dt className="text-[11.5px] text-[var(--fg-dim)]">{label}</dt>
- <dd className="mt-0.5 truncate text-[13px] text-foreground">{children}</dd>
- </div>
- );
-}
-
-/**
- * An agent's working folder as its row shows it: inside the machine's
- * workspaces folder, which the page shows once above, only the part after it;
+ * An agent's working folder as its row shows it: inside the device's
+ * workspaces folder, which the Software card shows, only the part after it;
* anywhere else, the whole path.
*/
export function shortFolder(folder: string, workspacesDir: string | null): string {
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-providers.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-providers.tsx
index 47bf2bd03..43a0f4aa4 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-providers.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-providers.tsx
@@ -6,14 +6,14 @@ import {
loginKindsFor,
} from '@renderer/features/locations/components/add-agent-modal/give-machine-login';
import { MANAGED_AGENTS_KEY } from '@renderer/features/managed-agents/use-managed-agents';
-import {
- ProviderStatusRow,
- ReportedProviderLine,
-} from '@renderer/lib/components/provider-status-row';
+import { agoLabel } from '@renderer/features/switch-servers/server-times';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { reportedHeadline } from '@renderer/lib/components/reported-provider';
import { failureText } from '@renderer/lib/errors/describe-failure';
import { rpc } from '@renderer/lib/ipc';
import { useNavigate } from '@renderer/lib/layout/navigation-provider';
import { Button } from '@renderer/lib/ui/button';
+import { cn } from '@renderer/utils/utils';
import type {
MachineDetail,
MachineProviderDetail,
@@ -22,7 +22,9 @@ import {
isValidProviderId,
providerDisplayName,
} from '@shared/core/providers/agent-provider-registry';
-import { CollapsibleSection } from './collapsible-section';
+import { Card } from './detail-card';
+import { TonePill } from './machine-marks';
+import type { MachineTone } from './machine-state';
/** How often a recheck is asked about while the machine works on it. */
const RECHECK_POLL_MS = 1_500;
@@ -45,27 +47,37 @@ export function MachineProviders({
const missing = machine.providers.filter((p) => p.problem === 'not installed');
const thisComputer = machine.local?.kind === 'this-computer';
- // Folded at first: a provider that cannot run agents is already raised in a
- // notice above the details, so the list is reference.
return (
- <CollapsibleSection title="Providers" defaultOpen={false}>
+ <Card title="AI providers">
{machine.providers.length === 0 ? (
- <p className="py-[9px] text-[13px] text-[var(--fg-dim)]">Not reported yet.</p>
+ <p className="text-[13px] text-[var(--fg-dim)]">Not reported yet.</p>
) : (
- <div className="-mx-3 mt-1">
- {[...installed, ...missing].map((provider) => (
- <MachineProviderRow
- key={provider.provider}
- serverId={serverId}
- machine={machine}
- provider={provider}
- />
- ))}
- </div>
+ <table className="w-full table-fixed text-[13px]">
+ <thead>
+ <tr className="text-left text-[12px] text-[var(--fg-dim)]">
+ <th className="w-[18%] pb-2 font-normal">Provider</th>
+ <th className="w-[17%] pb-2 font-normal">Installed</th>
+ <th className="w-[15%] pb-2 font-normal">Sign-in</th>
+ <th className="pb-2 font-normal">Where the sign-in comes from</th>
+ <th className="w-[13%] pb-2 font-normal">Last checked</th>
+ <th className="w-[150px] pb-2" />
+ </tr>
+ </thead>
+ <tbody>
+ {[...installed, ...missing].map((provider) => (
+ <MachineProviderRow
+ key={provider.provider}
+ serverId={serverId}
+ machine={machine}
+ provider={provider}
+ />
+ ))}
+ </tbody>
+ </table>
)}
{missing.length > 0 &&
(thisComputer ? (
- <p className="mt-1 text-[13px] text-[var(--fg-dim)]">
+ <p className="mt-2 text-[12px] text-[var(--fg-dim)]">
Install providers on this computer from{' '}
<button
type="button"
@@ -77,12 +89,12 @@ export function MachineProviders({
.
</p>
) : (
- <p className="mt-1 text-[13px] text-[var(--fg-dim)]">
+ <p className="mt-2 text-[12px] text-[var(--fg-dim)]">
Switch cannot install a provider on {machine.name}: install its CLI there, then recheck
it here.
</p>
))}
- </CollapsibleSection>
+ </Card>
);
}
@@ -149,36 +161,43 @@ function MachineProviderRow({
: null;
return (
- <div>
- <ProviderStatusRow
- providerId={provider.provider}
- name={name}
- meta={provider.version ?? undefined}
- installed={installed}
- status={
- <span
- title={
- [
- provider.detail,
- provider.checkedAt
- ? `Checked ${new Date(provider.checkedAt).toLocaleString()}`
- : null,
- ]
- .filter(Boolean)
- .join(' · ') || undefined
- }
- >
- <ReportedProviderLine reported={provider} checking={checking} />
- {!checking && provider.authSource && (
- <span className="text-xs text-foreground-muted">
- {' · '}
- {signInSource(provider.authSource, machine)}
- </span>
- )}
+ <>
+ <tr className="border-t-[0.5px] border-[var(--hair-soft)]">
+ <td className="py-1.5">
+ <span className="flex items-center gap-2 truncate text-foreground">
+ <AgentIcon id={provider.provider} size={14} />
+ {name}
</span>
- }
- actions={
- <>
+ </td>
+ <td
+ className={cn('truncate py-1.5', installed ? 'text-foreground' : 'text-[var(--fg-dim)]')}
+ >
+ {installed
+ ? `Installed${provider.version ? ` · v${provider.version}` : ''}`
+ : 'Not installed'}
+ </td>
+ <td className="py-1.5" title={provider.detail ?? undefined}>
+ {!installed ? (
+ <span className="text-[var(--fg-dim)]">—</span>
+ ) : checking ? (
+ <span className="text-[var(--fg-dim)]">Checking…</span>
+ ) : (
+ <TonePill tone={signInTone(provider)} dot={false} label={reportedHeadline(provider)} />
+ )}
+ </td>
+ <td className="truncate py-1.5 text-foreground">
+ {installed && provider.ready && provider.authSource
+ ? signInSource(provider.authSource, machine)
+ : '—'}
+ </td>
+ <td
+ className="truncate py-1.5 text-[var(--fg-dim)]"
+ title={provider.checkedAt ? new Date(provider.checkedAt).toLocaleString() : undefined}
+ >
+ {provider.checkedAt ? agoLabel(provider.checkedAt, new Date()) : '—'}
+ </td>
+ <td className="py-1.5">
+ <div className="flex items-center justify-end gap-1">
{canGive && (
<Button
size="sm"
@@ -202,32 +221,41 @@ function MachineProviderRow({
Recheck
</Button>
)}
- </>
- }
- />
- {failure && (
- <p role="alert" className="px-3 pb-2 text-xs text-foreground-error">
- {failure}
- </p>
- )}
- {giving && known !== null && (
- <div className="px-3 pb-3">
- <GiveMachineLogin
- serverId={serverId}
- machine={machine}
- provider={known}
- onClose={() => setGiving(false)}
- />
- </div>
+ </div>
+ </td>
+ </tr>
+ {(failure || (giving && known !== null)) && (
+ <tr>
+ <td colSpan={6} className="pb-3">
+ {failure && (
+ <p role="alert" className="text-xs text-foreground-error">
+ {failure}
+ </p>
+ )}
+ {giving && known !== null && (
+ <GiveMachineLogin
+ serverId={serverId}
+ machine={machine}
+ provider={known}
+ onClose={() => setGiving(false)}
+ />
+ )}
+ </td>
+ </tr>
)}
- </div>
+ </>
);
}
+/** The sign-in pill's tone: signed in, a check still to come, or signed out. */
+function signInTone(provider: MachineProviderDetail): MachineTone {
+ if (provider.ready) return 'ok';
+ if (provider.problem === 'login not checked yet') return 'idle';
+ return 'warning';
+}
+
/** Where a provider's sign-in on the machine comes from, in a few words. */
function signInSource(source: 'local' | 'sealed', machine: MachineDetail): string {
- if (source === 'sealed') return 'login sent from Switch Console';
- return machine.local?.kind === 'this-computer'
- ? "this computer's own login"
- : "the machine's own login";
+ if (source === 'sealed') return 'Sent from Switch Console';
+ return machine.local?.kind === 'this-computer' ? "This computer's sign-in" : 'On the device';
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.test.ts b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.test.ts
index ded9da843..b2cd8039e 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.test.ts
@@ -6,13 +6,11 @@ import type {
import {
arrangeMachines,
controllerRelease,
- filterMachines,
lastContact,
machineCategory,
machineConnection,
machineNotices,
moveTarget,
- machineSummary,
platformLabel,
sessionsLabel,
} from './machine-state';
@@ -144,42 +142,6 @@ describe('arrangeMachines', () => {
});
});
-describe('filterMachines', () => {
- const machines = [
- machine({ id: 'm1', name: 'build-box', description: 'The GPU one' }),
- machine({ id: 'm2', name: 'laptop', local: { kind: 'this-computer' } }),
- ];
-
- it('keeps them all for an empty query', () => {
- expect(filterMachines(machines, ' ')).toEqual(machines);
- });
-
- it('matches the name, the description and the kind, ignoring case', () => {
- expect(filterMachines(machines, 'BUILD').map((m) => m.id)).toEqual(['m1']);
- expect(filterMachines(machines, 'gpu').map((m) => m.id)).toEqual(['m1']);
- expect(filterMachines(machines, 'this computer').map((m) => m.id)).toEqual(['m2']);
- });
-});
-
-describe('machineSummary', () => {
- it('says what it is, its OS and how many agents it runs', () => {
- expect(
- machineSummary(
- machine({
- id: 'm1',
- local: { kind: 'this-computer' },
- platform: { os: 'darwin', osVersion: '25.6.0', arch: 'arm64' },
- }),
- 2
- )
- ).toBe('This computer · macOS · 2 agents');
- });
-
- it('leaves out an OS it never reported and names an empty machine in words', () => {
- expect(machineSummary(machine({ id: 'm1' }), 0)).toBe('Agents controller · No agents');
- });
-});
-
describe('machineNotices', () => {
it('has nothing to say about a healthy machine', () => {
expect(machineNotices(machine({ id: 'm' }))).toEqual([]);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.ts b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.ts
index b9c4fa66b..ff0d18928 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-state.ts
@@ -65,13 +65,17 @@ export function lastContact(machine: MachineDetail, now: Date): string | null {
return times[0] ?? null;
}
-/** What the machine is to this person: this computer, an SSH host of theirs, or how it runs. */
+/**
+ * The device type, as the person tells devices apart: this computer, an SSH
+ * host this Console set up, the Switch cloud machine, another computer running
+ * Switch Console, or a standalone machine running the agents controller.
+ */
export function machineKindLabel(machine: Pick<MachineDetail, 'local' | 'cloud' | 'kind'>): string {
if (machine.local?.kind === 'this-computer') return 'This computer';
- if (machine.local?.kind === 'ssh-host') return `SSH host · ${machine.local.sshHost}`;
+ if (machine.local?.kind === 'ssh-host') return 'SSH host';
if (machine.cloud) return 'Switch cloud';
- if (machine.kind === 'console') return 'Switch Console';
- return 'Agents controller';
+ if (machine.kind === 'console') return 'Computer';
+ return 'Standalone machine';
}
const OS_NAMES: Record<string, string> = {
@@ -180,33 +184,6 @@ export function resourceLabel(
return `${format(free)} free of ${format(total)}`;
}
-/**
- * The machines whose name, description or kind contains `query`, ignoring
- * case. An empty query keeps them all.
- */
-export function filterMachines(machines: MachineDetail[], query: string): MachineDetail[] {
- const needle = query.trim().toLowerCase();
- if (needle === '') return machines;
- return machines.filter((machine) =>
- [machine.name, machine.description, machineKindLabel(machine)].some((text) =>
- text?.toLowerCase().includes(needle)
- )
- );
-}
-
-/**
- * One line saying what the machine is and what it runs, for its row in the
- * list: its kind, its operating system and how many agents are on it.
- */
-export function machineSummary(machine: MachineDetail, agentCount: number): string {
- const os = machine.platform
- ? (OS_NAMES[machine.platform.os.toLowerCase()] ?? machine.platform.os)
- : null;
- const agents =
- agentCount === 0 ? 'No agents' : `${agentCount} ${agentCount === 1 ? 'agent' : 'agents'}`;
- return [machineKindLabel(machine), os, agents].filter(Boolean).join(' · ');
-}
-
/** Something about the machine to act on or wait for, shown above its details. */
export type MachineNotice = { key: string; tone: MachineTone; title: string; body: string };
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-view.tsx
index b6653b945..d79f4b763 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-view.tsx
@@ -21,16 +21,16 @@ const MachineTitlebar = observer(function MachineTitlebar() {
<ServerSectionTitlebar
serverId={params.serverId}
icon={Server}
- label="Your Machines"
- onSectionClick={() => navigate('machines', { serverId: params.serverId })}
+ label="Devices"
+ onSectionClick={() => navigate('settings', { tab: 'devices' })}
item={{ label: params.name }}
/>
);
});
/**
- * One of the person's machines, with everything it last reported. Read from
- * the same list as the machines page: the server has no call for one machine.
+ * One of the person's devices, with everything it last reported. Read from
+ * the same list as Settings → Devices: the server has no call for one machine.
*/
const MachinePanel = observer(function MachinePanel() {
const { params } = useParams('machine');
@@ -42,7 +42,7 @@ const MachinePanel = observer(function MachinePanel() {
return (
<div className="relative z-10 flex min-h-0 flex-1 flex-col bg-background">
<div className="flex min-h-0 flex-1 flex-col overflow-auto">
- <div className="mx-auto w-full max-w-[720px] px-6 pt-10 pb-10">
+ <div className="mx-auto w-full max-w-[1080px] px-6 pt-10 pb-10">
{machines.error && !(server && isFrozenServer(server)) ? (
<p role="alert" className="text-sm text-destructive">
{failureText(machines.error, 'Could not load this machine.')}
@@ -55,7 +55,7 @@ const MachinePanel = observer(function MachinePanel() {
</ServerTableEmpty>
) : !machine ? (
<ServerTableEmpty>
- {params.name} is no longer one of your machines on {server?.name ?? 'this server'}.
+ {params.name} is no longer one of your devices on {server?.name ?? 'this server'}.
</ServerTableEmpty>
) : (
<MachineDetails
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machines-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/machines-view.tsx
deleted file mode 100644
index df127a75d..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machines-view.tsx
+++ /dev/null
@@ -1,243 +0,0 @@
-import { Plus, Server } from 'lucide-react';
-import { observer } from 'mobx-react-lite';
-import { useState } from 'react';
-import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
-import { useManagedAgents } from '@renderer/features/managed-agents/use-managed-agents';
-import { isFrozenServer } from '@renderer/features/switch-servers/managed-server-state';
-import { ServerPage, ServerTableEmpty } from '@renderer/features/switch-servers/server-page';
-import { ServerSectionTitlebar } from '@renderer/features/switch-servers/server-section-titlebar';
-import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
-import { failureText } from '@renderer/lib/errors/describe-failure';
-import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
-import { useShowModal } from '@renderer/lib/modal/modal-provider';
-import { Button } from '@renderer/lib/ui/button';
-import { DisclosureRow } from '@renderer/lib/ui/disclosure-row';
-import { SearchInput } from '@renderer/lib/ui/search-input';
-import { SegmentedControl } from '@renderer/lib/ui/segmented-control';
-import { Spinner } from '@renderer/lib/ui/spinner';
-import type { MachineDetail, ManagedAgentView } from '@shared/core/managed-agents/managed-agents';
-import { MachineIcon, TonePill } from './machine-marks';
-import {
- arrangeMachines,
- controllerRelease,
- filterMachines,
- MACHINE_CATEGORY_LABELS,
- type MachineCategory,
- machineCategory,
- machineConnection,
- machineSummary,
-} from './machine-state';
-import { useMachineDetails } from './use-machines';
-
-function useServerId(): string {
- return useParams('machines').params.serverId;
-}
-
-const MachinesTitlebar = observer(function MachinesTitlebar() {
- return <ServerSectionTitlebar serverId={useServerId()} icon={Server} label="Your Machines" />;
-});
-
-/**
- * The computers that run the signed-in person's managed agents on this
- * server: this computer, their SSH hosts, headless controllers and a Switch
- * cloud machine. One row each, opening the machine's own page; removed
- * machines are folded away at the end. Read-only for now.
- *
- * The server returns the whole list in one response, unpaged, and it holds
- * only this person's own machines, so the filter runs over all of them here.
- */
-const MachinesPanel = observer(function MachinesPanel() {
- const serverId = useServerId();
- const server = switchServersStore.servers.find((s) => s.id === serverId);
- const machines = useMachineDetails(serverId);
- const managed = useManagedAgents(serverId);
- const showAddMachineModal = useShowModal('addMachineModal');
-
- return (
- <ServerPage
- width={880}
- title="Your Machines"
- description={`Computers running an agents controller for you on ${server?.name ?? 'this server'}. Each runs the agents you place on it and reports what it sees.`}
- action={
- machines.data ? (
- <Button size="sm" onClick={() => showAddMachineModal({ serverId })}>
- <Plus className="size-4" />
- Add machine
- </Button>
- ) : undefined
- }
- >
- {machines.error && !(server && isFrozenServer(server)) ? (
- <p role="alert" className="text-sm text-destructive">
- {failureText(machines.error, 'Could not load your machines.')}
- </p>
- ) : machines.data === undefined ? (
- <Spinner />
- ) : machines.data === null ? (
- <ServerTableEmpty>
- {server?.name ?? 'This server'} does not have agent management turned on.
- </ServerTableEmpty>
- ) : (
- <MachineList serverId={serverId} machines={machines.data} agents={managed.data ?? []} />
- )}
- </ServerPage>
- );
-});
-
-function MachineList({
- serverId,
- machines,
- agents,
-}: {
- serverId: string;
- machines: MachineDetail[];
- /** The person's managed agents, wherever each is placed. */
- agents: ManagedAgentView[];
-}) {
- const [filter, setFilter] = useState('');
- const [category, setCategory] = useState<'all' | MachineCategory>('all');
- const [showRemoved, setShowRemoved] = useState(false);
- const arranged = arrangeMachines(machines);
- // Only the groups the person has a machine in: a tab with nothing behind it filters nothing.
- const categories = (Object.keys(MACHINE_CATEGORY_LABELS) as MachineCategory[]).filter((c) =>
- arranged.live.some((machine) => machineCategory(machine) === c)
- );
- const inCategory = (list: MachineDetail[]) =>
- category === 'all' ? list : list.filter((machine) => machineCategory(machine) === category);
- const live = filterMachines(inCategory(arranged.live), filter);
- const removed = filterMachines(inCategory(arranged.removed), filter);
- const filtering = filter.trim() !== '' || category !== 'all';
- const placedOn = (machine: MachineDetail) =>
- agents.filter((agent) => agent.machine?.id === machine.id).length;
-
- if (machines.length === 0)
- return (
- <ServerTableEmpty>
- No machines yet. This computer joins when you run a managed agent on it, and so does an SSH
- host; a headless agents controller joins once it is enrolled.
- </ServerTableEmpty>
- );
-
- return (
- <div className="flex flex-col gap-6">
- <div className="flex items-center gap-3">
- {categories.length > 1 && (
- <SegmentedControl
- value={category}
- onChange={setCategory}
- ariaLabel="Show machines of one kind"
- className="shrink-0"
- options={[
- { value: 'all', label: 'All' },
- ...categories.map((c) => ({ value: c, label: MACHINE_CATEGORY_LABELS[c] })),
- ]}
- />
- )}
- <SearchInput
- value={filter}
- onChange={(e) => setFilter(e.target.value)}
- placeholder="Filter machines…"
- aria-label="Filter machines by name, description or kind"
- containerClassName="flex-1"
- />
- </div>
- {live.length === 0 && removed.length === 0 ? (
- <p className="py-2 text-sm text-foreground-muted">
- {filter.trim() === ''
- ? 'No machine of this kind.'
- : `No machine here matches “${filter.trim()}”.`}
- </p>
- ) : (
- <>
- {live.length > 0 && (
- <div className="divide-y divide-border overflow-hidden rounded-[10px] border border-border">
- {live.map((machine) => (
- <MachineRow
- key={machine.id}
- serverId={serverId}
- machine={machine}
- agentCount={placedOn(machine)}
- />
- ))}
- </div>
- )}
- {removed.length > 0 && (
- <div>
- <DisclosureRow
- // A filter that only matches removed machines would otherwise
- // show nothing but a closed fold.
- open={showRemoved || (filtering && live.length === 0)}
- title="Removed"
- summary="Machines revoked from Switch"
- meta={removed.length}
- onToggle={() => setShowRemoved((open) => !open)}
- />
- {(showRemoved || (filtering && live.length === 0)) && (
- <div className="mt-2 divide-y divide-border overflow-hidden rounded-[10px] border border-border">
- {removed.map((machine) => (
- <MachineRow
- key={machine.id}
- serverId={serverId}
- machine={machine}
- agentCount={placedOn(machine)}
- />
- ))}
- </div>
- )}
- </div>
- )}
- </>
- )}
- </div>
- );
-}
-
-/** One machine: what it is and what runs on it, whether it is connected, and a way into its page. */
-function MachineRow({
- serverId,
- machine,
- agentCount,
-}: {
- serverId: string;
- machine: MachineDetail;
- agentCount: number;
-}) {
- const { navigate } = useNavigate();
- const connection = machineConnection(machine);
- const badge = controllerRelease(machine).badge;
- return (
- <button
- type="button"
- onClick={() => navigate('machine', { serverId, machineId: machine.id, name: machine.name })}
- className="flex w-full cursor-pointer items-center gap-3 bg-background px-4 py-3 text-left transition-colors hover:bg-[var(--fill)]"
- >
- <MachineIcon machine={machine} />
- <div className="flex min-w-0 flex-1 flex-col">
- <span className="truncate font-mono text-sm font-medium text-foreground">
- {machine.name}
- </span>
- <span className="truncate text-xs text-foreground-muted">
- {machineSummary(machine, agentCount)}
- </span>
- </div>
- {badge && machine.state !== 'revoked' && (
- <TonePill tone={badge.tone} label={badge.label} dot={false} />
- )}
- <TonePill tone={connection.tone} label={connection.label} title={connection.title} />
- </button>
- );
-}
-
-export const machinesView = {
- WrapView: ({ children }: { children: React.ReactNode; serverId: string }) => <>{children}</>,
- TitlebarSlot: MachinesTitlebar,
- MainPanel: MachinesPanel,
- canActivate: (params: unknown): GuardResult => {
- const serverId =
- typeof params === 'object' && params !== null
- ? (params as { serverId?: unknown }).serverId
- : undefined;
- if (typeof serverId !== 'string') return { ok: false, redirect: 'home' };
- return { ok: true };
- },
-} satisfies ViewDefinition<{ serverId: string }>;
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/move-agent-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/move-agent-modal.tsx
index d8144e7d6..a03cbe6fa 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/move-agent-modal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/move-agent-modal.tsx
@@ -80,13 +80,16 @@ export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {
return (
<>
<DialogHeader>
- <DialogTitle>Move {label} to another machine</DialogTitle>
+ <DialogTitle>Move {label} to another device</DialogTitle>
</DialogHeader>
<DialogContentArea className="space-y-3 pt-0">
<DialogDescription>
- {label} stops on {agent.machine?.name ?? 'its machine'} and starts on the machine you
- pick. Its chats, rooms and settings stay the same.
+ {label} stops on {agent.machine?.name ?? 'its device'} and starts on the device you pick.
+ Its chats, rooms and settings stay the same.
</DialogDescription>
+ <p id="move-to-label" className="text-[12px] text-foreground-muted">
+ Move to
+ </p>
{machines.error ? (
<p role="alert" className="text-sm text-destructive">
{failureText(machines.error, 'Could not read your machines.')}
@@ -94,9 +97,13 @@ export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {
) : machines.data === undefined ? (
<Spinner />
) : others.length === 0 ? (
- <p className="text-sm text-foreground-muted">You have no other machine to move it to.</p>
+ <p className="text-sm text-foreground-muted">You have no other device to move it to.</p>
) : (
- <div role="radiogroup" className="max-h-[360px] space-y-2 overflow-y-auto">
+ <div
+ role="radiogroup"
+ aria-labelledby="move-to-label"
+ className="max-h-[360px] space-y-2 overflow-y-auto"
+ >
{others.map(({ machine, target }) => (
<TargetRow
key={machine.id}
@@ -112,7 +119,7 @@ export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {
<Info className="mt-px size-3.5 shrink-0" />
<span>
Files in its working folder{folder ? ` (${folder})` : ''} don&apos;t move. Anything it
- needs from there must be on the new machine.
+ needs from there must be on the new device.
</span>
</p>
{error && (
@@ -176,9 +183,7 @@ function TargetRow({
<span className="truncate text-sm text-foreground">
{thisComputer ? 'This computer' : machine.name}
</span>
- {!thisComputer && (
- <TonePill tone="idle" dot={false} label={machineKindLabel(machine).split(' · ')[0]!} />
- )}
+ {!thisComputer && <TonePill tone="idle" dot={false} label={machineKindLabel(machine)} />}
<TonePill tone={online ? 'ok' : 'problem'} label={online ? 'Online' : 'Offline'} />
</span>
<span className={cn('mt-0.5 block truncate text-xs', LINE_TEXT[target.tone])}>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/rename-machine-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/rename-machine-modal.tsx
index 5ebee242a..867c9e872 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/machines/rename-machine-modal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/rename-machine-modal.tsx
@@ -27,7 +27,7 @@ type Props = BaseModalProps<void> & {
currentDescription: string | null;
};
-/** Renames one of the person's machines and changes its description; an empty description clears it. */
+/** Renames one of the person's devices and changes its description; an empty description clears it. */
export function RenameMachineModal({
serverId,
machineId,
@@ -70,7 +70,7 @@ export function RenameMachineModal({
await queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, serverId] });
onSuccess();
} catch (err) {
- setError(failureText(err, 'Could not save the machine.'));
+ setError(failureText(err, 'Could not save the device.'));
setSaving(false);
}
};
@@ -78,7 +78,7 @@ export function RenameMachineModal({
return (
<>
<DialogHeader showCloseButton={false}>
- <DialogTitle>Rename machine</DialogTitle>
+ <DialogTitle>Rename device</DialogTitle>
</DialogHeader>
<DialogContentArea className="pt-0">
<FieldGroup>
@@ -93,7 +93,7 @@ export function RenameMachineModal({
autoFocus
/>
{trimmedName.length === 0 && (
- <p className="mt-1 text-xs text-destructive">A machine needs a name.</p>
+ <p className="mt-1 text-xs text-destructive">A device needs a name.</p>
)}
{nameTooLong && (
<p className="mt-1 text-xs text-destructive">
@@ -106,7 +106,7 @@ export function RenameMachineModal({
<Textarea
value={description}
onChange={(e) => setDescription(e.target.value)}
- placeholder="What this machine is for"
+ placeholder="What this device is for"
rows={3}
/>
{descriptionTooLong && (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/use-device-actions.ts b/console/apps/switch-console-desktop/src/renderer/features/machines/use-device-actions.ts
new file mode 100644
index 000000000..68dc30935
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/use-device-actions.ts
@@ -0,0 +1,54 @@
+import { useQueryClient } from '@tanstack/react-query';
+import { useState } from 'react';
+import { MANAGED_AGENTS_KEY } from '@renderer/features/managed-agents/use-managed-agents';
+import { failureText } from '@renderer/lib/errors/describe-failure';
+import { rpc } from '@renderer/lib/ipc';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import type { MachineDetail } from '@shared/core/managed-agents/managed-agents';
+
+/**
+ * Renaming and removing one of the person's devices, as its card and its page
+ * both offer them. Switch names the cloud machine, so it is not renamed; this
+ * computer and SSH hosts belong to the Console that set them up, which takes
+ * them away itself, so only a standalone machine is removed from here.
+ */
+export function useDeviceActions(serverId: string, machine: MachineDetail, agentCount: number) {
+ const showRenameModal = useShowModal('renameMachineModal');
+ const showConfirm = useShowModal('confirmActionModal');
+ const queryClient = useQueryClient();
+ const [error, setError] = useState<string | null>(null);
+ const live = machine.state !== 'revoked';
+
+ const rename = () =>
+ showRenameModal({
+ serverId,
+ machineId: machine.id,
+ currentName: machine.name,
+ currentDescription: machine.description,
+ });
+
+ const remove = () =>
+ showConfirm({
+ title: `Remove ${machine.name}?`,
+ description:
+ agentCount === 0
+ ? `${machine.name} stops running agents for you and cannot reconnect. To use it again, enroll it again.`
+ : `${machine.name} stops running agents for you and cannot reconnect. The ${agentCount === 1 ? 'agent' : `${agentCount} agents`} on it stay placed on it and do not run until you move them.`,
+ confirmLabel: 'Remove',
+ onSuccess: () => {
+ setError(null);
+ rpc.managedAgents
+ .removeMachine({ serverId, machineId: machine.id })
+ .then(() => queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, serverId] }))
+ .catch((err: unknown) => setError(failureText(err, `Could not remove ${machine.name}.`)));
+ },
+ });
+
+ return {
+ renamable: live && !machine.cloud,
+ removable: live && !machine.cloud && machine.local === null,
+ rename,
+ remove,
+ error,
+ };
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx
index e23e5e6b0..3513529c4 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/managed-agents/managed-agent-view.tsx
@@ -188,7 +188,7 @@ function ManagedAgentActionItems({ agent }: { agent: ManagedAgentView }) {
)}
<DropdownMenuItem disabled={busy} onClick={() => showMoveModal({ agent })}>
<ArrowRightLeft className="size-4" />
- Move to another machine…
+ Move to another device…
</DropdownMenuItem>
{!chatsOn && (
<>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/this-computer-status.ts b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/this-computer-status.ts
index 5a67bfb07..513d34e33 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/this-computer-status.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/agents-page/this-computer-status.ts
@@ -39,4 +39,3 @@ export function installSourcesDiffer(
reported !== null && installedHere(reported, localStatus) !== installedHere(null, localStatus)
);
}
-
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/components/SettingsPage.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/components/SettingsPage.tsx
index 459866762..50225df7c 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/components/SettingsPage.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/components/SettingsPage.tsx
@@ -1,5 +1,6 @@
import React, { useCallback } from 'react';
import { MigrationSettingsPage } from '@renderer/features/agent-migration/migration-settings-page';
+import { DevicesSettingsPage } from '@renderer/features/machines/devices-settings-page';
import { RemoteHostsSettingsPage } from '@renderer/features/remote-hosts/views/remote-hosts-view';
import { PageHeader } from '@renderer/lib/components/page-header';
import { PageContent, PageLayout, PageSidebarMenu } from '@renderer/lib/components/page-layout';
@@ -27,6 +28,7 @@ export type SettingsPageTab =
| 'browser'
| 'interface'
| 'remote-hosts'
+ | 'devices'
| 'managed-agents'
| 'docs';
@@ -80,6 +82,7 @@ const TAB_CONTENT: Partial<Record<SettingsPageTab, () => React.ReactNode>> = {
'clis-models': () => <AgentsSettingsPage />,
interface: () => <InterfaceSettingsPage />,
'remote-hosts': () => <RemoteHostsSettingsPage />,
+ devices: () => <DevicesSettingsPage />,
'managed-agents': () => <MigrationSettingsPage />,
};
@@ -117,14 +120,17 @@ export function SettingsPage({
// Switch Console v0 hides Account, Integrations, Connections (SSH), and Browser tabs.
{ id: 'general', label: 'General' },
{ id: 'clis-models', label: 'Agent providers' },
+ { id: 'devices', label: 'Devices' },
{ id: 'remote-hosts', label: 'Remote hosts' },
{ id: 'managed-agents', label: 'Managed agents' },
{ id: 'interface', label: 'Interface' },
{ id: 'docs', label: 'Docs', isExternal: true },
];
- const tabs = allTabs.filter((tab) => agentManagement || tab.id !== 'managed-agents');
+ const needsAgentManagement = (tab: SettingsPageTab) =>
+ tab === 'managed-agents' || tab === 'devices';
+ const tabs = allTabs.filter((tab) => agentManagement || !needsAgentManagement(tab.id));
- const shownTab = !agentManagement && activeTab === 'managed-agents' ? 'general' : activeTab;
+ const shownTab = !agentManagement && needsAgentManagement(activeTab) ? 'general' : activeTab;
const currentContent = TAB_CONTENT[shownTab]?.();
return (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav-views.ts b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav-views.ts
index 0f3beb939..e84eb4338 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav-views.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav-views.ts
@@ -1,7 +1,6 @@
export type WorkspaceNavView =
| 'server'
| 'serverAgents'
- | 'machines'
| 'serverRooms'
| 'connectors'
| 'templates'
@@ -15,20 +14,17 @@ export type WorkspaceNavView =
* connections are on, its connector settings needing them, and for whoever
* runs the server from this Console, whose status is under Admin's Server
* heading: the others are run by someone else, and there is nothing here to
- * start, stop or update. Your Machines follows Your Agents where the server
- * runs agent management: with it off there are no machines to list.
+ * start, stop or update.
*/
export function workspaceNavViews(server: {
managed: boolean;
serviceConnections: boolean;
administers: boolean;
- agentManagement: boolean;
}): WorkspaceNavView[] {
const admin = (server.serviceConnections && server.administers) || server.managed;
return [
'server',
'serverAgents',
- ...(server.agentManagement ? (['machines'] as const) : []),
'serverRooms',
...(server.serviceConnections ? (['connectors'] as const) : []),
'templates',
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
index 7eb5845b1..92c2447e8 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
@@ -1,13 +1,4 @@
-import {
- Bot,
- DoorOpen,
- FileText,
- House,
- type LucideIcon,
- Plug,
- Server,
- ShieldCheck,
-} from 'lucide-react';
+import { Bot, DoorOpen, FileText, House, type LucideIcon, Plug, ShieldCheck } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useRoomHealth } from '@renderer/features/switch-rooms/connection-health';
import { ManagedServerDot } from '@renderer/features/switch-servers/managed-server-dot';
@@ -34,8 +25,6 @@ export const WorkspaceNav = observer(function WorkspaceNav() {
const { currentView } = useWorkspaceSlots();
const { params: homeParams } = useParams('server');
const { params: agentsParams } = useParams('serverAgents');
- const { params: machinesParams } = useParams('machines');
- const { params: machineParams } = useParams('machine');
const { params: roomsParams } = useParams('serverRooms');
const { params: connectorsParams } = useParams('connectors');
const { params: templatesParams } = useParams('templates');
@@ -43,8 +32,7 @@ export const WorkspaceNav = observer(function WorkspaceNav() {
const { params: managedServerParams } = useParams('managedServer');
const active = switchServersStore.activeServer;
const health = useRoomHealth(active?.id ?? null);
- const flags = useFeatureFlags(active?.id ?? null);
- const serviceConnections = flags.service_connections;
+ const serviceConnections = useFeatureFlags(active?.id ?? null).service_connections;
const warningCount =
health.data?.agents.filter((agent) => connectionNeedsAttention(agent.state)).length ?? 0;
if (!active) return null;
@@ -64,18 +52,12 @@ export const WorkspaceNav = observer(function WorkspaceNav() {
> = {
server: { icon: House, label: 'Home', params: homeParams },
serverAgents: { icon: Bot, label: 'Your Agents', params: agentsParams },
- machines: { icon: Server, label: 'Your Machines', params: machinesParams },
serverRooms: { icon: DoorOpen, label: 'Your Rooms', params: roomsParams },
connectors: { icon: Plug, label: 'Connectors', params: connectorsParams },
templates: { icon: FileText, label: 'Templates', params: templatesParams },
admin: { icon: ShieldCheck, label: 'Admin', params: adminParams },
};
- const shown = workspaceNavViews({
- managed: active.managed,
- serviceConnections,
- administers,
- agentManagement: flags.agent_management,
- });
+ const shown = workspaceNavViews({ managed: active.managed, serviceConnections, administers });
return (
<SidebarMenu className="flex flex-col gap-[2px] px-2 pt-2">
@@ -87,9 +69,7 @@ export const WorkspaceNav = observer(function WorkspaceNav() {
isActive={
view === 'admin'
? onAdmin || onStatus
- : view === 'machines' && isCurrentView(currentView, 'machine')
- ? machineParams?.serverId === active.id
- : isCurrentView(currentView, view) && params?.serverId === active.id
+ : isCurrentView(currentView, view) && params?.serverId === active.id
}
onClick={() => navigate(view === 'admin' ? adminTarget : view, { serverId: active.id })}
className={cn(frozen && view !== 'admin' && FROZEN)}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/connectors.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/connectors.test.ts
index 3dbaf2ec6..e3c619a9c 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/connectors.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/tests/connectors.test.ts
@@ -776,51 +776,24 @@ describe('with the service_connections flag off', () => {
managed: false,
serviceConnections: false,
administers: true,
- agentManagement: false,
});
expect(shown).not.toContain('connectors');
expect(shown).not.toContain('admin');
expect(
- workspaceNavViews({
- managed: true,
- serviceConnections: true,
- administers: true,
- agentManagement: false,
- })
+ workspaceNavViews({ managed: true, serviceConnections: true, administers: true })
).toEqual(['server', 'serverAgents', 'serverRooms', 'connectors', 'templates', 'admin']);
});
it('shows Admin only to whoever administers the workspace or runs its server', () => {
expect(
- workspaceNavViews({
- managed: false,
- serviceConnections: true,
- administers: false,
- agentManagement: false,
- })
+ workspaceNavViews({ managed: false, serviceConnections: true, administers: false })
).toEqual(['server', 'serverAgents', 'serverRooms', 'connectors', 'templates']);
// The server's status lives under Admin, for whoever runs it, flag or role aside.
expect(
- workspaceNavViews({
- managed: true,
- serviceConnections: false,
- administers: false,
- agentManagement: false,
- })
+ workspaceNavViews({ managed: true, serviceConnections: false, administers: false })
).toEqual(['server', 'serverAgents', 'serverRooms', 'templates', 'admin']);
});
- it('shows Your Machines after Your Agents only where the server runs agent management', () => {
- expect(
- workspaceNavViews({
- managed: false,
- serviceConnections: false,
- administers: false,
- agentManagement: true,
- })
- ).toEqual(['server', 'serverAgents', 'machines', 'serverRooms', 'templates']);
- });
-
it('opens Admin on its sections, or on the server’s status where there are none to use', () => {
expect(adminNavTarget({ serviceConnections: true, administers: true, frozen: false })).toBe(
'admin'
diff --git a/console/apps/switch-console-desktop/src/shared/core/views/view-ids.ts b/console/apps/switch-console-desktop/src/shared/core/views/view-ids.ts
index f2226cead..aed7ce5ce 100644
--- a/console/apps/switch-console-desktop/src/shared/core/views/view-ids.ts
+++ b/console/apps/switch-console-desktop/src/shared/core/views/view-ids.ts
@@ -18,7 +18,6 @@ export const VIEW_IDS = [
'server',
'managedServer',
'serverAgents',
- 'machines',
'machine',
'connectors',
'serverRooms',