Skip to content

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

Settings follows the new design: your things, your account, the ways out

Simon Flack1b89442575f2
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.ts
index b39a55b07..c914bec49 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
@@ -1,7 +1,7 @@
import { toast } from 'sonner';
import type { AdminSection } from '@renderer/features/admin/admin-sections';
import { isAgentSection } from '@renderer/features/managed-agents/agent-sections';
-import type { SettingsPageTab } from '@renderer/features/settings/components/SettingsPage';
+import { resolveSettingsTab } from '@renderer/features/settings/settings-tabs';
import { findBuddy } from '@renderer/features/switch-buddy/buddy-identity';
import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
import { administersWorkspaceInScope } from '@renderer/features/switch-servers/workspace-admin';
@@ -27,7 +27,7 @@ export async function openConsoleLink(raw: string): Promise<void> {
const { link } = parsed;
if (link.page === 'settings') {
appState.navigation.navigate('settings', {
- tab: (link.tab ?? 'general') as SettingsPageTab,
+ tab: resolveSettingsTab(link.tab),
});
return;
}
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 9f3dbf984..bd59669f8 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,13 +1,28 @@
-import React, { useCallback } from 'react';
+import { observer } from 'mobx-react-lite';
+import React 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 { openServerPage } from '@renderer/features/switch-servers/open-server-page';
+import { servesWebGateway } from '@renderer/features/switch-servers/server-gateway';
import { PageHeader } from '@renderer/lib/components/page-header';
-import { PageContent, PageLayout, PageSidebarMenu } from '@renderer/lib/components/page-layout';
+import { PageContent, PageLayout, PageSidebarSections } from '@renderer/lib/components/page-layout';
import { useAnyServerFeatureFlag } from '@renderer/lib/hooks/useFeatureFlags';
import { openExternalUrl } from '@renderer/lib/open-external';
+import { dashboardOrigin } from '@shared/core/switch-servers/switch-servers';
import { SWITCH_CONSOLE_DOCS_URL } from '@shared/urls';
import { AgentsSettingsPage } from '../agents-page/AgentsSettingsPage';
+import { AccountSettingsPage } from '../pages/account-page';
+import { ApiKeysSettingsPage } from '../pages/api-keys-page';
+import { MessagingAppsSettingsPage } from '../pages/messaging-apps-page';
+import { settingsServer } from '../pages/settings-server';
+import { SystemStatusSettingsPage } from '../pages/system-status-page';
+import {
+ type SettingsItemId,
+ type SettingsPageTab,
+ settingsSections,
+ shownSettingsTab,
+} from '../settings-tabs';
import NotificationSettingsCard from './NotificationSettingsCard';
import { OnboardingChecklistRow } from './OnboardingSettingsRow';
import { ReplayOnboardingRow } from './ReplayOnboardingRow';
@@ -18,33 +33,18 @@ import {
} from './SessionSettingsRows';
import TelemetrySettingsCard from './TelemetrySettingsCard';
import ThemeCard from './ThemeCard';
-import { UpdateCard } from './UpdateCard';
-
-export type SettingsPageTab =
- | 'general'
- | 'clis-models'
- | 'integrations'
- | 'connections'
- | 'browser'
- | 'interface'
- | 'remote-hosts'
- | 'devices'
- | 'managed-agents'
- | 'docs';
-// ---------------------------------------------------------------------------
-// Tab page components
-// ---------------------------------------------------------------------------
+export { resolveSettingsTab, type SettingsPageTab } from '../settings-tabs';
-function GeneralSettingsPage() {
+function PreferencesSettingsPage() {
return (
<div className="space-y-8 pb-10">
<PageHeader
sticky
- title="General"
- description="Manage your account, privacy settings, notifications, and app updates."
+ title="Preferences"
+ description="How Switch Console looks and behaves on this computer."
/>
- <UpdateCard />
+ <ThemeCard />
<AutoGenerateSessionNamesRow />
<AutoTrustWorktreesRow />
<PreserveSessionNameCapitalizationRow />
@@ -56,48 +56,19 @@ function GeneralSettingsPage() {
);
}
-function InterfaceSettingsPage() {
- return (
- <div className="space-y-8 pb-4">
- <PageHeader
- sticky
- title="Interface"
- description="Customize the appearance and behavior of the app."
- />
- <ThemeCard />
- </div>
- );
-}
-
-// ---------------------------------------------------------------------------
-// SettingsPage
-// ---------------------------------------------------------------------------
-
-/**
- * The tabs that have a pane to show. `docs` is an external link, and several
- * `SettingsPageTab` values are hidden in v0, so this is a subset.
- */
-const TAB_CONTENT: Partial<Record<SettingsPageTab, () => React.ReactNode>> = {
- general: () => <GeneralSettingsPage />,
+const TAB_CONTENT: Record<SettingsPageTab, () => React.ReactNode> = {
+ preferences: () => <PreferencesSettingsPage />,
+ 'messaging-apps': () => <MessagingAppsSettingsPage />,
'clis-models': () => <AgentsSettingsPage />,
- interface: () => <InterfaceSettingsPage />,
+ 'api-keys': () => <ApiKeysSettingsPage />,
'remote-hosts': () => <RemoteHostsSettingsPage />,
devices: () => <DevicesSettingsPage />,
'managed-agents': () => <MigrationSettingsPage />,
+ status: () => <SystemStatusSettingsPage />,
+ account: () => <AccountSettingsPage />,
};
-/**
- * A persisted snapshot can name a tab this build no longer renders — one hidden
- * in v0, or retired outright. Showing Settings with an empty pane and no tab
- * selected reads as broken, so fall back to General.
- */
-export function resolveSettingsTab(tab: unknown): SettingsPageTab {
- return typeof tab === 'string' && Object.hasOwn(TAB_CONTENT, tab)
- ? (tab as SettingsPageTab)
- : 'general';
-}
-
-export function SettingsPage({
+export const SettingsPage = observer(function SettingsPage({
tab: activeTab,
onTabChange,
}: {
@@ -107,50 +78,39 @@ export function SettingsPage({
// Only offered while some server runs agent management: elsewhere there is
// nothing to move to managed and nothing managed to look after.
const agentManagement = useAnyServerFeatureFlag('agent_management');
- const handleDocsClick = useCallback(() => {
- void openExternalUrl(SWITCH_CONSOLE_DOCS_URL, 'Could not open the documentation');
- }, []);
+ const { server, user } = settingsServer();
+ // Workspace settings are the gateway's, open to every member there. A
+ // Switch this Console runs without Docker serves no gateway.
+ const workspaceSettings = server !== null && user !== null && servesWebGateway(server);
+ const sections = settingsSections({
+ hasServer: server !== null,
+ agentManagement,
+ workspaceSettings,
+ });
+ const shownTab = shownSettingsTab(activeTab, sections);
- type Tab = {
- id: SettingsPageTab;
- label: string;
- isExternal?: boolean;
+ const select = (id: SettingsItemId) => {
+ if (id === 'docs') {
+ void openExternalUrl(SWITCH_CONSOLE_DOCS_URL, 'Could not open the documentation');
+ } else if (id === 'workspace-settings') {
+ if (server) void openServerPage(server.id, `${dashboardOrigin(server)}/workspace`);
+ } else {
+ onTabChange(id);
+ }
};
- const allTabs: Tab[] = [
- // Switch Console v0 hides Account, Integrations, Connections (SSH), and Browser tabs.
- { id: 'general', label: 'General' },
- { id: 'clis-models', label: 'Agent providers' },
- { id: 'devices', label: 'Your devices' },
- { id: 'remote-hosts', label: 'Remote hosts' },
- { id: 'managed-agents', label: 'Managed agents' },
- { id: 'interface', label: 'Interface' },
- { id: 'docs', label: 'Docs', isExternal: true },
- ];
- const needsAgentManagement = (tab: SettingsPageTab) =>
- tab === 'managed-agents' || tab === 'devices';
- const tabs = allTabs.filter((tab) => agentManagement || !needsAgentManagement(tab.id));
-
- const shownTab = !agentManagement && needsAgentManagement(activeTab) ? 'general' : activeTab;
- const currentContent = TAB_CONTENT[shownTab]?.();
return (
<PageLayout
- width={880}
+ width={960}
sidebar={
- <PageSidebarMenu
- items={tabs}
+ <PageSidebarSections
+ sections={sections}
activeId={shownTab}
- onSelect={(item) => {
- if (item.isExternal) {
- handleDocsClick();
- } else {
- onTabChange(item.id);
- }
- }}
+ onSelect={(item) => select(item.id)}
/>
}
>
- {currentContent && <PageContent>{currentContent}</PageContent>}
+ <PageContent>{TAB_CONTENT[shownTab]()}</PageContent>
</PageLayout>
);
-}
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/pages/account-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/account-page.tsx
new file mode 100644
index 000000000..e4bdc1845
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/account-page.tsx
@@ -0,0 +1,257 @@
+import { useMutation } from '@tanstack/react-query';
+import { LogOut, Pencil, Trash2 } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect, useState } from 'react';
+import { toast } from 'sonner';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { PageHeader } from '@renderer/lib/components/page-header';
+import { describeFailure } from '@renderer/lib/errors/describe-failure';
+import { rpc } from '@renderer/lib/ipc';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { Button } from '@renderer/lib/ui/button';
+import { Input } from '@renderer/lib/ui/input';
+import { Label } from '@renderer/lib/ui/label';
+import { type SwitchServer, type SwitchUser } from '@shared/core/switch-servers/switch-servers';
+import { OnSignedInServer } from './settings-server';
+
+/** Your profile on the server, and how to leave it. */
+export function AccountSettingsPage() {
+ return (
+ <div className="space-y-8 pb-10">
+ <PageHeader
+ sticky
+ title="Your account"
+ description="Your profile in Switch, and how to leave it."
+ />
+ <OnSignedInServer>
+ {({ server, user }) => <Account server={server} user={user} />}
+ </OnSignedInServer>
+ </div>
+ );
+}
+
+const Account = observer(function Account({
+ server,
+ user,
+}: {
+ server: SwitchServer;
+ user: SwitchUser;
+}) {
+ const showDeleteAccount = useShowModal('deleteAccountModal');
+ // Whether this server signs people in with a password at all; one that uses
+ // only single sign-on has no password of yours to change.
+ const passwords = switchServersStore.authConfigFor(server.id)?.passwordLoginEnabled ?? false;
+ useEffect(() => {
+ void switchServersStore.ensureAuthConfig(server.id);
+ }, [server.id]);
+
+ return (
+ <div className="space-y-6">
+ <DisplayName serverId={server.id} name={user.name} />
+ <div className="space-y-1.5">
+ <Label htmlFor="account-email">Email</Label>
+ <Input id="account-email" value={user.email} readOnly className="max-w-md" />
+ </div>
+ {passwords && <ChangePassword serverId={server.id} />}
+
+ <div className="flex items-center justify-between gap-4 rounded-lg border border-border p-4">
+ <div className="min-w-0 space-y-0.5">
+ <p className="text-sm text-foreground">Sign out of this Console</p>
+ <p className="text-sm text-foreground-muted">
+ This computer only. Your agents keep running and your other devices stay signed in.
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="shrink-0"
+ onClick={() => void switchServersStore.logout(server.id)}
+ >
+ <LogOut className="size-4" />
+ Sign out
+ </Button>
+ </div>
+
+ <div className="space-y-3 rounded-lg border border-destructive/40 p-4">
+ <div className="space-y-0.5">
+ <p className="text-sm text-destructive">Delete account</p>
+ <p className="text-sm text-foreground-muted">
+ Permanent: your agents stop and leave every room, and your devices are unregistered.
+ </p>
+ </div>
+ <Button
+ variant="destructive"
+ size="sm"
+ onClick={() =>
+ showDeleteAccount({ serverId: server.id, serverName: server.name, email: user.email })
+ }
+ >
+ <Trash2 className="size-4" />
+ Delete my account
+ </Button>
+ </div>
+ </div>
+ );
+});
+
+/** Your name as others in the workspace see it, changed in place. */
+function DisplayName({ serverId, name }: { serverId: string; name: string }) {
+ const [editing, setEditing] = useState(false);
+ const [draft, setDraft] = useState(name);
+ const save = useMutation({
+ mutationFn: () => rpc.switchServers.updateMyName({ serverId, name: draft.trim() }),
+ onSuccess: async () => {
+ setEditing(false);
+ await switchServersStore.refreshStatus(serverId);
+ },
+ onError: (error) => {
+ const { headline, detail } = describeFailure(error, 'Could not change your name.');
+ toast.error(headline, detail ? { description: detail } : undefined);
+ },
+ });
+ const trimmed = draft.trim();
+ return (
+ <form
+ className="space-y-1.5"
+ onSubmit={(event) => {
+ event.preventDefault();
+ if (trimmed && trimmed !== name) save.mutate();
+ else setEditing(false);
+ }}
+ >
+ <Label htmlFor="account-name">Display name</Label>
+ <div className="flex max-w-md items-center gap-2">
+ <Input
+ id="account-name"
+ value={editing ? draft : name}
+ readOnly={!editing}
+ maxLength={255}
+ autoFocus={editing}
+ onChange={(event) => setDraft(event.target.value)}
+ onKeyDown={(event) => {
+ if (event.key === 'Escape') setEditing(false);
+ }}
+ />
+ {editing ? (
+ <>
+ <Button type="submit" size="sm" disabled={!trimmed || save.isPending}>
+ Save
+ </Button>
+ <Button type="button" size="sm" variant="ghost" onClick={() => setEditing(false)}>
+ Cancel
+ </Button>
+ </>
+ ) : (
+ <Button
+ type="button"
+ size="icon-sm"
+ variant="ghost"
+ aria-label="Change display name"
+ onClick={() => {
+ setDraft(name);
+ setEditing(true);
+ }}
+ >
+ <Pencil className="size-4" />
+ </Button>
+ )}
+ </div>
+ </form>
+ );
+}
+
+function ChangePassword({ serverId }: { serverId: string }) {
+ const [open, setOpen] = useState(false);
+ const [current, setCurrent] = useState('');
+ const [next, setNext] = useState('');
+ const [confirm, setConfirm] = useState('');
+ const reset = () => {
+ setOpen(false);
+ setCurrent('');
+ setNext('');
+ setConfirm('');
+ };
+ const change = useMutation({
+ mutationFn: () =>
+ rpc.switchServers.changeMyPassword({
+ serverId,
+ currentPassword: current,
+ newPassword: next,
+ }),
+ onSuccess: () => {
+ reset();
+ toast.success('Password changed');
+ },
+ onError: (error) => {
+ const { headline, detail } = describeFailure(error, 'Could not change your password.');
+ toast.error(headline, detail ? { description: detail } : undefined);
+ },
+ });
+
+ if (!open) {
+ return (
+ <div className="space-y-1.5">
+ <Label>Password</Label>
+ <div>
+ <Button variant="outline" size="sm" onClick={() => setOpen(true)}>
+ Change password
+ </Button>
+ </div>
+ </div>
+ );
+ }
+ const mismatch = confirm.length > 0 && confirm !== next;
+ return (
+ <form
+ className="max-w-md space-y-3"
+ onSubmit={(event) => {
+ event.preventDefault();
+ if (current && next && next === confirm) change.mutate();
+ }}
+ >
+ <div className="space-y-1.5">
+ <Label htmlFor="account-current-password">Current password</Label>
+ <Input
+ id="account-current-password"
+ type="password"
+ autoComplete="current-password"
+ value={current}
+ onChange={(event) => setCurrent(event.target.value)}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="account-new-password">New password</Label>
+ <Input
+ id="account-new-password"
+ type="password"
+ autoComplete="new-password"
+ value={next}
+ onChange={(event) => setNext(event.target.value)}
+ />
+ </div>
+ <div className="space-y-1.5">
+ <Label htmlFor="account-confirm-password">Confirm new password</Label>
+ <Input
+ id="account-confirm-password"
+ type="password"
+ autoComplete="new-password"
+ value={confirm}
+ onChange={(event) => setConfirm(event.target.value)}
+ />
+ {mismatch && <p className="text-xs text-destructive">The passwords do not match.</p>}
+ </div>
+ <div className="flex gap-2">
+ <Button
+ type="submit"
+ size="sm"
+ disabled={!current || !next || next !== confirm || change.isPending}
+ >
+ Change password
+ </Button>
+ <Button type="button" size="sm" variant="ghost" onClick={reset}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/pages/api-keys-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/api-keys-page.tsx
new file mode 100644
index 000000000..35e284488
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/api-keys-page.tsx
@@ -0,0 +1,300 @@
+import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
+import { Check, Copy, Plus, Trash2 } from 'lucide-react';
+import { useState } from 'react';
+import { toast } from 'sonner';
+import { PageHeader } from '@renderer/lib/components/page-header';
+import { describeFailure } from '@renderer/lib/errors/describe-failure';
+import { rpc } from '@renderer/lib/ipc';
+import { Button } from '@renderer/lib/ui/button';
+import { Input } from '@renderer/lib/ui/input';
+import { Spinner } from '@renderer/lib/ui/spinner';
+import {
+ type CreatedRegistrationKey,
+ type SwitchApiKey,
+} from '@shared/core/switch-servers/switch-servers';
+import { splitApiKeys } from './api-keys';
+import { OnSignedInServer, SectionLabel } from './settings-server';
+
+export const apiKeysQueryKey = (serverId: string) => ['my-api-keys', serverId];
+
+/**
+ * Your keys on the server: the registration keys you made to register agents
+ * with, and your agents' own keys. Everyone's keys are the workspace's
+ * business, in the gateway; these are only yours.
+ */
+export function ApiKeysSettingsPage() {
+ return (
+ <div className="space-y-8 pb-10">
+ <PageHeader
+ sticky
+ title="API keys"
+ description="Your keys: the ones you register agents with, and your agents' own."
+ />
+ <OnSignedInServer>{({ server }) => <ApiKeys serverId={server.id} />}</OnSignedInServer>
+ </div>
+ );
+}
+
+function ApiKeys({ serverId }: { serverId: string }) {
+ const queryClient = useQueryClient();
+ const keys = useQuery({
+ queryKey: apiKeysQueryKey(serverId),
+ queryFn: () => rpc.switchServers.listMyApiKeys(serverId),
+ });
+ const [created, setCreated] = useState<CreatedRegistrationKey | null>(null);
+ const refresh = () => void queryClient.invalidateQueries({ queryKey: apiKeysQueryKey(serverId) });
+
+ if (keys.isLoading) {
+ return (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner /> Loading keys…
+ </div>
+ );
+ }
+ if (keys.isError) {
+ return (
+ <p className="text-sm text-destructive">
+ {describeFailure(keys.error, 'Could not load your keys.').headline}
+ </p>
+ );
+ }
+ const { registration, agent } = splitApiKeys(keys.data ?? []);
+
+ return (
+ <div className="space-y-8">
+ <section className="space-y-3">
+ <SectionLabel>Registration keys</SectionLabel>
+ <p className="text-sm text-foreground-muted">
+ An agent registers with Switch using one of these.
+ </p>
+ <CreateRegistrationKey
+ serverId={serverId}
+ onCreated={(key) => {
+ setCreated(key);
+ refresh();
+ }}
+ />
+ {created && <CreatedKey created={created} onDismiss={() => setCreated(null)} />}
+ <KeyTable
+ serverId={serverId}
+ keys={registration}
+ empty="You have no registration keys."
+ canDelete
+ onDeleted={refresh}
+ />
+ </section>
+ <section className="space-y-3">
+ <SectionLabel>Agent keys</SectionLabel>
+ <p className="text-sm text-foreground-muted">
+ Each of your agents signs in with its own key.
+ </p>
+ <KeyTable
+ serverId={serverId}
+ keys={agent}
+ empty="None of your agents has a key yet."
+ canDelete={false}
+ onDeleted={refresh}
+ />
+ </section>
+ </div>
+ );
+}
+
+function CreateRegistrationKey({
+ serverId,
+ onCreated,
+}: {
+ serverId: string;
+ onCreated: (key: CreatedRegistrationKey) => void;
+}) {
+ const [label, setLabel] = useState('');
+ const create = useMutation({
+ mutationFn: () => rpc.switchServers.createRegistrationKey({ serverId, label: label.trim() }),
+ onSuccess: (key) => {
+ setLabel('');
+ onCreated(key);
+ },
+ onError: (error) => {
+ const { headline, detail } = describeFailure(error, 'Could not create the key.');
+ toast.error(headline, detail ? { description: detail } : undefined);
+ },
+ });
+ return (
+ <form
+ className="flex items-center gap-2"
+ onSubmit={(event) => {
+ event.preventDefault();
+ if (label.trim()) create.mutate();
+ }}
+ >
+ <Input
+ aria-label="New key's label"
+ placeholder="Label, such as the agent or machine it is for"
+ value={label}
+ maxLength={255}
+ onChange={(event) => setLabel(event.target.value)}
+ className="max-w-sm"
+ />
+ <Button type="submit" size="sm" disabled={!label.trim() || create.isPending}>
+ <Plus className="size-4" />
+ Create registration key
+ </Button>
+ </form>
+ );
+}
+
+/** A key just made: shown in full here, once, so it can be copied. */
+function CreatedKey({
+ created,
+ onDismiss,
+}: {
+ created: CreatedRegistrationKey;
+ onDismiss: () => void;
+}) {
+ return (
+ <div className="space-y-2 rounded-lg border border-border bg-background-1 p-3">
+ <p className="text-sm text-foreground">
+ <span className="font-medium">{created.label}</span> is ready. Copy it now: this is the only
+ time it is shown in full.
+ </p>
+ <div className="flex items-center gap-2">
+ <code className="min-w-0 flex-1 truncate rounded bg-background-2 px-2 py-1 font-mono text-xs">
+ {created.key}
+ </code>
+ <CopyButton label="Copy key" read={() => Promise.resolve(created.key)} />
+ <Button size="sm" variant="ghost" onClick={onDismiss}>
+ Done
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+function KeyTable({
+ serverId,
+ keys,
+ empty,
+ canDelete,
+ onDeleted,
+}: {
+ serverId: string;
+ keys: SwitchApiKey[];
+ empty: string;
+ canDelete: boolean;
+ onDeleted: () => void;
+}) {
+ if (keys.length === 0) return <p className="text-sm text-foreground-muted">{empty}</p>;
+ return (
+ <div className="overflow-hidden rounded-lg border border-border">
+ <table className="w-full border-collapse text-sm">
+ <thead>
+ <tr className="border-b border-border text-left text-xs text-foreground-muted">
+ <th className="px-3 py-2 font-normal">Label</th>
+ <th className="px-3 py-2 font-normal">Key prefix</th>
+ <th className="px-3 py-2 font-normal">Created</th>
+ <th className="px-3 py-2" />
+ </tr>
+ </thead>
+ <tbody>
+ {keys.map((key) => (
+ <tr key={key.id} className="border-b border-border last:border-b-0">
+ <td className="px-3 py-2 text-foreground">{key.label}</td>
+ <td className="px-3 py-2 font-mono text-xs text-foreground-muted">
+ {key.keyPrefix}…
+ </td>
+ <td className="px-3 py-2 text-foreground-muted">{key.createdAt.slice(0, 10)}</td>
+ <td className="px-3 py-2">
+ <span className="flex items-center justify-end gap-1">
+ <CopyButton
+ label={`Copy ${key.label}`}
+ read={() => rpc.switchServers.revealApiKey({ serverId, keyId: key.id })}
+ />
+ {canDelete && key.type === 'registration' && (
+ <DeleteKeyButton serverId={serverId} apiKey={key} onDeleted={onDeleted} />
+ )}
+ </span>
+ </td>
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ );
+}
+
+function CopyButton({ label, read }: { label: string; read: () => Promise<string> }) {
+ const [copied, setCopied] = useState(false);
+ const copy = async () => {
+ try {
+ await navigator.clipboard.writeText(await read());
+ setCopied(true);
+ setTimeout(() => setCopied(false), 1500);
+ } catch (error) {
+ const { headline, detail } = describeFailure(error, 'Could not copy the key.');
+ toast.error(headline, detail ? { description: detail } : undefined);
+ }
+ };
+ return (
+ <Button size="icon-sm" variant="ghost" aria-label={label} onClick={() => void copy()}>
+ {copied ? <Check className="size-4" /> : <Copy className="size-4" />}
+ </Button>
+ );
+}
+
+/** Deleting a key stops every agent still registering with it, so it asks first. */
+function DeleteKeyButton({
+ serverId,
+ apiKey,
+ onDeleted,
+}: {
+ serverId: string;
+ apiKey: SwitchApiKey;
+ onDeleted: () => void;
+}) {
+ const [confirming, setConfirming] = useState(false);
+ const remove = useMutation({
+ mutationFn: () => rpc.switchServers.deleteApiKey({ serverId, keyId: apiKey.id }),
+ onSuccess: () => {
+ setConfirming(false);
+ onDeleted();
+ },
+ onError: (error) => {
+ setConfirming(false);
+ const { headline, detail } = describeFailure(error, 'Could not delete the key.');
+ toast.error(headline, detail ? { description: detail } : undefined);
+ },
+ });
+ if (!confirming) {
+ return (
+ <Button
+ size="icon-sm"
+ variant="ghost"
+ aria-label={`Delete ${apiKey.label}`}
+ onClick={() => setConfirming(true)}
+ >
+ <Trash2 className="size-4" />
+ </Button>
+ );
+ }
+ return (
+ <span className="flex items-center gap-1">
+ <span className="text-xs text-foreground-muted">Delete?</span>
+ <Button
+ size="sm"
+ variant="ghost"
+ disabled={remove.isPending}
+ onClick={() => setConfirming(false)}
+ >
+ No
+ </Button>
+ <Button
+ size="sm"
+ variant="destructive"
+ disabled={remove.isPending}
+ onClick={() => remove.mutate()}
+ >
+ {remove.isPending ? 'Deleting…' : 'Delete'}
+ </Button>
+ </span>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/pages/api-keys.ts b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/api-keys.ts
new file mode 100644
index 000000000..649cb2eed
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/api-keys.ts
@@ -0,0 +1,12 @@
+import { type SwitchApiKey } from '@shared/core/switch-servers/switch-servers';
+
+/** Registration keys first, then agent keys; anything else is not the person's to manage here. */
+export function splitApiKeys(keys: readonly SwitchApiKey[]): {
+ registration: SwitchApiKey[];
+ agent: SwitchApiKey[];
+} {
+ return {
+ registration: keys.filter((key) => key.type === 'registration' || key.type === 'bootstrap'),
+ agent: keys.filter((key) => key.type === 'agent'),
+ };
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/pages/messaging-apps-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/messaging-apps-page.tsx
new file mode 100644
index 000000000..1f62103c1
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/messaging-apps-page.tsx
@@ -0,0 +1,19 @@
+import { MessagingAppsCard } from '@renderer/features/switch-servers/MessagingAppsCard';
+import { PageHeader } from '@renderer/lib/components/page-header';
+import { OnSignedInServer } from './settings-server';
+
+/** Your accounts in the workspace's messaging apps, so your agents know you there. */
+export function MessagingAppsSettingsPage() {
+ return (
+ <div className="space-y-8 pb-10">
+ <PageHeader
+ sticky
+ title="Messaging apps"
+ description="Link your account in each app so your agents recognise you there."
+ />
+ <OnSignedInServer>
+ {({ server }) => <MessagingAppsCard serverId={server.id} personal />}
+ </OnSignedInServer>
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/pages/settings-server.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/settings-server.tsx
new file mode 100644
index 000000000..58215fa8b
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/settings-server.tsx
@@ -0,0 +1,88 @@
+import { observer } from 'mobx-react-lite';
+import { type ReactNode } from 'react';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { useNavigate } from '@renderer/lib/layout/navigation-provider';
+import { Button } from '@renderer/lib/ui/button';
+import { type SwitchServer, type SwitchUser } from '@shared/core/switch-servers/switch-servers';
+
+export type SignedInServer = { server: SwitchServer; user: SwitchUser };
+
+/** The server Settings' server pages are about: the one the workspace switcher has on. */
+export function settingsServer(): { server: SwitchServer | null; user: SwitchUser | null } {
+ const server = switchServersStore.activeServer;
+ const status = server ? switchServersStore.statusFor(server.id) : null;
+ return { server, user: status?.connected ? (status.user ?? null) : null };
+}
+
+/**
+ * A page that needs you signed in to the active server, or what to do about
+ * it when you are not.
+ */
+export const OnSignedInServer = observer(function OnSignedInServer({
+ children,
+}: {
+ children: (signedIn: SignedInServer) => ReactNode;
+}) {
+ const { navigate } = useNavigate();
+ const { server, user } = settingsServer();
+ if (!server) {
+ return <Notice>Add a workspace to see this.</Notice>;
+ }
+ if (!user) {
+ return (
+ <Notice
+ action={
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => navigate('server', { serverId: server.id })}
+ >
+ Sign in
+ </Button>
+ }
+ >
+ Sign in to {server.name} to see this.
+ </Notice>
+ );
+ }
+ return <>{children({ server, user })}</>;
+});
+
+function Notice({ children, action }: { children: ReactNode; action?: ReactNode }) {
+ return (
+ <div className="flex items-center justify-between gap-3 rounded-lg border border-border p-4">
+ <p className="text-sm text-foreground-muted">{children}</p>
+ {action}
+ </div>
+ );
+}
+
+/** A Settings pane's heading: what it is, and in a line, what it covers. */
+export function SettingsPaneHeader({
+ title,
+ description,
+ action,
+}: {
+ title: string;
+ description?: ReactNode;
+ action?: ReactNode;
+}) {
+ return (
+ <header className="flex items-start justify-between gap-4">
+ <div className="min-w-0 space-y-1">
+ <h1 className="text-lg font-semibold text-foreground">{title}</h1>
+ {description && <p className="text-sm text-foreground-muted">{description}</p>}
+ </div>
+ {action && <div className="shrink-0">{action}</div>}
+ </header>
+ );
+}
+
+/** A small uppercase label over a group of rows. */
+export function SectionLabel({ children }: { children: ReactNode }) {
+ return (
+ <h2 className="text-xs font-medium tracking-wide text-foreground-muted uppercase">
+ {children}
+ </h2>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/pages/system-status-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/system-status-page.tsx
new file mode 100644
index 000000000..5f38f7bb6
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/pages/system-status-page.tsx
@@ -0,0 +1,66 @@
+import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import { ManagedServerPage } from '@renderer/features/switch-servers/managed-server-view';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { PageHeader } from '@renderer/lib/components/page-header';
+import { type SwitchServer } from '@shared/core/switch-servers/switch-servers';
+import { UpdateCard } from '../components/UpdateCard';
+import { SectionLabel } from './settings-server';
+
+/**
+ * The Switch your agents and rooms run on, and this Console's own version.
+ *
+ * A Switch this Console runs is operated here — start, stop, update, logs —
+ * since no one else can. Anyone else's server is only reported on: whoever
+ * runs it looks after it.
+ */
+export const SystemStatusSettingsPage = observer(function SystemStatusSettingsPage() {
+ const server = switchServersStore.activeServer;
+ return (
+ <div className="space-y-8 pb-10">
+ <PageHeader
+ sticky
+ title="System status"
+ description="The Switch your agents and rooms run on, and this Console."
+ />
+ {server?.managed ? (
+ <ManagedServerPage server={server} embedded />
+ ) : server ? (
+ <ServiceStatus server={server} />
+ ) : null}
+ <section className="space-y-3">
+ <SectionLabel>Switch Console</SectionLabel>
+ <UpdateCard />
+ </section>
+ </div>
+ );
+});
+
+const ServiceStatus = observer(function ServiceStatus({ server }: { server: SwitchServer }) {
+ const store = switchServersStore;
+ useEffect(() => {
+ void store.refreshStatus(server.id);
+ }, [server.id, store]);
+ const status = store.statusFor(server.id);
+ const unreachable = store.isUnreachable(server.id);
+ const version = status?.user?.server?.version ?? null;
+ const state = unreachable
+ ? { tone: 'bg-red-500', label: 'Cannot reach the server' }
+ : status?.connected
+ ? { tone: 'bg-green-500', label: 'Operational' }
+ : { tone: 'bg-[var(--fg-passive)]', label: 'Not signed in' };
+ return (
+ <section className="space-y-3">
+ <SectionLabel>Service</SectionLabel>
+ <div className="space-y-1 rounded-lg border border-border p-4">
+ <p className="flex items-center gap-2 text-sm text-foreground">
+ <span aria-hidden className={`inline-block size-2 rounded-full ${state.tone}`} />
+ {state.label}
+ </p>
+ <p className="text-sm text-foreground">{server.name}</p>
+ <p className="font-mono text-xs text-foreground-muted">{server.url}</p>
+ {version && <p className="text-sm text-foreground-muted">Version {version}</p>}
+ </div>
+ </section>
+ );
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/settings-tabs.ts b/console/apps/switch-console-desktop/src/renderer/features/settings/settings-tabs.ts
new file mode 100644
index 000000000..fc98d0475
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/settings-tabs.ts
@@ -0,0 +1,107 @@
+/**
+ * Settings' sections, and who sees which.
+ *
+ * Settings is about this person and this computer, so most of it is the same
+ * for everyone. What changes is what needs a server (your messaging accounts,
+ * keys and account live on one), what needs agent management, and whether the
+ * server serves the web gateway that its workspace settings live in.
+ */
+
+export type SettingsPageTab =
+ | 'preferences'
+ | 'messaging-apps'
+ | 'clis-models'
+ | 'api-keys'
+ | 'devices'
+ | 'remote-hosts'
+ | 'managed-agents'
+ | 'status'
+ | 'account';
+
+/** Links out of Settings: they open somewhere else rather than a pane. */
+export type SettingsLink = 'workspace-settings' | 'docs';
+
+export type SettingsItemId = SettingsPageTab | SettingsLink;
+
+export type SettingsItem = { id: SettingsItemId; label: string; isExternal?: boolean };
+
+export const SETTINGS_TABS: readonly SettingsPageTab[] = [
+ 'preferences',
+ 'messaging-apps',
+ 'clis-models',
+ 'api-keys',
+ 'devices',
+ 'remote-hosts',
+ 'managed-agents',
+ 'status',
+ 'account',
+];
+
+/**
+ * Tabs Settings had before, and where each went. A link from an older
+ * switch-buddy, a persisted navigation snapshot or an update notice may still
+ * name one.
+ */
+export const FORMER_SETTINGS_TABS: Readonly<Record<string, SettingsPageTab>> = {
+ general: 'preferences',
+ interface: 'preferences',
+};
+
+export function resolveSettingsTab(tab: unknown): SettingsPageTab {
+ if (typeof tab !== 'string') return 'preferences';
+ if ((SETTINGS_TABS as readonly string[]).includes(tab)) return tab as SettingsPageTab;
+ return Object.hasOwn(FORMER_SETTINGS_TABS, tab) ? FORMER_SETTINGS_TABS[tab]! : 'preferences';
+}
+
+export type SettingsAudience = {
+ /** A server is active, so there is an account, keys and messaging apps to show. */
+ hasServer: boolean;
+ /** Some server runs agent management, so there is something to move to managed. */
+ agentManagement: boolean;
+ /** The active server serves the web gateway, and you are signed in to it. */
+ workspaceSettings: boolean;
+};
+
+/**
+ * The sidebar's sections, in order: this computer and your work, then your
+ * account, then the ways out. The workspace's own settings are the gateway's,
+ * open to every member there; the organization's will join them.
+ */
+export function settingsSections(audience: SettingsAudience): SettingsItem[][] {
+ const main: SettingsItem[] = [
+ { id: 'preferences', label: 'Preferences' },
+ ...(audience.hasServer ? [{ id: 'messaging-apps' as const, label: 'Messaging apps' }] : []),
+ { id: 'clis-models', label: 'Agent providers' },
+ ...(audience.hasServer ? [{ id: 'api-keys' as const, label: 'API keys' }] : []),
+ // The devices Switch knows are yours exist only where agent management runs.
+ ...(audience.agentManagement ? [{ id: 'devices' as const, label: 'Your devices' }] : []),
+ // The SSH hosts this Console reaches are this computer's own list.
+ { id: 'remote-hosts', label: 'Remote hosts' },
+ ...(audience.agentManagement
+ ? [{ id: 'managed-agents' as const, label: 'Managed agents' }]
+ : []),
+ { id: 'status', label: 'System status' },
+ ];
+ const account: SettingsItem[] = audience.hasServer
+ ? [{ id: 'account', label: 'Your account' }]
+ : [];
+ const links: SettingsItem[] = [
+ ...(audience.workspaceSettings
+ ? [{ id: 'workspace-settings' as const, label: 'Workspace settings', isExternal: true }]
+ : []),
+ { id: 'docs', label: 'Docs', isExternal: true },
+ ];
+ return [main, account, links];
+}
+
+/**
+ * The tab to show: the one asked for while the sidebar offers it, else
+ * Preferences, so a tab that went away (a server signed out of, agent
+ * management turned off) never leaves an empty pane.
+ */
+export function shownSettingsTab(
+ tab: SettingsPageTab,
+ sections: readonly (readonly SettingsItem[])[]
+): SettingsPageTab {
+ return sections.some((items) => items.some((item) => item.id === tab)) ? tab : 'preferences';
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/settings/settings-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/settings/settings-view.tsx
index 110e01933..cba06c2ac 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/settings/settings-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/settings/settings-view.tsx
@@ -10,7 +10,7 @@ import { useParams } from '@renderer/lib/layout/navigation-provider';
const SettingsTabContext = createContext<{
tab: SettingsPageTab;
onTabChange: (tab: SettingsPageTab) => void;
-}>({ tab: 'general', onTabChange: () => {} });
+}>({ tab: 'preferences', onTabChange: () => {} });
/** Minimal passthrough — exists so the registry can infer WrapParams<'settings'>. */
export function SettingsViewWrapper({
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/MessagingAppsCard.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/MessagingAppsCard.tsx
index 709571ed5..f1b5e5f81 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/MessagingAppsCard.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/MessagingAppsCard.tsx
@@ -111,9 +111,16 @@ const WAITING_EXPLANATION =
export const MessagingAppsCard = observer(function MessagingAppsCard({
serverId,
className,
+ personal = false,
}: {
serverId: string;
className?: string;
+ /**
+ * Only your own accounts in each app, for Settings: linking and unlinking
+ * them. The workspace's side — connecting an app, its token, its defaults —
+ * is for its admins, on Home and in the workspace settings.
+ */
+ personal?: boolean;
}) {
const queryClient = useQueryClient();
const showConnectMessagingApp = useShowModal('connectMessagingAppModal');
@@ -122,7 +129,8 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
const showConnectChat = useShowModal('connectChatModal');
const showRequireLinkConfirmation = useShowModal('requireLinkConfirmationModal');
const workspaceId = workspacesStore.idOnServerInScope(serverId);
- const isAdmin = administersWorkspaceInScope(serverId);
+ const administers = administersWorkspaceInScope(serverId);
+ const isAdmin = administers && !personal;
const flags = useFeatureFlags(serverId);
// With chats on, Switch Console's own chats and rooms need no messaging app.
const chatsWithoutApp = flags.agent_chats || flags.group_chats;
@@ -370,10 +378,12 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
) : bridges.length === 0 && !bridgesQuery.isLoading ? (
<p className="mt-3 text-xs text-foreground-muted">
{chatsWithoutApp
- ? `No messaging app is connected. They are optional: chats and rooms in Switch Console work without one. ${isAdmin ? 'Connect one to also reach your agents from Slack, Discord and others.' : 'An owner or admin of this workspace can connect one to reach your agents from Slack, Discord and others.'}`
+ ? `No messaging app is connected. They are optional: chats and rooms in Switch Console work without one. ${isAdmin ? 'Connect one to also reach your agents from Slack, Discord and others.' : administers ? 'Connect one from Home to also reach your agents from Slack, Discord and others.' : 'An owner or admin of this workspace can connect one to reach your agents from Slack, Discord and others.'}`
: isAdmin
? 'No messaging app is connected, so rooms created here would be unreachable. Connect one to get started.'
- : 'No messaging app is connected. An owner or admin of this workspace can connect one.'}
+ : administers
+ ? 'No messaging app is connected. Connect one from Home.'
+ : 'No messaging app is connected. An owner or admin of this workspace can connect one.'}
</p>
) : (
<div className="mt-2 flex flex-col">
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/managed-server-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/managed-server-view.tsx
index baa4b54aa..669e837c6 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/managed-server-view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/managed-server-view.tsx
@@ -137,10 +137,13 @@ const ManagedServerInAdmin = observer(function ManagedServerInAdmin({
);
});
-const ManagedServerPage = observer(function ManagedServerPage({
+export const ManagedServerPage = observer(function ManagedServerPage({
server,
+ embedded = false,
}: {
server: SwitchServer;
+ /** Set inside another page, Settings' System status, which pads it already. */
+ embedded?: boolean;
}) {
const sshHost = server.managementKind === 'remote' ? server.sshHost : null;
const confirm = useSharedActionConfirm(sshHost);
@@ -240,7 +243,7 @@ const ManagedServerPage = observer(function ManagedServerPage({
});
return (
- <div className="min-w-0 pt-10 pb-10">
+ <div className={embedded ? 'min-w-0' : 'min-w-0 pt-10 pb-10'}>
<div className="w-full max-w-[720px] space-y-[18px]">
<header className="flex items-center gap-3">
<span className="flex size-9 shrink-0 items-center justify-center rounded-[10px] bg-[var(--fill)]">
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/components/page-layout.tsx b/console/apps/switch-console-desktop/src/renderer/lib/components/page-layout.tsx
index e904f115a..ab63b5a25 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/components/page-layout.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/page-layout.tsx
@@ -86,6 +86,49 @@ export function PageSidebarGroups<T extends string>({
);
}
+/**
+ * `PageSidebarMenu` in sections split by a rule, for a page whose items fall
+ * into kinds without needing a heading to say so: the rule is enough.
+ * Empty sections are left out, so no two rules stand together.
+ */
+export function PageSidebarSections<T extends string>({
+ sections,
+ activeId,
+ onSelect,
+}: {
+ sections: ReadonlyArray<ReadonlyArray<PageSidebarItem<T>>>;
+ activeId: T;
+ onSelect: (item: PageSidebarItem<T>) => void;
+}) {
+ return (
+ <div className="sticky top-0 self-start py-10 [-webkit-app-region:drag]">
+ <nav className="flex w-52 flex-col [-webkit-app-region:no-drag]">
+ {sections
+ .filter((items) => items.length > 0)
+ .map((items, index) => (
+ <div
+ key={items[0]!.id}
+ role="group"
+ className={cn(
+ 'flex flex-col gap-0.5',
+ index > 0 && 'mt-3 border-t border-border pt-3'
+ )}
+ >
+ {items.map((item) => (
+ <PageSidebarButton
+ key={item.id}
+ item={item}
+ active={item.id === activeId}
+ onSelect={onSelect}
+ />
+ ))}
+ </div>
+ ))}
+ </nav>
+ </div>
+ );
+}
+
function PageSidebarButton<T extends string>({
item,
active,
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/stores/update-store.ts b/console/apps/switch-console-desktop/src/renderer/lib/stores/update-store.ts
index 4100fd49a..12306e6c5 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/stores/update-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/lib/stores/update-store.ts
@@ -352,7 +352,7 @@ export class UpdateStore {
action: {
label: createUpdateToastActionLabel(),
onClick: () => {
- appState.navigation.navigate('settings', { tab: 'general' });
+ appState.navigation.navigate('settings', { tab: 'status' });
if (this.state.status === 'available') {
void this.download();
}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/settings-pages.test.ts b/console/apps/switch-console-desktop/src/renderer/tests/settings-pages.test.ts
new file mode 100644
index 000000000..5b29357c9
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/tests/settings-pages.test.ts
@@ -0,0 +1,105 @@
+import { describe, expect, it } from 'vitest';
+import { splitApiKeys } from '@renderer/features/settings/pages/api-keys';
+import {
+ resolveSettingsTab,
+ type SettingsAudience,
+ settingsSections,
+ shownSettingsTab,
+} from '@renderer/features/settings/settings-tabs';
+import { parseConsoleLink } from '@shared/core/deeplinks/console-links';
+import { type SwitchApiKey } from '@shared/core/switch-servers/switch-servers';
+
+const everyone: SettingsAudience = {
+ hasServer: true,
+ agentManagement: true,
+ workspaceSettings: true,
+};
+
+const ids = (audience: SettingsAudience) =>
+ settingsSections(audience).map((items) => items.map((item) => item.id));
+
+describe('Settings sections', () => {
+ it('lists the design order: your things, then your account, then the ways out', () => {
+ expect(ids(everyone)).toEqual([
+ [
+ 'preferences',
+ 'messaging-apps',
+ 'clis-models',
+ 'api-keys',
+ 'devices',
+ 'remote-hosts',
+ 'managed-agents',
+ 'status',
+ ],
+ ['account'],
+ ['workspace-settings', 'docs'],
+ ]);
+ });
+
+ it('keeps only what stands without a server when there is none', () => {
+ expect(ids({ hasServer: false, agentManagement: false, workspaceSettings: false })).toEqual([
+ ['preferences', 'clis-models', 'remote-hosts', 'status'],
+ [],
+ ['docs'],
+ ]);
+ });
+
+ it('offers workspace settings only where a gateway serves them', () => {
+ expect(ids({ ...everyone, workspaceSettings: false })[2]).toEqual(['docs']);
+ });
+
+ it('offers your devices and managed agents only with agent management', () => {
+ const main = ids({ ...everyone, agentManagement: false })[0];
+ expect(main).not.toContain('managed-agents');
+ expect(main).not.toContain('devices');
+ expect(main).toContain('remote-hosts');
+ });
+
+ it('falls back to Preferences for a tab the sidebar does not offer', () => {
+ const noServer = settingsSections({
+ hasServer: false,
+ agentManagement: false,
+ workspaceSettings: false,
+ });
+ expect(shownSettingsTab('account', noServer)).toBe('preferences');
+ expect(shownSettingsTab('remote-hosts', noServer)).toBe('remote-hosts');
+ expect(shownSettingsTab('devices', noServer)).toBe('preferences');
+ });
+
+ it('sends the tabs Settings used to have where they went', () => {
+ expect(resolveSettingsTab('general')).toBe('preferences');
+ expect(resolveSettingsTab('interface')).toBe('preferences');
+ expect(resolveSettingsTab('remote-hosts')).toBe('remote-hosts');
+ expect(resolveSettingsTab('api-keys')).toBe('api-keys');
+ expect(resolveSettingsTab('nonsense')).toBe('preferences');
+ expect(resolveSettingsTab(undefined)).toBe('preferences');
+ });
+
+ it("still opens an older switch-buddy's links to retired tabs", () => {
+ for (const tab of ['general', 'interface', 'remote-hosts', 'devices', 'account']) {
+ expect(parseConsoleLink(`switchdash://open/settings?tab=${tab}`)).toMatchObject({ ok: true });
+ }
+ expect(parseConsoleLink('switchdash://open/settings?tab=browser')).toMatchObject({ ok: false });
+ });
+});
+
+const key = (id: string, type: string): SwitchApiKey => ({
+ id,
+ label: id,
+ type,
+ keyPrefix: 'abc',
+ createdAt: '2026-11-03',
+});
+
+describe('API keys', () => {
+ it('splits registration keys from agent keys and drops anything else', () => {
+ const split = splitApiKeys([
+ key('r', 'registration'),
+ key('b', 'bootstrap'),
+ key('a', 'agent'),
+ key('x', 'other'),
+ ]);
+ expect(split.registration.map((k) => k.id)).toEqual(['r', 'b']);
+ expect(split.agent.map((k) => k.id)).toEqual(['a']);
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/shared/core/deeplinks/console-links.ts b/console/apps/switch-console-desktop/src/shared/core/deeplinks/console-links.ts
index 91d30794d..cb73ec08a 100644
--- a/console/apps/switch-console-desktop/src/shared/core/deeplinks/console-links.ts
+++ b/console/apps/switch-console-desktop/src/shared/core/deeplinks/console-links.ts
@@ -26,6 +26,11 @@ type PageSpec = {
id?: 'agent' | 'room' | 'template';
/** The values `tab` may take, when the page has tabs. */
tabs?: readonly string[];
+ /**
+ * Tabs the page had before, still accepted: an older server's switch-buddy
+ * may write them, and the page sends each where it went.
+ */
+ formerTabs?: readonly string[];
};
export const CONSOLE_PAGES = {
@@ -59,7 +64,18 @@ export const CONSOLE_PAGES = {
},
settings: {
description: "Switch Console's settings.",
- tabs: ['general', 'clis-models', 'remote-hosts', 'managed-agents', 'interface'],
+ tabs: [
+ 'preferences',
+ 'messaging-apps',
+ 'clis-models',
+ 'api-keys',
+ 'devices',
+ 'remote-hosts',
+ 'managed-agents',
+ 'status',
+ 'account',
+ ],
+ formerTabs: ['general', 'interface'],
},
} as const satisfies Record<string, PageSpec>;
@@ -109,7 +125,7 @@ export function parseConsoleLink(raw: string): ConsoleLinkResult {
return { ok: false, reason: `This link to a ${spec.id} does not say which one.` };
}
const tab = url.searchParams.get('tab');
- if (tab !== null && !(spec.tabs ?? []).includes(tab)) {
+ if (tab !== null && ![...(spec.tabs ?? []), ...(spec.formerTabs ?? [])].includes(tab)) {
return { ok: false, reason: `That page has no "${tab}" tab.` };
}
return { ok: true, link: { page, id, tab, server: url.searchParams.get('server') } };
diff --git a/core/switch_core/official_templates/switch-buddy/AGENT.md b/core/switch_core/official_templates/switch-buddy/AGENT.md
index 98c093e2d..066bac3b6 100644
--- a/core/switch_core/official_templates/switch-buddy/AGENT.md
+++ b/core/switch_core/official_templates/switch-buddy/AGENT.md
@@ -218,7 +218,7 @@ per place, at the moment it is needed; not a list of every page.
| Connectors: services such as GitHub | `switchdash://open/connections` |
| Invite people to the workspace | `switchdash://open/invite` |
| Admin, for workspace admins and whoever runs the server: which connectors the workspace offers (`tab=connectors`), the apps they sign in through (`tab=apps`, for whoever runs the server), and the server's own Status page | `switchdash://open/admin` |
-| Switch Console's settings (`tab=general`, `clis-models`, `remote-hosts`, `managed-agents` or `interface`) | `switchdash://open/settings` |
+| Switch Console's settings (`tab=preferences`, `messaging-apps` to link their own accounts, `clis-models` for agent providers, `api-keys`, `devices` for their machines and SSH hosts, `managed-agents`, `status` or `account`) | `switchdash://open/settings` |
- Ids come from your tools: an agent's id from `list_managed_agents` or
`get_agent_detail`, a room's from `list_rooms`, a template's from