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
Devices: address review on recheck, connection state, and placing agents
Petr Bauch567782c2055b
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 6b691500e..ba90d01f8 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@@ -89,6 +89,17 @@ function machinesOn(serverId: string): Promise<OwnedMachine[] | null> {return controllersOn(serverId, ownedMachines);}+/** Runs a management call, giving a refusal Switch explains (a 4xx) in Switch's own words. */+async function inSwitchsWords<T>(call: () => Promise<T>): Promise<T> {+ try {+ return await call();+ } catch (error) {+ if (error instanceof GatewayError && error.status !== undefined && error.status < 500)+ throw new Error(managementErrorMessage(error));+ throw error;+ }+}+/*** The signed-in user's managed agents on a server, as the server holds them:* every one, whatever machine it runs on. Console keeps no copy.@@ -219,8 +230,9 @@ export const managedAgentsController = createRPCController({/*** A one-time code to enroll a new machine with, and the address it enrolls- * against: the one the server names, else the one Console reaches it at.- * `loopback` says that address only works on this computer.+ * against: the one the server names, else the one Console reaches it at,+ * which `fallback` discloses. `loopback` says that address only works on+ * this computer.*/machineEnrollment: (serverId: string): Promise<MachineEnrollment> =>withReachableServerWorkspaceSession(serverId, async (server) => {@@ -231,6 +243,7 @@ export const managedAgentsController = createRPCController({expiresAt: issued.expiresAt,serverUrl,loopback: isLoopbackUrl(serverUrl),+ fallback: issued.serverUrl === null,};}),@@ -268,15 +281,9 @@ export const managedAgentsController = createRPCController({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;- }- }),+ withReachableServerWorkspaceSession(params.serverId, (server) =>+ inSwitchsWords(() => updateManagementController(server, params.machineId, params.changes))+ ),/*** Removes one of the owner's machines from Switch: its credential is@@ -284,15 +291,9 @@ export const managedAgentsController = createRPCController({* 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;- }- }),+ withReachableServerWorkspaceSession(params.serverId, (server) =>+ inSwitchsWords(() => revokeManagementController(server, params.machineId))+ ),/** How a recheck went, by the operation `recheckMachineProvider` answered. */machineRecheckOutcome: (params: {@@ -316,18 +317,14 @@ export const managedAgentsController = createRPCController({}): Promise<void> =>withReachableServerWorkspaceSession(params.serverId, async (server) => {const definition = definitionBody(params.changes.definition);- try {- await updateManagedAgent(server, params.agentId, {+ await inSwitchsWords(() =>+ updateManagedAgent(server, params.agentId, {definition: Object.keys(definition).length > 0 ? definition : null,...(params.changes.machineId !== undefined? { controllerId: params.changes.machineId }: {}),- });- } catch (error) {- if (error instanceof GatewayError && error.status !== undefined && error.status < 500)- throw new Error(managementErrorMessage(error));- throw error;- }+ })+ );}),/** Starts or stops it on its machine. */diff --git a/console/apps/switch-console-desktop/src/main/core/managed-agents/machine-enrollment-rpc.test.ts b/console/apps/switch-console-desktop/src/main/core/managed-agents/machine-enrollment-rpc.test.tsnew file mode 100644index 000000000..1a744522f--- /dev/null+++ b/console/apps/switch-console-desktop/src/main/core/managed-agents/machine-enrollment-rpc.test.ts@@ -0,0 +1,55 @@+import { beforeEach, describe, expect, it, vi } from 'vitest';++const mocks = vi.hoisted(() => ({ issueMachineEnrollment: vi.fn() }));++vi.mock('@main/core/agent-migration/agent-migration', () => ({ agentMigrationService: {} }));+vi.mock('@main/lib/logger', () => ({ log: { warn: vi.fn(), error: vi.fn(), info: vi.fn() } }));+vi.mock('@main/core/embedded-controller/embedded-controllers', () => ({+ embeddedControllerService: {},+}));+vi.mock('@main/core/host-controllers/host-controllers', () => ({ hostControllerService: {} }));+vi.mock('@main/core/workspaces/workspaces-store', () => ({ requireWorkspaceForServer: vi.fn() }));+vi.mock('@main/core/workspaces/workspace-session', () => ({+ withReachableServerWorkspaceSession: (_serverId: string, run: (server: unknown) => unknown) =>+ run({ id: 'server-1', url: 'https://switch.internal.example' }),+}));+vi.mock('@main/core/switch-servers/gateway-client', () => ({+ AgentManagementUnavailableError: class extends Error {},+ GatewayError: class extends Error {},+ managementErrorMessage: vi.fn(),+ issueMachineEnrollment: mocks.issueMachineEnrollment,+}));++const { managedAgentsController } = await import('./controller');++beforeEach(() => vi.clearAllMocks());++describe('machineEnrollment', () => {+ it('uses the address the server names', async () => {+ mocks.issueMachineEnrollment.mockResolvedValue({+ code: 'c',+ expiresAt: '2026-11-04T10:10:00Z',+ serverUrl: 'https://switch.example.com',+ });+ expect(await managedAgentsController.machineEnrollment('server-1')).toEqual({+ code: 'c',+ expiresAt: '2026-11-04T10:10:00Z',+ serverUrl: 'https://switch.example.com',+ loopback: false,+ fallback: false,+ });+ });++ it('says when it falls back to the address Console reaches the server at', async () => {+ mocks.issueMachineEnrollment.mockResolvedValue({+ code: 'c',+ expiresAt: '2026-11-04T10:10:00Z',+ serverUrl: null,+ });+ expect(await managedAgentsController.machineEnrollment('server-1')).toMatchObject({+ serverUrl: 'https://switch.internal.example',+ loopback: false,+ fallback: true,+ });+ });+});diff --git a/console/apps/switch-console-desktop/src/renderer/features/deeplinks/open-console-link.ts b/console/apps/switch-console-desktop/src/renderer/features/deeplinks/open-console-link.tsindex 69f2d9727..b39a55b07 100644--- a/console/apps/switch-console-desktop/src/renderer/features/deeplinks/open-console-link.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/deeplinks/open-console-link.ts@@ -85,7 +85,7 @@ async function openOnServer(serverId: string, link: ConsoleLink): Promise<void>return;case 'agents/new':navigation.navigate('serverAgents', { serverId });- showModal('addAgentModal', { entryPoint: 'link', machineId: null });+ showModal('addAgentModal', { entryPoint: 'link', machine: null });return;case 'agent':await openAgent(serverId, link.id!, link.tab);diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsxindex 33580033b..940ef8c0d 100644--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/add-agent-modal/add-agent-modal.tsx@@ -10,18 +10,21 @@ export type AddLocationModalProps = BaseModalProps<void> & {* under the same heading as the ones that did not.*/entryPoint: UiEntryPoint;- /** The machine the agent goes on, picked already: null to start on this computer. */- machineId: string | null;+ /**+ * The machine the agent goes on, picked already, with the server it is on+ * (which need not be the active one): null to start on this computer.+ */+ machine: { serverId: string; machineId: string } | null;};-export function AddAgentModal({ onClose, entryPoint, machineId }: AddLocationModalProps) {+export function AddAgentModal({ onClose, entryPoint, machine }: AddLocationModalProps) {return (<NewAgentFormonClose={onClose}onBack={null}entryPoint={entryPoint}- serverId={null}- initialRunLocation={machineId ? machineRunLocation(machineId) : 'local'}+ serverId={machine?.serverId ?? null}+ initialRunLocation={machine ? machineRunLocation(machine.machineId) : 'local'}/>);}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.tsxindex 0a10072fe..ef973ffbb 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@@ -107,12 +107,24 @@ export function AddMachineModal({ serverId, onClose }: Props) {</Field></FieldGroup>- {issued.loopback && (+ {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. Anotherdevice needs an address it can reach Switch at: change <code>--server</code> tothat.</p>+ ) : (+ issued.fallback && (+ <p+ role="status"+ className="rounded-md border border-border-warning bg-background-warning px-3 py-2 text-xs text-foreground-warning"+ >+ This server has no public address set, so these commands use the address this+ Console reaches it at, {issued.serverUrl}. If the device reaches Switch at another+ address (behind a proxy, or by an internal name), change <code>--server</code> to+ that.+ </p>+ ))}{nameTooLong || descriptionTooLong ? (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.tsxindex 6977f39a7..da71b1f89 100644--- 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@@ -104,8 +104,13 @@ function DevicesBody({const managed = useManagedAgents(serverId);const [showRemoved, setShowRemoved] = useState(false);- if (machines.error && !frozen)- return (+ // A frozen workspace's banner already says why the server cannot answer.+ if (machines.error)+ return frozen ? (+ <p className="pt-4 text-sm text-foreground-muted">+ Your devices show here once the server answers again.+ </p>+ ) : (<p role="alert" className="pt-4 text-sm text-destructive">{failureText(machines.error, 'Could not load your devices.')}</p>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 b296fdb22..b9bbdc524 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@@ -37,9 +37,11 @@ import {machineKindLabel,machineNotices,type MachineTone,+ placedAgents,platformLabel,+ resourceLabel,+ sessionsLabel,} from './machine-state';-import type { PlacedAgents } from './machine-state';import { useDeviceActions } from './use-device-actions';/** A notice's box, in the server page's hues. */@@ -81,16 +83,17 @@ const PROCESS_TONE: Record<string, MachineTone> = {export function MachineDetails({serverId,machine,- placed,- placedState,+ managed,}: {serverId: string;machine: MachineDetail;- /** The managed agents placed on it. */- placed: ManagedAgentView[];- /** Whether `placed` is read yet, for Remove's warning about the agents it strands. */- placedState: PlacedAgents;+ /** The person's managed agents, as their list query has them. */+ managed: { data: ManagedAgentView[] | null | undefined; isError: boolean };}) {+ // Null until the list is read (or when it could not be): nothing can then be said about whose an agent is.+ const mine = managed.isError || managed.data === undefined ? null : (managed.data ?? []);+ const placed = (mine ?? []).filter((agent) => agent.machine?.id === machine.id);+ const placedState = placedAgents(managed, machine.id);const connection = machineConnection(machine);const notices = machineNotices(machine);const removed = machine.state === 'revoked';@@ -142,7 +145,10 @@ export function MachineDetails({: 'It can take a new agent once it is online.'}onClick={() =>- showAddAgentModal({ entryPoint: 'machine_page', machineId: machine.id })+ showAddAgentModal({+ entryPoint: 'machine_page',+ machine: { serverId, machineId: machine.id },+ })}><Plus className="size-4" />@@ -185,7 +191,7 @@ export function MachineDetails({)}{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} />+ <AgentsCard machine={machine} placed={placed} mine={mine} />{!removed && <MachineProviders serverId={serverId} machine={machine} />}</div>);@@ -268,10 +274,11 @@ function ConnectionCard({ machine }: { machine: MachineDetail }) {}function Usage({ free, total }: { free: number; total: number }) {- if (total <= 0) return <>—</>;+ const label = resourceLabel(free, total, formatBytes);+ if (label === null) return <>—</>;return (<div>- {formatBytes(free)} free of {formatBytes(total)}+ {label}<Progressvalue={Math.round(((total - free) / total) * 100)}aria-label="Used"@@ -304,11 +311,7 @@ function SystemCard({ machine }: { machine: MachineDetail }) {<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>+ <Row label="Sessions">{`${sessionsLabel(resources)} running`}</Row></>)}</dl>@@ -373,15 +376,26 @@ function CloudMachineSection({ serverId, machine }: { serverId: string; machine:/*** 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.+ * movable to another device, and any others it reports running that are not+ * this person's, which they cannot open. Until their agents are listed none+ * is called someone else's, and one of theirs placed elsewhere (the device+ * still reporting an agent just moved off it) is not either.*/-function AgentsCard({ machine, placed }: { machine: MachineDetail; placed: ManagedAgentView[] }) {+function AgentsCard({+ machine,+ placed,+ mine,+}: {+ machine: MachineDetail;+ placed: ManagedAgentView[];+ mine: ManagedAgentView[] | null;+}) {const { navigate } = useNavigate();const showMoveModal = useShowModal('moveAgentModal');- const unlisted = machine.agents.filter(- (report) => !placed.some((agent) => agent.agentId === report.agentId)- );+ const unlisted =+ mine === null+ ? []+ : machine.agents.filter((report) => !mine.some((agent) => agent.agentId === report.agentId));const count = placed.length + unlisted.length;return (<Carddiff --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 43a0f4aa4..dede7d796 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@@ -133,13 +133,16 @@ function MachineProviderRow({operationId: operationId!,}),enabled: operationId !== null,+ retry: false,+ // A read that failed ends the wait: its error is shown, and Recheck asks again.refetchInterval: (query) =>- query.state.data?.state === 'pending' || query.state.data === undefined+ query.state.status !== 'error' &&+ (query.state.data?.state === 'pending' || query.state.data === undefined)? RECHECK_POLL_MS: false,});const result = outcome.data;- const done = result !== undefined && result.state !== 'pending';+ const done = outcome.isError || (result !== undefined && result.state !== 'pending');// What the machine found arrives with its report: read it now rather than at the next poll.useEffect(() => {if (done) void queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, serverId] });@@ -156,9 +159,11 @@ function MachineProviderRow({const failure = recheck.error? failureText(recheck.error, `Could not ask ${machine.name} to check ${name}.`)- : result?.state === 'failed'- ? result.message- : null;+ : outcome.error+ ? failureText(outcome.error, `Could not find out how ${machine.name} checked ${name}.`)+ : result?.state === 'failed'+ ? result.message+ : null;return (<>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 0cd9bf08a..9fee18d29 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@@ -72,6 +72,12 @@ describe('machineConnection', () => {'Never connected');});++ it('calls a machine the server says is online online, with no connection recorded yet', () => {+ const online = machine({ id: 'm', state: 'online', connection: null });+ expect(machineConnection(online)).toEqual({ label: 'Online', tone: 'ok', title: 'Connected.' });+ expect(machineNotices(online).map((notice) => notice.key)).not.toContain('connection');+ });});describe('controllerRelease', () => {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 749afc731..59c879b02 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@@ -33,18 +33,21 @@ export function machineConnection(machine: MachineDetail): MachineBadge {tone: 'idle',title: machine.revokedAt ? `Removed from Switch ${when(machine.revokedAt)}.` : 'Removed.',};+ // Online is decided by the server; the connection ledger can be empty even+ // then (the server sends none until it has recorded a connect), so it only+ // adds when.+ if (machine.state === 'online')+ return {+ label: 'Online',+ tone: 'ok',+ title: connection ? `Connected since ${when(connection.connectedAt)}.` : 'Connected.',+ };if (machine.state === 'unknown' || connection === null)return {label: 'Never connected',tone: 'idle',title: 'Has never connected to Switch. It does once its controller is started.',};- if (machine.state === 'online')- return {- label: 'Online',- tone: 'ok',- title: `Connected since ${when(connection.connectedAt)}.`,- };const why = connection.disconnectReason? (DISCONNECT_REASON[connection.disconnectReason] ?? connection.disconnectReason): null;@@ -215,7 +218,10 @@ export function machineNotices(machine: MachineDetail): MachineNotice[] {title: 'Offline',body: `${connection.title} The agents placed on it do not run until it is back.`,});- else if (machine.state === 'unknown' || machine.connection === null)+ else if (+ machine.state === 'unknown' ||+ (machine.state !== 'online' && machine.connection === null)+ )notices.push({key: 'connection',tone: 'idle',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.tsxindex a6e6116ed..6d8823e24 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@@ -10,7 +10,6 @@ import { failureText } from '@renderer/lib/errors/describe-failure';import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';import { Spinner } from '@renderer/lib/ui/spinner';import { MachineDetails } from './machine-details';-import { placedAgents } from './machine-state';import { useMachineDetails } from './use-machines';type MachineParams = { serverId: string; machineId: string; name: string };@@ -44,10 +43,17 @@ const MachinePanel = observer(function MachinePanel() {<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-[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.')}- </p>+ {machines.error ? (+ // A frozen workspace's banner already says why the server cannot answer.+ server && isFrozenServer(server) ? (+ <ServerTableEmpty>+ This device shows here once the server answers again.+ </ServerTableEmpty>+ ) : (+ <p role="alert" className="text-sm text-destructive">+ {failureText(machines.error, 'Could not load this machine.')}+ </p>+ )) : machines.data === undefined ? (<Spinner />) : machines.data === null ? (@@ -59,12 +65,7 @@ const MachinePanel = observer(function MachinePanel() {{params.name} is no longer one of your devices on {server?.name ?? 'this server'}.</ServerTableEmpty>) : (- <MachineDetails- serverId={params.serverId}- machine={machine}- placed={(managed.data ?? []).filter((agent) => agent.machine?.id === machine.id)}- placedState={placedAgents(managed, machine.id)}- />+ <MachineDetails serverId={params.serverId} machine={machine} managed={managed} />)}</div></div>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.tsxindex a03cbe6fa..4d2c689c4 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@@ -58,16 +58,21 @@ export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {a.machine.name.localeCompare(b.machine.name));const folder = agent.status?.directory ?? agent.definition.directory;+ // The list refreshes while the dialog is open: a pick whose device went+ // offline or lost its provider since is no pick, so Move cannot send it.+ const chosen =+ others.find(({ machine, target }) => machine.id === picked && target.selectable)?.machine.id ??+ null;const move = async () => {- if (!picked) return;+ if (!chosen) return;setMoving(true);setError(null);try {await rpc.managedAgents.update({serverId: agent.serverId,agentId: agent.agentId,- changes: { definition: {}, machineId: picked },+ changes: { definition: {}, machineId: chosen },});await queryClient.invalidateQueries({ queryKey: [MANAGED_AGENTS_KEY, agent.serverId] });onSuccess();@@ -109,7 +114,7 @@ export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {key={machine.id}machine={machine}target={target}- picked={picked === machine.id}+ picked={chosen === machine.id}onPick={() => setPicked(machine.id)}/>))}@@ -132,7 +137,7 @@ export function MoveAgentModal({ agent, onSuccess, onClose }: Props) {<Button variant="outline" onClick={onClose}>Cancel</Button>- <ConfirmButton onClick={() => void move()} disabled={!picked || moving}>+ <ConfirmButton onClick={() => void move()} disabled={!chosen || moving}>{moving ? 'Moving…' : `Move ${label}`}</ConfirmButton></DialogFooter>diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/use-machines.ts b/console/apps/switch-console-desktop/src/renderer/features/machines/use-machines.tsindex 52d8ff218..7c88167dd 100644--- a/console/apps/switch-console-desktop/src/renderer/features/machines/use-machines.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/use-machines.ts@@ -1,14 +1,19 @@import { useQuery } from '@tanstack/react-query';-import { MANAGED_AGENTS_KEY } from '@renderer/features/managed-agents/use-managed-agents';+import {+ MANAGED_AGENTS_KEY,+ refreshEvery,+} from '@renderer/features/managed-agents/use-managed-agents';+import { useUserChangesLive } from '@renderer/features/managed-agents/use-user-changes';import { serverAvailability } from '@renderer/features/switch-servers/server-availability';import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';import { workspacesStore } from '@renderer/features/workspaces/workspaces-store';import { rpc } from '@renderer/lib/ipc';/**- * How often the page reads the machines again: often enough that a machine- * going on- or offline shows while the page is looked at. react-query pauses- * while the window is hidden.+ * How often the page reads the machines again against a server that does not+ * push changes: often enough that a machine going on- or offline shows while+ * the page is looked at. One that pushes them says when to read. react-query+ * pauses while the window is hidden.*/const MACHINES_REFRESH_MS = 5_000;@@ -19,6 +24,7 @@ const MACHINES_REFRESH_MS = 5_000;* those refreshes this too.*/export function useMachineDetails(serverId: string) {+ const pushed = useUserChangesLive(serverId);const signedIn =switchServersStore.isConnected(serverId) && serverAvailability(serverId) !== 'dormant';return useQuery({@@ -30,7 +36,8 @@ export function useMachineDetails(serverId: string) {],queryFn: () => rpc.managedAgents.machineDetails(serverId),enabled: signedIn,- refetchInterval: MACHINES_REFRESH_MS,+ refetchInterval: (query) =>+ refreshEvery(MACHINES_REFRESH_MS, pushed, query.state.status === 'error'),retry: false,});}diff --git a/console/apps/switch-console-desktop/src/renderer/features/onboarding/use-onboarding-checklist.ts b/console/apps/switch-console-desktop/src/renderer/features/onboarding/use-onboarding-checklist.tsindex 9eec99dc9..40c71ff51 100644--- a/console/apps/switch-console-desktop/src/renderer/features/onboarding/use-onboarding-checklist.ts+++ b/console/apps/switch-console-desktop/src/renderer/features/onboarding/use-onboarding-checklist.ts@@ -70,7 +70,7 @@ export function useOnboardingChecklist(): OnboardingChecklist {navigate('settings', { tab: 'clis-models' });return;case 'onboardAgents':- showAddAgentModal({ entryPoint: 'onboarding', machineId: null });+ showAddAgentModal({ entryPoint: 'onboarding', machine: null });return;case 'createRoom':showCreateRoomModal({});diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsxindex c43f7c334..a16a59cb9 100644--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsx@@ -344,7 +344,7 @@ export const SessionsSectionHeader = observer(function SessionsSectionHeader({</DropdownMenuItem><DropdownMenuSeparator /><DropdownMenuItem- onClick={() => showAddLocationModal({ entryPoint: 'sidebar', machineId: null })}+ onClick={() => showAddLocationModal({ entryPoint: 'sidebar', machine: null })}><UserPlus className="mr-1.5 h-4 w-4" />Add an agentdiff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-agents-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-agents-view.tsxindex 51e80dab2..c561b2250 100644--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-agents-view.tsx+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-agents-view.tsx@@ -116,7 +116,7 @@ const ServerAgentsPanel = observer(function ServerAgentsPanel() {<div className="grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-[14px]"><buttontype="button"- onClick={() => showAddAgentModal({ entryPoint: 'server_page', machineId: null })}+ onClick={() => showAddAgentModal({ entryPoint: 'server_page', machine: null })}className="flex min-h-[184px] cursor-pointer items-center justify-center rounded-[11px] border border-dashed border-border text-foreground-muted transition-colors hover:border-border-1 hover:bg-[var(--sel-soft)] hover:text-foreground"aria-label="Add agent">diff --git a/console/apps/switch-console-desktop/src/renderer/lib/commands/app-commands.ts b/console/apps/switch-console-desktop/src/renderer/lib/commands/app-commands.tsindex bff4747ea..75cade088 100644--- a/console/apps/switch-console-desktop/src/renderer/lib/commands/app-commands.ts+++ b/console/apps/switch-console-desktop/src/renderer/lib/commands/app-commands.ts@@ -48,7 +48,7 @@ function createAppCommandProvider(): CommandProvider {shortcutKey: newLocationDef.shortcutKey,group: newLocationDef.group,execute() {- showModal('addAgentModal', { entryPoint: 'command_palette', machineId: null });+ showModal('addAgentModal', { entryPoint: 'command_palette', machine: null });},},{diff --git a/console/apps/switch-console-desktop/src/renderer/lib/components/provider-status-row.tsx b/console/apps/switch-console-desktop/src/renderer/lib/components/provider-status-row.tsxindex efb9c6448..156961798 100644--- a/console/apps/switch-console-desktop/src/renderer/lib/components/provider-status-row.tsx+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/provider-status-row.tsx@@ -17,8 +17,6 @@ export function ProviderStatusRow({name,installed,status,- meta,- actions,onClick,}: {providerId: string;@@ -26,10 +24,6 @@ export function ProviderStatusRow({installed: boolean;/** The line under the name: sign-in state, or a check in progress. */status: ReactNode;- /** A short note after the name, such as the version. */- meta?: string;- /** Buttons beside the badge. Not with `onClick`: a button cannot hold buttons. */- actions?: ReactNode;/** Makes the whole row a button. */onClick?: () => void;}) {@@ -47,12 +41,8 @@ export function ProviderStatusRow({</div><div className="flex w-full min-w-0 flex-col gap-0.5"><div className="flex w-full items-center justify-between gap-2">- <span className="min-w-0 truncate text-sm text-foreground">- {name}- {meta && <span className="text-foreground-muted"> · {meta}</span>}- </span>+ <span className="min-w-0 truncate text-sm text-foreground">{name}</span><div className="flex shrink-0 items-center gap-1.5">- {actions}{installed ? <InstalledBadge /> : <UninstalledBadge />}</div></div>diff --git a/console/apps/switch-console-desktop/src/shared/core/managed-agents/machine-enrollment.ts b/console/apps/switch-console-desktop/src/shared/core/managed-agents/machine-enrollment.tsindex 654b573ac..cf2e7c534 100644--- a/console/apps/switch-console-desktop/src/shared/core/managed-agents/machine-enrollment.ts+++ b/console/apps/switch-console-desktop/src/shared/core/managed-agents/machine-enrollment.ts@@ -12,6 +12,11 @@ export type MachineEnrollment = {serverUrl: string;/** `serverUrl` names this computer, so no other machine can reach it there. */loopback: boolean;+ /**+ * The server names no public address (`GATEWAY_PUBLIC_URL`), so `serverUrl`+ * is the one this Console reaches it at, which another machine may not.+ */+ fallback: boolean;};/** The longest name and description a machine can enroll with. */