Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.
Python agent-orchestrationaiai-agentschatopsdiscordlangchainmcpmicrosoft-teamsmulti-agentopen-sourceopenaiself-hostedslack
Console machines: rename, remove, move an agent, kind filter, sign-in source
Massimo Cairoefac2dae0205
diff --git a/console/apps/switch-console-desktop/src/main/core/managed-agents/controller.ts b/console/apps/switch-console-desktop/src/main/core/managed-agents/controller.tsindex 247013c9b..6b691500e 100644--- a/console/apps/switch-console-desktop/src/main/core/managed-agents/controller.ts+++ b/console/apps/switch-console-desktop/src/main/core/managed-agents/controller.ts@@ -21,8 +21,10 @@ import {recheckMachineProvider,type ManagementController,managementErrorMessage,+ revokeManagementController,setManagedAgentDesiredState,updateManagedAgent,+ updateManagementController,} from '@main/core/switch-servers/gateway-client';import {localGoogleCredentialsPath,@@ -256,6 +258,42 @@ export const managedAgentsController = createRPCController({recheckMachineProvider(server, params.machineId, params.provider)),+ /**+ * Renames one of the owner's machines and/or changes its description;+ * `description: null` clears it. Switch refuses a name it does not take,+ * in its own words.+ */+ updateMachine: (params: {+ serverId: string;+ machineId: string;+ changes: { name?: string; description?: string | null };+ }): Promise<void> =>+ withReachableServerWorkspaceSession(params.serverId, async (server) => {+ try {+ await updateManagementController(server, params.machineId, params.changes);+ } catch (error) {+ if (error instanceof GatewayError && error.status !== undefined && error.status < 500)+ throw new Error(managementErrorMessage(error));+ throw error;+ }+ }),++ /**+ * Removes one of the owner's machines from Switch: its credential is+ * deleted and it cannot reconnect. The agents placed on it stay placed on+ * it, and do not run until they are moved.+ */+ removeMachine: (params: { serverId: string; machineId: string }): Promise<void> =>+ withReachableServerWorkspaceSession(params.serverId, async (server) => {+ try {+ await revokeManagementController(server, params.machineId);+ } catch (error) {+ if (error instanceof GatewayError && error.status !== undefined && error.status < 500)+ throw new Error(managementErrorMessage(error));+ throw error;+ }+ }),+/** How a recheck went, by the operation `recheckMachineProvider` answered. */machineRecheckOutcome: (params: {serverId: string;diff --git a/console/apps/switch-console-desktop/src/main/core/managed-agents/owned-machines.ts b/console/apps/switch-console-desktop/src/main/core/managed-agents/owned-machines.tsindex 1f354b7ad..cd64bbdfb 100644--- a/console/apps/switch-console-desktop/src/main/core/managed-agents/owned-machines.ts+++ b/console/apps/switch-console-desktop/src/main/core/managed-agents/owned-machines.ts@@ -83,6 +83,7 @@ export function machineDetails(return {...machineProvider(entry),version: check?.version ?? null,+ authSource: check?.authSource ?? null,checkedAt: check?.checkedAt ?? null,};}),diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.tsindex a52927c47..f5e6ff67b 100644--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.ts+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.test.ts@@ -3339,6 +3339,7 @@ describe('agent management calls', () => {provider: 'claude',installed: true,auth: 'ok',+ auth_source: 'sealed',version: '2.1.0',checked_at: '2026-10-01T10:29:00Z',},@@ -3376,7 +3377,14 @@ describe('agent management calls', () => {sessionsRunning: 1,sessionsMax: 0,},- providerChecks: [{ provider: 'claude', version: '2.1.0', checkedAt: '2026-10-01T10:29:00Z' }],+ providerChecks: [+ {+ provider: 'claude',+ version: '2.1.0',+ authSource: 'sealed',+ checkedAt: '2026-10-01T10:29:00Z',+ },+ ],agents: [{agentId: 'a1',diff --git a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.tsindex 36e6a0571..88b2eaf95 100644--- a/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts+++ b/console/apps/switch-console-desktop/src/main/core/switch-servers/gateway-client.ts@@ -4066,8 +4066,13 @@ export type ControllerReport = {sessionsRunning: number;sessionsMax: number;} | null;- /** Each provider's version and when it was last checked, beside `providers`. */- providerChecks: { provider: string; version: string | null; checkedAt: string | null }[];+ /** Each provider's version, where its sign-in comes from and when it was last checked, beside `providers`. */+ providerChecks: {+ provider: string;+ version: string | null;+ authSource: 'local' | 'sealed' | null;+ checkedAt: string | null;+ }[];/** Each agent it runs, as it last saw it. */agents: ControllerAgentReport[];};@@ -4403,6 +4408,10 @@ function controllerReport(status: unknown): ControllerReport | null {{provider: provider.provider,version: jsonText(provider.version),+ authSource:+ provider.auth_source === 'local' || provider.auth_source === 'sealed'+ ? provider.auth_source+ : null,checkedAt: jsonText(provider.checked_at),},];diff --git a/console/apps/switch-console-desktop/src/renderer/app/modal-registry.ts b/console/apps/switch-console-desktop/src/renderer/app/modal-registry.tsindex e89f0effe..8c9025c82 100644--- a/console/apps/switch-console-desktop/src/renderer/app/modal-registry.ts+++ b/console/apps/switch-console-desktop/src/renderer/app/modal-registry.ts@@ -13,6 +13,8 @@ import { AddAgentModal } from '@renderer/features/locations/components/add-agentimport { DeleteAgentModal } from '@renderer/features/locations/components/delete-agent-modal';import { ResetAgentModal } from '@renderer/features/locations/components/reset-agent-modal';import { AddMachineModal } from '@renderer/features/machines/add-machine-modal';+import { MoveAgentModal } from '@renderer/features/machines/move-agent-modal';+import { RenameMachineModal } from '@renderer/features/machines/rename-machine-modal';import { AddHostModal } from '@renderer/features/remote-hosts/add-host-modal';import { RemoveAgentConfigModal } from '@renderer/features/remote-hosts/remove-agent-config-modal';import { CreateSessionModal } from '@renderer/features/sessions/create-session-modal/create-session-modal';@@ -72,6 +74,11 @@ export const modalRegistry = {sessionModal: createModal(CreateSessionModal, { dismissOnOutsideClick: false }),addAgentModal: createModal(AddAgentModal, { size: 'lg', dismissOnOutsideClick: false }),addMachineModal: createModal(AddMachineModal, { size: 'lg' }),+ moveAgentModal: createModal(MoveAgentModal, { size: 'md' }),+ renameMachineModal: createModal(RenameMachineModal, {+ size: 'sm',+ dismissOnOutsideClick: false,+ }),saveTemplateModal: createModal(SaveTemplateModal, { size: 'sm', dismissOnOutsideClick: false }),confirmActionModal: createModal(ConfirmActionDialog, { size: 'xs' }),deleteAgentModal: createModal(DeleteAgentModal, { size: 'sm' }),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.tsxindex 946c4ac61..ea0da444d 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,13 +1,20 @@-import { Plus } from 'lucide-react';+import { useQueryClient } from '@tanstack/react-query';+import { Pencil, Plus, Trash2 } from 'lucide-react';+import { useState } from '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';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 { 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';@@ -82,6 +89,33 @@ export function MachineDetails({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}.`))+ );+ },+ });return (<div className="space-y-[18px]">@@ -98,6 +132,29 @@ export function MachineDetails({{[machineKindLabel(machine), platform].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 && (<Buttonsize="sm"@@ -119,6 +176,12 @@ export function MachineDetails({<p className="text-[13px] whitespace-pre-line text-foreground">{machine.description}</p>)}+ {removeError && (+ <p role="alert" className="text-sm text-destructive">+ {removeError}+ </p>+ )}+{notices.map((notice) => (<MessageBox key={notice.key} tone={NOTICE_TONE[notice.tone]} title={notice.title}><p>{notice.body}</p>@@ -126,12 +189,32 @@ export function MachineDetails({))}<DetailsSection machine={machine} />+ {machine.cloud && !removed && <CloudMachineSection serverId={serverId} machine={machine} />}{!removed && <MachineProviders serverId={serverId} machine={machine} />}- {!removed && <AgentsSection machine={machine} placed={placed} />}+ {/* Kept on a removed machine: its agents stay placed on it until they are moved. */}+ <AgentsSection machine={machine} placed={placed} /></div>);}+/**+ * 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+ * controller on it that this page is about.+ */+function CloudMachineSection({ serverId, machine }: { serverId: string; machine: MachineDetail }) {+ const cloud = useCloudMachines(serverId);+ const hosted = cloud.data?.find((candidate) => candidate.controller_id === machine.id);+ if (cloud.error)+ return (+ <p role="alert" className="text-sm text-destructive">+ {failureText(cloud.error, 'Could not read the cloud machine.')}+ </p>+ );+ if (!hosted) return null;+ return <CloudMachineCard machine={hosted} serverId={serverId} />;+}+/*** The agents on the machine: those placed on it, each opening its page, and* any others it reports running, which this person cannot open.@@ -144,6 +227,7 @@ function AgentsSection({placed: ManagedAgentView[];}) {const { navigate } = useNavigate();+ const showMoveModal = useShowModal('moveAgentModal');const unlisted = machine.agents.filter((report) => !placed.some((agent) => agent.agentId === report.agentId));@@ -160,32 +244,51 @@ function AgentsSection({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 (- <button+ <divkey={agent.agentId}- type="button"- onClick={() =>- navigate('managedAgent', {- serverId: agent.serverId,- agentId: agent.agentId,- name: label,- })- }- className="-mx-2 flex w-[calc(100%+1rem)] cursor-pointer items-center gap-2.5 rounded-md border-b-[0.5px] border-[var(--hair-soft)] px-2 py-[7px] text-left text-[13px] transition-colors hover:bg-[var(--sel-soft)]"+ 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)]">- <AgentAvatar- name={label}- iconUrl={agent.iconUrl}- serverId={agent.serverId}- size={20}- />- <span className="min-w-0 flex-1 truncate text-foreground">{label}</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+ 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 ?? ''}+ </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 })}+ >+ Move…+ </Button>+ </div>);})}{unlisted.map((report) => (@@ -269,6 +372,24 @@ function DetailsSection({ machine }: { machine: MachineDetail }) {</>)}{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>diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-marks.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-marks.tsxindex 3cf3f933b..0093c8770 100644--- a/console/apps/switch-console-desktop/src/renderer/features/machines/machine-marks.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/machine-marks.tsx@@ -47,7 +47,7 @@ export function MachineIcon({machine,className,}: {- machine: MachineDetail;+ machine: Pick<MachineDetail, 'local' | 'cloud' | 'kind'>;className?: string;}) {const Icon =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.tsxindex 281a21450..d2b00e3db 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@@ -169,6 +169,12 @@ function MachineProviderRow({}><ReportedProviderLine reported={provider} checking={checking} />+ {!checking && provider.authSource && (+ <span className="text-xs text-foreground-muted">+ {' · '}+ {signInSource(provider.authSource, machine)}+ </span>+ )}</span>}actions={@@ -217,3 +223,11 @@ function MachineProviderRow({</div>);}++/** 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 'sent from Switch Console';+ return machine.local?.kind === 'this-computer'+ ? "this computer's sign-in"+ : 'signed in on the machine';+}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.tsindex fd99fb55a..ded9da843 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@@ -1,12 +1,17 @@import { describe, expect, it } from 'vitest';-import type { MachineDetail } from '@shared/core/managed-agents/managed-agents';+import type {+ MachineDetail,+ MachineProviderDetail,+} from '@shared/core/managed-agents/managed-agents';import {arrangeMachines,controllerRelease,filterMachines,lastContact,+ machineCategory,machineConnection,machineNotices,+ moveTarget,machineSummary,platformLabel,sessionsLabel,@@ -220,6 +225,7 @@ describe('machineNotices', () => {problem: 'login expired',detail: null,version: null,+ authSource: null,checkedAt: null,},{@@ -228,6 +234,7 @@ describe('machineNotices', () => {problem: 'not installed',detail: null,version: null,+ authSource: null,checkedAt: null,},],@@ -255,3 +262,62 @@ describe('sessionsLabel', () => {expect(sessionsLabel({ ...resources, sessionsMax: 0 })).toBe('1');});});++describe('moveTarget', () => {+ const ready: MachineProviderDetail = {+ provider: 'claude',+ ready: true,+ problem: null,+ detail: null,+ version: null,+ authSource: null,+ checkedAt: null,+ };++ it('takes an agent on a connected machine with its provider signed in', () => {+ expect(moveTarget(machine({ id: 'm', providers: [ready] }), 'claude')).toMatchObject({+ selectable: true,+ tone: 'ok',+ });+ });++ it('refuses what Switch refuses: offline, not installed, signed out', () => {+ expect(+ moveTarget(machine({ id: 'm', state: 'offline', providers: [ready] }), 'claude')+ ).toMatchObject({+ selectable: false,+ line: 'Offline. Bring it online to move agents here.',+ });+ expect(moveTarget(machine({ id: 'm', providers: [] }), 'claude').selectable).toBe(false);+ for (const problem of ['not installed', 'not logged in', 'login expired'])+ expect(+ moveTarget(machine({ id: 'm', providers: [{ ...ready, ready: false, problem }] }), 'claude')+ .selectable+ ).toBe(false);+ });++ it('lets a sign-in not checked yet through, as Switch does', () => {+ expect(+ moveTarget(+ machine({+ id: 'm',+ providers: [{ ...ready, ready: false, problem: 'login not checked yet' }],+ }),+ 'claude'+ )+ ).toMatchObject({ selectable: true, tone: 'warning' });+ });+});++describe('machineCategory', () => {+ it('groups the cloud machine, SSH hosts and every other computer', () => {+ expect(machineCategory(machine({ id: 'c', cloud: true }))).toBe('cloud');+ expect(machineCategory(machine({ id: 's', local: { kind: 'ssh-host', sshHost: 'box' } }))).toBe(+ 'ssh-host'+ );+ expect(machineCategory(machine({ id: 't', local: { kind: 'this-computer' } }))).toBe(+ 'computer'+ );+ expect(machineCategory(machine({ id: 'd' }))).toBe('computer');+ });+});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.tsindex f13fdd0e1..b9c4fa66b 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@@ -1,4 +1,4 @@-import type { MachineDetail } from '@shared/core/managed-agents/managed-agents';+import type { MachineDetail, OwnedMachine } from '@shared/core/managed-agents/managed-agents';import { providerDisplayName } from '@shared/core/providers/agent-provider-registry';export type MachineTone = 'ok' | 'warning' | 'problem' | 'idle';@@ -66,7 +66,7 @@ export function lastContact(machine: MachineDetail, now: Date): string | null {}/** What the machine is to this person: this computer, an SSH host of theirs, or how it runs. */-export function machineKindLabel(machine: MachineDetail): string {+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.cloud) return 'Switch cloud';@@ -269,3 +269,68 @@ export function sessionsLabel(resources: NonNullable<MachineDetail['resources']>? `${resources.sessionsRunning} of ${resources.sessionsMax}`: `${resources.sessionsRunning}`;}++/** Where a machine stands as a place to move an agent to, and the line saying so. */+export type MoveTarget = { selectable: boolean; tone: MachineTone; line: string };++/** The provider problems Switch refuses a placement for, as the machine reports them. */+const REFUSED_PROBLEMS = new Set(['not installed', 'not logged in', 'login expired']);++/**+ * Whether an agent running `provider` can be moved to `machine`, by the rules+ * Switch places it by: the machine is connected, and has the provider+ * installed and not signed out. A sign-in it has not checked yet is let+ * through, as Switch lets it through.+ */+export function moveTarget(machine: OwnedMachine, provider: string): MoveTarget {+ const name = providerDisplayName(provider) ?? provider;+ if (machine.state === 'revoked')+ return { selectable: false, tone: 'idle', line: 'Removed from Switch.' };+ if (machine.state !== 'online')+ return {+ selectable: false,+ tone: 'idle',+ line: 'Offline. Bring it online to move agents here.',+ };+ const reported = machine.providers.find((p) => p.provider === provider);+ if (!reported)+ return { selectable: false, tone: 'warning', line: `${name} isn't installed here.` };+ if (reported.ready) return { selectable: true, tone: 'ok', line: `Ready: ${name} signed in` };+ if (reported.problem !== null && REFUSED_PROBLEMS.has(reported.problem))+ return {+ selectable: false,+ tone: 'warning',+ line:+ reported.problem === 'not installed'+ ? `${name} isn't installed here.`+ : reported.problem === 'login expired'+ ? `${name}'s sign-in has expired here. Sign in first.`+ : `${name} isn't signed in here. Sign in first.`,+ };+ return {+ selectable: true,+ tone: 'warning',+ line: `${name}: ${reported.problem ?? 'not checked yet'}`,+ };+}++/** The groups the machines page filters by: what a machine is, as the person tells them apart. */+export type MachineCategory = 'cloud' | 'ssh-host' | 'computer';++export const MACHINE_CATEGORY_LABELS: Record<MachineCategory, string> = {+ cloud: 'Cloud',+ 'ssh-host': 'SSH hosts',+ computer: 'Computers',+};++/**+ * Which group a machine falls in: the Switch cloud machine, an SSH host this+ * Console set up, or any other computer, this one and headless controllers+ * alike. An SSH host enrolled from another Console is a computer here, since+ * only the Console that set it up knows it is one.+ */+export function machineCategory(machine: Pick<MachineDetail, 'local' | 'cloud'>): MachineCategory {+ if (machine.cloud) return 'cloud';+ if (machine.local?.kind === 'ssh-host') return 'ssh-host';+ return 'computer';+}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.tsxindex 7ac3706ce..df127a75d 100644--- 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@@ -13,6 +13,7 @@ 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';@@ -20,6 +21,9 @@ import {arrangeMachines,controllerRelease,filterMachines,+ MACHINE_CATEGORY_LABELS,+ type MachineCategory,+ machineCategory,machineConnection,machineSummary,} from './machine-state';@@ -91,11 +95,18 @@ function MachineList({agents: ManagedAgentView[];}) {const [filter, setFilter] = useState('');+ const [category, setCategory] = useState<'all' | MachineCategory>('all');const [showRemoved, setShowRemoved] = useState(false);const arranged = arrangeMachines(machines);- const live = filterMachines(arranged.live, filter);- const removed = filterMachines(arranged.removed, filter);- const filtering = filter.trim() !== '';+ // 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;@@ -109,15 +120,32 @@ function MachineList({return (<div className="flex flex-col gap-6">- <SearchInput- value={filter}- onChange={(e) => setFilter(e.target.value)}- placeholder="Filter machines…"- aria-label="Filter machines by name, description or kind"- />+ <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">- No machine here matches “{filter.trim()}”.+ {filter.trim() === ''+ ? 'No machine of this kind.'+ : `No machine here matches “${filter.trim()}”.`}</p>) : (<>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.tsxnew file mode 100644index 000000000..d9b2167bd--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/move-agent-modal.tsx@@ -0,0 +1,180 @@+import { useQueryClient } from '@tanstack/react-query';+import { Info } from 'lucide-react';+import { useState } from 'react';+import { managedAgentLabel } from '@renderer/features/managed-agents/managed-agent-state';+import {+ MANAGED_AGENTS_KEY,+ useOwnedMachines,+} from '@renderer/features/managed-agents/use-managed-agents';+import { failureText } from '@renderer/lib/errors/describe-failure';+import { rpc } from '@renderer/lib/ipc';+import type { BaseModalProps } from '@renderer/lib/modal/modal-provider';+import { Button } from '@renderer/lib/ui/button';+import { ConfirmButton } from '@renderer/lib/ui/confirm-button';+import {+ DialogContentArea,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@renderer/lib/ui/dialog';+import { Spinner } from '@renderer/lib/ui/spinner';+import { cn } from '@renderer/utils/utils';+import type { ManagedAgentView, OwnedMachine } from '@shared/core/managed-agents/managed-agents';+import { MachineIcon, TonePill } from './machine-marks';+import { machineKindLabel, moveTarget } from './machine-state';++type Props = BaseModalProps<void> & { agent: ManagedAgentView };++const LINE_TEXT = {+ ok: 'text-foreground-muted',+ warning: 'text-foreground-warning',+ problem: 'text-foreground-error',+ idle: 'text-foreground-muted',+} as const;++/**+ * Moves a managed agent to another of its owner's machines. Each machine says+ * whether it can take the agent, by the rules Switch places it by; the ones+ * that cannot are listed but not picked. Its files stay where they are.+ */+export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {+ const machines = useOwnedMachines(agent.serverId);+ const queryClient = useQueryClient();+ const [picked, setPicked] = useState<string | null>(null);+ const [moving, setMoving] = useState(false);+ const [error, setError] = useState<string | null>(null);+ const label = managedAgentLabel(agent);+ const provider = agent.definition.provider;+ const others = (machines.data ?? []).filter(+ (machine) => machine.id !== agent.machine?.id && machine.state !== 'revoked'+ );+ const folder = agent.status?.directory ?? agent.definition.directory;++ const move = async () => {+ if (!picked) return;+ setMoving(true);+ setError(null);+ try {+ await rpc.managedAgents.update({+ serverId: agent.serverId,+ agentId: agent.agentId,+ changes: { definition: {}, machineId: picked },+ });+ await queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, agent.serverId] });+ onSuccess();+ } catch (err) {+ setError(failureText(err, `Could not move ${label}.`));+ setMoving(false);+ }+ };++ return (+ <>+ <DialogHeader>+ <DialogTitle>Move {label} to another machine</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.+ </DialogDescription>+ {machines.error ? (+ <p role="alert" className="text-sm text-destructive">+ {failureText(machines.error, 'Could not read your machines.')}+ </p>+ ) : machines.data === undefined ? (+ <Spinner />+ ) : others.length === 0 ? (+ <p className="text-sm text-foreground-muted">You have no other machine to move it to.</p>+ ) : (+ <div role="radiogroup" className="max-h-[360px] space-y-2 overflow-y-auto">+ {others.map((machine) => (+ <TargetRow+ key={machine.id}+ machine={machine}+ provider={provider}+ picked={picked === machine.id}+ onPick={() => setPicked(machine.id)}+ />+ ))}+ </div>+ )}+ <p className="flex gap-2 rounded-md bg-background-tertiary px-3 py-2 text-xs text-foreground-muted">+ <Info className="mt-px size-3.5 shrink-0" />+ <span>+ Files in its working folder{folder ? ` (${folder})` : ''} don't move. Anything it+ needs from there must be on the new machine.+ </span>+ </p>+ {error && (+ <p role="alert" className="text-xs text-destructive">+ {error}+ </p>+ )}+ </DialogContentArea>+ <DialogFooter>+ <Button variant="outline" onClick={onClose}>+ Cancel+ </Button>+ <ConfirmButton onClick={() => void move()} disabled={!picked || moving}>+ {moving ? 'Moving…' : `Move ${label}`}+ </ConfirmButton>+ </DialogFooter>+ </>+ );+}++function TargetRow({+ machine,+ provider,+ picked,+ onPick,+}: {+ machine: OwnedMachine;+ provider: string;+ picked: boolean;+ onPick: () => void;+}) {+ const target = moveTarget(machine, provider);+ const online = machine.state === 'online';+ return (+ <button+ type="button"+ role="radio"+ aria-checked={picked}+ disabled={!target.selectable}+ onClick={onPick}+ className={cn(+ 'flex w-full items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors',+ picked ? 'border-foreground' : 'border-border',+ target.selectable+ ? 'cursor-pointer hover:bg-[var(--sel-soft)]'+ : 'cursor-not-allowed opacity-60'+ )}+ >+ <span+ aria-hidden+ className={cn(+ 'flex size-4 shrink-0 items-center justify-center rounded-full border',+ picked ? 'border-foreground' : 'border-border'+ )}+ >+ {picked && <span className="size-2 rounded-full bg-foreground" />}+ </span>+ <MachineIcon machine={machine} />+ <span className="min-w-0 flex-1">+ <span className="flex min-w-0 items-center gap-2">+ <span className="truncate text-sm text-foreground">+ {machine.local?.kind === 'this-computer' ? 'This computer' : machine.name}+ </span>+ <TonePill tone="idle" dot={false} label={machineKindLabel(machine).split(' · ')[0]!} />+ <TonePill tone={online ? 'ok' : 'problem'} label={online ? 'Online' : 'Offline'} />+ </span>+ <span className={cn('mt-0.5 block truncate text-xs', LINE_TEXT[target.tone])}>+ {target.line}+ </span>+ </span>+ </button>+ );+}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.tsxnew file mode 100644index 000000000..5ebee242a--- /dev/null+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/rename-machine-modal.tsx@@ -0,0 +1,135 @@+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 type { BaseModalProps } from '@renderer/lib/modal/modal-provider';+import { Button } from '@renderer/lib/ui/button';+import { ConfirmButton } from '@renderer/lib/ui/confirm-button';+import {+ DialogContentArea,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from '@renderer/lib/ui/dialog';+import { Field, FieldGroup, FieldLabel } from '@renderer/lib/ui/field';+import { Input } from '@renderer/lib/ui/input';+import { Textarea } from '@renderer/lib/ui/textarea';+import {+ MAX_MACHINE_DESCRIPTION,+ MAX_MACHINE_NAME,+} from '@shared/core/managed-agents/machine-enrollment';++type Props = BaseModalProps<void> & {+ serverId: string;+ machineId: string;+ currentName: string;+ currentDescription: string | null;+};++/** Renames one of the person's machines and changes its description; an empty description clears it. */+export function RenameMachineModal({+ serverId,+ machineId,+ currentName,+ currentDescription,+ onSuccess,+ onClose,+}: Props) {+ const queryClient = useQueryClient();+ const [name, setName] = useState(currentName);+ const [description, setDescription] = useState(currentDescription ?? '');+ const [saving, setSaving] = useState(false);+ const [error, setError] = useState<string | null>(null);++ const trimmedName = name.trim();+ const trimmedDescription = description.trim();+ const nameChanged = trimmedName !== currentName;+ const descriptionChanged = trimmedDescription !== (currentDescription ?? '');+ const nameTooLong = trimmedName.length > MAX_MACHINE_NAME;+ const descriptionTooLong = trimmedDescription.length > MAX_MACHINE_DESCRIPTION;+ const valid =+ trimmedName.length > 0 &&+ !nameTooLong &&+ !descriptionTooLong &&+ (nameChanged || descriptionChanged);++ const save = async () => {+ if (!valid) return;+ setSaving(true);+ setError(null);+ try {+ await rpc.managedAgents.updateMachine({+ serverId,+ machineId,+ changes: {+ ...(nameChanged ? { name: trimmedName } : {}),+ ...(descriptionChanged ? { description: trimmedDescription || null } : {}),+ },+ });+ await queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, serverId] });+ onSuccess();+ } catch (err) {+ setError(failureText(err, 'Could not save the machine.'));+ setSaving(false);+ }+ };++ return (+ <>+ <DialogHeader showCloseButton={false}>+ <DialogTitle>Rename machine</DialogTitle>+ </DialogHeader>+ <DialogContentArea className="pt-0">+ <FieldGroup>+ <Field>+ <FieldLabel>Name</FieldLabel>+ <Input+ value={name}+ onChange={(e) => setName(e.target.value)}+ onKeyDown={(e) => {+ if (e.key === 'Enter') void save();+ }}+ autoFocus+ />+ {trimmedName.length === 0 && (+ <p className="mt-1 text-xs text-destructive">A machine needs a name.</p>+ )}+ {nameTooLong && (+ <p className="mt-1 text-xs text-destructive">+ At most {MAX_MACHINE_NAME} characters.+ </p>+ )}+ </Field>+ <Field>+ <FieldLabel>Description (optional)</FieldLabel>+ <Textarea+ value={description}+ onChange={(e) => setDescription(e.target.value)}+ placeholder="What this machine is for"+ rows={3}+ />+ {descriptionTooLong && (+ <p className="mt-1 text-xs text-destructive">+ At most {MAX_MACHINE_DESCRIPTION} characters.+ </p>+ )}+ </Field>+ </FieldGroup>+ {error && (+ <p role="alert" className="mt-2 text-xs text-destructive">+ {error}+ </p>+ )}+ </DialogContentArea>+ <DialogFooter>+ <Button variant="outline" onClick={onClose}>+ Cancel+ </Button>+ <ConfirmButton onClick={() => void save()} disabled={!valid || saving}>+ {saving ? 'Saving…' : 'Save'}+ </ConfirmButton>+ </DialogFooter>+ </>+ );+}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.tsxindex 97dfb6a2f..e23e5e6b0 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@@ -1,4 +1,4 @@-import { MoreVertical, Power, PowerOff, Trash2 } from 'lucide-react';+import { ArrowRightLeft, MoreVertical, Power, PowerOff, Trash2 } from 'lucide-react';import { observer } from 'mobx-react-lite';import type { ReactNode } from 'react';import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';@@ -25,6 +25,7 @@ import { TitlebarBreadcrumb } from '@renderer/lib/components/titlebar/titlebar-bimport { failureText } from '@renderer/lib/errors/describe-failure';import { useFeatureFlags } from '@renderer/lib/hooks/useFeatureFlags';import { useParams } from '@renderer/lib/layout/navigation-provider';+import { useShowModal } from '@renderer/lib/modal/modal-provider';import { Button } from '@renderer/lib/ui/button';import {DropdownMenu,@@ -170,6 +171,7 @@ function ManagedAgentActionsMenu({ agent }: { agent: ManagedAgentView }) {function ManagedAgentActionItems({ agent }: { agent: ManagedAgentView }) {const { busy, setDesiredState, remove } = useManagedAgentActions(agent);const chatsOn = useFeatureFlags(agent.serverId).agent_chats;+ const showMoveModal = useShowModal('moveAgentModal');return (<>@@ -184,6 +186,10 @@ function ManagedAgentActionItems({ agent }: { agent: ManagedAgentView }) {Turn on agent</DropdownMenuItem>)}+ <DropdownMenuItem disabled={busy} onClick={() => showMoveModal({ agent })}>+ <ArrowRightLeft className="size-4" />+ Move to another machine…+ </DropdownMenuItem>{!chatsOn && (<><DropdownMenuSeparator />diff --git a/console/apps/switch-console-desktop/src/shared/core/managed-agents/managed-agents.ts b/console/apps/switch-console-desktop/src/shared/core/managed-agents/managed-agents.tsindex b42cd4dc4..3f7625454 100644--- a/console/apps/switch-console-desktop/src/shared/core/managed-agents/managed-agents.ts+++ b/console/apps/switch-console-desktop/src/shared/core/managed-agents/managed-agents.ts@@ -137,6 +137,11 @@ export type OwnedMachine = ManagedMachine & {/** A provider on a machine with its version and when the machine last checked it. */export type MachineProviderDetail = MachineProvider & {version: string | null;+ /**+ * Where its sign-in comes from: the machine's own (`local`) or one given to+ * it from Switch Console (`sealed`); null when it has none or did not say.+ */+ authSource: 'local' | 'sealed' | null;checkedAt: string | null;};