Skip to content

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

Keep devices on screen when a refresh fails, and fix enrollment and remove copy

Petr Bauchad974884bbcd
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.ts
index ba90d01f8..6fab62148 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
@@ -237,13 +237,15 @@ export const managedAgentsController = createRPCController({
machineEnrollment: (serverId: string): Promise<MachineEnrollment> =>
withReachableServerWorkspaceSession(serverId, async (server) => {
const issued = await issueMachineEnrollment(server);
- const serverUrl = issued.serverUrl ?? server.url;
+ // A server with GATEWAY_PUBLIC_URL set but empty names "" rather than null.
+ const named = issued.serverUrl?.trim() || null;
+ const serverUrl = named ?? server.url;
return {
code: issued.code,
expiresAt: issued.expiresAt,
serverUrl,
loopback: isLoopbackUrl(serverUrl),
- fallback: issued.serverUrl === null,
+ fallback: named === null,
};
}),
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.ts
index 1a744522f..27068ed6d 100644
--- 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.ts
@@ -52,4 +52,16 @@ describe('machineEnrollment', () => {
fallback: true,
});
});
+
+ it('treats an empty address from the server as none named', async () => {
+ mocks.issueMachineEnrollment.mockResolvedValue({
+ code: 'c',
+ expiresAt: '2026-11-04T10:10:00Z',
+ serverUrl: '',
+ });
+ expect(await managedAgentsController.machineEnrollment('server-1')).toMatchObject({
+ serverUrl: 'https://switch.internal.example',
+ fallback: true,
+ });
+ });
});
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
index da71b1f89..9abdd81fc 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
@@ -31,6 +31,7 @@ import {
machineConnection,
} from './machine-state';
import { type PlacedAgents, placedAgents } from './machine-state';
+import { RefreshFailed } from './refresh-failed';
import { useDeviceActions } from './use-device-actions';
import { useMachineDetails } from './use-machines';
@@ -105,7 +106,7 @@ function DevicesBody({
const [showRemoved, setShowRemoved] = useState(false);
// A frozen workspace's banner already says why the server cannot answer.
- if (machines.error)
+ if (machines.error && !machines.data)
return frozen ? (
<p className="pt-4 text-sm text-foreground-muted">
Your devices show here once the server answers again.
@@ -132,11 +133,14 @@ function DevicesBody({
return (
<div className="flex flex-col gap-6 pt-4 pb-10">
+ {machines.error && <RefreshFailed error={machines.error} frozen={frozen} />}
{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.`}
+ : filter === 'all'
+ ? 'No devices.'
+ : `Nothing under ${MACHINE_CATEGORY_LABELS[filter as MachineCategory]}.`}
</p>
) : (
<div className="grid grid-cols-2 gap-3">
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 6d8823e24..3fb0b9c09 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,6 +10,7 @@ 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 { RefreshFailed } from './refresh-failed';
import { useMachineDetails } from './use-machines';
type MachineParams = { serverId: string; machineId: string; name: string };
@@ -43,7 +44,7 @@ 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 ? (
+ {machines.error && !machines.data ? (
// A frozen workspace's banner already says why the server cannot answer.
server && isFrozenServer(server) ? (
<ServerTableEmpty>
@@ -65,7 +66,12 @@ 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} managed={managed} />
+ <div className="flex flex-col gap-4">
+ {machines.error && (
+ <RefreshFailed error={machines.error} frozen={!!server && isFrozenServer(server)} />
+ )}
+ <MachineDetails serverId={params.serverId} machine={machine} managed={managed} />
+ </div>
)}
</div>
</div>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/machines/refresh-failed.tsx b/console/apps/switch-console-desktop/src/renderer/features/machines/refresh-failed.tsx
new file mode 100644
index 000000000..e5321a472
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/machines/refresh-failed.tsx
@@ -0,0 +1,15 @@
+import { failureText } from '@renderer/lib/errors/describe-failure';
+
+/**
+ * Shown above devices already on screen when refreshing them fails, so the
+ * page keeps what the server last sent instead of going blank, and says so.
+ * A frozen workspace's banner already says why the server cannot answer.
+ */
+export function RefreshFailed({ error, frozen }: { error: unknown; frozen: boolean }) {
+ if (frozen) return null;
+ return (
+ <p role="alert" className="text-sm text-destructive">
+ {failureText(error, 'Could not refresh your devices.')} Showing what the server last sent.
+ </p>
+ );
+}
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
index a44dc2bec..fca446701 100644
--- 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
@@ -54,7 +54,7 @@ export function useDeviceActions(serverId: string, machine: MachineDetail, place
placed.kind === 'unreadable'
? `${machine.name} stops running agents for you and cannot reconnect. Your agents could not be listed, so this cannot say which are on it: any placed on it stay there and do not run until you move them.`
: placed.kind === 'known' && placed.count > 0
- ? `${machine.name} stops running agents for you and cannot reconnect. The ${placed.count === 1 ? 'agent' : `${placed.count} agents`} on it stay placed on it and do not run until you move them.`
+ ? `${machine.name} stops running agents for you and cannot reconnect. ${placed.count === 1 ? 'The agent on it stays placed on it and does not run until you move it.' : `The ${placed.count} agents on it stay placed on it and do not run until you move them.`}`
: `${machine.name} stops running agents for you and cannot reconnect. To use it again, enroll it again.`,
confirmLabel: 'Remove',
onSuccess: () => {