Skip to content

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

feat(console): make a server a workspace, behind a switcher (CHOO-2158) (#231)

Louis Amaudruz13b142d52b4c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ffb3c303d..1bc71ceb8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -603,6 +603,94 @@ version of their own to them without also giving them a release of their own.
### [Unreleased]
+#### Changed
+
+- **A server is now a workspace, and you switch between them.** The list of
+ servers that sat in the sidebar has been replaced by a switcher at the top,
+ showing the one you are in and opening onto the rest — each with where it
+ runs and whether it is reachable. Everything below it already belonged to
+ that server; now the sidebar says so. Under the switcher is that server's
+ Home, which is the page you used to reach by clicking the server in the
+ list, and the titlebar names the path to it (CHOO-2158).
+- The session list is a section of its own, headed **Sessions**, with the
+ grouping control labelled as what it is — group by **By Agent** or **By
+ Room** — rather than sitting alone at the top of the tree where it read as
+ the sidebar's whole navigation (CHOO-2158).
+- The welcome screen is reachable from the switcher as **About Switch**, as
+ well as from the Switch mark at the bottom of the sidebar. With no servers
+ added, the sidebar is just **Add a server** over the setup checklist
+ (CHOO-2158).
+- **A server's Home page reads as a dashboard rather than a stack of cards.**
+ It opens with the server, where it runs and who you are signed in as, then
+ how many agents, rooms and messaging apps are on it, and gives the rest of
+ the page over to the things you act on (CHOO-2158).
+- **Messaging apps are a table.** Which account is you, whether Switch may
+ create channels there, and the app's actions are columns you can read down
+ rather than facts to be opened one row at a time. Turning channel creation on
+ or off is now in the row instead of behind its menu, and a platform that
+ cannot create channels at all says so rather than showing the switch off.
+ Unlinking stays in the menu — it is irreversible, and the row is where you
+ press to *change* an account (CHOO-2158).
+- The managed stack has a section of its own with a **Restart**, and shows its
+ live output, which until now was only visible while adding a server. An
+ available switch-core update is announced at the top of the page rather than
+ inside that section, and **Reset** sits alone at the bottom, away from Start
+ and Stop (CHOO-2158).
+- The Mattermost sign-in details Switch Console generates open in a dialog from
+ the app's row, rather than expanding underneath it (CHOO-2158).
+- **A server's agents and rooms each have a page.** Under the switcher, next to
+ Home, **Your Agents** lists every agent registered on the server with the
+ provider it runs, where that is, and how many of the server's rooms it is in;
+ **Your Rooms** lists the rooms with the messaging app each is bridged to and
+ how many agents are in it. Both start a session or add a member from the row,
+ and carry the same actions the sidebar rows do. Until now the only way to see
+ either as a list was to scroll the sidebar tree (CHOO-2158).
+- **An agent's page opens with the agent.** Its mark, its name, the server it is
+ registered on and what it runs, with **Create Session** alongside — where the
+ page used to begin at a list of sessions, with the agent named only in the
+ titlebar. Sessions are framed as a list, each saying which room it is talking
+ in, or that it is in none (CHOO-2158).
+- **The titlebar says where you are, in full.** A session now reads
+ agent / room / session rather than naming its directory and itself, and a room
+ is its own heading with its messaging app's mark. An agent's page carries the
+ same connection status and actions menu its server's pages do (CHOO-2158).
+- Agents are described by their provider's name — **Claude Code**, **Codex** —
+ rather than the `claude` and `codex` they are keyed by (CHOO-2158).
+- **Every session in the sidebar has an actions button.** Pin, rename, archive
+ and delete were reachable only by right-clicking, which nothing in the
+ interface said you could do; they are now on a menu in the row as well. Both
+ menus are built from one list, so an action cannot arrive on one and be
+ missing from the other (CHOO-2158).
+- **Expanding a row in the sidebar is now the chevron's job alone**, and the
+ chevron has moved to the end of the row, appearing on hover with that row's
+ other actions. Opening an agent or a room no longer unfolds it, so reading one
+ thing does not rearrange the tree around it, and the agent's provider mark
+ stays visible instead of turning into a chevron under the pointer. A row with
+ nothing beneath it has no chevron at all (CHOO-2158).
+- **A room in the sidebar no longer counts its agents.** The pair of numbers on
+ the row — agents this computer runs, agents it does not — sat where the expand
+ control now goes and told you little. The sidebar lists the agents it can
+ actually open; a room's full membership is a column on **Your Rooms**, which
+ is the page for reading rooms as a list (CHOO-2158).
+- **Anything you can click now says so under the pointer.** Buttons, sidebar
+ rows, menu entries and tabs show the hand cursor; Tailwind's reset had left
+ them all on the arrow (CHOO-2158).
+
+#### Fixed
+
+- **Adding your first server left the app with no workspace selected.** Nothing
+ chose it, so the sidebar stayed on "Add a server" until the next launch
+ (CHOO-2158).
+- **Removing the server you were in could leave the app with no workspace at
+ all** — no switcher, no destinations, no sidebar tree — because the remembered
+ server was still named as the active one. A remembered server that no longer
+ exists now counts as no choice, and the app picks one (CHOO-2158).
+- Removing an agent from its own page removed the first agent in that directory,
+ which is a different agent whenever a directory holds more than one
+ (CHOO-2158).
+- The empty session list offered to "spawn a claude session" whatever the agent
+ actually runs (CHOO-2158).
+
### [0.25.0] - 2026-08-15
#### Added
diff --git a/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts b/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts
index c72f2e6a6..eeff5f35d 100644
--- a/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts
+++ b/console/apps/switch-console-desktop/src/renderer/app/view-registry.ts
@@ -6,13 +6,15 @@ import { remoteHostsView } from '@renderer/features/remote-hosts/views/remote-ho
import { sessionView } from '@renderer/features/sessions/view';
import { settingsView } from '@renderer/features/settings/settings-view';
import { roomView } from '@renderer/features/switch-rooms/view';
+import { serverAgentsView } from '@renderer/features/switch-servers/server-agents-view';
+import { serverRoomsView } from '@renderer/features/switch-servers/server-rooms-view';
import { serverView } from '@renderer/features/switch-servers/view';
import type { CommandProvider } from '@renderer/lib/commands/types';
import { appState } from '@renderer/lib/stores/app-state';
// Switch Console views: agents-at-a-location (location), sessions (session), home, settings,
-// server (a connected Switch gateway). Automations, library, skills, and mcp
-// were removed.
+// and a connected Switch gateway's workspace — its Home (server) plus that
+// server's agents and rooms. Automations, library, skills, and mcp were removed.
export const views = {
home: homeView,
location: locationView,
@@ -20,6 +22,8 @@ export const views = {
room: roomView,
settings: settingsView,
server: serverView,
+ serverAgents: serverAgentsView,
+ serverRooms: serverRoomsView,
remoteHosts: remoteHostsView,
remoteHost: remoteHostView,
// oxlint-disable-next-line typescript/no-explicit-any
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/location-titlebar.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/location-titlebar.tsx
index 67facd3a0..392ba69b5 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/location-titlebar.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/location-titlebar.tsx
@@ -1,77 +1,61 @@
-import { ChevronDown, Ellipsis, Server, Trash2 } from 'lucide-react';
+import { Bot, ExternalLink, MoreVertical, RotateCcw, Server, Trash2 } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useConfirmDeleteAgent } from '@renderer/features/locations/hooks/use-confirm-delete-agent';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import {
asMounted,
getLocationStore,
locationDisplayName,
locationViewKind,
} from '@renderer/features/locations/stores/location-selectors';
+import { ServerStatusPill } from '@renderer/features/switch-servers/server-presentation';
+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
import { OpenInMenu } from '@renderer/lib/components/titlebar/open-in-menu';
import { Titlebar } from '@renderer/lib/components/titlebar/Titlebar';
+import { TitlebarBreadcrumb } from '@renderer/lib/components/titlebar/titlebar-breadcrumb';
+import { useToast } from '@renderer/lib/hooks/use-toast';
+import { rpc } from '@renderer/lib/ipc';
import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { Button } from '@renderer/lib/ui/button';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@renderer/lib/ui/dropdown-menu';
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
+import type { Agent } from '@shared/core/agents/agents';
-const MountedLocationTitlebarLeft = observer(function LocationTitlebarLeft({
- locationId,
-}: {
- locationId: string;
-}) {
- const { navigate } = useNavigate();
- const store = getLocationStore(locationId);
- const displayName = locationDisplayName(store) ?? 'this location';
- const confirmDeleteAgent = useConfirmDeleteAgent();
-
- return (
- <div className="flex h-full items-center gap-2 px-2">
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <button className="group flex items-center gap-1.5 text-sm text-foreground-muted hover:text-foreground">
- <span className="text-sm">{displayName}</span>
- <ChevronDown className="size-3.5" />
- </button>
- }
- >
- <Ellipsis className="size-4" />
- </DropdownMenuTrigger>
- <DropdownMenuContent className="min-w-40">
- <DropdownMenuItem
- className="flex items-center gap-2 text-foreground-destructive"
- onClick={() => {
- void confirmDeleteAgent({
- locationId,
- locationLabel: displayName,
- onDeleted: () => navigate('home'),
- });
- }}
- >
- <Trash2 className="size-4" />
- Remove Agent
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
- );
-});
-
-const LocationTitlebarLeft = observer(function LocationTitlebarLeft({
+/**
+ * The agent this page is about. Falls back to the location's own name while the
+ * agent list is still loading, or when the route carries no agent name.
+ */
+const AgentCrumb = observer(function AgentCrumb({
locationId,
+ agent,
}: {
locationId: string;
+ agent: Agent | null;
}) {
- const store = getLocationStore(locationId);
- const displayName = locationDisplayName(store);
+ const label = agent?.name ?? locationDisplayName(getLocationStore(locationId)) ?? 'Agent';
return (
- <div className="flex items-center gap-2 px-2">
- <span className="text-sm text-foreground-muted">{displayName}</span>
- </div>
+ <TitlebarBreadcrumb
+ crumbs={[
+ {
+ key: 'agent',
+ icon: agent?.providerId ? (
+ <AgentIcon id={agent.providerId} size={14} className="shrink-0" />
+ ) : (
+ <Bot className="size-3.5 shrink-0" />
+ ),
+ label,
+ },
+ ]}
+ />
);
});
@@ -100,30 +84,120 @@ function RemoteLocationPath({ host, dir }: { host: string; dir: string }) {
);
}
+/**
+ * The agent's own actions, in the same order and wording the Your Agents table
+ * offers them — the two places act on the same agent, so they must not read as
+ * two different sets of powers.
+ */
+const AgentActionsMenu = observer(function AgentActionsMenu({
+ locationId,
+ agent,
+ sshHost,
+}: {
+ locationId: string;
+ agent: Agent | null;
+ sshHost: string | null;
+}) {
+ const { navigate } = useNavigate();
+ const showConfirmReset = useShowModal('resetAgentModal');
+ const confirmDeleteAgent = useConfirmDeleteAgent();
+ const { toastPromise } = useToast();
+
+ const label = agent?.name ?? locationDisplayName(getLocationStore(locationId)) ?? 'this agent';
+ const gatewayUrl =
+ agent?.serverId && agent.switchAgentId
+ ? switchRoomsStore.gatewayAgentUrl(agent.serverId, agent.switchAgentId)
+ : null;
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="ghost" size="sm" className="size-7 p-0" aria-label={`${label} actions`}>
+ <MoreVertical className="size-4" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
+ {gatewayUrl && agent?.serverId && (
+ <DropdownMenuItem
+ onClick={() =>
+ void rpc.switchServers.openGatewayPage({ serverId: agent.serverId!, url: gatewayUrl })
+ }
+ >
+ <ExternalLink className="size-4" />
+ Open in gateway
+ </DropdownMenuItem>
+ )}
+ {sshHost !== null && agent && (
+ <DropdownMenuItem
+ onClick={() =>
+ showConfirmReset({
+ agentLabel: label,
+ onSuccess: () => {
+ void toastPromise(rpc.agents.resetRemoteAgent({ agentId: agent.id }), {
+ loading: `Resetting ${label}…`,
+ success: `${label} was reset`,
+ error: (error) =>
+ `Failed to reset agent: ${error instanceof Error ? error.message : String(error)}`,
+ });
+ },
+ })
+ }
+ >
+ <RotateCcw className="size-4" />
+ Reset agent…
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={() => {
+ void confirmDeleteAgent({
+ locationId,
+ agentId: agent?.id,
+ locationLabel: label,
+ onDeleted: () => navigate('home'),
+ });
+ }}
+ >
+ <Trash2 className="size-4" />
+ Remove agent…
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+});
+
export const LocationTitlebar = observer(function LocationTitlebar() {
const {
- params: { locationId },
+ params: { locationId, agentName },
} = useParams('location');
const store = getLocationStore(locationId);
- const kind = locationViewKind(store);
+ const agent = agentsStore.agentAtLocation(locationId, agentName);
+ const server = agent?.serverId
+ ? (switchServersStore.servers.find((s) => s.id === agent.serverId) ?? null)
+ : null;
- if (kind !== 'ready') {
- return <Titlebar leftSlot={<LocationTitlebarLeft locationId={locationId} />} />;
- }
-
- const mounted = asMounted(store);
- if (!mounted) return <Titlebar leftSlot={<LocationTitlebarLeft locationId={locationId} />} />;
+ const mounted = locationViewKind(store) === 'ready' ? asMounted(store) : undefined;
return (
<Titlebar
- leftSlot={<MountedLocationTitlebarLeft locationId={locationId} />}
+ leftSlot={<AgentCrumb locationId={locationId} agent={agent} />}
rightSlot={
- <div className="mr-2 flex items-center gap-2">
- {mounted.data.sshHost === null ? (
- <OpenInMenu path={mounted.data.dir} className="h-7 bg-background" />
- ) : (
- <RemoteLocationPath host={mounted.data.sshHost} dir={mounted.data.dir} />
- )}
+ <div className="mr-1 flex items-center gap-1.5">
+ {mounted &&
+ (mounted.data.sshHost === null ? (
+ <OpenInMenu path={mounted.data.dir} className="h-7 bg-background" />
+ ) : (
+ <RemoteLocationPath host={mounted.data.sshHost} dir={mounted.data.dir} />
+ ))}
+ {server && <ServerStatusPill server={server} />}
+ <AgentActionsMenu
+ locationId={locationId}
+ agent={agent}
+ sshHost={mounted?.data.sshHost ?? null}
+ />
</div>
}
/>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/active-location.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/active-location.tsx
index 8fd5236d0..311841296 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/active-location.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/active-location.tsx
@@ -1,4 +1,5 @@
import { observer } from 'mobx-react-lite';
+import { AgentPageHeader } from '@renderer/features/locations/components/main-panel/agent-page-header';
import { SessionList } from '@renderer/features/locations/components/session-view/session-list';
import { SettingsPanel } from '@renderer/features/locations/components/settings-view/settings-panel';
import { SidecarPanel } from '@renderer/features/locations/components/settings-view/sidecar-panel';
@@ -20,7 +21,7 @@ function LocationViewNav({
onChange: (view: LocationView) => void;
}) {
return (
- <div className="py-10">
+ <div>
<nav className="flex min-h-0 w-52 flex-col gap-0.5 overflow-y-auto" aria-label="Location">
{items.map((item) => {
const isActive = item.id === activeView;
@@ -72,6 +73,7 @@ export const ActiveLocation = observer(function ActiveLocation() {
return (
<div className="flex h-full min-h-0 w-full flex-1 flex-col overflow-hidden">
<div className="mx-auto flex h-full min-h-0 w-full max-w-[1060px] flex-col gap-6 px-8">
+ <AgentPageHeader />
<div className="grid min-h-0 flex-1 grid-cols-[13rem_minmax(0,1fr)] gap-8 overflow-hidden">
<LocationViewNav
items={items}
@@ -79,7 +81,7 @@ export const ActiveLocation = observer(function ActiveLocation() {
onChange={(view) => store.view.setLocationView(view)}
/>
<div className="min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto">
- <div className="mx-auto flex h-full min-h-0 w-full max-w-4xl flex-col px-1 py-10">
+ <div className="mx-auto flex h-full min-h-0 w-full max-w-4xl flex-col px-1 pb-10">
{activeView === 'sessions' && <SessionList />}
{activeView === 'settings' && <SettingsPanel />}
{activeView === 'sidecar' && <SidecarPanel />}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-page-header.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-page-header.tsx
new file mode 100644
index 000000000..45bcc5af0
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/main-panel/agent-page-header.tsx
@@ -0,0 +1,62 @@
+import { Bot } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import {
+ getLocationStore,
+ locationDisplayName,
+} from '@renderer/features/locations/stores/location-selectors';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { useParams } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { Button } from '@renderer/lib/ui/button';
+import { BoundShortcut } from '@renderer/lib/ui/shortcut';
+import { providerDisplayName } from '@shared/core/providers/agent-provider-registry';
+
+/**
+ * Who this page is about, above its tabs: the agent's mark, its name, where it
+ * is registered and what it runs on, and the one action the page exists for.
+ *
+ * The page used to open straight onto a session list with the agent named only
+ * in the titlebar, which read as a list of sessions that happened to be
+ * somewhere rather than as an agent you are looking at.
+ */
+export const AgentPageHeader = observer(function AgentPageHeader() {
+ const {
+ params: { locationId, agentName },
+ } = useParams('location');
+ const showCreateSessionModal = useShowModal('sessionModal');
+
+ const agent = agentsStore.agentAtLocation(locationId, agentName);
+ const title = agent?.name ?? agentName ?? locationDisplayName(getLocationStore(locationId)) ?? '';
+
+ const serverName = agent?.serverId
+ ? (switchServersStore.servers.find((s) => s.id === agent.serverId)?.name ?? null)
+ : null;
+ const provider = providerDisplayName(agent?.providerId ?? null);
+ const subtitle = [serverName && `Agent on ${serverName}`, provider].filter(Boolean).join(' · ');
+
+ return (
+ <header className="flex shrink-0 items-start justify-between gap-4 pt-10">
+ <div className="flex min-w-0 items-center gap-3">
+ <span className="flex size-11 shrink-0 items-center justify-center rounded-lg border border-border bg-background-secondary">
+ {agent?.providerId ? (
+ <AgentIcon id={agent.providerId} size={22} />
+ ) : (
+ <Bot className="size-5 text-foreground-muted" />
+ )}
+ </span>
+ <div className="min-w-0">
+ <h1 className="truncate text-2xl font-semibold text-foreground">{title}</h1>
+ {subtitle && <p className="mt-0.5 truncate text-sm text-foreground-muted">{subtitle}</p>}
+ </div>
+ </div>
+ <Button
+ className="shrink-0"
+ onClick={() => showCreateSessionModal({ locationId, agentName })}
+ >
+ Create Session <BoundShortcut settingsKey="newSession" />
+ </Button>
+ </header>
+ );
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list-empty-state.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list-empty-state.tsx
index 6dbe25a21..765294372 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list-empty-state.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list-empty-state.tsx
@@ -1,8 +1,10 @@
import { Plus } from 'lucide-react';
import { observer } from 'mobx-react-lite';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import { useArrowKeyNavigation } from '@renderer/lib/hooks/use-arrow-key-navigation';
import { useShowModal } from '@renderer/lib/modal/modal-provider';
import { ActionListItem } from '@renderer/lib/ui/action-list-item';
+import { providerDisplayName } from '@shared/core/providers/agent-provider-registry';
export const SessionListEmptyState = observer(function SessionListEmptyState({
locationId,
@@ -13,12 +15,15 @@ export const SessionListEmptyState = observer(function SessionListEmptyState({
}) {
const showSessionModal = useShowModal('sessionModal');
+ const agent = agentsStore.agentAtLocation(locationId, agentName);
+ const provider = providerDisplayName(agent?.providerId ?? null);
+
const actions = [
{
label: 'New Session',
description: agentName
- ? `Spawn a claude session as ${agentName}`
- : 'Spawn a claude session for this agent',
+ ? `Start a ${provider ?? 'new'} session as ${agentName}`
+ : `Start a ${provider ?? 'new'} session for this agent`,
icon: Plus,
onActivate: () => showSessionModal({ locationId, agentName }),
},
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list.tsx
index 98d7622d2..03dbf8040 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-list.tsx
@@ -53,7 +53,7 @@ function SessionVirtualList({
return (
<div
ref={parentRef}
- className="min-h-0 flex-1 overflow-y-auto py-3"
+ className="min-h-0 flex-1 overflow-y-auto py-1"
style={{ scrollbarWidth: 'none' }}
>
<div style={{ height: virtualizer.getTotalSize(), position: 'relative' }}>
@@ -138,7 +138,6 @@ export const SessionList = observer(function SessionList() {
const store = asMounted(getLocationStore(locationId));
const sessionManager = getSessionManagerStore(locationId);
const showDeleteSession = useShowModal('deleteSessionModal');
- const showCreateSessionModal = useShowModal('sessionModal');
const sessionView = store?.view.sessionView ?? null;
@@ -215,8 +214,8 @@ export const SessionList = observer(function SessionList() {
: displaySessions;
return (
- <div className="relative flex h-full min-h-0 w-full flex-col">
- <div className="flex shrink-0 flex-col gap-4 border-b border-border pb-3">
+ <div className="relative flex h-full min-h-0 w-full flex-col gap-3">
+ <div className="flex shrink-0 flex-col gap-4">
<div className="flex flex-wrap items-center justify-between gap-2">
<ToggleGroup
multiple={false}
@@ -228,37 +227,37 @@ export const SessionList = observer(function SessionList() {
<ToggleGroupItem value="active">Active ({activeSessions.length})</ToggleGroupItem>
<ToggleGroupItem value="archived">Archived ({archivedSessions.length})</ToggleGroupItem>
</ToggleGroup>
- <div className="flex items-center gap-2">
- <SearchInput
- placeholder="Search sessions…"
- value={sessionView.searchQuery}
- onChange={(e) => sessionView.setSearchQuery(e.target.value)}
- className="flex-1"
- />
- <Button onClick={() => showCreateSessionModal({ locationId, agentName })}>
- Create Session <BoundShortcut settingsKey="newSession" />
- </Button>
- </div>
+ <SearchInput
+ placeholder="Search sessions…"
+ value={sessionView.searchQuery}
+ onChange={(e) => sessionView.setSearchQuery(e.target.value)}
+ className="w-56"
+ />
</div>
</div>
+ {/* The border frames a list. With nothing to list it frames empty space,
+ which reads as a list that failed to load rather than as an agent with
+ no sessions yet. */}
{filteredSessions.length === 0 && sessionView.tab === 'active' ? (
<SessionListEmptyState locationId={locationId} agentName={agentName} />
) : (
- <SessionVirtualList
- sessions={filteredSessions}
- selectedIds={sessionView.selectedIds}
- onToggleSelect={(id, shiftKey) => {
- if (shiftKey) {
- sessionView.selectRange(
- filteredSessions.map((t) => t.data.id),
- id
- );
- } else {
- sessionView.toggleSelect(id);
- }
- }}
- />
+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-border">
+ <SessionVirtualList
+ sessions={filteredSessions}
+ selectedIds={sessionView.selectedIds}
+ onToggleSelect={(id, shiftKey) => {
+ if (shiftKey) {
+ sessionView.selectRange(
+ filteredSessions.map((t) => t.data.id),
+ id
+ );
+ } else {
+ sessionView.toggleSelect(id);
+ }
+ }}
+ />
+ </div>
)}
<SelectionBar
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-row.tsx b/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-row.tsx
index c3afc5ec3..7a0552b83 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-row.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/components/session-view/session-row.tsx
@@ -1,3 +1,4 @@
+import { MessageSquare } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useRef } from 'react';
import { AgentStatusIndicator } from '@renderer/features/sessions/components/agent-status-indicator';
@@ -7,8 +8,7 @@ import {
sessionAgentStatus,
} from '@renderer/features/sessions/stores/session-selectors';
import { type SessionStore } from '@renderer/features/sessions/stores/session-store';
-import { SessionRoomBadge } from '@renderer/features/switch-rooms/session-room-badge';
-import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { SessionRoomLabel } from '@renderer/features/switch-rooms/session-room-label';
import { useNavigate } from '@renderer/lib/layout/navigation-provider';
import { useShowModal } from '@renderer/lib/modal/modal-provider';
import { Checkbox } from '@renderer/lib/ui/checkbox';
@@ -73,43 +73,44 @@ export const SessionRow = observer(function SessionRow({
}}
className="group flex w-full items-center gap-2 rounded-lg p-3 transition-colors hover:bg-background-1"
>
- <div
- onPointerDownCapture={(e) => {
- shiftKeyRef.current = e.shiftKey;
- }}
- onKeyDownCapture={(e) => {
- shiftKeyRef.current = e.shiftKey;
- }}
- onClick={(e) => e.stopPropagation()}
- className={cn(
- 'transition-opacity',
- isSelected ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
- )}
- >
- <Checkbox
- checked={isSelected}
- onCheckedChange={() => {
- const shift = shiftKeyRef.current;
- shiftKeyRef.current = false;
- onToggleSelect(shift);
- }}
- aria-label="Select session"
+ {/* The row's mark and its checkbox share one slot: the checkbox is only
+ reachable by pointer, so reserving a column for it beside the mark
+ indents every row for a control that is invisible most of the time. */}
+ <div className="relative flex size-4 shrink-0 items-center justify-center">
+ <MessageSquare
+ className={cn(
+ 'size-4 text-foreground-passive transition-opacity',
+ isSelected ? 'opacity-0' : 'group-hover:opacity-0'
+ )}
/>
+ <div
+ onPointerDownCapture={(e) => {
+ shiftKeyRef.current = e.shiftKey;
+ }}
+ onKeyDownCapture={(e) => {
+ shiftKeyRef.current = e.shiftKey;
+ }}
+ onClick={(e) => e.stopPropagation()}
+ className={cn(
+ 'absolute inset-0 flex items-center justify-center transition-opacity',
+ isSelected ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'
+ )}
+ >
+ <Checkbox
+ checked={isSelected}
+ onCheckedChange={() => {
+ const shift = shiftKeyRef.current;
+ shiftKeyRef.current = false;
+ onToggleSelect(shift);
+ }}
+ aria-label="Select session"
+ />
+ </div>
</div>
<div className="flex min-w-0 flex-1 items-center gap-2">
- <div className="flex min-w-0 flex-1 items-center gap-2">
- <span className="min-w-0 truncate text-left text-sm">{session.data.title}</span>
- </div>
+ <span className="min-w-0 truncate text-left text-sm">{session.data.title}</span>
</div>
- <SessionRoomBadge sessionId={session.data.id} />
- {session.agentProviderId && (
- <span
- className="relative flex h-5 w-5 shrink-0 items-center justify-center overflow-hidden rounded-sm bg-background-2 ring-2 ring-background"
- title={session.agentProviderId}
- >
- <AgentIcon id={session.agentProviderId} size={14} />
- </span>
- )}
+ <SessionRoomLabel sessionId={session.data.id} />
<div
className={cn(
'flex min-w-8 shrink-0 items-center justify-end',
diff --git a/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts b/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts
index 4e45e0484..8de883b1e 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/locations/stores/agents-store.ts
@@ -65,6 +65,19 @@ export class AgentsStore {
return null;
}
+ /**
+ * The agent an agent page is routed to — its location plus its name, the pair
+ * every caller of the `location` view navigates with.
+ *
+ * Returns null rather than guessing when the route carries no name: a location
+ * can hold several agents, and picking one of them would put another agent's
+ * provider and identity above someone's session list.
+ */
+ agentAtLocation(locationId: string, agentName: string | undefined): Agent | null {
+ if (agentName === undefined) return null;
+ return (this.byLocation.get(locationId) ?? []).find((a) => a.name === agentName) ?? null;
+ }
+
/**
* This install's agents that are registered on a given Switch server, i.e.
* the ones Switch Console can actually act on there. The room views list and
diff --git a/console/apps/switch-console-desktop/src/renderer/features/onboarding/onboarding-checklist.tsx b/console/apps/switch-console-desktop/src/renderer/features/onboarding/onboarding-checklist.tsx
index 208e84b56..255be26a6 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/onboarding/onboarding-checklist.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/onboarding/onboarding-checklist.tsx
@@ -1,7 +1,7 @@
import { Check, ChevronDown, ChevronRight, X } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { openExternalUrl } from '@renderer/lib/open-external';
-import { MicroLabel } from '@renderer/lib/ui/label';
+import { SectionLabel } from '@renderer/lib/ui/label';
import { cn } from '@renderer/utils/utils';
import type { OnboardingStep, OnboardingStepId } from '@shared/core/onboarding/checklist';
import { SWITCH_CONSOLE_DOCS_URL } from '@shared/urls';
@@ -174,7 +174,9 @@ export const OnboardingChecklistPanel = observer(function OnboardingChecklistPan
) : (
<ChevronDown className="size-3.5 shrink-0" />
)}
- <MicroLabel className="text-foreground-tertiary-passive">Setting up Switch</MicroLabel>
+ <SectionLabel className="text-foreground-tertiary-passive">
+ Setting up Switch
+ </SectionLabel>
</button>
<button
type="button"
@@ -213,7 +215,7 @@ export function OnboardingChecklistCard({
return (
<div className="flex w-full flex-col gap-2 rounded-xl border border-border p-4">
<div className="flex items-center justify-between">
- <MicroLabel className="text-foreground-tertiary-passive">Setting up Switch</MicroLabel>
+ <SectionLabel className="text-foreground-tertiary-passive">Setting up Switch</SectionLabel>
<button
type="button"
onClick={onDismiss}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/onboarding/welcome-learn-more.tsx b/console/apps/switch-console-desktop/src/renderer/features/onboarding/welcome-learn-more.tsx
index 1b0113d3e..dbc3f362d 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/onboarding/welcome-learn-more.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/onboarding/welcome-learn-more.tsx
@@ -1,6 +1,6 @@
import { ArrowUpRight } from 'lucide-react';
import { openExternalUrl } from '@renderer/lib/open-external';
-import { MicroLabel } from '@renderer/lib/ui/label';
+import { SectionLabel } from '@renderer/lib/ui/label';
import { SWITCH_CONSOLE_DOCS_URL } from '@shared/urls';
/**
@@ -20,7 +20,7 @@ export function WelcomeLearnMore() {
return (
<div className="flex w-full flex-col gap-3 rounded-xl border border-border p-4">
<div className="flex items-center justify-between">
- <MicroLabel className="text-foreground-tertiary-passive">Learn more</MicroLabel>
+ <SectionLabel className="text-foreground-tertiary-passive">Learn more</SectionLabel>
<button
type="button"
onClick={() => openExternalUrl(SWITCH_CONSOLE_DOCS_URL, 'Could not open documentation')}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-actions-menu.tsx b/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-actions-menu.tsx
new file mode 100644
index 000000000..e646a8b51
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-actions-menu.tsx
@@ -0,0 +1,61 @@
+import { MoreVertical } from 'lucide-react';
+import React from 'react';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@renderer/lib/ui/dropdown-menu';
+import { cn } from '@renderer/utils/utils';
+import { sessionActions, type SessionActionsProps } from './session-actions';
+
+/**
+ * A session's actions, on a button.
+ *
+ * The same list the right-click menu offers, reachable without knowing to
+ * right-click — which nothing in the interface says you can.
+ */
+export function SessionActionsMenu({
+ sessionName,
+ className,
+ onOpenChange,
+ ...actionProps
+}: SessionActionsProps & {
+ sessionName: string;
+ className?: string;
+ /** Told when the menu opens or closes, so a row that only reveals this
+ * button on hover can keep it visible while its menu is up. */
+ onOpenChange?: (open: boolean) => void;
+}) {
+ return (
+ <DropdownMenu onOpenChange={onOpenChange}>
+ <DropdownMenuTrigger
+ className={cn(
+ 'flex size-6 items-center justify-center rounded-md text-foreground-tertiary-muted hover:bg-background-tertiary-2 hover:text-foreground-tertiary group-data-[active=true]/row:hover:bg-background-tertiary-3',
+ className
+ )}
+ aria-label={`Actions for ${sessionName || 'session'}`}
+ onMouseDown={(e) => e.preventDefault()}
+ onPointerDown={(e) => e.stopPropagation()}
+ onClick={(e) => e.stopPropagation()}
+ >
+ <MoreVertical className="size-3.5" />
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ {sessionActions(actionProps).map((action) => (
+ <React.Fragment key={action.key}>
+ {action.separatorBefore && <DropdownMenuSeparator />}
+ <DropdownMenuItem
+ variant={action.destructive ? 'destructive' : 'default'}
+ onClick={action.run}
+ >
+ {action.icon}
+ {action.label}
+ </DropdownMenuItem>
+ </React.Fragment>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-actions.tsx b/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-actions.tsx
new file mode 100644
index 000000000..0805a9915
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-actions.tsx
@@ -0,0 +1,137 @@
+import { Archive, Copy, MessageSquare, Pencil, Pin, PinOff, RotateCcw, Trash2 } from 'lucide-react';
+import type { ReactNode } from 'react';
+import { toast } from '@renderer/lib/hooks/use-toast';
+
+/**
+ * What can be done to a session, as one list.
+ *
+ * A session is acted on from two places that must offer the same things —
+ * right-clicking it, and the row's own actions button — and they were only the
+ * same for as long as someone kept them so. The list is built once here and
+ * both menus render it, so an action added to a session cannot arrive in one
+ * menu and be missing from the other.
+ */
+
+export interface SessionActionsProps {
+ isPinned: boolean;
+ canPin: boolean;
+ isArchived: boolean;
+ branchName?: string;
+ onPin: () => void;
+ onUnpin: () => void;
+ onRename: () => void;
+ onArchive: () => void;
+ onRestore?: () => void;
+ onReconnect?: () => void;
+ onConvertAutomation?: () => void;
+ onDelete: () => void;
+}
+
+export interface SessionAction {
+ key: string;
+ icon: ReactNode;
+ label: string;
+ run: () => void;
+ destructive?: boolean;
+ /** Set the item apart from the ones above it. */
+ separatorBefore?: boolean;
+}
+
+async function copyBranchName(branchName: string): Promise<void> {
+ try {
+ await navigator.clipboard.writeText(branchName);
+ toast({ title: 'Branch name copied' });
+ } catch {
+ toast({
+ title: 'Copy failed',
+ description: 'The branch name could not be copied to the clipboard.',
+ variant: 'destructive',
+ });
+ }
+}
+
+export function sessionActions({
+ isPinned,
+ canPin,
+ isArchived,
+ branchName,
+ onPin,
+ onUnpin,
+ onRename,
+ onArchive,
+ onRestore,
+ onReconnect,
+ onConvertAutomation,
+ onDelete,
+}: SessionActionsProps): SessionAction[] {
+ const actions: SessionAction[] = [];
+
+ if (canPin) {
+ actions.push(
+ isPinned
+ ? {
+ key: 'unpin',
+ icon: <PinOff className="size-4" />,
+ label: 'Unpin session',
+ run: onUnpin,
+ }
+ : { key: 'pin', icon: <Pin className="size-4" />, label: 'Pin session', run: onPin }
+ );
+ }
+ actions.push({
+ key: 'rename',
+ icon: <Pencil className="size-4" />,
+ label: 'Rename',
+ run: onRename,
+ });
+ if (onReconnect) {
+ actions.push({
+ key: 'reconnect',
+ icon: <RotateCcw className="size-4" />,
+ label: 'Reconnect',
+ run: onReconnect,
+ });
+ }
+ if (onConvertAutomation) {
+ actions.push({
+ key: 'convert',
+ icon: <MessageSquare className="size-4" />,
+ label: 'Convert to regular session',
+ run: onConvertAutomation,
+ });
+ }
+ if (!isArchived) {
+ actions.push({
+ key: 'archive',
+ icon: <Archive className="size-4" />,
+ label: 'Archive',
+ run: onArchive,
+ });
+ }
+ if (isArchived && onRestore) {
+ actions.push({
+ key: 'restore',
+ icon: <RotateCcw className="size-4" />,
+ label: 'Restore',
+ run: onRestore,
+ });
+ }
+ if (branchName) {
+ actions.push({
+ key: 'copy-branch',
+ icon: <Copy className="size-4" />,
+ label: 'Copy branch name',
+ run: () => void copyBranchName(branchName),
+ });
+ }
+ actions.push({
+ key: 'delete',
+ icon: <Trash2 className="size-4" />,
+ label: 'Delete',
+ run: onDelete,
+ destructive: true,
+ separatorBefore: true,
+ });
+
+ return actions;
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-context-menu.tsx b/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-context-menu.tsx
index 05c67095f..bbb469d3b 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-context-menu.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sessions/components/session-context-menu.tsx
@@ -1,6 +1,4 @@
-import { Archive, Copy, MessageSquare, Pencil, Pin, PinOff, RotateCcw, Trash2 } from 'lucide-react';
import React from 'react';
-import { toast } from '@renderer/lib/hooks/use-toast';
import {
ContextMenu,
ContextMenuContent,
@@ -8,108 +6,28 @@ import {
ContextMenuSeparator,
ContextMenuTrigger,
} from '@renderer/lib/ui/context-menu';
-
-interface SessionContextMenuProps {
- children: React.ReactNode;
- isPinned: boolean;
- canPin: boolean;
- isArchived: boolean;
- branchName?: string;
- onPin: () => void;
- onUnpin: () => void;
- onRename: () => void;
- onArchive: () => void;
- onRestore?: () => void;
- onReconnect?: () => void;
- onConvertAutomation?: () => void;
- onDelete: () => void;
-}
+import { sessionActions, type SessionActionsProps } from './session-actions';
export function SessionContextMenu({
children,
- isPinned,
- canPin,
- isArchived,
- branchName,
- onPin,
- onUnpin,
- onRename,
- onArchive,
- onRestore,
- onReconnect,
- onConvertAutomation,
- onDelete,
-}: SessionContextMenuProps) {
- const handleCopyBranchName = async () => {
- if (!branchName) return;
-
- try {
- await navigator.clipboard.writeText(branchName);
- toast({ title: 'Branch name copied' });
- } catch {
- toast({
- title: 'Copy failed',
- description: 'The branch name could not be copied to the clipboard.',
- variant: 'destructive',
- });
- }
- };
-
+ ...actionProps
+}: SessionActionsProps & { children: React.ReactNode }) {
return (
<ContextMenu>
<ContextMenuTrigger>{children}</ContextMenuTrigger>
<ContextMenuContent>
- {canPin &&
- (isPinned ? (
- <ContextMenuItem onClick={onUnpin}>
- <PinOff className="size-4" />
- Unpin session
- </ContextMenuItem>
- ) : (
- <ContextMenuItem onClick={onPin}>
- <Pin className="size-4" />
- Pin session
+ {sessionActions(actionProps).map((action) => (
+ <React.Fragment key={action.key}>
+ {action.separatorBefore && <ContextMenuSeparator />}
+ <ContextMenuItem
+ variant={action.destructive ? 'destructive' : 'default'}
+ onClick={action.run}
+ >
+ {action.icon}
+ {action.label}
</ContextMenuItem>
- ))}
- <ContextMenuItem onClick={onRename}>
- <Pencil className="size-4" />
- Rename
- </ContextMenuItem>
- {onReconnect && (
- <ContextMenuItem onClick={onReconnect}>
- <RotateCcw className="size-4" />
- Reconnect
- </ContextMenuItem>
- )}
- {onConvertAutomation && (
- <ContextMenuItem onClick={onConvertAutomation}>
- <MessageSquare className="size-4" />
- Convert to regular session
- </ContextMenuItem>
- )}
- {!isArchived && (
- <ContextMenuItem onClick={onArchive}>
- <Archive className="size-4" />
- Archive
- </ContextMenuItem>
- )}
- {isArchived && onRestore && (
- <ContextMenuItem onClick={onRestore}>
- <RotateCcw className="size-4" />
- Restore
- </ContextMenuItem>
- )}
- {branchName && (
- <ContextMenuItem onClick={() => void handleCopyBranchName()}>
- <Copy className="size-4" />
- Copy branch name
- </ContextMenuItem>
- )}
- <ContextMenuSeparator />
- <ContextMenuItem variant="destructive" onClick={onDelete}>
- <Trash2 className="size-4" />
- Delete
- </ContextMenuItem>
+ </React.Fragment>
+ ))}
</ContextMenuContent>
</ContextMenu>
);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sessions/session-titlebar.tsx b/console/apps/switch-console-desktop/src/renderer/features/sessions/session-titlebar.tsx
index c97b8017c..d35b049d2 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sessions/session-titlebar.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sessions/session-titlebar.tsx
@@ -1,5 +1,7 @@
-import { Pin } from 'lucide-react';
+import { Bot, DoorOpen, MessageSquare, Pin } from 'lucide-react';
import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import {
getLocationStore,
locationDisplayName,
@@ -10,40 +12,89 @@ import {
getSessionStore,
sessionDisplayName,
} from '@renderer/features/sessions/stores/session-selectors';
+import { switchRoomsStore as sessionRoomsStore } from '@renderer/features/switch-rooms/switch-rooms-store';
+import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
import { Titlebar } from '@renderer/lib/components/titlebar/Titlebar';
+import {
+ TitlebarBreadcrumb,
+ type TitlebarCrumb,
+} from '@renderer/lib/components/titlebar/titlebar-breadcrumb';
import { useNavigate } from '@renderer/lib/layout/navigation-provider';
import { cn } from '@renderer/utils/utils';
-// Switch Console titlebar: agent / session breadcrumb plus a pin toggle. The Switch Console
-// git, issue, diff, preview, terminal-drawer and sidebar chrome is gone.
+/**
+ * Where the session sits: the agent running it, the room it is talking in, and
+ * the session itself — plus a pin toggle.
+ *
+ * The room step is dropped rather than faked when the session is in none, or
+ * when its room's name has not been read yet. A trail is a claim about where
+ * you are, so a step it cannot fill is a step it must not draw.
+ */
export const SessionTitlebar = observer(function SessionTitlebar() {
const { locationId, sessionId } = useSessionViewContext();
const sessionStore = getSessionStore(locationId, sessionId);
const sessionPayload = getRegisteredSessionData(locationId, sessionId);
- const locationName = locationDisplayName(getLocationStore(locationId));
const { navigate } = useNavigate();
+ useEffect(() => {
+ sessionRoomsStore.ensureLoaded();
+ }, []);
+
+ const agentName = sessionPayload?.agentName;
+ const agent = agentsStore.agentAtLocation(locationId, agentName);
+ const providerId = agent?.providerId ?? sessionStore?.agentProviderId ?? null;
+
+ const roomId = sessionRoomsStore.roomForSession(sessionId);
+ const roomName = roomId ? switchRoomsStore.roomNameById(roomId) : null;
+ const bridgeType = roomId ? switchRoomsStore.roomBridgeTypeById(roomId) : null;
+
+ const crumbs: TitlebarCrumb[] = [
+ {
+ key: 'agent',
+ icon: providerId ? (
+ <AgentIcon id={providerId} size={14} className="shrink-0" />
+ ) : (
+ <Bot className="size-3.5 shrink-0" />
+ ),
+ label: agentName ?? locationDisplayName(getLocationStore(locationId)) ?? 'Agent',
+ maxWidthClassName: 'max-w-40',
+ onClick: () => navigate('location', { locationId, agentName }),
+ },
+ ];
+
+ if (roomId && roomName) {
+ crumbs.push({
+ key: 'room',
+ icon: hasBridgeIcon(bridgeType) ? (
+ <BridgeIcon bridgeType={bridgeType} size={14} className="shrink-0" />
+ ) : (
+ <DoorOpen className="size-3.5 shrink-0" />
+ ),
+ label: roomName,
+ maxWidthClassName: 'max-w-40',
+ onClick: () => navigate('room', { roomId }),
+ });
+ }
+
+ crumbs.push({
+ key: 'session',
+ icon: <MessageSquare className="size-3.5 shrink-0" />,
+ label: sessionDisplayName(sessionStore) ?? 'Session',
+ });
+
return (
<Titlebar
leftSlot={
- <div className="flex items-center gap-1 px-2 text-sm text-foreground-muted">
- <button
- type="button"
- className="text-sm text-foreground-passive hover:text-foreground"
- onClick={() => navigate('location', { locationId })}
- >
- {locationName}
- </button>
- <span className="text-sm text-foreground-passive">/</span>
- <span className="max-w-56 truncate">{sessionDisplayName(sessionStore)}</span>
+ <div className="flex min-w-0 items-center">
+ <TitlebarBreadcrumb crumbs={crumbs} />
{sessionStore && sessionPayload && (
<button
type="button"
- className={cn(
- 'ml-1 text-foreground-muted',
- sessionPayload.isPinned && 'text-muted-foreground'
- )}
+ className="ml-1 text-foreground-muted"
onClick={() => sessionStore.setPinned(!sessionPayload.isPinned)}
+ aria-label={sessionPayload.isPinned ? 'Unpin session' : 'Pin session'}
>
<Pin
className={cn('size-3.5', sessionPayload.isPinned && 'text-foreground-muted')}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx
index 346ce85bb..4ccbac263 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-item.tsx
@@ -50,9 +50,13 @@ import { agentExpandKey, depthIndent } from './sidebar-store';
*/
export const SidebarAgentItem = observer(function SidebarAgentItem({
agent,
+ hasSessions,
depth = 0,
}: {
agent: Agent;
+ /** Whether this agent has anything to show when expanded. An expand control
+ * over nothing is a promise the row cannot keep. */
+ hasSessions: boolean;
depth?: number;
}) {
const { navigate } = useNavigate();
@@ -92,17 +96,14 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({
const sshHost = location.data?.sshHost ?? null;
const hostUnreachable = hostReachabilityStore.isBlocked(sshHost);
- const iconClass =
- 'absolute h-4 w-4 opacity-100 transition-opacity duration-150 group-hover/row:opacity-0';
const gatewayUrl =
agent.serverId && agent.switchAgentId
? switchRoomsStore.gatewayAgentUrl(agent.serverId, agent.switchAgentId)
: null;
- const open = () => {
- sidebarStore.ensureGroupExpanded(agentExpandKey(agent.id));
- navigate('location', { locationId: agent.locationId, agentName });
- };
+ // Opening the agent does not expand it. Expanding is the chevron's job alone,
+ // so what is unfolded in the tree stays as the reader left it.
+ const open = () => navigate('location', { locationId: agent.locationId, agentName });
return (
<ContextMenu>
@@ -116,27 +117,13 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({
onClick={open}
>
<div className="flex min-w-0 flex-1 items-center gap-1">
- <SidebarItemMiniButton
- type="button"
- aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
- className="relative"
- onClick={(e) => {
- e.stopPropagation();
- toggle();
- }}
- >
+ <span className="flex size-6 shrink-0 items-center justify-center">
{agent.providerId ? (
- <AgentIcon id={agent.providerId} size={16} className={iconClass} />
+ <AgentIcon id={agent.providerId} size={16} className="h-4 w-4" />
) : (
- <Bot className={iconClass} />
+ <Bot className="h-4 w-4" />
)}
- <ChevronRight
- className={cn(
- 'absolute h-4 w-4 opacity-0 transition-all duration-150 group-hover/row:opacity-100',
- expanded && 'rotate-90'
- )}
- />
- </SidebarItemMiniButton>
+ </span>
<SidebarMenuAction aria-label={`Open agent ${label}`} className="truncate select-none">
<span className="flex min-w-0 items-center gap-1.5">
<span className="truncate">{label}</span>
@@ -238,6 +225,22 @@ export const SidebarAgentItem = observer(function SidebarAgentItem({
<BoundShortcut settingsKey="newSession" variant="badge" />
</TooltipContent>
</Tooltip>
+ {hasSessions && (
+ <SidebarItemMiniButton
+ type="button"
+ aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
+ aria-expanded={expanded}
+ className="opacity-0 transition-opacity duration-150 group-hover/row:opacity-100 focus-visible:opacity-100"
+ onClick={(e) => {
+ e.stopPropagation();
+ toggle();
+ }}
+ >
+ <ChevronRight
+ className={cn('h-4 w-4 transition-transform duration-150', expanded && 'rotate-90')}
+ />
+ </SidebarItemMiniButton>
+ )}
</SidebarMenuRow>
</ContextMenuTrigger>
<ContextMenuContent>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-tree.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-tree.tsx
index d3db97d08..f6b06e7c0 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-tree.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/agent-tree.tsx
@@ -62,7 +62,7 @@ const AgentSessions = observer(function AgentSessions({
label={roomLabel(roomKey)}
nameKnown={isRoomNameKnown(roomKey)}
nameBlockedBySignIn={switchRoomsStore.roomNameBlockedBySignIn(roomKey)}
- count={roomSessions.length}
+ hasChildren={roomSessions.length > 0}
expanded={roomExpanded}
depth={depth}
bridgeType={switchRoomsStore.roomBridgeTypeById(roomKey)}
@@ -102,17 +102,20 @@ export const AgentTree = observer(function AgentTree() {
>
{entries.map((entry) => {
const expanded = sidebarStore.isGroupExpanded(agentExpandKey(entry.agent.id));
+ const sessions = agentSessions(entry);
return (
<SortableBranch
key={entry.agent.id}
id={makeDndId(AGENTS_CONTAINER, entry.agent.id)}
- header={<SidebarAgentItem agent={entry.agent} depth={0} />}
+ header={
+ <SidebarAgentItem agent={entry.agent} hasSessions={sessions.length > 0} depth={0} />
+ }
>
{expanded && (
<AgentSessions
agentId={entry.agent.id}
locationId={entry.agent.locationId}
- sessions={agentSessions(entry)}
+ sessions={sessions}
depth={1}
/>
)}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/left-sidebar.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/left-sidebar.tsx
index 25a4f543f..8a733dadd 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/left-sidebar.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/left-sidebar.tsx
@@ -9,9 +9,9 @@ import { SwitchConsoleMark } from '@renderer/lib/switch-console-mark';
import { BoundShortcut } from '@renderer/lib/ui/shortcut';
import { cn } from '@renderer/utils/utils';
import { SWITCH_CONSOLE_DOCS_URL } from '@shared/urls';
-import { ServersSidebarSection } from '../switch-servers/ServersSidebarSection';
-import { LocationsGroupLabel } from './locations-group-label';
+import { WorkspaceSwitcher } from '../switch-servers/workspace-switcher';
import { SidebarPinnedSessionList } from './pinned-session-list';
+import { SessionsSectionHeader } from './sessions-section-header';
import { SidebarGroupedList } from './sidebar-grouped-list';
import {
SidebarContainer,
@@ -26,6 +26,7 @@ import { SidebarSearchTrigger } from './sidebar-search-trigger';
import { SidebarSpace } from './sidebar-space';
import { UpdateSection } from './update-section';
import { useSidebarDrop } from './use-sidebar-drop';
+import { WorkspaceNav } from './workspace-nav';
export const LeftSidebar: React.FC = observer(function LeftSidebar() {
const { navigate } = useNavigate();
@@ -54,9 +55,15 @@ export const LeftSidebar: React.FC = observer(function LeftSidebar() {
<SidebarContainer className="min-h-0 w-full flex-1 border-r-0">
<SidebarContent className="flex flex-col">
<SidebarPinnedSessionList />
- <ServersSidebarSection />
- <SidebarGroup className="mb-0 flex min-h-0 flex-1 flex-col">
- <LocationsGroupLabel />
+ {/* The sidebar reads as three blocks — which server, that server's
+ pages, then its sessions — so the vertical rhythm between them
+ lives here rather than as padding each block sets for itself. */}
+ <div className="flex flex-col gap-3">
+ <WorkspaceSwitcher />
+ <WorkspaceNav />
+ </div>
+ <SidebarGroup className="mt-5 mb-0 flex min-h-0 flex-1 flex-col">
+ <SessionsSectionHeader />
<SidebarGroupContent className="flex min-h-0 flex-1 flex-col">
<SidebarMenu className="flex min-h-0 flex-1 flex-col">
<SidebarGroupedList />
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/pinned-session-list.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/pinned-session-list.tsx
index b1164733f..d8232f0ab 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/pinned-session-list.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/pinned-session-list.tsx
@@ -1,6 +1,6 @@
import { observer } from 'mobx-react-lite';
import { sidebarStore } from '@renderer/lib/stores/app-state';
-import { MicroLabel } from '@renderer/lib/ui/label';
+import { SectionLabel } from '@renderer/lib/ui/label';
import { SidebarSessionItem } from './session-item';
import { SidebarGroup, SidebarMenu } from './sidebar-primitives';
@@ -11,7 +11,7 @@ export const SidebarPinnedSessionList = observer(function SidebarPinnedSessionLi
return (
<SidebarGroup className="flex shrink-0 flex-col">
<div className="flex h-[40px] items-center justify-between pr-2.5 pl-5">
- <MicroLabel className="text-foreground-tertiary-passive">Pinned</MicroLabel>
+ <SectionLabel className="text-foreground-tertiary-passive">Pinned</SectionLabel>
</div>
<SidebarMenu className="px-3 pb-2">
{entries.map(({ locationId, sessionId }) => (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx
index 38d83981c..9b551ee99 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-agent-row.tsx
@@ -37,10 +37,14 @@ import { depthIndent, roomAgentGroupKey } from './sidebar-store';
export const RoomAgentRow = observer(function RoomAgentRow({
agent,
roomId,
+ hasSessions,
depth,
}: {
agent: Agent;
roomId: string;
+ /** Whether this agent has sessions in this room. No sessions, no expand
+ * control — the row would unfold into nothing. */
+ hasSessions: boolean;
depth: number;
}) {
const { navigate } = useNavigate();
@@ -70,9 +74,6 @@ export const RoomAgentRow = observer(function RoomAgentRow({
if (!location) return null;
- const iconClass =
- 'absolute h-4 w-4 opacity-100 transition-opacity duration-150 group-hover/row:opacity-0';
-
const removeFromRoom = () => {
const serverId = switchRoomsStore.roomServerId(roomId);
if (!serverId || !agent.switchAgentId) return;
@@ -99,33 +100,18 @@ export const RoomAgentRow = observer(function RoomAgentRow({
data-active={isActive || undefined}
isActive={isActive}
onMouseDown={(e) => e.preventDefault()}
- onClick={() => {
- sidebarStore.ensureGroupExpanded(expandKey);
- navigate('location', { locationId: agent.locationId, agentName: agent.name, roomId });
- }}
+ onClick={() =>
+ navigate('location', { locationId: agent.locationId, agentName: agent.name, roomId })
+ }
>
<div className="flex min-w-0 flex-1 items-center gap-1">
- <SidebarItemMiniButton
- type="button"
- aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
- className="relative"
- onClick={(e) => {
- e.stopPropagation();
- sidebarStore.toggleGroupExpanded(expandKey);
- }}
- >
+ <span className="flex size-6 shrink-0 items-center justify-center">
{agent.providerId ? (
- <AgentIcon id={agent.providerId} size={16} className={iconClass} />
+ <AgentIcon id={agent.providerId} size={16} className="h-4 w-4" />
) : (
- <Bot className={iconClass} />
+ <Bot className="h-4 w-4" />
)}
- <ChevronRight
- className={cn(
- 'absolute h-4 w-4 opacity-0 transition-all duration-150 group-hover/row:opacity-100',
- expanded && 'rotate-90'
- )}
- />
- </SidebarItemMiniButton>
+ </span>
<SidebarMenuAction aria-label={`Open agent ${label}`} className="truncate select-none">
<span className="flex min-w-0 items-center gap-1.5">
<span className="truncate">{label}</span>
@@ -162,6 +148,22 @@ export const RoomAgentRow = observer(function RoomAgentRow({
/>
<TooltipContent>New session in this room</TooltipContent>
</Tooltip>
+ {hasSessions && (
+ <SidebarItemMiniButton
+ type="button"
+ aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
+ aria-expanded={expanded}
+ className="opacity-0 transition-opacity duration-150 group-hover/row:opacity-100 focus-visible:opacity-100"
+ onClick={(e) => {
+ e.stopPropagation();
+ sidebarStore.toggleGroupExpanded(expandKey);
+ }}
+ >
+ <ChevronRight
+ className={cn('h-4 w-4 transition-transform duration-150', expanded && 'rotate-90')}
+ />
+ </SidebarItemMiniButton>
+ )}
</SidebarMenuRow>
</ContextMenuTrigger>
<ContextMenuContent>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-tree.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-tree.tsx
index 2e4b75b36..71e83a0b9 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-tree.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/room-tree.tsx
@@ -135,8 +135,7 @@ export const RoomTree = observer(function RoomTree() {
label={roomLabel(roomKey)}
nameKnown={isRoomNameKnown(roomKey)}
nameBlockedBySignIn={switchRoomsStore.roomNameBlockedBySignIn(roomKey)}
- count={agentsInRoom.length}
- undrawableCount={switchRoomsStore.undrawableMemberCount(roomKey)}
+ hasChildren={agentsInRoom.length > 0}
expanded={expanded}
depth={0}
bridgeType={switchRoomsStore.roomBridgeTypeById(roomKey)}
@@ -163,7 +162,12 @@ export const RoomTree = observer(function RoomTree() {
);
return (
<Fragment key={entry.agent.id}>
- <RoomAgentRow agent={entry.agent} roomId={roomKey} depth={1} />
+ <RoomAgentRow
+ agent={entry.agent}
+ roomId={roomKey}
+ hasSessions={sessionsHere.length > 0}
+ depth={1}
+ />
{agentExpanded &&
sessionsHere.map((session) => (
<SidebarSessionItem
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-item.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-item.tsx
index a9c89b7a1..e465c722c 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-item.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/session-item.tsx
@@ -1,5 +1,7 @@
import { MessageSquare } from 'lucide-react';
import { observer } from 'mobx-react-lite';
+import { useState } from 'react';
+import { SessionActionsMenu } from '@renderer/features/sessions/components/session-actions-menu';
import { SessionContextMenu } from '@renderer/features/sessions/components/session-context-menu';
import {
getSessionManagerStore,
@@ -32,6 +34,7 @@ export const SidebarSessionItem = observer(function SidebarSessionItem({
const { navigate } = useNavigate();
const showRename = useShowModal('renameSessionModal');
const showDeleteSession = useShowModal('deleteSessionModal');
+ const [actionsOpen, setActionsOpen] = useState(false);
const { currentView } = useWorkspaceSlots();
const { params } = useParams('session');
@@ -72,19 +75,21 @@ export const SidebarSessionItem = observer(function SidebarSessionItem({
const canPin = session.state !== 'unregistered';
+ const actions = {
+ isPinned: session.data.isPinned,
+ canPin,
+ isArchived: false,
+ onPin: () => void session.setPinned(true),
+ onUnpin: () => void session.setPinned(false),
+ onRename: handleRename,
+ onArchive: handleArchive,
+ onReconnect: undefined,
+ onConvertAutomation: undefined,
+ onDelete: handleDelete,
+ };
+
return (
- <SessionContextMenu
- isPinned={session.data.isPinned}
- canPin={canPin}
- isArchived={false}
- onPin={() => void session.setPinned(true)}
- onUnpin={() => void session.setPinned(false)}
- onRename={handleRename}
- onArchive={handleArchive}
- onReconnect={undefined}
- onConvertAutomation={undefined}
- onDelete={handleDelete}
- >
+ <SessionContextMenu {...actions}>
<SidebarMenuRow
className={cn(
'group/row flex items-center justify-between px-1 h-8 gap-1',
@@ -111,8 +116,21 @@ export const SidebarSessionItem = observer(function SidebarSessionItem({
{sessionName}
</span>
</SidebarMenuAction>
- <div className="ml-2 flex shrink-0 items-center justify-end gap-1.5">
- <SessionSidebarTrailingSlot session={session} />
+ {/* The status and the actions button take turns in one slot rather than
+ sitting side by side: the row is narrow, and a second control
+ appearing on hover would shorten the title just as it is being read. */}
+ <div className="ml-2 flex min-w-6 shrink-0 items-center justify-end gap-1.5">
+ {!actionsOpen && (
+ <span className="flex items-center group-hover/row:hidden">
+ <SessionSidebarTrailingSlot session={session} />
+ </span>
+ )}
+ <SessionActionsMenu
+ {...actions}
+ sessionName={sessionName}
+ className={actionsOpen ? 'flex' : 'hidden group-hover/row:flex'}
+ onOpenChange={setActionsOpen}
+ />
</div>
</SidebarMenuRow>
</SessionContextMenu>
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/locations-group-label.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsx
similarity index 58%
rename from console/apps/switch-console-desktop/src/renderer/features/sidebar/locations-group-label.tsx
rename to console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsx
index 1bac8df01..d06236089 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/locations-group-label.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sessions-section-header.tsx
@@ -1,6 +1,5 @@
-import { DoorOpen, Filter, Laptop, ListFilter, Plus, Server, UserPlus, Users } from 'lucide-react';
+import { ArrowUpDown, DoorOpen, Filter, Laptop, Plus, Server, UserPlus } from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import type { ComponentType } from 'react';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { AgentIcon } from '@renderer/lib/components/agent-icon';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
@@ -19,6 +18,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@renderer/lib/ui/dropdown-menu';
+import { SectionLabel } from '@renderer/lib/ui/label';
import { ToggleGroup, ToggleGroupItem } from '@renderer/lib/ui/toggle-group';
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
import { cn } from '@renderer/utils/utils';
@@ -31,25 +31,25 @@ const CONNECTION_LABEL: Record<AgentConnectionKind, string> = {
remote: 'Remote',
};
-const GROUPING_OPTIONS: {
- value: SidebarGrouping;
- label: string;
- icon: ComponentType<{ className?: string }>;
-}[] = [
- { value: 'agent', label: 'Agents', icon: Users },
- { value: 'room', label: 'Rooms', icon: DoorOpen },
+const GROUPING_OPTIONS: { value: SidebarGrouping; label: string }[] = [
+ { value: 'agent', label: 'By Agent' },
+ { value: 'room', label: 'By Room' },
];
/**
* View switcher for the grouped sidebar — a segmented control that shows both
- * groupings (Agents / Rooms) side by side, with the active one highlighted, so
- * the choice is discoverable at a glance rather than hidden behind an icon menu.
+ * groupings side by side, with the active one highlighted, so the choice is
+ * discoverable at a glance rather than hidden behind an icon menu.
+ *
+ * The labels carry no icon. "By Agent" and "By Room" already say it, and two
+ * glyphs inside a control this small crowd it without adding meaning.
* Observer-wrapped so the active selection updates reactively.
*/
const ViewGroupingToggle = observer(function ViewGroupingToggle() {
return (
<ToggleGroup
size="sm"
+ spacing={1}
multiple={false}
value={[sidebarStore.grouping]}
onValueChange={([value]) => {
@@ -57,16 +57,22 @@ const ViewGroupingToggle = observer(function ViewGroupingToggle() {
if (opt) sidebarStore.setGrouping(opt.value);
}}
aria-label="Group sidebar by"
+ // The raised option has to read as sitting *in* the track, not as a
+ // button dropped on top of a box: concentric corners (inner radius =
+ // outer radius less the padding) and only a hairline of track showing
+ // around it.
+ className="h-7 gap-px rounded-lg border-transparent bg-background-tertiary-2 p-px"
>
- {GROUPING_OPTIONS.map((opt) => {
- const OptIcon = opt.icon;
- return (
- <ToggleGroupItem key={opt.value} value={opt.value} aria-label={opt.label}>
- <OptIcon className="mr-1 h-3.5 w-3.5" />
- {opt.label}
- </ToggleGroupItem>
- );
- })}
+ {GROUPING_OPTIONS.map((opt) => (
+ <ToggleGroupItem
+ key={opt.value}
+ value={opt.value}
+ aria-label={opt.label}
+ className="rounded-[7px] px-2.5 hover:bg-transparent aria-pressed:bg-background data-pressed:bg-background data-[state=on]:bg-background"
+ >
+ {opt.label}
+ </ToggleGroupItem>
+ ))}
</ToggleGroup>
);
});
@@ -241,7 +247,12 @@ const FilterDropdown = observer(function FilterDropdown() {
);
});
-export const LocationsGroupLabel = observer(function LocationsGroupLabel() {
+/**
+ * The Sessions section's header: what the list below is, then how it is
+ * arranged. The grouping toggle used to sit alone on a single row, where it
+ * read as the sidebar's whole navigation rather than as one list's setting.
+ */
+export const SessionsSectionHeader = observer(function SessionsSectionHeader() {
const showAddLocationModal = useShowModal('addAgentModal');
const showCreateRoomModal = useShowModal('createRoomModal');
// The add button offers both actions rather than the one matching the current
@@ -251,116 +262,122 @@ export const LocationsGroupLabel = observer(function LocationsGroupLabel() {
const roomMode = sidebarStore.grouping === 'room';
return (
- <div className="flex h-[40px] items-center justify-between pr-2.5 pl-2.5">
- <ViewGroupingToggle />
- <div className="flex items-center gap-1">
- <DropdownMenu>
- <Tooltip>
- <DropdownMenuTrigger
- render={
- <TooltipTrigger
- render={
- <button
- type="button"
- aria-label={roomMode ? 'Sort rooms' : 'Sort agents'}
- className={buttonVariants({
- size: 'icon-xs',
- variant: 'ghost',
- className:
- 'hover:bg-transparent text-foreground-muted hover:text-foreground',
- })}
+ <>
+ <div className="flex h-[22px] items-center justify-between pr-2.5 pl-2.5">
+ <SectionLabel>Sessions</SectionLabel>
+ <span className="text-xs text-foreground-passive">Group by</span>
+ </div>
+ <div className="flex h-[36px] items-center justify-between pr-2.5 pl-2.5">
+ <ViewGroupingToggle />
+ <div className="flex items-center gap-1">
+ <DropdownMenu>
+ <Tooltip>
+ <DropdownMenuTrigger
+ render={
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ aria-label={roomMode ? 'Sort rooms' : 'Sort agents'}
+ className={buttonVariants({
+ size: 'icon-xs',
+ variant: 'ghost',
+ className:
+ 'hover:bg-transparent text-foreground-muted hover:text-foreground',
+ })}
+ >
+ <ArrowUpDown />
+ </button>
+ }
+ />
+ }
+ />
+ <TooltipContent>Sort by</TooltipContent>
+ </Tooltip>
+ <DropdownMenuContent className="min-w-48">
+ <DropdownMenuGroup>
+ <DropdownMenuLabel>Sort by</DropdownMenuLabel>
+ {roomMode ? (
+ // Rooms are places, so they order by their own properties, and
+ // separately from the session sort — switching view must not
+ // silently re-order the other one.
+ <DropdownMenuRadioGroup value={sidebarStore.roomSortBy}>
+ <DropdownMenuRadioItem
+ value="name"
+ onClick={() => sidebarStore.setRoomSortBy('name')}
>
- <ListFilter />
- </button>
- }
- />
- }
- />
- <TooltipContent>Sort by</TooltipContent>
- </Tooltip>
- <DropdownMenuContent className="min-w-48">
- <DropdownMenuGroup>
- <DropdownMenuLabel>Sort by</DropdownMenuLabel>
- {roomMode ? (
- // Rooms are places, so they order by their own properties, and
- // separately from the session sort — switching view must not
- // silently re-order the other one.
- <DropdownMenuRadioGroup value={sidebarStore.roomSortBy}>
- <DropdownMenuRadioItem
- value="name"
- onClick={() => sidebarStore.setRoomSortBy('name')}
- >
- Name
- </DropdownMenuRadioItem>
- <DropdownMenuRadioItem
- value="created-at"
- onClick={() => sidebarStore.setRoomSortBy('created-at')}
- >
- Created
- </DropdownMenuRadioItem>
- <DropdownMenuRadioItem
- value="updated-at"
- onClick={() => sidebarStore.setRoomSortBy('updated-at')}
- >
- Last active
- </DropdownMenuRadioItem>
- </DropdownMenuRadioGroup>
- ) : (
- <DropdownMenuRadioGroup value={sidebarStore.sessionSortBy}>
- <DropdownMenuRadioItem
- value="created-at"
- onClick={() => sidebarStore.applySort('created-at')}
- >
- Created at
- </DropdownMenuRadioItem>
- <DropdownMenuRadioItem
- value="updated-at"
- onClick={() => sidebarStore.applySort('updated-at')}
- >
- Last used
- </DropdownMenuRadioItem>
- </DropdownMenuRadioGroup>
- )}
- </DropdownMenuGroup>
- </DropdownMenuContent>
- </DropdownMenu>
- <FilterDropdown />
- <DropdownMenu>
- <Tooltip>
- <DropdownMenuTrigger
- render={
- <TooltipTrigger
- render={
- <button
- type="button"
- aria-label="Add"
- className={buttonVariants({
- size: 'icon-xs',
- variant: 'ghost',
- className:
- 'hover:bg-transparent text-foreground-muted hover:text-foreground',
- })}
+ Name
+ </DropdownMenuRadioItem>
+ <DropdownMenuRadioItem
+ value="created-at"
+ onClick={() => sidebarStore.setRoomSortBy('created-at')}
>
- <Plus />
- </button>
- }
- />
- }
- />
- <TooltipContent>Add</TooltipContent>
- </Tooltip>
- <DropdownMenuContent className="min-w-48" align="start">
- <DropdownMenuItem onClick={() => showAddLocationModal({})}>
- <UserPlus className="mr-1.5 h-4 w-4" />
- Add an agent
- </DropdownMenuItem>
- <DropdownMenuItem onClick={() => showCreateRoomModal({})}>
- <DoorOpen className="mr-1.5 h-4 w-4" />
- Create a room
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ Created
+ </DropdownMenuRadioItem>
+ <DropdownMenuRadioItem
+ value="updated-at"
+ onClick={() => sidebarStore.setRoomSortBy('updated-at')}
+ >
+ Last active
+ </DropdownMenuRadioItem>
+ </DropdownMenuRadioGroup>
+ ) : (
+ <DropdownMenuRadioGroup value={sidebarStore.sessionSortBy}>
+ <DropdownMenuRadioItem
+ value="created-at"
+ onClick={() => sidebarStore.applySort('created-at')}
+ >
+ Created at
+ </DropdownMenuRadioItem>
+ <DropdownMenuRadioItem
+ value="updated-at"
+ onClick={() => sidebarStore.applySort('updated-at')}
+ >
+ Last used
+ </DropdownMenuRadioItem>
+ </DropdownMenuRadioGroup>
+ )}
+ </DropdownMenuGroup>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <FilterDropdown />
+ <DropdownMenu>
+ <Tooltip>
+ <DropdownMenuTrigger
+ render={
+ <TooltipTrigger
+ render={
+ <button
+ type="button"
+ aria-label="Add"
+ className={buttonVariants({
+ size: 'icon-xs',
+ variant: 'ghost',
+ className:
+ 'hover:bg-transparent text-foreground-muted hover:text-foreground',
+ })}
+ >
+ <Plus />
+ </button>
+ }
+ />
+ }
+ />
+ <TooltipContent>Add</TooltipContent>
+ </Tooltip>
+ <DropdownMenuContent className="min-w-48" align="start">
+ <DropdownMenuItem onClick={() => showAddLocationModal({})}>
+ <UserPlus className="mr-1.5 h-4 w-4" />
+ Add an agent
+ </DropdownMenuItem>
+ <DropdownMenuItem onClick={() => showCreateRoomModal({})}>
+ <DoorOpen className="mr-1.5 h-4 w-4" />
+ Create a room
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
</div>
- </div>
+ </>
);
});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx
index 7264d8096..d30bc4b92 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-grouped-list.tsx
@@ -90,11 +90,24 @@ export const SidebarGroupedList = observer(function SidebarGroupedList() {
sidebarStore.hasActiveFilters &&
sidebarStore.filteredLocations.length === 0;
+ // A server with nothing on it yet left the panel blank, which reads as the
+ // list having failed to load rather than as there being nothing to list.
+ const showEmptyState =
+ !showFilterEmptyState &&
+ !sidebarStore.hasActiveFilters &&
+ switchServersStore.activeServerId !== null &&
+ sidebarStore.orderedLocations.length === 0 &&
+ switchRoomsStore.listedRoomsInActiveScope.length === 0;
+
return (
<div ref={scrollerRef} className="min-h-0 flex-1 overflow-y-auto px-3 pt-1 pb-3">
<RoomStateDisclosure />
{showFilterEmptyState ? (
<p className="px-2 py-3 text-xs text-foreground-muted">No agents match filters</p>
+ ) : showEmptyState ? (
+ <p className="px-2 py-3 text-xs text-foreground-muted">
+ No sessions running on this server.
+ </p>
) : sidebarStore.grouping === 'room' ? (
<RoomTree />
) : (
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-primitives.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-primitives.tsx
index 289eec302..ecd41c356 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-primitives.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-primitives.tsx
@@ -81,7 +81,7 @@ export const SidebarItemMiniButton = React.forwardRef<
SidebarItemMiniButton.displayName = 'SidebarItemMiniButton';
const sidebarMenuItemClass =
- 'flex w-full font-normal h-8 text-foreground-tertiary-muted rounded-lg items-center hover:bg-background-tertiary-1 hover:text-foreground-tertiary gap-2 px-3 py-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[active=true]:bg-background-tertiary-2 data-[active=true]:text-foreground-tertiary';
+ 'flex w-full cursor-pointer font-normal h-8 text-foreground-tertiary-muted rounded-lg items-center hover:bg-background-tertiary-1 hover:text-foreground-tertiary gap-2 px-3 py-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 data-[active=true]:bg-background-tertiary-2 data-[active=true]:text-foreground-tertiary';
interface SidebarMenuButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
isActive?: boolean;
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx
index 64d2270b0..c2ce3d4b4 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/sidebar-room-grouping.tsx
@@ -100,15 +100,17 @@ export function groupByRoom(
}
/**
- * A room header row. The leading icon doubles as the expand toggle — it shows
- * the bridged platform's logo (Slack, Mattermost, …) for bridged rooms, else a
- * generic door icon, and swaps to a chevron on hover (rotated when expanded).
- * Clicking the row body toggles expand/collapse; opening the room in the gateway
- * web app is scoped to the dedicated "go to" button (named rooms only).
+ * A room header row. It leads with the bridged platform's logo (Slack,
+ * Mattermost, …), or a generic door icon when the room is not bridged.
+ *
+ * Clicking the row opens the room; expanding and collapsing it belongs to the
+ * chevron at the far end and to nothing else, so reading a room never rearranges
+ * the tree underneath it. A row with no room behind it (Unassigned) has nothing
+ * to open and so is not clickable at all.
*/
export function RoomRow({
label,
- count,
+ hasChildren,
expanded,
onToggle,
onOpenGateway,
@@ -118,23 +120,18 @@ export function RoomRow({
isActive = false,
depth = 0,
bridgeType = null,
- undrawableCount = null,
nameKnown = true,
nameBlockedBySignIn = false,
}: {
label: string;
- count: number;
+ /** Whether there is anything under this room to unfold. */
+ hasChildren: boolean;
/** False when `label` is a stand-in because the room's name has not loaded.
* Rendered as visibly provisional rather than as the room's name. */
nameKnown?: boolean;
/** True when the name is missing because the room's server is signed out —
* something to act on, not to wait for. */
nameBlockedBySignIn?: boolean;
- /** Members the server counts that this install cannot draw — agents
- * registered on another Switch Console, plus any whose membership failed to load.
- * Disclosed next to the count so a member that exists but cannot be shown is
- * not read as a member that is not there. Null when unknown. */
- undrawableCount?: number | null;
expanded: boolean;
onToggle: () => void;
onOpenGateway: () => void;
@@ -156,37 +153,22 @@ export function RoomRow({
const channelLinkable = onOpenChannel !== null && hasBridgeIcon(bridgeType);
return (
<SidebarMenuRow
- className="group/room flex h-8 items-center gap-1 px-1"
+ className={cn(
+ 'group/room flex h-8 items-center gap-1 px-1',
+ onSelect === null && 'cursor-default'
+ )}
isActive={isActive}
style={depthIndent(depth)}
onMouseDown={(e) => e.preventDefault()}
- onClick={onSelect ?? onToggle}
+ onClick={onSelect ?? undefined}
>
- <SidebarItemMiniButton
- type="button"
- aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
- className="relative"
- onClick={(e) => {
- e.stopPropagation();
- onToggle();
- }}
- >
+ <span className="flex size-6 shrink-0 items-center justify-center">
{hasBridgeIcon(bridgeType) ? (
- <BridgeIcon
- bridgeType={bridgeType}
- size={16}
- className="absolute h-4 w-4 opacity-100 transition-opacity duration-150 group-hover/room:opacity-0"
- />
+ <BridgeIcon bridgeType={bridgeType} size={16} className="h-4 w-4" />
) : (
- <DoorOpen className="absolute h-4 w-4 text-foreground-muted opacity-100 transition-opacity duration-150 group-hover/room:opacity-0" />
+ <DoorOpen className="h-4 w-4 text-foreground-muted" />
)}
- <ChevronRight
- className={cn(
- 'absolute h-4 w-4 opacity-0 transition-all duration-150 group-hover/room:opacity-100',
- expanded && 'rotate-90'
- )}
- />
- </SidebarItemMiniButton>
+ </span>
{nameKnown ? (
<span className="min-w-0 flex-1 truncate text-sm">{label}</span>
) : (
@@ -263,19 +245,21 @@ export function RoomRow({
/>
<TooltipContent>Open in gateway</TooltipContent>
</Tooltip>
- <span className="shrink-0 text-xs text-foreground-tertiary-passive">{count}</span>
- {undrawableCount !== null && undrawableCount > 0 && (
- <Tooltip>
- <TooltipTrigger
- render={
- <span className="shrink-0 text-xs text-foreground-muted">+{undrawableCount}</span>
- }
+ {hasChildren && (
+ <SidebarItemMiniButton
+ type="button"
+ aria-label={`${expanded ? 'Collapse' : 'Expand'} ${label}`}
+ aria-expanded={expanded}
+ className="opacity-0 transition-opacity duration-150 group-hover/room:opacity-100 focus-visible:opacity-100"
+ onClick={(e) => {
+ e.stopPropagation();
+ onToggle();
+ }}
+ >
+ <ChevronRight
+ className={cn('h-4 w-4 transition-transform duration-150', expanded && 'rotate-90')}
/>
- <TooltipContent>
- {undrawableCount} more {undrawableCount === 1 ? 'member is' : 'members are'} in this
- room but not on this copy of Switch Console, so they cannot be shown here
- </TooltipContent>
- </Tooltip>
+ </SidebarItemMiniButton>
)}
</SidebarMenuRow>
);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
new file mode 100644
index 000000000..de0743fb5
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/sidebar/workspace-nav.tsx
@@ -0,0 +1,45 @@
+import { Bot, DoorOpen, House } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { switchServersStore } from '@renderer/features/switch-servers/switch-servers-store';
+import { isCurrentView, useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
+import { useWorkspaceSlots } from '@renderer/lib/layout/workspace-slots';
+import { SidebarMenu, SidebarMenuButton } from './sidebar-primitives';
+
+/**
+ * The active server's own destinations, under the workspace switcher.
+ *
+ * Three places, not a tree: the server's Home, everything it has registered as
+ * an agent, and everywhere those agents work. The section is deliberately flat
+ * and short — the sessions tree below is where depth belongs.
+ */
+export const WorkspaceNav = observer(function WorkspaceNav() {
+ const { navigate } = useNavigate();
+ const { currentView } = useWorkspaceSlots();
+ const { params: homeParams } = useParams('server');
+ const { params: agentsParams } = useParams('serverAgents');
+ const { params: roomsParams } = useParams('serverRooms');
+ const active = switchServersStore.activeServer;
+ if (!active) return null;
+
+ const destinations = [
+ { view: 'server', icon: House, label: 'Home', params: homeParams },
+ { view: 'serverAgents', icon: Bot, label: 'Your Agents', params: agentsParams },
+ { view: 'serverRooms', icon: DoorOpen, label: 'Your Rooms', params: roomsParams },
+ ] as const;
+
+ return (
+ <SidebarMenu className="px-2">
+ {destinations.map(({ view, icon: Icon, label, params }) => (
+ <SidebarMenuButton
+ key={view}
+ isActive={isCurrentView(currentView, view) && params?.serverId === active.id}
+ onClick={() => navigate(view, { serverId: active.id })}
+ className="h-7 px-2.5"
+ >
+ <Icon className="size-4 shrink-0" />
+ {label}
+ </SidebarMenuButton>
+ ))}
+ </SidebarMenu>
+ );
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/session-room-badge.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/session-room-badge.tsx
deleted file mode 100644
index c8385f1a5..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/session-room-badge.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { Radio } from 'lucide-react';
-import { observer } from 'mobx-react-lite';
-import { useEffect } from 'react';
-import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
-import { switchRoomsStore } from './switch-rooms-store';
-
-/**
- * Small indicator shown on a session when its agent is connected to a Switch
- * room. Renders nothing when the session is not connected to any room.
- */
-export const SessionRoomBadge = observer(function SessionRoomBadge({
- sessionId,
-}: {
- sessionId: string;
-}) {
- useEffect(() => {
- switchRoomsStore.ensureLoaded();
- }, []);
-
- const roomId = switchRoomsStore.roomForSession(sessionId);
- if (!roomId) return null;
-
- return (
- <Tooltip>
- <TooltipTrigger>
- <span className="flex shrink-0 items-center text-foreground-passive">
- <Radio className="h-3.5 w-3.5" aria-label="Connected to a Switch room" />
- </span>
- </TooltipTrigger>
- <TooltipContent>Connected to Switch room {roomId}</TooltipContent>
- </Tooltip>
- );
-});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/session-room-label.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/session-room-label.tsx
new file mode 100644
index 000000000..255fada91
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/session-room-label.tsx
@@ -0,0 +1,35 @@
+import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import { switchRoomsStore as serverRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
+import { switchRoomsStore } from './switch-rooms-store';
+
+/**
+ * Which Switch room a session is talking in, as the session lists show it.
+ *
+ * Three answers, deliberately not collapsed into two: the room's name, "No
+ * room", and nothing at all. The last covers a failed connection seed or a room
+ * list that has not been read — a session whose room could not be looked up
+ * must not be reported as being in none, since "no room" is the state someone
+ * would go and fix.
+ */
+export const SessionRoomLabel = observer(function SessionRoomLabel({
+ sessionId,
+}: {
+ sessionId: string;
+}) {
+ useEffect(() => {
+ switchRoomsStore.ensureLoaded();
+ }, []);
+
+ if (switchRoomsStore.seedError) return null;
+
+ const roomId = switchRoomsStore.roomForSession(sessionId);
+ if (!roomId) {
+ return <span className="shrink-0 text-xs text-foreground-passive">No room</span>;
+ }
+
+ const name = serverRoomsStore.roomNameById(roomId);
+ if (!name) return null;
+
+ return <span className="max-w-32 shrink-0 truncate text-xs text-foreground-muted">{name}</span>;
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx
index 9eefc603a..2d20e76fd 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-rooms/view.tsx
@@ -1,10 +1,11 @@
-import { ExternalLink } from 'lucide-react';
+import { DoorOpen, ExternalLink } from 'lucide-react';
import { observer } from 'mobx-react-lite';
import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
import { switchRoomsStore } from '@renderer/features/switch-servers/switch-rooms-store';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';
import { Titlebar } from '@renderer/lib/components/titlebar/Titlebar';
+import { TitlebarBreadcrumb } from '@renderer/lib/components/titlebar/titlebar-breadcrumb';
import { useParams } from '@renderer/lib/layout/navigation-provider';
import { Button } from '@renderer/lib/ui/button';
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
@@ -48,25 +49,32 @@ const OpenInMessagingApp = observer(function OpenInMessagingApp({ roomId }: { ro
);
});
+/**
+ * A room opened on its own is its own root: it belongs to a server and to every
+ * agent in it, and picking one of those to stand in front of it would be a
+ * claim about how you got here rather than about where you are.
+ */
const RoomTitlebar = observer(function RoomTitlebar() {
const { params } = useParams('room');
const name = switchRoomsStore.roomNameById(params.roomId);
- const serverName = switchRoomsStore.roomServerName(params.roomId);
+ const bridgeType = switchRoomsStore.roomBridgeTypeById(params.roomId);
return (
<Titlebar
leftSlot={
- <div className="flex items-center gap-1 px-2 text-sm text-foreground-muted">
- {serverName && (
- <>
- <span className="max-w-40 truncate text-sm text-foreground-passive">
- {serverName}
- </span>
- <span className="text-sm text-foreground-passive">/</span>
- </>
- )}
- <span className="max-w-56 truncate">{name ?? 'Room'}</span>
- </div>
+ <TitlebarBreadcrumb
+ crumbs={[
+ {
+ key: 'room',
+ icon: hasBridgeIcon(bridgeType) ? (
+ <BridgeIcon bridgeType={bridgeType} size={14} className="shrink-0" />
+ ) : (
+ <DoorOpen className="size-3.5 shrink-0" />
+ ),
+ label: name ?? 'Room',
+ },
+ ]}
+ />
}
rightSlot={
<div className="mr-2 flex items-center gap-1">
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
index 967117b39..30f4b22c5 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/AddServerModal.tsx
@@ -1,6 +1,6 @@
import { CircleCheck, Globe, Laptop, Server, TriangleAlert } from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import { useCallback, useEffect, useRef, useState } from 'react';
+import { useCallback, useEffect, useState } from 'react';
import { HostReachabilityNotice } from '@renderer/features/remote-hosts/host-reachability-notice';
import { toast } from '@renderer/lib/hooks/use-toast';
import { rpc } from '@renderer/lib/ipc';
@@ -19,6 +19,7 @@ import { Input } from '@renderer/lib/ui/input';
import { Spinner } from '@renderer/lib/ui/spinner';
import type { ServerApiUrlPropagation } from '@shared/core/switch-servers/switch-servers';
import { localServerStore } from './local-server-store';
+import { LogTail } from './log-tail';
import { remoteServerStore } from './remote-server-store';
import { switchServersStore } from './switch-servers-store';
@@ -354,43 +355,6 @@ function DockerStatus({
return null;
}
-/**
- * The command's output so far.
- *
- * `placeholder` keeps the panel on screen before the first line arrives. Docker
- * is silent for a while at the start of a pull — it is resolving the registry,
- * not stalled — and an empty space there read as nothing happening at all. It
- * is styled apart from the output so it cannot be mistaken for a line docker
- * printed.
- */
-function LogTail({ lines, placeholder }: { lines: string[]; placeholder: string | null }) {
- const ref = useRef<HTMLDivElement>(null);
-
- useEffect(() => {
- const el = ref.current;
- if (el) el.scrollTop = el.scrollHeight;
- }, [lines]);
-
- if (lines.length === 0 && !placeholder) return null;
-
- return (
- <div
- ref={ref}
- className="max-h-48 overflow-auto rounded-md border border-border bg-background-tertiary p-2 font-mono text-[11px] leading-relaxed text-foreground-muted"
- >
- {lines.length === 0 && placeholder && (
- <div className="text-foreground-tertiary-passive italic">{placeholder}</div>
- )}
- {lines.map((line, i) => (
- // Log lines have no stable id; index is fine for an append-only tail.
- <div key={i} className="break-all whitespace-pre-wrap">
- {line}
- </div>
- ))}
- </div>
- );
-}
-
// ---------------------------------------------------------------------------
// Step 2b — remote-host managed setup (pick an onboarded SSH host → start)
// ---------------------------------------------------------------------------
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/BundledChatSignIn.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/BundledChatSignIn.tsx
index 0db9b8668..46f21c29f 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/BundledChatSignIn.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/BundledChatSignIn.tsx
@@ -1,8 +1,20 @@
import { useQuery } from '@tanstack/react-query';
-import { Check, ChevronDown, ChevronRight, Copy, Eye, EyeOff } from 'lucide-react';
+import { Check, Copy, ExternalLink, Eye, EyeOff, KeyRound } from 'lucide-react';
import { useCallback, useState } from 'react';
+import { BridgeIcon } from '@renderer/lib/components/bridge-icon';
import { rpc } from '@renderer/lib/ipc';
+import { openExternalUrl } from '@renderer/lib/open-external';
import { Button } from '@renderer/lib/ui/button';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogContentArea,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@renderer/lib/ui/dialog';
import { Spinner } from '@renderer/lib/ui/spinner';
function CopyButton({ value, label }: { value: string; label: string }) {
@@ -75,63 +87,88 @@ function CredentialRow({
* so it is never exposed to the LAN, so the copy must not invite the user to
* try a device that cannot reach it.
*
- * Collapsed by default, and the values are only fetched once it is opened: the
- * password should not cross into the renderer for everyone who merely looks at
- * the server page. When Switch Console cannot read the real values it says which
- * one is missing and why, and shows nothing else — a template password would
- * only send the user round a login loop.
+ * The values are only fetched once the dialog is opened: the password should
+ * not cross into the renderer for everyone who merely looks at the server page.
+ * When Switch Console cannot read the real values it says which one is missing
+ * and why, and shows nothing else — a template password would only send the
+ * user round a login loop.
*/
-export function BundledChatSignIn({ serverId }: { serverId: string }) {
- const [expanded, setExpanded] = useState(false);
+export function BundledChatSignIn({
+ serverId,
+ bridgeDisplayName,
+}: {
+ serverId: string;
+ bridgeDisplayName: string;
+}) {
+ const [open, setOpen] = useState(false);
const signInQuery = useQuery({
queryKey: ['bundled-chat-sign-in', serverId],
queryFn: () => rpc.switchServers.getBundledChatSignIn(serverId),
- enabled: expanded,
+ enabled: open,
});
const signIn = signInQuery.data;
+ const url = signIn?.kind === 'available' ? signIn.url : null;
return (
- <div className="mt-1 ml-6">
+ <>
<Button
variant="ghost"
- size="sm"
- className="h-auto px-1 py-0.5 text-xs text-foreground-muted"
- aria-expanded={expanded}
- onClick={() => setExpanded((e) => !e)}
+ size="icon-xs"
+ aria-label={`${bridgeDisplayName} sign-in details`}
+ title={`${bridgeDisplayName} sign-in details`}
+ onClick={() => setOpen(true)}
>
- {expanded ? <ChevronDown className="size-3.5" /> : <ChevronRight className="size-3.5" />}
- Sign-in details
+ <KeyRound className="size-3" />
</Button>
- {expanded && (
- <div className="mt-2 space-y-2">
- <p className="text-xs text-foreground-muted">
- Use these to sign in to this chat in a browser or the Mattermost desktop app on this
- computer.
- </p>
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogContent>
+ <DialogHeader>
+ <BridgeIcon bridgeType="mattermost" size={16} />
+ <DialogTitle>{bridgeDisplayName} sign-in details</DialogTitle>
+ </DialogHeader>
+ <DialogContentArea className="space-y-3">
+ <DialogDescription>
+ Use these to sign in to this chat in a browser or the {bridgeDisplayName} desktop app
+ on this computer.
+ </DialogDescription>
- {signInQuery.isLoading ? (
- <Spinner className="size-3.5" />
- ) : signInQuery.isError ? (
- <p className="text-destructive text-xs">
- Could not read the sign-in details:{' '}
- {signInQuery.error instanceof Error
- ? signInQuery.error.message
- : String(signInQuery.error)}
- </p>
- ) : signIn?.kind === 'unavailable' ? (
- <p className="text-xs text-foreground-muted">{signIn.reason}</p>
- ) : signIn?.kind === 'available' ? (
- <>
- <CredentialRow label="Server" value={signIn.url} />
- <CredentialRow label="Username" value={signIn.username} />
- <CredentialRow label="Password" value={signIn.password} secret />
- </>
- ) : null}
- </div>
- )}
- </div>
+ {signInQuery.isLoading ? (
+ <Spinner className="size-3.5" />
+ ) : signInQuery.isError ? (
+ <p className="text-destructive text-xs">
+ Could not read the sign-in details:{' '}
+ {signInQuery.error instanceof Error
+ ? signInQuery.error.message
+ : String(signInQuery.error)}
+ </p>
+ ) : signIn?.kind === 'unavailable' ? (
+ <p className="text-xs text-foreground-muted">{signIn.reason}</p>
+ ) : signIn?.kind === 'available' ? (
+ <>
+ <CredentialRow label="Server" value={signIn.url} />
+ <CredentialRow label="Username" value={signIn.username} />
+ <CredentialRow label="Password" value={signIn.password} secret />
+ </>
+ ) : null}
+ </DialogContentArea>
+ <DialogFooter>
+ {url && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={() => void openExternalUrl(url, `Could not open ${bridgeDisplayName}`)}
+ >
+ <ExternalLink className="size-4" />
+ Open in browser
+ </Button>
+ )}
+ <DialogClose render={<Button size="sm" />}>Done</DialogClose>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </>
);
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx
index 32fc91fee..d0d656f58 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/LocalServerControls.tsx
@@ -1,31 +1,20 @@
-import { CircleStop, Play, TriangleAlert } from 'lucide-react';
+import { CircleStop, Play, RefreshCw, TriangleAlert } from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import { useEffect, useState } from 'react';
+import { useEffect } from 'react';
import { Alert, AlertDescription, AlertTitle } from '@renderer/lib/ui/alert';
import { Button } from '@renderer/lib/ui/button';
-import {
- Dialog,
- DialogClose,
- DialogContent,
- DialogContentArea,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from '@renderer/lib/ui/dialog';
import { Spinner } from '@renderer/lib/ui/spinner';
import { localServerStore } from './local-server-store';
-import { VersionDriftNotice } from './VersionDriftNotice';
-
-const card = 'rounded-lg border border-border bg-card p-4';
+import { LogTail } from './log-tail';
+import { StackSection, StackStatusRow } from './server-stack-section';
/**
- * Lifecycle controls for the managed local Switch stack: live status, Docker
- * guidance, and start / stop / reset. Rendered inside the managed server's page.
+ * Lifecycle for the managed local Switch stack: live status, Docker guidance,
+ * and start / restart / stop. Rendered as its own section of the server's page;
+ * resetting it lives at the bottom of that page rather than here.
*/
export const LocalServerControls = observer(function LocalServerControls() {
const store = localServerStore;
- const [resetOpen, setResetOpen] = useState(false);
useEffect(() => {
void store.checkDocker();
@@ -33,173 +22,92 @@ export const LocalServerControls = observer(function LocalServerControls() {
const transitioning = store.isTransitioning;
const dockerUnavailable = store.docker && !store.docker.available ? store.docker : null;
- const drift = store.drift;
// Report the version the stack is actually on, not the one this build wants —
- // they diverge exactly when the drift notice below has something to say.
+ // they diverge exactly when the page's drift notice has something to say.
const runningVersion = store.status?.deployedVersion ?? store.status?.version ?? '';
// A stack ahead of this build must not be started at all: doing so would point
// it at a core older than its database has migrated to (CHOO-1736).
- const downgradeBlocked = drift?.direction === 'downgrade';
+ const downgradeBlocked = store.drift?.direction === 'downgrade';
return (
- <div className={`${card} space-y-4`}>
- <div className="flex items-start justify-between gap-3">
- <div className="space-y-1">
- <h3 className="text-sm font-medium text-foreground">Managed server</h3>
- <p className="text-xs text-foreground-muted">
- Runs the full Switch stack on this computer with Docker (switch-core {runningVersion}).
- </p>
- </div>
- <PhaseBadge />
- </div>
-
- <VersionDriftNotice
- drift={drift}
- disabled={transitioning}
- onRestart={() => void store.start()}
+ <StackSection title="Local server">
+ <StackStatusRow
+ phase={store.phase}
+ detail={store.isRunning ? `switch-core ${runningVersion}` : 'not running'}
+ actions={
+ store.isRunning ? (
+ <>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={transitioning}
+ onClick={() => void store.start()}
+ >
+ <RefreshCw className="size-4" />
+ Restart
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={transitioning}
+ onClick={() => void store.stop()}
+ >
+ <CircleStop className="size-4" />
+ Stop
+ </Button>
+ </>
+ ) : (
+ <Button
+ size="sm"
+ disabled={transitioning || downgradeBlocked}
+ onClick={() => void store.start()}
+ >
+ <Play className="size-4" />
+ {store.phase === 'error' && !downgradeBlocked ? 'Retry' : 'Start'}
+ </Button>
+ )
+ }
/>
- {store.message && transitioning && (
- <div className="flex items-center gap-2 text-sm text-foreground-muted">
- <Spinner className="size-3.5" />
- <span>{store.message}</span>
- </div>
- )}
-
- {dockerUnavailable && (
- <Alert variant="destructive">
- <TriangleAlert className="size-4" />
- <AlertTitle>
- {dockerUnavailable.reason === 'not-installed'
- ? 'Docker is not installed'
- : 'Docker is not running'}
- </AlertTitle>
- <AlertDescription>{dockerUnavailable.detail}</AlertDescription>
- </Alert>
- )}
-
- {store.error && !dockerUnavailable && (
- <Alert variant="destructive">
- <AlertTitle>Something went wrong</AlertTitle>
- <AlertDescription>{store.error}</AlertDescription>
- </Alert>
- )}
+ <div className="space-y-3 p-3">
+ {store.message && transitioning && (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner className="size-3.5" />
+ <span>{store.message}</span>
+ </div>
+ )}
- <div className="flex items-center gap-2">
- {store.isRunning ? (
- <Button
- variant="outline"
- size="sm"
- disabled={transitioning}
- onClick={() => void store.stop()}
- >
- <CircleStop className="size-4" />
- Stop
- </Button>
- ) : (
- <Button
- size="sm"
- disabled={transitioning || downgradeBlocked}
- onClick={() => void store.start()}
- >
- <Play className="size-4" />
- {store.phase === 'error' && !downgradeBlocked ? 'Retry' : 'Start'}
- </Button>
+ {dockerUnavailable && (
+ <Alert variant="destructive">
+ <TriangleAlert className="size-4" />
+ <AlertTitle>
+ {dockerUnavailable.reason === 'not-installed'
+ ? 'Docker is not installed'
+ : 'Docker is not running'}
+ </AlertTitle>
+ <AlertDescription>{dockerUnavailable.detail}</AlertDescription>
+ </Alert>
)}
- </div>
- <p className="text-xs text-foreground-tertiary-passive">
- The stack keeps running when you close Switch Console.
- </p>
+ {store.error && !dockerUnavailable && (
+ <Alert variant="destructive">
+ <AlertTitle>Something went wrong</AlertTitle>
+ <AlertDescription>{store.error}</AlertDescription>
+ </Alert>
+ )}
- <div className="mt-1 flex items-center justify-between gap-3 border-t border-border pt-4">
- <div className="space-y-0.5">
- <p className="text-xs font-medium text-foreground">Reset</p>
- <p className="text-xs text-foreground-tertiary-passive">
- Permanently deletes the stack's data and every agent configured against it.
+ {/* What the stack is, until it has said something itself. Once it is
+ talking, its own output is the more useful thing to keep on screen. */}
+ {store.logs.length > 0 ? (
+ <LogTail lines={store.logs} placeholder={null} />
+ ) : (
+ <p className="text-xs text-foreground-muted">
+ Runs the full Switch stack on this computer with Docker
+ {runningVersion ? ` (switch-core ${runningVersion})` : ''}. It keeps running when you
+ close Switch Console — your agents, rooms and messaging apps come back with it.
</p>
- </div>
- <Button
- variant="outline"
- size="sm"
- disabled={transitioning}
- className="shrink-0 border-red-500/40 text-red-500 hover:bg-red-500/10 hover:text-red-500"
- onClick={() => setResetOpen(true)}
- >
- Reset…
- </Button>
+ )}
</div>
-
- <ResetDialog
- open={resetOpen}
- onOpenChange={setResetOpen}
- disabled={transitioning}
- onConfirm={() => {
- setResetOpen(false);
- void store.reset();
- }}
- />
- </div>
- );
-});
-
-const ResetDialog = observer(function ResetDialog({
- open,
- onOpenChange,
- disabled,
- onConfirm,
-}: {
- open: boolean;
- onOpenChange: (open: boolean) => void;
- disabled: boolean;
- onConfirm: () => void;
-}) {
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent>
- <DialogHeader>
- <TriangleAlert className="size-4 text-red-500" />
- <DialogTitle>Reset server on this computer</DialogTitle>
- </DialogHeader>
- <DialogContentArea>
- <DialogDescription>
- This permanently deletes this managed server and everything on it — all rooms, messages,
- and{' '}
- <strong className="text-foreground">every agent you've configured against it</strong>.
- This can't be undone. A fresh Start rebuilds an empty stack from scratch.
- </DialogDescription>
- </DialogContentArea>
- <DialogFooter>
- <DialogClose render={<Button variant="outline" size="sm" />}>Cancel</DialogClose>
- <Button variant="destructive" size="sm" disabled={disabled} onClick={onConfirm}>
- Reset and delete all agents
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-});
-
-const PhaseBadge = observer(function PhaseBadge() {
- const phase = localServerStore.phase;
- const label: Record<typeof phase, string> = {
- stopped: 'Stopped',
- starting: 'Starting',
- running: 'Running',
- stopping: 'Stopping',
- error: 'Error',
- };
- const dot: Record<typeof phase, string> = {
- stopped: 'bg-foreground-muted',
- starting: 'bg-amber-500',
- running: 'bg-green-500',
- stopping: 'bg-amber-500',
- error: 'bg-red-500',
- };
- return (
- <span className="flex items-center gap-1.5 text-xs text-foreground-muted">
- <span aria-hidden className={`inline-block size-2 rounded-full ${dot[phase]}`} />
- {label[phase]}
- </span>
+ </StackSection>
);
});
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 38943a7fc..8492931dd 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
@@ -2,6 +2,7 @@ import { useQueryClient, useQuery } from '@tanstack/react-query';
import {
CircleAlert,
ExternalLink,
+ Info,
Link2,
MessageSquare,
MoreVertical,
@@ -10,7 +11,7 @@ import {
Unlink,
} from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import { useEffect, useState } from 'react';
+import { useEffect, useMemo, useState } from 'react';
import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';
import { rpc } from '@renderer/lib/ipc';
@@ -20,16 +21,18 @@ import { Badge } from '@renderer/lib/ui/badge';
import { Button } from '@renderer/lib/ui/button';
import {
DropdownMenu,
- DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@renderer/lib/ui/dropdown-menu';
import { Spinner } from '@renderer/lib/ui/spinner';
+import { Switch } from '@renderer/lib/ui/switch';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
import { log } from '@renderer/utils/logger';
import type { LinkedIdentity, RemoteBridge } from '@shared/core/switch-servers/switch-servers';
import { BundledChatSignIn } from './BundledChatSignIn';
+import { orderBridges } from './messaging-apps-order';
import {
hasUnlinkedMessagingApp,
shouldOfferIdentityLinkOnConnect,
@@ -78,7 +81,7 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
enabled: !!serverId,
});
- const bridges = bridgesQuery.data ?? [];
+ const bridges = useMemo(() => orderBridges(bridgesQuery.data ?? []), [bridgesQuery.data]);
const {
identities,
@@ -159,7 +162,6 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
</div>
{isAdmin && (
<Button
- variant="outline"
size="sm"
onClick={() =>
showConnectMessagingApp({
@@ -194,10 +196,6 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
)}
</div>
- <p className="mt-1 text-xs text-foreground-muted">
- Which account is you in each app, so your agents can recognise you.
- </p>
-
{/* Same shape as the addressing editor's owner warning, so the two
readings of one problem look like one problem. */}
{unrecognisedIn.length > 0 && (
@@ -228,43 +226,82 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
: 'No messaging app is connected. An admin on this server can connect one.'}
</p>
) : (
- <ul className="mt-2 divide-y divide-border">
- {bridges.map((bridge) => (
- <MessagingAppRow
- key={bridge.id}
- serverId={serverId}
- bridge={bridge}
- /* Nothing is drawn in the identity column until the list
- arrives: "not linked" and "not known yet" look identical, and
- offering to link an account the user already has is the more
- confusing of the two. */
- identities={identities}
- currentUserId={currentUserId}
- onReleased={refreshIdentities}
- showBundledSignIn={isManaged && bridge.type === 'mattermost'}
- isAdmin={isAdmin}
- savingChannelCreation={savingBridgeId === bridge.id}
- onToggleChannelCreation={(enabled) =>
- void handleToggleChannelCreation(bridge, enabled)
- }
- onDisconnect={() =>
- showDisconnectMessagingApp({
- serverId,
- bridgeId: bridge.id,
- bridgeDisplayName: bridge.displayName,
- onSuccess: () => {
- void queryClient.invalidateQueries({
- queryKey: ['remote-bridges', serverId],
- });
- // The rooms on that bridge went with it, so the sidebar is
- // stale in a way the bridge list alone does not repair.
- void switchRoomsStore.refreshRoomState();
- },
- })
- }
- />
- ))}
- </ul>
+ <div className="mt-2 overflow-hidden rounded-lg border border-border">
+ <table className="w-full table-fixed border-collapse text-sm">
+ <thead>
+ <tr className="border-b border-border bg-background-secondary text-xs text-foreground-muted">
+ <th scope="col" className="px-3 py-2 text-left font-normal">
+ App
+ </th>
+ <th scope="col" className="px-3 py-2 text-left font-normal">
+ <span className="inline-flex items-center gap-1">
+ Your account
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span
+ tabIndex={0}
+ aria-label="Which account is you in each app, so your agents can recognise you."
+ className="inline-flex"
+ >
+ <Info className="size-3.5" />
+ </span>
+ }
+ />
+ <TooltipContent>
+ Which account is you in each app, so your agents can recognise you.
+ </TooltipContent>
+ </Tooltip>
+ </span>
+ </th>
+ <th scope="col" className="w-32 px-3 py-2 text-left font-normal">
+ Channels
+ </th>
+ <th scope="col" className="w-28 px-3 py-2 text-right font-normal">
+ Actions
+ </th>
+ </tr>
+ </thead>
+ <tbody className="divide-y divide-border">
+ {bridges.map((bridge) => (
+ <MessagingAppRow
+ key={bridge.id}
+ serverId={serverId}
+ bridge={bridge}
+ /* Nothing is drawn in the identity column until the list
+ arrives: "not linked" and "not known yet" look identical,
+ and offering to link an account the user already has is the
+ more confusing of the two. */
+ identities={identities}
+ currentUserId={currentUserId}
+ onReleased={refreshIdentities}
+ showBundledSignIn={isManaged && bridge.type === 'mattermost'}
+ isAdmin={isAdmin}
+ savingChannelCreation={savingBridgeId === bridge.id}
+ onToggleChannelCreation={(enabled) =>
+ void handleToggleChannelCreation(bridge, enabled)
+ }
+ onDisconnect={() =>
+ showDisconnectMessagingApp({
+ serverId,
+ bridgeId: bridge.id,
+ bridgeDisplayName: bridge.displayName,
+ onSuccess: () => {
+ void queryClient.invalidateQueries({
+ queryKey: ['remote-bridges', serverId],
+ });
+ // The rooms on that bridge went with it, so the sidebar
+ // is stale in a way the bridge list alone does not
+ // repair.
+ void switchRoomsStore.refreshRoomState();
+ },
+ })
+ }
+ />
+ ))}
+ </tbody>
+ </table>
+ </div>
)}
{toggleError && <p className="text-destructive mt-2 text-xs">{toggleError}</p>}
</div>
@@ -272,15 +309,13 @@ export const MessagingAppsCard = observer(function MessagingAppsCard({
});
/**
- * One app: its name, which account on it is the signed-in user, and a menu of
- * everything else.
+ * One app: its name, which account on it is the signed-in user, whether Switch
+ * may open channels on it, and a menu of everything else.
*
- * The row states one fact — which account here is you — and offers the one
- * action that changes it. Everything rarer or more dangerous (unlinking,
- * channel creation, disconnecting the app) sits behind the menu, so the common
- * reading is not competing with five controls. The identity column is a fixed
- * width and the trailing controls always occupy their slot, so several apps
- * line up as columns rather than as differently ragged lines.
+ * Unlinking and channel creation are read far more often than they are changed,
+ * so they are columns rather than menu items — the menu keeps the rarer and the
+ * destructive. The trailing controls always occupy their slot so several apps
+ * keep a straight right edge.
*/
export function MessagingAppRow({
serverId,
@@ -332,12 +367,21 @@ export function MessagingAppRow({
}
};
+ // Why the switch cannot be moved, when it cannot. Said in a tooltip rather
+ // than left to a greyed control, because "off" and "this platform cannot do
+ // it at all" are different claims and look identical otherwise.
+ const channelsLockedReason = !bridge.channelCreationSupported
+ ? `${platform} cannot create channels from Switch. Make the chat in the app and add the bot to it.`
+ : !isAdmin
+ ? 'Only an admin on this server can change this.'
+ : null;
+
return (
- <li className="py-1 text-sm">
- <div className="flex items-center gap-2">
- {/* The badges belong to the name, so they travel with it rather than
- drifting into the middle of the row on a wide card. */}
- <div className="flex min-w-0 flex-1 items-center gap-2">
+ <tr className="text-sm">
+ {/* The badges belong to the name, so they travel with it rather than
+ drifting into the middle of the row on a wide table. */}
+ <td className="px-3 py-2">
+ <div className="flex min-w-0 items-center gap-2">
{hasBridgeIcon(bridge.type) ? (
<BridgeIcon bridgeType={bridge.type} size={16} />
) : (
@@ -350,111 +394,129 @@ export function MessagingAppRow({
this is where that becomes visible. */}
{bridge.status !== 'active' && <Badge variant="destructive">{bridge.status}</Badge>}
</div>
+ </td>
- {/* One control in both states, so the column reads as a column: the
- handle when there is one, the invitation to supply it when not. */}
- <div className="flex w-40 shrink-0 items-center justify-end">
- {identities === null ? null : identity === null ? (
- <Button variant="outline" size="xs" onClick={claim}>
- <Link2 className="size-3" />
- Link
- </Button>
- ) : (
- <Button
- variant="ghost"
- size="xs"
- className="min-w-0 text-foreground-muted"
- title={`Change which ${bridge.displayName} account is you`}
- onClick={claim}
- >
- <span className="truncate">{handleOf(identity)}</span>
- </Button>
- )}
- </div>
-
- {/* Offered only when the link resolves — an older server, or a bridge
- that is down, reports none, and a button that cannot do anything is
- worse than no button. The slot is held either way so the rows keep a
- straight right edge. */}
- {bridge.homeUrl ? (
+ {/* One control in both states, so the column reads as a column: the
+ handle when there is one, the invitation to supply it when not. */}
+ <td className="px-3 py-2">
+ {identities === null ? null : identity === null ? (
+ <Button variant="outline" size="xs" onClick={claim}>
+ <Link2 className="size-3" />
+ Link
+ </Button>
+ ) : (
+ // One control, not two. Unlinking is irreversible and rare, and a
+ // cross beside the handle puts it one mis-click from the button you
+ // press to *change* the account (CHOO-2137); it lives in the row menu.
<Button
variant="ghost"
- size="icon-xs"
- aria-label={`Open ${platform}`}
- title={`Open ${platform}`}
- onClick={() =>
- void openExternalUrl(bridge.homeUrl as string, `Could not open ${platform}`)
- }
+ size="xs"
+ className="min-w-0 font-mono text-foreground-muted"
+ title={`Change which ${bridge.displayName} account is you`}
+ onClick={claim}
>
- <ExternalLink className="size-3" />
+ <span className="truncate">{handleOf(identity)}</span>
</Button>
- ) : (
- <span aria-hidden className="size-6 shrink-0" />
)}
+ {releaseError !== null && <p className="text-destructive mt-0.5 text-xs">{releaseError}</p>}
+ </td>
- <DropdownMenu>
- <DropdownMenuTrigger
+ <td className="px-3 py-2">
+ <Tooltip>
+ <TooltipTrigger
render={
- <Button
- variant="ghost"
- size="icon-xs"
- aria-label={`${bridge.displayName} actions`}
- disabled={releasing}
- >
- {releasing ? <Spinner className="size-3" /> : <MoreVertical className="size-3" />}
- </Button>
+ <div className="flex w-fit items-center gap-2">
+ <Switch
+ checked={bridge.canCreateChannels}
+ disabled={channelsLockedReason !== null || savingChannelCreation}
+ onCheckedChange={(next) => onToggleChannelCreation(next)}
+ aria-label={`Let Switch create channels on ${bridge.displayName}`}
+ />
+ {/* "Off" and "this platform has no such thing" are different
+ claims, and an unticked disabled switch makes them look the
+ same (CHOO-2137). Say which one it is. */}
+ <span className="text-xs text-foreground-muted">
+ {!bridge.channelCreationSupported
+ ? 'Not supported'
+ : bridge.canCreateChannels
+ ? 'On'
+ : 'Off'}
+ </span>
+ </div>
}
/>
- <DropdownMenuContent align="end">
- <DropdownMenuItem onClick={claim}>
- <Link2 className="size-4" />
- {identity === null ? 'Link my account…' : 'Change my account…'}
- </DropdownMenuItem>
- {identity !== null && (
- <DropdownMenuItem onClick={() => void release(identity.id)}>
- <Unlink className="size-4" />
- Unlink {handleOf(identity)}
- </DropdownMenuItem>
- )}
+ <TooltipContent>
+ {channelsLockedReason ??
+ `Whether Switch may create a channel on ${platform} when you make a room.`}
+ </TooltipContent>
+ </Tooltip>
+ </td>
- <DropdownMenuSeparator />
- <DropdownMenuCheckboxItem
- checked={bridge.canCreateChannels}
- disabled={!isAdmin || !bridge.channelCreationSupported || savingChannelCreation}
- onCheckedChange={(next) => onToggleChannelCreation(next)}
+ <td className="px-3 py-2">
+ <div className="flex items-center justify-end">
+ {showBundledSignIn && (
+ <BundledChatSignIn serverId={serverId} bridgeDisplayName={bridge.displayName} />
+ )}
+
+ {/* Offered only when the link resolves — an older server, or a bridge
+ that is down, reports none, and a button that cannot do anything is
+ worse than no button. The slot is held either way so the rows keep a
+ straight right edge. */}
+ {bridge.homeUrl ? (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label={`Open ${platform}`}
+ title={`Open ${platform}`}
+ onClick={() =>
+ void openExternalUrl(bridge.homeUrl as string, `Could not open ${platform}`)
+ }
>
- Can create channels
- </DropdownMenuCheckboxItem>
- {/* A disabled empty tick reads as "off", which is a different
- claim from "this platform cannot do it at all". Plain text rather
- than a menu label: a label is a heading for a group of items, and
- Base UI requires one to sit inside a group — this is a caption
- for the item above it. */}
- {!bridge.channelCreationSupported && (
- <p className="max-w-56 px-2 py-1 text-xs text-foreground-muted">
- {platform} cannot create channels from Switch. Make the chat in the app and add the
- bot to it.
- </p>
- )}
+ <ExternalLink className="size-3" />
+ </Button>
+ ) : (
+ <span aria-hidden className="size-6 shrink-0" />
+ )}
- {isAdmin && (
- <>
- <DropdownMenuSeparator />
- <DropdownMenuItem variant="destructive" onClick={onDisconnect}>
- <Trash2 className="size-4" />
- Disconnect app…
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label={`${bridge.displayName} actions`}
+ disabled={releasing}
+ >
+ <MoreVertical className="size-3" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={claim}>
+ <Link2 className="size-4" />
+ {identity === null ? 'Link my account…' : 'Change my account…'}
+ </DropdownMenuItem>
+ {identity !== null && (
+ <DropdownMenuItem onClick={() => void release(identity.id)}>
+ <Unlink className="size-4" />
+ Unlink {handleOf(identity)}
</DropdownMenuItem>
- </>
- )}
- </DropdownMenuContent>
- </DropdownMenu>
- </div>
+ )}
- {releaseError !== null && (
- <p className="text-destructive mt-0.5 ml-6 text-xs">{releaseError}</p>
- )}
- {showBundledSignIn && <BundledChatSignIn serverId={serverId} />}
- </li>
+ {isAdmin && (
+ <>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem variant="destructive" onClick={onDisconnect}>
+ <Trash2 className="size-4" />
+ Disconnect app…
+ </DropdownMenuItem>
+ </>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </td>
+ </tr>
);
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx
index 4e6796228..fa00cc9bc 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/RemoteServerControls.tsx
@@ -1,40 +1,26 @@
-import { CircleStop, Play, TriangleAlert } from 'lucide-react';
+import { CircleStop, Play, RefreshCw, TriangleAlert } from 'lucide-react';
import { observer } from 'mobx-react-lite';
-import { useEffect, useState } from 'react';
+import { useEffect } from 'react';
import { Alert, AlertDescription, AlertTitle } from '@renderer/lib/ui/alert';
import { Button } from '@renderer/lib/ui/button';
-import {
- Dialog,
- DialogClose,
- DialogContent,
- DialogContentArea,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from '@renderer/lib/ui/dialog';
import { Spinner } from '@renderer/lib/ui/spinner';
+import { LogTail } from './log-tail';
import { remoteServerStore } from './remote-server-store';
-import { VersionDriftNotice } from './VersionDriftNotice';
-
-const card = 'rounded-lg border border-border bg-card p-4';
+import { StackSection, StackStatusRow } from './server-stack-section';
/**
- * Lifecycle controls for a Switch Console-managed Switch stack running on a remote
- * host: live status, Docker guidance, start / stop / reset — driven over the
- * host's SSH connection. Rendered inside the managed remote server's page.
+ * Lifecycle for a managed Switch stack running in Docker on an SSH host. The
+ * same section as the local one, reading through per-host accessors; resetting
+ * it lives at the bottom of the server's page rather than here.
*/
export const RemoteServerControls = observer(function RemoteServerControls({
sshHost,
name,
}: {
sshHost: string;
- /** The registered server's name, reused when restarting so the record's name
- * is preserved (not blanked). */
name: string;
}) {
const store = remoteServerStore;
- const [resetOpen, setResetOpen] = useState(false);
useEffect(() => {
void store.init();
@@ -49,188 +35,93 @@ export const RemoteServerControls = observer(function RemoteServerControls({
const running = store.isRunning(sshHost);
const docker = store.dockerFor(sshHost);
const dockerUnavailable = docker && !docker.available ? docker : null;
- const drift = store.driftFor(sshHost);
// Report the version the host is actually on, not the one this build wants —
- // they diverge exactly when the drift notice below has something to say.
+ // they diverge exactly when the page's drift notice has something to say.
const runningVersion = status.deployedVersion ?? status.version;
// A stack ahead of this build must not be started at all: doing so would point
// it at a core older than its database has migrated to (CHOO-1736).
- const downgradeBlocked = drift?.direction === 'downgrade';
+ const downgradeBlocked = store.driftFor(sshHost)?.direction === 'downgrade';
+ const logs = store.logsFor(sshHost);
return (
- <div className={`${card} space-y-4`}>
- <div className="flex items-start justify-between gap-3">
- <div className="space-y-1">
- <h3 className="text-sm font-medium text-foreground">Managed server</h3>
- <p className="text-xs text-foreground-muted">
- Runs the full Switch stack in Docker on {sshHost}, bridged to this computer over SSH
- {runningVersion ? ` (switch-core ${runningVersion})` : ''}.
- </p>
- </div>
- <PhaseBadge sshHost={sshHost} />
- </div>
-
- <VersionDriftNotice
- drift={drift}
- disabled={transitioning}
- onRestart={() => void store.start(sshHost, name)}
+ <StackSection title={`Server on ${sshHost}`}>
+ <StackStatusRow
+ phase={hostBlocked ? 'unreachable' : status.phase}
+ detail={running ? `switch-core ${runningVersion}` : 'not running'}
+ actions={
+ running ? (
+ <>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={transitioning}
+ onClick={() => void store.start(sshHost, name)}
+ >
+ <RefreshCw className="size-4" />
+ Restart
+ </Button>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={transitioning}
+ onClick={() => void store.stop(sshHost)}
+ >
+ <CircleStop className="size-4" />
+ Stop
+ </Button>
+ </>
+ ) : (
+ <Button
+ size="sm"
+ disabled={transitioning || downgradeBlocked}
+ onClick={() => void store.start(sshHost, name)}
+ >
+ <Play className="size-4" />
+ {status.phase === 'error' && !downgradeBlocked ? 'Retry' : 'Start'}
+ </Button>
+ )
+ }
/>
- {status.message && transitioning && (
- <div className="flex items-center gap-2 text-sm text-foreground-muted">
- <Spinner className="size-3.5" />
- <span>{status.message}</span>
- </div>
- )}
-
- {dockerUnavailable && (
- <Alert variant="destructive">
- <TriangleAlert className="size-4" />
- <AlertTitle>
- {dockerUnavailable.reason === 'not-installed'
- ? 'Docker is not installed on the host'
- : 'Docker is not running on the host'}
- </AlertTitle>
- <AlertDescription>{dockerUnavailable.detail}</AlertDescription>
- </Alert>
- )}
-
- {store.error && !dockerUnavailable && (
- <Alert variant="destructive">
- <AlertTitle>Something went wrong</AlertTitle>
- <AlertDescription>{store.error}</AlertDescription>
- </Alert>
- )}
+ <div className="space-y-3 p-3">
+ {status.message && transitioning && (
+ <div className="flex items-center gap-2 text-sm text-foreground-muted">
+ <Spinner className="size-3.5" />
+ <span>{status.message}</span>
+ </div>
+ )}
- <div className="flex items-center gap-2">
- {running ? (
- <Button
- variant="outline"
- size="sm"
- disabled={transitioning}
- onClick={() => void store.stop(sshHost)}
- >
- <CircleStop className="size-4" />
- Stop
- </Button>
- ) : (
- <Button
- size="sm"
- disabled={transitioning || downgradeBlocked}
- onClick={() => void store.start(sshHost, name)}
- >
- <Play className="size-4" />
- {status.phase === 'error' && !downgradeBlocked ? 'Retry' : 'Start'}
- </Button>
+ {dockerUnavailable && (
+ <Alert variant="destructive">
+ <TriangleAlert className="size-4" />
+ <AlertTitle>
+ {dockerUnavailable.reason === 'not-installed'
+ ? 'Docker is not installed on the host'
+ : 'Docker is not running on the host'}
+ </AlertTitle>
+ <AlertDescription>{dockerUnavailable.detail}</AlertDescription>
+ </Alert>
)}
- </div>
- <p className="text-xs text-foreground-tertiary-passive">
- The stack keeps running on {sshHost} when you close Switch Console. Remote-host agents stay
- connected; agents on this computer can reach it while Switch Console is open.
- </p>
+ {store.error && !dockerUnavailable && (
+ <Alert variant="destructive">
+ <AlertTitle>Something went wrong</AlertTitle>
+ <AlertDescription>{store.error}</AlertDescription>
+ </Alert>
+ )}
- <div className="mt-1 flex items-center justify-between gap-3 border-t border-border pt-4">
- <div className="space-y-0.5">
- <p className="text-xs font-medium text-foreground">Reset</p>
- <p className="text-xs text-foreground-tertiary-passive">
- Permanently deletes the stack's data and every agent configured against it.
+ {/* What the stack is, until it has said something itself. Once it is
+ talking, its own output is the more useful thing to keep on screen. */}
+ {logs.length > 0 ? (
+ <LogTail lines={logs} placeholder={null} />
+ ) : (
+ <p className="text-xs text-foreground-muted">
+ Runs the full Switch stack in Docker on {sshHost}, bridged to this computer over SSH
+ {runningVersion ? ` (switch-core ${runningVersion})` : ''}. It keeps running when you
+ close Switch Console; agents on this computer can reach it while Switch Console is open.
</p>
- </div>
- <Button
- variant="outline"
- size="sm"
- disabled={transitioning}
- className="shrink-0 border-red-500/40 text-red-500 hover:bg-red-500/10 hover:text-red-500"
- onClick={() => setResetOpen(true)}
- >
- Reset…
- </Button>
+ )}
</div>
-
- <ResetDialog
- sshHost={sshHost}
- open={resetOpen}
- onOpenChange={setResetOpen}
- disabled={transitioning}
- onConfirm={() => {
- setResetOpen(false);
- void store.reset(sshHost);
- }}
- />
- </div>
- );
-});
-
-const ResetDialog = observer(function ResetDialog({
- sshHost,
- open,
- onOpenChange,
- disabled,
- onConfirm,
-}: {
- sshHost: string;
- open: boolean;
- onOpenChange: (open: boolean) => void;
- disabled: boolean;
- onConfirm: () => void;
-}) {
- return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent>
- <DialogHeader>
- <TriangleAlert className="size-4 text-red-500" />
- <DialogTitle>Reset server on {sshHost}</DialogTitle>
- </DialogHeader>
- <DialogContentArea>
- <DialogDescription>
- This permanently deletes this managed server and everything on it — all rooms, messages,
- and{' '}
- <strong className="text-foreground">every agent you've configured against it</strong>.
- This can't be undone. A fresh Start rebuilds an empty stack from scratch.
- </DialogDescription>
- </DialogContentArea>
- <DialogFooter>
- <DialogClose render={<Button variant="outline" size="sm" />}>Cancel</DialogClose>
- <Button variant="destructive" size="sm" disabled={disabled} onClick={onConfirm}>
- Reset and delete all agents
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
- );
-});
-
-const PhaseBadge = observer(function PhaseBadge({ sshHost }: { sshHost: string }) {
- // Never report a stack state we cannot currently observe: with the host down,
- // `running` is a memory of the last time we could see it (CHOO-1780).
- if (remoteServerStore.isHostBlocked(sshHost)) {
- return (
- <span className="flex items-center gap-1.5 text-xs text-foreground-muted">
- <span aria-hidden className="inline-block size-2 rounded-full bg-amber-500" />
- Host unreachable
- </span>
- );
- }
- const phase = remoteServerStore.phaseFor(sshHost);
- const label: Record<typeof phase, string> = {
- stopped: 'Stopped',
- starting: 'Starting',
- running: 'Running',
- stopping: 'Stopping',
- error: 'Error',
- };
- const dot: Record<typeof phase, string> = {
- stopped: 'bg-foreground-muted',
- starting: 'bg-amber-500',
- running: 'bg-green-500',
- stopping: 'bg-amber-500',
- error: 'bg-red-500',
- };
- return (
- <span className="flex items-center gap-1.5 text-xs text-foreground-muted">
- <span aria-hidden className={`inline-block size-2 rounded-full ${dot[phase]}`} />
- {label[phase]}
- </span>
+ </StackSection>
);
});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
deleted file mode 100644
index fb66f9b38..000000000
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/ServersSidebarSection.tsx
+++ /dev/null
@@ -1,323 +0,0 @@
-import {
- ArrowUpCircle,
- ChevronDown,
- ChevronRight,
- ExternalLink,
- Laptop,
- Pencil,
- Plus,
- Trash2,
- TriangleAlert,
-} from 'lucide-react';
-import { observer } from 'mobx-react-lite';
-import { useEffect } from 'react';
-import { isCurrentView, useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
-import { useWorkspaceSlots } from '@renderer/lib/layout/workspace-slots';
-import { useShowModal } from '@renderer/lib/modal/modal-provider';
-import { buttonVariants } from '@renderer/lib/ui/button';
-import {
- ContextMenu,
- ContextMenuContent,
- ContextMenuItem,
- ContextMenuTrigger,
-} from '@renderer/lib/ui/context-menu';
-import { MicroLabel } from '@renderer/lib/ui/label';
-import { Spinner } from '@renderer/lib/ui/spinner';
-import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
-import { cn } from '@renderer/utils/utils';
-import type { SwitchVersionDrift } from '@shared/core/managed-switch-server/managed-switch-server';
-import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
-import { SidebarMenu, SidebarMenuButton } from '../sidebar/sidebar-primitives';
-import { localServerStore } from './local-server-store';
-import { remoteServerStore } from './remote-server-store';
-import { serverAvailability } from './server-availability';
-import { serverIcon } from './server-icon';
-import { switchServersStore } from './switch-servers-store';
-
-export const ServersSidebarSection = observer(function ServersSidebarSection() {
- const store = switchServersStore;
- const showAddServerModal = useShowModal('addServerModal');
-
- useEffect(() => {
- void store.init();
- void localServerStore.init();
- void remoteServerStore.init();
- const onFocus = () => void store.recoverStale();
- window.addEventListener('focus', onFocus);
- return () => {
- window.removeEventListener('focus', onFocus);
- localServerStore.dispose();
- remoteServerStore.dispose();
- };
- }, [store]);
-
- // Adding a server — local or remote — is reached from the header's "+" only.
- // A managed server still gets a placeholder row while it starts, so the list
- // shows it before the record exists.
- const hasManagedServer = store.servers.some((s) => s.managed);
- // The selected server scopes the whole sidebar. When the list is collapsed the
- // rows are hidden, so surface the active server's name here to keep it clear
- // which server is selected in any context.
- const activeServer = store.servers.find((s) => s.id === store.activeServerId);
-
- return (
- <div className="flex flex-col">
- <div className="flex h-[40px] items-center justify-between pr-2.5 pl-2">
- <button
- type="button"
- onClick={() => store.toggleServersExpanded()}
- className="flex min-w-0 items-center gap-1 rounded-md px-1 py-0.5 text-foreground-tertiary-passive hover:text-foreground-tertiary"
- aria-label={store.serversExpanded ? 'Collapse servers' : 'Expand servers'}
- >
- {store.serversExpanded ? (
- <ChevronDown className="size-3.5 shrink-0" />
- ) : (
- <ChevronRight className="size-3.5 shrink-0" />
- )}
- <MicroLabel className="text-foreground-tertiary-passive">Servers</MicroLabel>
- {!store.serversExpanded && activeServer && (
- <span className="min-w-0 truncate text-xs font-medium text-foreground-muted">
- · {activeServer.name}
- </span>
- )}
- </button>
- <Tooltip>
- <TooltipTrigger
- render={
- <button
- type="button"
- onClick={() => showAddServerModal({})}
- aria-label="Add server"
- className={buttonVariants({
- size: 'icon-xs',
- variant: 'ghost',
- className: 'hover:bg-transparent text-foreground-muted hover:text-foreground',
- })}
- >
- <Plus />
- </button>
- }
- />
- <TooltipContent>Add server</TooltipContent>
- </Tooltip>
- </div>
-
- {store.serversExpanded && (
- <SidebarMenu className="px-2 pb-1">
- {store.servers.map((server) => (
- <ServerEntry key={server.id} serverId={server.id} />
- ))}
- {/* Before the managed record exists (still pulling/starting, or a
- failed attempt), show a placeholder entry so the local server is
- always visible in the list — not only once it's healthy. */}
- {!hasManagedServer && localServerStore.phase !== 'stopped' && (
- <LocalServerPendingEntry onOpen={() => showAddServerModal({ mode: 'local' })} />
- )}
- </SidebarMenu>
- )}
- </div>
- );
-});
-
-const LocalServerPendingEntry = observer(function LocalServerPendingEntry({
- onOpen,
-}: {
- onOpen: () => void;
-}) {
- const phase = localServerStore.phase;
- const failed = phase === 'error';
- return (
- <SidebarMenuButton onClick={onOpen} className="justify-between">
- <span className="flex min-w-0 items-center gap-2">
- <Laptop className="size-4 shrink-0" />
- <span className="truncate">
- {failed ? 'Local server (setup failed)' : 'Local Switch server'}
- </span>
- <span
- aria-hidden
- className={cn('size-1.5 shrink-0 rounded-full', failed ? 'bg-red-500' : 'bg-amber-500')}
- />
- </span>
- {phase === 'starting' && <Spinner className="size-3.5 shrink-0" />}
- </SidebarMenuButton>
- );
-});
-
-/**
- * Flags a managed server whose switch-core no longer matches the version this
- * build pins (CHOO-1736), so an available update is visible from the sidebar
- * rather than only on the server's own page.
- *
- * Sits beside the connection dot rather than recolouring it: the dot answers
- * "can I reach this server", which stays true of a server running a stale core.
- */
-function ServerDriftIndicator({ drift }: { drift: SwitchVersionDrift }) {
- const upgrade = drift.direction === 'upgrade';
- const label = upgrade
- ? `switch-core ${drift.expected} is available (running ${drift.deployed})`
- : drift.direction === 'downgrade'
- ? `Runs switch-core ${drift.deployed} — newer than this app expects (${drift.expected})`
- : drift.direction === 'unreadable'
- ? `Can't read which switch-core this runs; this app expects ${drift.expected}`
- : `Runs switch-core ${drift.deployed}; this app expects ${drift.expected}`;
-
- return (
- <Tooltip>
- <TooltipTrigger
- render={
- <span
- aria-label={label}
- className={cn(
- 'flex shrink-0 items-center',
- upgrade ? 'text-foreground-warning' : 'text-red-500'
- )}
- >
- {upgrade ? (
- <ArrowUpCircle className="size-3.5" />
- ) : (
- <TriangleAlert className="size-3.5" />
- )}
- </span>
- }
- />
- <TooltipContent>{label}</TooltipContent>
- </Tooltip>
- );
-}
-
-function ServerIcon({ server, isScoped }: { server: SwitchServer; isScoped: boolean }) {
- const Icon = serverIcon(server);
- return <Icon className={cn('size-4 shrink-0', isScoped && 'text-foreground')} />;
-}
-
-const ServerEntry = observer(function ServerEntry({ serverId }: { serverId: string }) {
- const store = switchServersStore;
- const { navigate } = useNavigate();
- const { currentView } = useWorkspaceSlots();
- const { params } = useParams('server');
- const showRenameServerModal = useShowModal('renameServerModal');
- const showDeleteServerModal = useShowModal('deleteServerModal');
- const showEditServerModal = useShowModal('addServerModal');
-
- const server = store.servers.find((s) => s.id === serverId);
- if (!server) return null;
-
- const connected = store.isConnected(serverId);
- const isViewing = isCurrentView(currentView, 'server') && params.serverId === serverId;
- // The active server scopes the whole sidebar (agents/rooms/sessions). Selecting
- // a server makes it active and opens its page. The scoped server stays
- // highlighted regardless of which view is open — navigating to an agent,
- // session, or room must not clear the "this server is selected" affordance.
- const isScoped = store.activeServerId === serverId;
-
- const availability = serverAvailability(serverId);
- const dormant = availability === 'dormant';
- const needsSignIn = availability === 'signed-out';
-
- // Drift is reported for a stopped stack too — its volumes still hold the
- // schema the last version migrated to — so this is deliberately not gated on
- // `managedRunning`.
- const drift = !server.managed
- ? null
- : server.managementKind === 'remote' && server.sshHost
- ? remoteServerStore.driftFor(server.sshHost)
- : localServerStore.drift;
-
- return (
- <ContextMenu>
- <ContextMenuTrigger
- render={
- <SidebarMenuButton
- isActive={isScoped}
- onClick={() => {
- void store.setActive(serverId);
- navigate('server', { serverId });
- }}
- className="relative justify-between"
- >
- {isScoped && (
- <span
- aria-hidden
- className="bg-accent absolute top-1/2 left-0 h-4 w-0.5 -translate-y-1/2 rounded-full"
- />
- )}
- <span className="flex min-w-0 items-center gap-2">
- <ServerIcon server={server} isScoped={isScoped} />
- <span className={cn('truncate', isScoped && 'font-medium text-foreground')}>
- {server.name}
- </span>
- {server.managed && (
- <span className="shrink-0 rounded bg-background-tertiary px-1 py-px text-[10px] font-medium tracking-wide text-foreground-muted uppercase">
- {server.managementKind === 'remote'
- ? (server.sshHost ?? 'Remote')
- : 'This computer'}
- </span>
- )}
- <span
- aria-hidden
- className={cn(
- 'size-1.5 shrink-0 rounded-full',
- // Amber reads as "warming up". Neither signed-out nor
- // unreachable is transitional: both mean this server's data
- // is unavailable right now, so both are red.
- dormant ? 'bg-foreground-muted' : connected ? 'bg-green-500' : 'bg-red-500'
- )}
- />
- {drift && <ServerDriftIndicator drift={drift} />}
- </span>
- {needsSignIn && (
- <span
- role="button"
- tabIndex={0}
- onClick={(e) => {
- e.stopPropagation();
- navigate('server', { serverId });
- }}
- className="shrink-0 rounded border border-red-500/40 px-1.5 py-0.5 text-xs font-medium text-red-500 hover:bg-red-500/10"
- >
- Sign in
- </span>
- )}
- </SidebarMenuButton>
- }
- />
- <ContextMenuContent>
- <ContextMenuItem
- onClick={() => showRenameServerModal({ serverId, currentName: server.name })}
- >
- <Pencil className="size-4" />
- Rename…
- </ContextMenuItem>
- {!server.managed && (
- <ContextMenuItem
- onClick={() =>
- showEditServerModal({
- serverId,
- initialName: server.name,
- initialGatewayUrl: server.gatewayUrl,
- initialApiUrl: server.apiUrl,
- })
- }
- >
- <ExternalLink className="size-4" />
- Edit connection…
- </ContextMenuItem>
- )}
- <ContextMenuItem
- variant="destructive"
- onClick={() =>
- showDeleteServerModal({
- serverId,
- onSuccess: () => {
- if (isViewing) navigate('home');
- },
- })
- }
- >
- <Trash2 className="size-4" />
- Delete server…
- </ContextMenuItem>
- </ContextMenuContent>
- </ContextMenu>
- );
-});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/log-tail.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/log-tail.tsx
new file mode 100644
index 000000000..c046c11fb
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/log-tail.tsx
@@ -0,0 +1,38 @@
+import { useEffect, useRef } from 'react';
+
+/**
+ * The managed stack's recent output, scrolled to the newest line.
+ *
+ * `placeholder` keeps the panel on screen before the first line arrives. Docker
+ * is silent for a while at the start of a pull — it is resolving the registry,
+ * not stalled — and an empty space there read as nothing happening at all. It
+ * is styled apart from the output so it cannot be mistaken for a line docker
+ * printed.
+ */
+export function LogTail({ lines, placeholder }: { lines: string[]; placeholder: string | null }) {
+ const ref = useRef<HTMLDivElement>(null);
+
+ useEffect(() => {
+ const el = ref.current;
+ if (el) el.scrollTop = el.scrollHeight;
+ }, [lines]);
+
+ if (lines.length === 0 && !placeholder) return null;
+
+ return (
+ <div
+ ref={ref}
+ className="max-h-48 overflow-auto rounded-md border border-border bg-background-tertiary p-2 font-mono text-[11px] leading-relaxed text-foreground-muted"
+ >
+ {lines.length === 0 && placeholder && (
+ <div className="text-foreground-tertiary-passive italic">{placeholder}</div>
+ )}
+ {lines.map((line, i) => (
+ // Log lines have no stable id; index is fine for an append-only tail.
+ <div key={i} className="break-all whitespace-pre-wrap">
+ {line}
+ </div>
+ ))}
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/messaging-apps-order.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/messaging-apps-order.test.ts
new file mode 100644
index 000000000..aad821951
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/messaging-apps-order.test.ts
@@ -0,0 +1,46 @@
+import { describe, expect, it } from 'vitest';
+import type { RemoteBridge } from '@shared/core/switch-servers/switch-servers';
+import { orderBridges } from './messaging-apps-order';
+
+function bridge(id: string, displayName: string): RemoteBridge {
+ return {
+ id,
+ type: 'slack',
+ displayName,
+ status: 'active',
+ isDefault: false,
+ homeUrl: null,
+ channelCreationSupported: true,
+ canCreateChannels: true,
+ directorySearchSupported: true,
+ };
+}
+
+describe('the order messaging apps are listed in', () => {
+ it('does not depend on the order the gateway sent them', () => {
+ // The same four apps as two different responses. Toggling a row refetches
+ // the list, so if the order tracked the response the table would reshuffle
+ // under the cursor of whoever just clicked.
+ const first = [
+ bridge('b1', 'Slack Test'),
+ bridge('b2', 'Mattermost'),
+ bridge('b3', 'Telegram'),
+ bridge('b4', 'Discord'),
+ ];
+ const second = [first[2], first[0], first[3], first[1]];
+
+ expect(orderBridges(first).map((b) => b.id)).toEqual(orderBridges(second).map((b) => b.id));
+ });
+
+ it('separates apps that share a display name, rather than letting them swap', () => {
+ const sent = [bridge('b2', 'test'), bridge('b1', 'test')];
+ expect(orderBridges(sent).map((b) => b.id)).toEqual(['b1', 'b2']);
+ expect(orderBridges([...sent].reverse()).map((b) => b.id)).toEqual(['b1', 'b2']);
+ });
+
+ it('leaves the caller’s list alone', () => {
+ const sent = [bridge('b1', 'Zulip'), bridge('b2', 'Discord')];
+ orderBridges(sent);
+ expect(sent.map((b) => b.id)).toEqual(['b1', 'b2']);
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/messaging-apps-order.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/messaging-apps-order.ts
new file mode 100644
index 000000000..883fb899c
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/messaging-apps-order.ts
@@ -0,0 +1,16 @@
+import type { RemoteBridge } from '@shared/core/switch-servers/switch-servers';
+
+/**
+ * The order the messaging apps table lists apps in.
+ *
+ * Decided here rather than taken as the gateway sends it, because the gateway
+ * makes no promise about order: flipping one row's channel switch refetches the
+ * list, and an order that follows the response deals the whole table out again
+ * underneath the cursor of whoever just clicked. Name, then id — the tiebreak
+ * matters because two apps really can share a display name.
+ */
+export function orderBridges(bridges: readonly RemoteBridge[]): RemoteBridge[] {
+ return [...bridges].sort(
+ (a, b) => a.displayName.localeCompare(b.displayName) || a.id.localeCompare(b.id)
+ );
+}
diff --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.tsx
new file mode 100644
index 000000000..1fb8be817
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-agents-view.tsx
@@ -0,0 +1,245 @@
+import { Bot, ExternalLink, MoreVertical, Plus, RotateCcw, Trash2 } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
+import { useConfirmDeleteAgent } from '@renderer/features/locations/hooks/use-confirm-delete-agent';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import { getLocationStore } from '@renderer/features/locations/stores/location-selectors';
+import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';
+import { AgentIcon } from '@renderer/lib/components/agent-icon';
+import { useToast } from '@renderer/lib/hooks/use-toast';
+import { rpc } from '@renderer/lib/ipc';
+import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { Button } from '@renderer/lib/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@renderer/lib/ui/dropdown-menu';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
+import type { Agent } from '@shared/core/agents/agents';
+import { providerDisplayName } from '@shared/core/providers/agent-provider-registry';
+import { ServerPage, ServerTable, ServerTableEmpty } from './server-page';
+import { ServerSectionTitlebar } from './server-section-titlebar';
+import { switchRoomsStore } from './switch-rooms-store';
+import { switchServersStore } from './switch-servers-store';
+
+const COLUMNS = [
+ { key: 'agent', label: 'Agent' },
+ { key: 'provider', label: 'Provider' },
+ { key: 'rooms', label: 'Rooms', className: 'w-24' },
+ { key: 'actions', label: 'Actions', className: 'w-28 text-right' },
+] as const;
+
+function useServerId(): string {
+ return useParams('serverAgents').params.serverId;
+}
+
+const ServerAgentsTitlebar = observer(function ServerAgentsTitlebar() {
+ return <ServerSectionTitlebar serverId={useServerId()} icon={Bot} label="Your Agents" />;
+});
+
+const ServerAgentsPanel = observer(function ServerAgentsPanel() {
+ const serverId = useServerId();
+ const server = switchServersStore.servers.find((s) => s.id === serverId);
+ const showAddAgentModal = useShowModal('addAgentModal');
+
+ // The sidebar reads the same two things, but this page must not be right only
+ // when the sidebar happened to be open first.
+ useEffect(() => {
+ void refreshSidebarRoomState(false);
+ }, [serverId]);
+
+ const agents = agentsStore.agentsOnServer(serverId);
+
+ return (
+ <ServerPage
+ title="Your Agents"
+ description={`Agents on ${server?.name ?? 'this server'}. Add one, set how it is addressed, and start sessions.`}
+ action={
+ <Button size="sm" onClick={() => showAddAgentModal({})}>
+ <Plus className="size-4" />
+ Add agent
+ </Button>
+ }
+ >
+ {agents.length === 0 ? (
+ <ServerTableEmpty>
+ No agents are registered on this server yet. Add one to start sessions with it.
+ </ServerTableEmpty>
+ ) : (
+ <ServerTable columns={COLUMNS}>
+ {agents.map((agent) => (
+ <AgentRow key={agent.id} agent={agent} serverId={serverId} />
+ ))}
+ </ServerTable>
+ )}
+ </ServerPage>
+ );
+});
+
+const AgentRow = observer(function AgentRow({
+ agent,
+ serverId,
+}: {
+ agent: Agent;
+ serverId: string;
+}) {
+ const { navigate } = useNavigate();
+ const showCreateSessionModal = useShowModal('sessionModal');
+ const showConfirmReset = useShowModal('resetAgentModal');
+ const confirmDeleteAgent = useConfirmDeleteAgent();
+ const { toastPromise } = useToast();
+
+ const location = getLocationStore(agent.locationId);
+ const sshHost = location?.data?.sshHost ?? null;
+ const label = agent.name || 'Unnamed agent';
+ const provider = providerDisplayName(agent.providerId);
+
+ const gatewayUrl =
+ agent.switchAgentId && switchRoomsStore.gatewayAgentUrl(serverId, agent.switchAgentId);
+
+ return (
+ <tr className="text-sm">
+ <td className="px-3 py-2">
+ <button
+ type="button"
+ className="flex min-w-0 items-center gap-2 text-left hover:underline"
+ onClick={() => navigate('location', { locationId: agent.locationId, agentName: label })}
+ >
+ {agent.providerId ? (
+ <AgentIcon id={agent.providerId} size={16} className="shrink-0" />
+ ) : (
+ <Bot className="size-4 shrink-0 text-foreground-muted" />
+ )}
+ <span className="truncate">{label}</span>
+ </button>
+ </td>
+
+ <td className="truncate px-3 py-2 text-foreground-muted">
+ {provider ? `${provider} · ` : ''}
+ {sshHost ?? 'this computer'}
+ </td>
+
+ <td className="px-3 py-2 text-foreground-muted">
+ <AgentRoomCount agent={agent} serverId={serverId} />
+ </td>
+
+ <td className="px-3 py-2">
+ <div className="flex items-center justify-end">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label={`New session for ${label}`}
+ onClick={() =>
+ showCreateSessionModal({ locationId: agent.locationId, agentName: label })
+ }
+ >
+ <Plus className="size-3" />
+ </Button>
+ }
+ />
+ <TooltipContent>New session</TooltipContent>
+ </Tooltip>
+
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="ghost" size="icon-xs" aria-label={`${label} actions`}>
+ <MoreVertical className="size-3" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
+ {gatewayUrl && (
+ <DropdownMenuItem
+ onClick={() =>
+ void rpc.switchServers.openGatewayPage({ serverId, url: gatewayUrl })
+ }
+ >
+ <ExternalLink className="size-4" />
+ Open in gateway
+ </DropdownMenuItem>
+ )}
+ {sshHost != null && (
+ <DropdownMenuItem
+ onClick={() =>
+ showConfirmReset({
+ agentLabel: label,
+ onSuccess: () => {
+ void toastPromise(rpc.agents.resetRemoteAgent({ agentId: agent.id }), {
+ loading: `Resetting ${label}…`,
+ success: `${label} was reset`,
+ error: (error) =>
+ `Failed to reset agent: ${error instanceof Error ? error.message : String(error)}`,
+ });
+ },
+ })
+ }
+ >
+ <RotateCcw className="size-4" />
+ Reset agent…
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onClick={() => {
+ void confirmDeleteAgent({
+ locationId: agent.locationId,
+ agentId: agent.id,
+ locationLabel: label,
+ onDeleted: () => {},
+ });
+ }}
+ >
+ <Trash2 className="size-4" />
+ Remove agent…
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </td>
+ </tr>
+ );
+});
+
+/**
+ * How many of this server's rooms the agent is in.
+ *
+ * An agent whose membership has not been read yet shows an em dash, not a zero:
+ * "in no rooms" is a thing you would go and fix, and it must not be said about
+ * an agent we simply have not asked about.
+ */
+const AgentRoomCount = observer(function AgentRoomCount({
+ agent,
+ serverId,
+}: {
+ agent: Agent;
+ serverId: string;
+}) {
+ if (!agent.switchAgentId) return <span>—</span>;
+ const memberships = switchRoomsStore.roomsFor(serverId, agent.switchAgentId);
+ if (memberships === undefined) return <span>—</span>;
+ return <span>{memberships.filter((room) => !room.archived).length}</span>;
+});
+
+export const serverAgentsView = {
+ WrapView: ({ children }: { children: React.ReactNode; serverId: string }) => <>{children}</>,
+ TitlebarSlot: ServerAgentsTitlebar,
+ MainPanel: ServerAgentsPanel,
+ canActivate: (params: unknown): GuardResult => {
+ const serverId =
+ typeof params === 'object' && params !== null
+ ? (params as { serverId?: unknown }).serverId
+ : undefined;
+ if (typeof serverId !== 'string') return { ok: false, redirect: 'home' };
+ return { ok: true };
+ },
+} satisfies ViewDefinition<{ serverId: string }>;
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx
new file mode 100644
index 000000000..4e0097df1
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-page.tsx
@@ -0,0 +1,87 @@
+import type { ReactNode } from 'react';
+import { cn } from '@renderer/utils/utils';
+
+/**
+ * The shell a server's list pages sit in — the same column width and header
+ * shape as the server's Home, so moving between the three does not move the
+ * title or resize the content under you.
+ */
+export function ServerPage({
+ title,
+ description,
+ action,
+ children,
+}: {
+ title: string;
+ description: string;
+ action: ReactNode;
+ children: ReactNode;
+}) {
+ return (
+ <div className="relative z-10 flex min-h-0 flex-1 flex-col overflow-auto bg-background">
+ <div className="mx-auto w-full max-w-4xl space-y-6 p-6">
+ <header className="flex items-start justify-between gap-3">
+ <div className="min-w-0">
+ <h2 className="truncate text-2xl font-semibold text-foreground">{title}</h2>
+ <p className="mt-1 text-sm text-foreground-muted">{description}</p>
+ </div>
+ <div className="flex shrink-0 items-center gap-2">{action}</div>
+ </header>
+ {children}
+ </div>
+ </div>
+ );
+}
+
+export type ServerTableColumn = {
+ key: string;
+ label: string;
+ /** Width and alignment for this column, e.g. `w-28 text-right`. */
+ className?: string;
+};
+
+/**
+ * A page-level table, matching the messaging apps table on the server's Home.
+ *
+ * `table-fixed` with widths on the trailing columns is what keeps the actions
+ * against the right edge whatever the names in the first column are, so two
+ * such tables on different pages line up rather than each finding their own
+ * column widths from their own content.
+ */
+export function ServerTable({
+ columns,
+ children,
+}: {
+ columns: readonly ServerTableColumn[];
+ children: ReactNode;
+}) {
+ return (
+ <div className="overflow-hidden rounded-lg border border-border">
+ <table className="w-full table-fixed border-collapse text-sm">
+ <thead>
+ <tr className="border-b border-border bg-background-secondary text-xs text-foreground-muted">
+ {columns.map((column) => (
+ <th
+ key={column.key}
+ scope="col"
+ className={cn('px-3 py-2 text-left font-normal', column.className)}
+ >
+ {column.label}
+ </th>
+ ))}
+ </tr>
+ </thead>
+ <tbody className="divide-y divide-border">{children}</tbody>
+ </table>
+ </div>
+ );
+}
+
+/** The empty case for one of those tables: the border stays, the rows do not. */
+export function ServerTableEmpty({ children }: { children: ReactNode }) {
+ return (
+ <div className="rounded-lg border border-border px-3 py-8 text-center text-sm text-foreground-muted">
+ {children}
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-presentation.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-presentation.tsx
new file mode 100644
index 000000000..d779f7d2f
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-presentation.tsx
@@ -0,0 +1,205 @@
+import { ArrowUpCircle, TriangleAlert } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reachability-store';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
+import { cn } from '@renderer/utils/utils';
+import type { SwitchVersionDrift } from '@shared/core/managed-switch-server/managed-switch-server';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
+import { localServerStore } from './local-server-store';
+import { remoteServerStore } from './remote-server-store';
+import { serverAvailability } from './server-availability';
+
+/**
+ * How a server presents itself wherever it is listed — the switcher button, the
+ * switcher menu, the titlebar. Kept in one place so those three cannot describe
+ * the same server differently.
+ */
+export type ServerState =
+ | 'host-unreachable'
+ | 'not-running'
+ | 'unreachable'
+ | 'signed-out'
+ | 'running-local'
+ | 'connected';
+
+export function serverState(server: SwitchServer): ServerState {
+ if (
+ server.managementKind === 'remote' &&
+ server.sshHost &&
+ hostReachabilityStore.isBlocked(server.sshHost)
+ ) {
+ return 'host-unreachable';
+ }
+ switch (serverAvailability(server.id)) {
+ case 'dormant':
+ return 'not-running';
+ case 'unreachable':
+ return 'unreachable';
+ case 'signed-out':
+ return 'signed-out';
+ case 'available':
+ return server.managed && server.managementKind !== 'remote' ? 'running-local' : 'connected';
+ }
+}
+
+const STATE_LABEL: Record<ServerState, string> = {
+ 'host-unreachable': 'Host unreachable',
+ 'not-running': 'Not running',
+ unreachable: 'Unreachable',
+ 'signed-out': 'Signed out',
+ 'running-local': 'Running',
+ connected: 'Connected',
+};
+
+/** The state as a listed server reads it, next to its placement badge. */
+export function serverStatusLabel(server: SwitchServer): string {
+ return STATE_LABEL[serverState(server)];
+}
+
+/**
+ * The state as the switcher button reads it. It has no placement badge beside
+ * it — the whole button is the one server — so the local stack says where it
+ * runs here instead.
+ */
+const SUBTITLE_LABEL: Record<ServerState, string> = {
+ ...STATE_LABEL,
+ 'running-local': 'Running locally',
+};
+
+export function serverSubtitleLabel(server: SwitchServer): string {
+ return SUBTITLE_LABEL[serverState(server)];
+}
+
+/** Where a server runs. Null for one reached by URL: this app does not know. */
+export function serverPlacementLabel(server: SwitchServer): string | null {
+ if (!server.managed) return null;
+ if (server.managementKind === 'remote') return server.sshHost ?? 'Remote';
+ return 'This computer';
+}
+
+/**
+ * Drift is reported for a stopped stack too — its volumes still hold the schema
+ * the last version migrated to — so this is deliberately not gated on the stack
+ * running.
+ */
+export function serverDrift(server: SwitchServer): SwitchVersionDrift | null {
+ if (!server.managed) return null;
+ if (server.managementKind === 'remote' && server.sshHost) {
+ return remoteServerStore.driftFor(server.sshHost);
+ }
+ return localServerStore.drift;
+}
+
+const AVATAR_SIZE = {
+ sm: 'size-6 text-xs',
+ md: 'size-7 text-sm',
+ lg: 'size-9 rounded-lg text-lg',
+} as const;
+
+export function ServerAvatar({
+ server,
+ size,
+}: {
+ server: SwitchServer;
+ size: keyof typeof AVATAR_SIZE;
+}) {
+ const initial = server.name.trim().charAt(0).toUpperCase() || '?';
+ return (
+ <span
+ aria-hidden
+ className={cn(
+ 'flex shrink-0 items-center justify-center rounded-md bg-foreground font-medium text-background',
+ AVATAR_SIZE[size]
+ )}
+ >
+ {initial}
+ </span>
+ );
+}
+
+/**
+ * Whether this server can be reached right now. Amber would read as "warming
+ * up"; neither signed-out nor unreachable is transitional, so both are red and
+ * only a stack that is not running is neutral.
+ */
+export const ServerStatusDot = observer(function ServerStatusDot({
+ server,
+}: {
+ server: SwitchServer;
+}) {
+ const state = serverState(server);
+ return (
+ <span
+ aria-hidden
+ className={cn(
+ 'size-1.5 shrink-0 rounded-full',
+ state === 'not-running'
+ ? 'bg-foreground-muted'
+ : state === 'connected' || state === 'running-local'
+ ? 'bg-green-500'
+ : 'bg-red-500'
+ )}
+ />
+ );
+});
+
+/**
+ * The connection state as a titlebar reads it. Every page that belongs to a
+ * server carries it, including an agent's own page — an agent is unreachable
+ * for exactly as long as its server is, and that is worth saying where you are
+ * about to start a session rather than only on the server's pages.
+ */
+export const ServerStatusPill = observer(function ServerStatusPill({
+ server,
+}: {
+ server: SwitchServer;
+}) {
+ return (
+ <span className="flex items-center gap-1.5 rounded-full bg-background-tertiary px-2 py-0.5 text-xs text-foreground-muted">
+ <ServerStatusDot server={server} />
+ {serverStatusLabel(server)}
+ </span>
+ );
+});
+
+/**
+ * Flags a managed server whose switch-core no longer matches the version this
+ * build pins (CHOO-1736), so an available update is visible from the switcher
+ * rather than only on the server's own page.
+ *
+ * Sits beside the connection dot rather than recolouring it: the dot answers
+ * "can I reach this server", which stays true of a server running a stale core.
+ */
+export function ServerDriftIndicator({ drift }: { drift: SwitchVersionDrift }) {
+ const upgrade = drift.direction === 'upgrade';
+ const label = upgrade
+ ? `switch-core ${drift.expected} is available (running ${drift.deployed})`
+ : drift.direction === 'downgrade'
+ ? `Runs switch-core ${drift.deployed} — newer than this app expects (${drift.expected})`
+ : drift.direction === 'unreadable'
+ ? `Can't read which switch-core this runs; this app expects ${drift.expected}`
+ : `Runs switch-core ${drift.deployed}; this app expects ${drift.expected}`;
+
+ return (
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <span
+ aria-label={label}
+ className={cn(
+ 'flex shrink-0 items-center',
+ upgrade ? 'text-foreground-warning' : 'text-red-500'
+ )}
+ >
+ {upgrade ? (
+ <ArrowUpCircle className="size-3.5" />
+ ) : (
+ <TriangleAlert className="size-3.5" />
+ )}
+ </span>
+ }
+ />
+ <TooltipContent>{label}</TooltipContent>
+ </Tooltip>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-reset-section.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-reset-section.tsx
new file mode 100644
index 000000000..d0270e914
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-reset-section.tsx
@@ -0,0 +1,86 @@
+import { TriangleAlert } from 'lucide-react';
+import { useState } from 'react';
+import { Button } from '@renderer/lib/ui/button';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogContentArea,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@renderer/lib/ui/dialog';
+
+/**
+ * Throwing away a managed stack, at the very bottom of its server's page.
+ *
+ * Last and on its own, below a rule: it is the one thing here that destroys
+ * work, and it should not sit next to Start and Stop where a misread costs
+ * every agent on the server.
+ */
+export function ServerResetSection({
+ dialogTitle,
+ disabled,
+ onConfirm,
+}: {
+ /** Names the stack being destroyed — the confirmation has to say which. */
+ dialogTitle: string;
+ disabled: boolean;
+ onConfirm: () => void;
+}) {
+ const [open, setOpen] = useState(false);
+
+ return (
+ <section className="border-t border-border pt-5">
+ <div className="flex items-center justify-between gap-3">
+ <div className="space-y-0.5">
+ <h3 className="text-sm font-medium text-foreground">Reset</h3>
+ <p className="text-xs text-foreground-muted">
+ Permanently deletes the stack's data and every agent configured against it.
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={disabled}
+ className="shrink-0 border-red-500/40 text-red-500 hover:bg-red-500/10 hover:text-red-500"
+ onClick={() => setOpen(true)}
+ >
+ Reset…
+ </Button>
+ </div>
+
+ <Dialog open={open} onOpenChange={setOpen}>
+ <DialogContent>
+ <DialogHeader>
+ <TriangleAlert className="size-4 text-red-500" />
+ <DialogTitle>{dialogTitle}</DialogTitle>
+ </DialogHeader>
+ <DialogContentArea>
+ <DialogDescription>
+ This permanently deletes this managed server and everything on it — all rooms,
+ messages, and{' '}
+ <strong className="text-foreground">every agent you've configured against it</strong>.
+ This can't be undone. A fresh Start rebuilds an empty stack from scratch.
+ </DialogDescription>
+ </DialogContentArea>
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" size="sm" />}>Cancel</DialogClose>
+ <Button
+ variant="destructive"
+ size="sm"
+ disabled={disabled}
+ onClick={() => {
+ setOpen(false);
+ onConfirm();
+ }}
+ >
+ Reset and delete all agents
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ </section>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx
new file mode 100644
index 000000000..70df96eb2
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-rooms-view.tsx
@@ -0,0 +1,199 @@
+import { DoorOpen, ExternalLink, MoreVertical, Plus, UserPlus } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import type { GuardResult, ViewDefinition } from '@renderer/app/view-registry';
+import { refreshSidebarRoomState } from '@renderer/features/sidebar/sidebar-tree-data';
+import { BridgeIcon, hasBridgeIcon } from '@renderer/lib/components/bridge-icon';
+import { bridgePlatformLabel } from '@renderer/lib/components/bridge-platform';
+import { rpc } from '@renderer/lib/ipc';
+import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { openExternalUrl } from '@renderer/lib/open-external';
+import { Button } from '@renderer/lib/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
+} from '@renderer/lib/ui/dropdown-menu';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/lib/ui/tooltip';
+import type { RemoteRoomSummary } from '@shared/core/switch-servers/switch-servers';
+import { ServerPage, ServerTable, ServerTableEmpty } from './server-page';
+import { ServerSectionTitlebar } from './server-section-titlebar';
+import { switchRoomsStore } from './switch-rooms-store';
+import { switchServersStore } from './switch-servers-store';
+
+const COLUMNS = [
+ { key: 'room', label: 'Room' },
+ { key: 'bridge', label: 'Bridged to' },
+ { key: 'agents', label: 'Agents', className: 'w-24' },
+ { key: 'actions', label: 'Actions', className: 'w-28 text-right' },
+] as const;
+
+function useServerId(): string {
+ return useParams('serverRooms').params.serverId;
+}
+
+const ServerRoomsTitlebar = observer(function ServerRoomsTitlebar() {
+ return <ServerSectionTitlebar serverId={useServerId()} icon={DoorOpen} label="Your Rooms" />;
+});
+
+const ServerRoomsPanel = observer(function ServerRoomsPanel() {
+ const serverId = useServerId();
+ const server = switchServersStore.servers.find((s) => s.id === serverId);
+ const showCreateRoomModal = useShowModal('createRoomModal');
+
+ useEffect(() => {
+ void refreshSidebarRoomState(false);
+ }, [serverId]);
+
+ const rooms = switchRoomsStore.listedRoomsOnServer(serverId);
+ const signedOut = switchRoomsStore.serversNotSignedIn.some((s) => s.id === serverId);
+ const failed = switchRoomsStore.serversThatFailedToLoad.some((s) => s.id === serverId);
+
+ return (
+ <ServerPage
+ title="Your Rooms"
+ description={`Rooms on ${server?.name ?? 'this server'}. Create one, see who is in it, and where it is bridged.`}
+ action={
+ <Button size="sm" disabled={signedOut} onClick={() => showCreateRoomModal({ serverId })}>
+ <Plus className="size-4" />
+ Create room
+ </Button>
+ }
+ >
+ {/* Three ways to have no rows, and only one of them means "there are no
+ rooms". Saying that in the other two would send someone off to create a
+ room they already have. */}
+ {signedOut ? (
+ <ServerTableEmpty>
+ Sign in to {server?.name ?? 'this server'} to see its rooms.
+ </ServerTableEmpty>
+ ) : failed ? (
+ <ServerTableEmpty>
+ This server&apos;s room list could not be read. Refresh from Home to try again.
+ </ServerTableEmpty>
+ ) : rooms.length === 0 ? (
+ <ServerTableEmpty>
+ No rooms here yet. Create one to give your agents somewhere to work.
+ </ServerTableEmpty>
+ ) : (
+ <ServerTable columns={COLUMNS}>
+ {rooms.map((room) => (
+ <RoomRow key={room.id} room={room} serverId={serverId} />
+ ))}
+ </ServerTable>
+ )}
+ </ServerPage>
+ );
+});
+
+const RoomRow = observer(function RoomRow({
+ room,
+ serverId,
+}: {
+ room: RemoteRoomSummary;
+ serverId: string;
+}) {
+ const { navigate } = useNavigate();
+ const showAddAgentsToRoomModal = useShowModal('addAgentsToRoomModal');
+
+ const platform = bridgePlatformLabel(room.bridgeType);
+ const gatewayUrl = switchRoomsStore.gatewayRoomUrl(room.id);
+ const channelUrl = switchRoomsStore.roomChannelUrl(room.id);
+
+ return (
+ <tr className="text-sm">
+ <td className="px-3 py-2">
+ <button
+ type="button"
+ className="flex min-w-0 items-center gap-2 text-left hover:underline"
+ onClick={() => navigate('room', { roomId: room.id })}
+ >
+ {hasBridgeIcon(room.bridgeType) ? (
+ <BridgeIcon bridgeType={room.bridgeType} size={16} className="shrink-0" />
+ ) : (
+ <DoorOpen className="size-4 shrink-0 text-foreground-muted" />
+ )}
+ <span className="truncate">{room.name}</span>
+ </button>
+ </td>
+
+ <td className="truncate px-3 py-2 text-foreground-muted">
+ {room.bridgeType ? (room.bridgeDisplayName ?? platform) : 'Not bridged'}
+ </td>
+
+ <td className="px-3 py-2 text-foreground-muted">{room.agentCount}</td>
+
+ <td className="px-3 py-2">
+ <div className="flex items-center justify-end">
+ <Tooltip>
+ <TooltipTrigger
+ render={
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label={`Add agents to ${room.name}`}
+ onClick={() => showAddAgentsToRoomModal({ roomId: room.id })}
+ >
+ <Plus className="size-3" />
+ </Button>
+ }
+ />
+ <TooltipContent>Add agents</TooltipContent>
+ </Tooltip>
+
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button variant="ghost" size="icon-xs" aria-label={`${room.name} actions`}>
+ <MoreVertical className="size-3" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={() => showAddAgentsToRoomModal({ roomId: room.id })}>
+ <UserPlus className="size-4" />
+ Add agents…
+ </DropdownMenuItem>
+ {channelUrl && (
+ <DropdownMenuItem
+ onClick={() =>
+ void openExternalUrl(channelUrl, `Could not open the room in ${platform}`)
+ }
+ >
+ <ExternalLink className="size-4" />
+ Open in {platform}
+ </DropdownMenuItem>
+ )}
+ {gatewayUrl && (
+ <DropdownMenuItem
+ onClick={() =>
+ void rpc.switchServers.openGatewayPage({ serverId, url: gatewayUrl })
+ }
+ >
+ <ExternalLink className="size-4" />
+ Open in gateway
+ </DropdownMenuItem>
+ )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </td>
+ </tr>
+ );
+});
+
+export const serverRoomsView = {
+ WrapView: ({ children }: { children: React.ReactNode; serverId: string }) => <>{children}</>,
+ TitlebarSlot: ServerRoomsTitlebar,
+ MainPanel: ServerRoomsPanel,
+ canActivate: (params: unknown): GuardResult => {
+ const serverId =
+ typeof params === 'object' && params !== null
+ ? (params as { serverId?: unknown }).serverId
+ : undefined;
+ if (typeof serverId !== 'string') return { ok: false, redirect: 'home' };
+ return { ok: true };
+ },
+} satisfies ViewDefinition<{ serverId: string }>;
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-section-titlebar.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-section-titlebar.tsx
new file mode 100644
index 000000000..c79343daa
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-section-titlebar.tsx
@@ -0,0 +1,54 @@
+import type { LucideIcon } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { Titlebar } from '@renderer/lib/components/titlebar/Titlebar';
+import { TitlebarBreadcrumb } from '@renderer/lib/components/titlebar/titlebar-breadcrumb';
+import { ServerAvatar, ServerStatusPill } from './server-presentation';
+import { switchServersStore } from './switch-servers-store';
+
+/**
+ * The titlebar shared by every page of a server's workspace: which server, then
+ * which of its sections, then how the connection is doing.
+ *
+ * One component rather than one per page, because the breadcrumb is the only
+ * thing telling you which workspace you are in — three copies of it are three
+ * chances for the pages to disagree about that.
+ */
+export const ServerSectionTitlebar = observer(function ServerSectionTitlebar({
+ serverId,
+ icon: SectionIcon,
+ label,
+}: {
+ serverId: string;
+ icon: LucideIcon;
+ label: string;
+}) {
+ const server = switchServersStore.servers.find((s) => s.id === serverId);
+ return (
+ <Titlebar
+ leftSlot={
+ <TitlebarBreadcrumb
+ crumbs={[
+ {
+ key: 'server',
+ icon: server && <ServerAvatar server={server} size="sm" />,
+ label: server?.name ?? 'Server',
+ maxWidthClassName: 'max-w-40',
+ },
+ {
+ key: 'section',
+ icon: <SectionIcon className="size-3.5 shrink-0" />,
+ label,
+ },
+ ]}
+ />
+ }
+ rightSlot={
+ server && (
+ <div className="mr-1 flex items-center gap-1.5">
+ <ServerStatusPill server={server} />
+ </div>
+ )
+ }
+ />
+ );
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-stack-section.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-stack-section.tsx
new file mode 100644
index 000000000..340fbee4e
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-stack-section.tsx
@@ -0,0 +1,69 @@
+import type { ReactNode } from 'react';
+
+/** The lifecycle states a managed stack reports, local or remote. */
+export type StackPhase = 'stopped' | 'starting' | 'running' | 'stopping' | 'error' | 'unreachable';
+
+const PHASE_LABEL: Record<StackPhase, string> = {
+ stopped: 'Stopped',
+ starting: 'Starting',
+ running: 'Running',
+ stopping: 'Stopping',
+ error: 'Error',
+ unreachable: 'Host unreachable',
+};
+
+const PHASE_DOT: Record<StackPhase, string> = {
+ stopped: 'bg-foreground-muted',
+ starting: 'bg-amber-500',
+ running: 'bg-green-500',
+ stopping: 'bg-amber-500',
+ error: 'bg-red-500',
+ unreachable: 'bg-amber-500',
+};
+
+/**
+ * The managed stack's own section of a server page — a titled card holding a
+ * status line and whatever the stack currently has to say for itself.
+ *
+ * Shared by the local and remote controls so the two read as the same thing in
+ * two places rather than as two features that happen to look alike.
+ */
+export function StackSection({ title, children }: { title: string; children: ReactNode }) {
+ return (
+ <section className="space-y-2">
+ <h3 className="text-sm font-medium text-foreground">{title}</h3>
+ <div className="bg-card divide-y divide-border rounded-lg border border-border">
+ {children}
+ </div>
+ </section>
+ );
+}
+
+/**
+ * Where the stack is and what can be done about it, on one line.
+ *
+ * `detail` is deliberately terse and monospaced: it is the machine's answer,
+ * not a sentence, and it sits beside the state rather than explaining it.
+ */
+export function StackStatusRow({
+ phase,
+ detail,
+ actions,
+}: {
+ phase: StackPhase;
+ detail: string;
+ actions: ReactNode;
+}) {
+ return (
+ <div className="flex items-center justify-between gap-3 p-3">
+ <div className="flex min-w-0 items-center gap-2.5">
+ <span className="flex shrink-0 items-center gap-1.5 rounded-full bg-background-tertiary px-2 py-0.5 text-xs text-foreground-muted">
+ <span aria-hidden className={`size-1.5 rounded-full ${PHASE_DOT[phase]}`} />
+ {PHASE_LABEL[phase]}
+ </span>
+ <span className="truncate font-mono text-xs text-foreground-muted">{detail}</span>
+ </div>
+ <div className="flex shrink-0 items-center gap-2">{actions}</div>
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-stat-tiles.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-stat-tiles.tsx
new file mode 100644
index 000000000..85d573057
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/server-stat-tiles.tsx
@@ -0,0 +1,57 @@
+import { useQuery } from '@tanstack/react-query';
+import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
+import { rpc } from '@renderer/lib/ipc';
+import { switchRoomsStore } from './switch-rooms-store';
+
+/**
+ * How much of this server Switch Console is holding: the agents onboarded
+ * through it, the rooms it lists, and the messaging apps bridged to it.
+ *
+ * These count what is on screen elsewhere in the app, not what the server
+ * reports about itself — the numbers have to agree with the sidebar and the
+ * Your Agents / Your Rooms pages, or they answer a question nobody asked.
+ */
+export const ServerStatTiles = observer(function ServerStatTiles({
+ serverId,
+}: {
+ serverId: string;
+}) {
+ // Shares the key every other bridge reader uses, so the list is already in
+ // cache by the time this renders and the tile never fetches on its own.
+ const bridgesQuery = useQuery({
+ queryKey: ['remote-bridges', serverId],
+ queryFn: () => rpc.switchServers.listRemoteBridges(serverId),
+ enabled: !!serverId,
+ });
+
+ // The sidebar loads this too, but the page must not depend on the sidebar
+ // having been mounted first to report a true number.
+ useEffect(() => {
+ if (!agentsStore.loaded) void agentsStore.load();
+ }, []);
+
+ return (
+ <div className="grid grid-cols-3 gap-3">
+ <StatTile
+ label="Your Agents"
+ value={agentsStore.loaded ? agentsStore.agentsOnServer(serverId).length : null}
+ />
+ <StatTile label="Your Rooms" value={switchRoomsStore.listedRoomsOnServer(serverId).length} />
+ <StatTile label="Messaging apps" value={bridgesQuery.data?.length ?? null} />
+ </div>
+ );
+});
+
+/** A number that is not known yet reads as an em dash rather than as zero:
+ * "no messaging apps" is a fact worth acting on and must not be faked while
+ * the list is still loading. */
+function StatTile({ label, value }: { label: string; value: number | null }) {
+ return (
+ <div className="bg-card rounded-lg border border-border px-4 py-3">
+ <p className="text-xs text-foreground-muted">{label}</p>
+ <p className="mt-1 text-2xl text-foreground">{value ?? '—'}</p>
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts
index 977fa7073..2691a60a2 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.test.ts
@@ -312,31 +312,6 @@ describe('agent memberships', () => {
expect(store.localMemberIds('gone')).toEqual([]);
});
- it('discloses members the server counts that this install cannot draw', async () => {
- serversStore.servers = [{ id: 'srv-a', managed: true }];
- serversStore.activeServerId = 'srv-a';
- listRemoteRooms.mockImplementation(async () => [
- room('shared', 'user-of-srv-a', { agentCount: 3 }),
- ]);
- listAgentRooms.mockImplementation(async () => [
- { roomId: 'shared', roomName: 'r', archived: false, status: 'live', roomRole: null },
- ]);
- const store = new SwitchRoomsStore();
-
- await store.loadRoomNames();
- await store.ensureMembershipsFor([{ serverId: 'srv-a', switchAgentId: 'agent-1' }]);
-
- // One member is drawable here; the other two exist but belong elsewhere.
- expect(store.localMemberIds('shared')).toEqual(['agent-1']);
- expect(store.undrawableMemberCount('shared')).toBe(1 + 1);
- });
-
- it('reports the undrawable count as unknown until the room list has loaded', () => {
- const store = new SwitchRoomsStore();
-
- expect(store.undrawableMemberCount('never-loaded')).toBeNull();
- });
-
it('re-reads every tracked agent on refresh, not just the ones already cached', async () => {
// An agent created after the sidebar mounted has no cache entry, so a
// refresh keyed on the cache would never fetch it.
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts
index c65459fae..1594f4baa 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-rooms-store.ts
@@ -84,14 +84,6 @@ export class SwitchRoomsStore {
return this.roomServerById.get(roomId) ?? null;
}
- /** Display name of the server a room belongs to, for the room titlebar's
- * breadcrumb. Null while rooms are still loading. */
- roomServerName(roomId: string): string | null {
- const serverId = this.roomServerById.get(roomId);
- if (!serverId) return null;
- return switchServersStore.servers.find((s) => s.id === serverId)?.name ?? null;
- }
-
/**
* URL of a room's detail page in the gateway web app, or null if the room's
* owning server isn't known yet (names/servers are loaded by loadRoomNames).
@@ -135,16 +127,22 @@ export class SwitchRoomsStore {
const serverIds = activeServerId
? [activeServerId]
: [...new Set([...this.allRoomsByServer.keys(), ...this.ownedRoomsByServer.keys()])];
- const listed = serverIds.flatMap((serverId) => {
- const managed = switchServersStore.servers.find((s) => s.id === serverId)?.managed ?? false;
- return (
- (managed ? this.allRoomsByServer.get(serverId) : this.ownedRoomsByServer.get(serverId)) ??
- []
- );
- });
+ const listed = serverIds.flatMap((serverId) => this.listedRoomsOnServer(serverId));
return listed.sort((a, b) => a.name.localeCompare(b.name));
}
+ /**
+ * The rooms one server contributes to the lists above, under the same scope
+ * rule. Named separately so a page about a single server asks for that
+ * server rather than for whichever one happens to be active.
+ */
+ listedRoomsOnServer(serverId: string): RemoteRoomSummary[] {
+ const managed = switchServersStore.servers.find((s) => s.id === serverId)?.managed ?? false;
+ return (
+ (managed ? this.allRoomsByServer.get(serverId) : this.ownedRoomsByServer.get(serverId)) ?? []
+ );
+ }
+
/**
* The same listed rooms as {@link listedRoomsInActiveScope}, but across every
* server rather than the active one.
@@ -159,13 +157,7 @@ export class SwitchRoomsStore {
const serverIds = [
...new Set([...this.allRoomsByServer.keys(), ...this.ownedRoomsByServer.keys()]),
];
- const listed = serverIds.flatMap((serverId) => {
- const managed = switchServersStore.servers.find((s) => s.id === serverId)?.managed ?? false;
- return (
- (managed ? this.allRoomsByServer.get(serverId) : this.ownedRoomsByServer.get(serverId)) ??
- []
- );
- });
+ const listed = serverIds.flatMap((serverId) => this.listedRoomsOnServer(serverId));
return listed.sort((a, b) => a.name.localeCompare(b.name));
}
@@ -358,8 +350,9 @@ export class SwitchRoomsStore {
* view that wants either reads this, so the two cannot disagree.
*
* Scope is deliberate. This install can only act on its own agents, so those
- * are the only members the sidebar draws (see {@link undrawableMemberCount}
- * for how the rest are disclosed).
+ * are the only members the sidebar can draw. A room's full membership, agents
+ * on other installs included, is the server's own count and is listed on the
+ * Your Rooms page.
*/
get localMemberIdsByRoom(): Map<string, string[]> {
const byRoom = new Map<string, string[]>();
@@ -380,22 +373,6 @@ export class SwitchRoomsStore {
return this.localMemberIdsByRoom.get(roomId) ?? [];
}
- /**
- * Members the server counts for a room that this install cannot draw — agents
- * registered elsewhere, plus any whose membership failed to load. Null when
- * the room's server list has not loaded, so the difference is unknown rather
- * than zero.
- *
- * This is never rendered as the member count. The count is the length of what
- * is drawn; this only discloses the gap, so a member that exists but cannot be
- * shown is not mistaken for a member that is not there.
- */
- undrawableMemberCount(roomId: string): number | null {
- const total = this.roomSummaryById(roomId)?.agentCount ?? null;
- if (total === null) return null;
- return Math.max(0, total - this.localMemberIds(roomId).length);
- }
-
/**
* Re-read every fact the sidebar's room state is built from: the room lists
* and the membership of every tracked agent.
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
index 231e8315a..190719d3c 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.test.ts
@@ -7,6 +7,7 @@ const listServers = vi.hoisted(() => vi.fn());
const getActiveServerId = vi.hoisted(() => vi.fn());
const setActiveServer = vi.hoisted(() => vi.fn());
const removeServer = vi.hoisted(() => vi.fn());
+const addServer = vi.hoisted(() => vi.fn());
/** SSH hosts the reachability manager currently considers down. */
const blockedHosts = vi.hoisted(() => new Set<string>());
@@ -20,6 +21,7 @@ vi.mock('@renderer/lib/ipc', () => ({
getActiveServerId,
setActiveServer,
removeServer,
+ addServer,
},
},
}));
@@ -266,6 +268,92 @@ describe('a server that cannot be reached', () => {
});
});
+/**
+ * A server is a workspace: the switcher, the sidebar and the sessions under it
+ * all read the active one, so "servers exist but none is active" is a state the
+ * UI cannot render. Nothing on the main side picks one, so the store must.
+ */
+describe('keeping a server active', () => {
+ it('selects the first server when nothing was active', async () => {
+ listServers.mockResolvedValue([server('srv-a'), server('srv-b')]);
+ getActiveServerId.mockResolvedValue(null);
+ const store = new SwitchServersStore();
+
+ await store.init();
+
+ expect(store.activeServerId).toBe('srv-a');
+ });
+
+ it('keeps the server the user last chose', async () => {
+ listServers.mockResolvedValue([server('srv-a'), server('srv-b')]);
+ getActiveServerId.mockResolvedValue('srv-b');
+ const store = new SwitchServersStore();
+
+ await store.init();
+
+ expect(store.activeServerId).toBe('srv-b');
+ });
+
+ it('re-selects when the stored server no longer exists', async () => {
+ // Removing the active server and adding another leaves the stored id
+ // naming the removed one. Reading that as a selection left the app with no
+ // workspace at all — no switcher, no destinations, no sidebar tree — while
+ // a perfectly good server sat in the list.
+ listServers.mockResolvedValue([server('srv-b')]);
+ getActiveServerId.mockResolvedValue('srv-gone');
+ const store = new SwitchServersStore();
+
+ await store.init();
+
+ expect(store.activeServerId).toBe('srv-b');
+ expect(store.activeServer?.id).toBe('srv-b');
+ });
+
+ it('activates the first server added, which nothing else does', async () => {
+ // Adding a server does not set it active on the main side, so without this
+ // the very first one left the app with no workspace to show — the sidebar
+ // stayed on "Add a server" until the next launch.
+ listServers.mockResolvedValue([]);
+ getActiveServerId.mockResolvedValue(null);
+ const store = new SwitchServersStore();
+ await store.init();
+
+ const created = server('srv-new');
+ addServer.mockResolvedValue(created);
+ listServers.mockResolvedValue([created]);
+
+ await store.addServer('New', created.gatewayUrl, created.apiUrl);
+
+ expect(store.activeServerId).toBe('srv-new');
+ });
+
+ it('does not move the workspace when a second server is added', async () => {
+ listServers.mockResolvedValue([server('srv-a')]);
+ getActiveServerId.mockResolvedValue('srv-a');
+ const store = new SwitchServersStore();
+ await store.init();
+
+ const created = server('srv-b');
+ addServer.mockResolvedValue(created);
+ listServers.mockResolvedValue([server('srv-a'), created]);
+
+ await store.addServer('B', created.gatewayUrl, created.apiUrl);
+
+ expect(store.activeServerId).toBe('srv-a');
+ });
+
+ it('leaves nothing active when there are no servers at all', async () => {
+ listServers.mockResolvedValue([]);
+ getActiveServerId.mockResolvedValue(null);
+ const store = new SwitchServersStore();
+
+ await store.init();
+
+ expect(store.activeServerId).toBeNull();
+ expect(store.activeServer).toBeNull();
+ });
+});
+
describe('the error banner', () => {
it('survives a background refresh, which cannot tell whether it is stale', async () => {
// A rejected password lives in the same field. A background sweep clearing
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
index 64ec5c85b..9bdfe810a 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/switch-servers-store.ts
@@ -40,8 +40,6 @@ export class SwitchServersStore {
/** Server ids with an in-flight status refresh. */
readonly refreshing = new Set<string>();
error: string | null = null;
- /** Whether the sidebar "Servers" section is expanded. */
- serversExpanded = true;
constructor() {
makeAutoObservable(this);
@@ -59,10 +57,6 @@ export class SwitchServersStore {
return this.servers.find((s) => s.id === this.activeServerId) ?? null;
}
- toggleServersExpanded(): void {
- this.serversExpanded = !this.serversExpanded;
- }
-
statusFor(serverId: string): ServerConnectionStatus | null {
return this.statuses.get(serverId) ?? null;
}
@@ -94,11 +88,7 @@ export class SwitchServersStore {
this.servers = servers;
this.activeServerId = activeServerId;
});
- // The sidebar scopes its whole view to the active server, so one must
- // always be selected when any server exists. Default to the first.
- if (!this.activeServerId && servers.length > 0) {
- await this.setActive(servers[0].id);
- }
+ await this.ensureActiveServer();
await this.refreshAllStatuses();
} catch (cause) {
this.setError(cause);
@@ -109,6 +99,23 @@ export class SwitchServersStore {
}
}
+ /**
+ * A server is a workspace: the switcher, the sidebar and the sessions under
+ * it all read the active one, so one must be selected whenever any server
+ * exists. Nothing on the main side picks it — adding the first server leaves
+ * the active id null — so every path that changes the list ends here.
+ *
+ * A stored id that no longer names a server counts as no selection. It is not
+ * hypothetical: removing the active server and adding another leaves the id
+ * pointing at the removed one, and treating that as a selection left the app
+ * with no workspace at all — no switcher, no sidebar tree, no way back.
+ */
+ private async ensureActiveServer(): Promise<void> {
+ if (this.activeServerId && this.servers.some((s) => s.id === this.activeServerId)) return;
+ const first = this.servers[0];
+ if (first) await this.setActive(first.id);
+ }
+
async refreshAllStatuses(): Promise<void> {
await Promise.all(this.servers.map((s) => this.refreshStatus(s.id)));
}
@@ -223,6 +230,7 @@ export class SwitchServersStore {
this.servers = servers;
this.activeServerId = activeServerId;
});
+ await this.ensureActiveServer();
await this.refreshStatus(created.id);
return created;
} catch (cause) {
@@ -311,10 +319,7 @@ export class SwitchServersStore {
this.authConfigWanted.delete(serverId);
this.unreachable.delete(serverId);
});
- // Keep a server scoped when any remain (the sidebar scopes to it).
- if (!this.activeServerId && servers.length > 0) {
- await this.setActive(servers[0].id);
- }
+ await this.ensureActiveServer();
} catch (cause) {
this.setError(cause);
}
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx
index 7c3d4d3f0..ce6ae18a6 100644
--- a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/view.tsx
@@ -1,10 +1,19 @@
-import { ExternalLink, MoreVertical, Pencil, PlugZap, RefreshCw, Trash2 } from 'lucide-react';
+import { useQueryClient } from '@tanstack/react-query';
+import {
+ ExternalLink,
+ House,
+ MoreVertical,
+ Pencil,
+ PlugZap,
+ RefreshCw,
+ Trash2,
+} from 'lucide-react';
import { observer } from 'mobx-react-lite';
import { useEffect, useState } from 'react';
import { type GuardResult, type ViewDefinition } from '@renderer/app/view-registry';
+import { agentsStore } from '@renderer/features/locations/stores/agents-store';
import { hostReachabilityStore } from '@renderer/features/remote-hosts/host-reachability-store';
import { HostUnreachablePanel } from '@renderer/features/remote-hosts/host-unreachable-panel';
-import { Titlebar } from '@renderer/lib/components/titlebar/Titlebar';
import { rpc } from '@renderer/lib/ipc';
import { useNavigate, useParams } from '@renderer/lib/layout/navigation-provider';
import { useShowModal } from '@renderer/lib/modal/modal-provider';
@@ -27,14 +36,15 @@ import { LocalServerControls } from './LocalServerControls';
import { MessagingAppsCard } from './MessagingAppsCard';
import { remoteServerStore } from './remote-server-store';
import { RemoteServerControls } from './RemoteServerControls';
+import { serverIcon } from './server-icon';
+import { ServerAvatar, serverDrift, serverPlacementLabel } from './server-presentation';
+import { ServerResetSection } from './server-reset-section';
+import { ServerSectionTitlebar } from './server-section-titlebar';
+import { ServerStatTiles } from './server-stat-tiles';
+import { switchRoomsStore } from './switch-rooms-store';
import { switchServersStore } from './switch-servers-store';
-
-/** Short badge label for where a server lives (see CHOO-1432 terminology). */
-function serverLocationLabel(server: SwitchServer): string | null {
- if (server.managementKind === 'remote') return server.sshHost ?? 'Remote host';
- if (server.managed) return 'This computer';
- return 'External';
-}
+import { myIdentitiesQueryKey } from './use-my-identities';
+import { VersionDriftNotice } from './VersionDriftNotice';
/** Whether a managed server's stack is currently running (via the store that
* owns its lifecycle). Non-managed servers are always "reachable". */
@@ -45,24 +55,28 @@ function isManagedRunning(server: SwitchServer): boolean {
return localServerStore.isRunning;
}
+/** Re-running the start pipeline is what picks up a new switch-core pin, so
+ * "restart to update" and "restart" are the same call on either store. */
+function restartStack(server: SwitchServer): void {
+ if (server.managementKind === 'remote' && server.sshHost) {
+ void remoteServerStore.start(server.sshHost, server.name);
+ return;
+ }
+ void localServerStore.start();
+}
+
const card = 'rounded-lg border border-border bg-card p-4';
+/** How long Refresh keeps spinning at minimum. Long enough to be seen as a
+ * response to the click, short enough not to feel like waiting. */
+const MIN_REFRESH_FEEDBACK_MS = 600;
+
function useServerId(): string {
return useParams('server').params.serverId;
}
const ServerTitlebar = observer(function ServerTitlebar() {
- const serverId = useServerId();
- const server = switchServersStore.servers.find((s) => s.id === serverId);
- return (
- <Titlebar
- leftSlot={
- <div className="flex items-center px-2">
- <span className="text-sm text-foreground-muted">{server?.name ?? 'Server'}</span>
- </div>
- }
- />
- );
+ return <ServerSectionTitlebar serverId={useServerId()} icon={House} label="Home" />;
});
const ServerMainPanel = observer(function ServerMainPanel() {
@@ -73,6 +87,38 @@ const ServerMainPanel = observer(function ServerMainPanel() {
const showRenameServerModal = useShowModal('renameServerModal');
const showDeleteServerModal = useShowModal('deleteServerModal');
const { navigate } = useNavigate();
+ const queryClient = useQueryClient();
+
+ const [refreshingPage, setRefreshingPage] = useState(false);
+
+ /**
+ * Everything the page is showing, re-read.
+ *
+ * The button sits in the page header, so its scope has to be the page: the
+ * connection alone would leave the counts, the messaging apps and the rooms
+ * exactly as stale as they were, under a control that claims to have
+ * refreshed them.
+ *
+ * Held on screen for a moment even when the reads come back instantly. A
+ * spinner that appears and vanishes inside one frame reads as a button that
+ * did nothing, which is the opposite of what it did.
+ */
+ const refreshEverything = async (): Promise<void> => {
+ setRefreshingPage(true);
+ try {
+ await Promise.all([
+ store.refreshServer(serverId),
+ queryClient.invalidateQueries({ queryKey: ['remote-bridges', serverId] }),
+ queryClient.invalidateQueries({ queryKey: myIdentitiesQueryKey(serverId) }),
+ queryClient.invalidateQueries({ queryKey: ['owns-owner-addressed-agent', serverId] }),
+ switchRoomsStore.refreshRoomState(),
+ agentsStore.load(),
+ new Promise((resolve) => setTimeout(resolve, MIN_REFRESH_FEEDBACK_MS)),
+ ]);
+ } finally {
+ setRefreshingPage(false);
+ }
+ };
// A managed server that isn't running has no gateway to reach — its
// connection status, sign-in, and web-app links are meaningless until it's up,
@@ -121,71 +167,92 @@ const ServerMainPanel = observer(function ServerMainPanel() {
const status = store.statusFor(serverId);
const connected = status?.connected ?? false;
- const refreshing = store.refreshing.has(serverId);
+ // A background status poll spins the button too: it is the same reading the
+ // button asks for, so the page should not look idle while one is in flight.
+ const busy = refreshingPage || store.refreshing.has(serverId);
+ const unreachable = store.isUnreachable(serverId);
+ const PlacementIcon = serverIcon(server);
+ const drift = serverDrift(server);
+ const stackTransitioning =
+ server.managementKind === 'remote' && server.sshHost
+ ? remoteServerStore.isTransitioning(server.sshHost) ||
+ remoteServerStore.isHostBlocked(server.sshHost)
+ : localServerStore.isTransitioning;
return (
<div className="relative z-10 flex min-h-0 flex-1 flex-col overflow-auto bg-background">
- <div className="mx-auto w-full max-w-2xl space-y-6 p-6">
- <header className="flex items-start justify-between gap-3">
- <div className="min-w-0 space-y-1">
- <div className="flex items-center gap-2">
- <h2 className="text-xl text-foreground">{server.name}</h2>
- {serverLocationLabel(server) && (
- <Badge variant="secondary">{serverLocationLabel(server)}</Badge>
- )}
- </div>
- <p className="truncate text-sm text-foreground-muted">{server.gatewayUrl}</p>
- <p className="truncate text-xs text-foreground-tertiary-passive">
- API: {server.apiUrl}
- </p>
- </div>
- <DropdownMenu>
- <DropdownMenuTrigger
- render={
- <Button
- variant="outline"
- size="icon-sm"
- className="shrink-0"
- aria-label="Server actions"
- >
- <MoreVertical className="size-4" />
- </Button>
- }
+ <div className="mx-auto w-full max-w-4xl space-y-6 p-6">
+ <header className="flex items-center justify-between gap-3">
+ <div className="flex min-w-0 items-center gap-3">
+ <ServerAvatar server={server} size="lg" />
+ <h2 className="truncate text-2xl font-semibold text-foreground">{server.name}</h2>
+ {/* Where the server lives, as the icon the switcher and the sidebar
+ already use for it rather than as a second vocabulary in words. */}
+ <PlacementIcon
+ aria-label={serverPlacementLabel(server) ?? 'Reached over the network'}
+ className="size-4 shrink-0 text-foreground-muted"
/>
- <DropdownMenuContent align="end">
- <DropdownMenuItem
- onClick={() => showRenameServerModal({ serverId, currentName: server.name })}
+ </div>
+ <div className="flex shrink-0 items-center gap-2">
+ {detailsVisible && (
+ <Button
+ variant="outline"
+ size="sm"
+ disabled={busy}
+ onClick={() => void refreshEverything()}
>
- <Pencil className="size-4" />
- Rename…
- </DropdownMenuItem>
- {!server.managed && (
+ {busy ? <Spinner className="size-4" /> : <RefreshCw className="size-4" />}
+ Refresh
+ </Button>
+ )}
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <Button
+ variant="outline"
+ size="icon-sm"
+ className="shrink-0"
+ aria-label="Server actions"
+ >
+ <MoreVertical className="size-4" />
+ </Button>
+ }
+ />
+ <DropdownMenuContent align="end">
<DropdownMenuItem
+ onClick={() => showRenameServerModal({ serverId, currentName: server.name })}
+ >
+ <Pencil className="size-4" />
+ Rename…
+ </DropdownMenuItem>
+ {!server.managed && (
+ <DropdownMenuItem
+ onClick={() =>
+ showEditServerModal({
+ serverId,
+ initialName: server.name,
+ initialGatewayUrl: server.gatewayUrl,
+ initialApiUrl: server.apiUrl,
+ })
+ }
+ >
+ <ExternalLink className="size-4" />
+ Edit connection…
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
onClick={() =>
- showEditServerModal({
- serverId,
- initialName: server.name,
- initialGatewayUrl: server.gatewayUrl,
- initialApiUrl: server.apiUrl,
- })
+ showDeleteServerModal({ serverId, onSuccess: () => navigate('home') })
}
>
- <ExternalLink className="size-4" />
- Edit connection…
+ <Trash2 className="size-4" />
+ Delete server…
</DropdownMenuItem>
- )}
- <DropdownMenuSeparator />
- <DropdownMenuItem
- variant="destructive"
- onClick={() =>
- showDeleteServerModal({ serverId, onSuccess: () => navigate('home') })
- }
- >
- <Trash2 className="size-4" />
- Delete server…
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
</header>
{store.error && (
@@ -195,6 +262,37 @@ const ServerMainPanel = observer(function ServerMainPanel() {
</Alert>
)}
+ {/* An available update is about the whole server, so it leads the page
+ rather than waiting inside the stack card further down. */}
+ <VersionDriftNotice
+ drift={drift}
+ disabled={stackTransitioning}
+ onRestart={() => restartStack(server)}
+ />
+
+ {detailsVisible && unreachable && <ServerUnreachableCard serverId={serverId} />}
+
+ {detailsVisible && !unreachable && (
+ <>
+ {connected ? (
+ <SignedInCard serverId={serverId} />
+ ) : (
+ <>
+ <div className={`${card} flex items-center justify-between gap-3`}>
+ <div className="flex items-center gap-2 text-sm">
+ <StatusDot connected={false} />
+ <span className="text-foreground-muted">Not signed in</span>
+ </div>
+ </div>
+ <LoginPanel serverId={serverId} />
+ </>
+ )}
+
+ {connected && <ServerStatTiles serverId={serverId} />}
+ {connected && <MessagingAppsCard serverId={serverId} />}
+ </>
+ )}
+
{server.managed &&
(server.managementKind === 'remote' && server.sshHost ? (
<RemoteServerControls sshHost={server.sshHost} name={server.name} />
@@ -202,67 +300,87 @@ const ServerMainPanel = observer(function ServerMainPanel() {
<LocalServerControls />
))}
- {detailsVisible && store.isUnreachable(serverId) && (
- <ServerUnreachableCard serverId={serverId} />
- )}
-
- {detailsVisible && !store.isUnreachable(serverId) && (
- <>
- <div className={`${card} flex items-center justify-between gap-3`}>
- <div className="flex items-center gap-2 text-sm">
- <StatusDot connected={connected} />
- {connected ? (
- <span className="text-foreground">
- Connected{status?.user ? ` as ${status.user.name || status.user.email}` : ''}
- </span>
- ) : (
- <span className="text-foreground-muted">Not signed in</span>
- )}
- {status?.user?.role && <Badge variant="secondary">{status.user.role}</Badge>}
- {refreshing && <Spinner className="size-3.5" />}
- </div>
- <div className="flex items-center gap-2">
- <Button
- variant="outline"
- size="sm"
- disabled={refreshing}
- onClick={() => void store.refreshServer(serverId)}
- >
- <RefreshCw className="size-4" />
- Refresh
- </Button>
- {connected && (
- <Button variant="ghost" size="sm" onClick={() => void store.logout(serverId)}>
- Sign out
- </Button>
- )}
- </div>
+ {detailsVisible && !unreachable && (
+ <div className={`${card} flex items-center justify-between gap-3`}>
+ <div className="min-w-0 space-y-0.5">
+ <h3 className="text-sm font-medium text-foreground">Full admin interface</h3>
+ <p className="text-xs text-foreground-muted">
+ Configure resources, API keys and users.
+ </p>
</div>
+ <Button
+ variant="outline"
+ size="sm"
+ className="shrink-0"
+ onClick={() =>
+ void rpc.switchServers.openGatewayPage({
+ serverId: server.id,
+ url: server.gatewayUrl,
+ })
+ }
+ >
+ <ExternalLink className="size-4" />
+ Open
+ </Button>
+ </div>
+ )}
- {!connected && <LoginPanel serverId={serverId} />}
+ {server.managed && (
+ <ServerResetSection
+ dialogTitle={
+ server.managementKind === 'remote' && server.sshHost
+ ? `Reset server on ${server.sshHost}`
+ : 'Reset server on this computer'
+ }
+ disabled={stackTransitioning}
+ onConfirm={() => {
+ if (server.managementKind === 'remote' && server.sshHost) {
+ void remoteServerStore.reset(server.sshHost);
+ return;
+ }
+ void localServerStore.reset();
+ }}
+ />
+ )}
+ </div>
+ </div>
+ );
+});
- {connected && <MessagingAppsCard serverId={serverId} className={card} />}
+/**
+ * Who you are on this server, and the way out.
+ *
+ * The account leads with a face and a name because that is the question being
+ * answered — which of your identities this server sees — rather than with the
+ * fact of a connection, which the titlebar's pill already carries.
+ */
+const SignedInCard = observer(function SignedInCard({ serverId }: { serverId: string }) {
+ const store = switchServersStore;
+ const user = store.statusFor(serverId)?.user;
+ const displayName = user?.name || user?.email || 'Signed in';
+ const initial = displayName.trim().charAt(0).toUpperCase() || '?';
- <div className={`${card} space-y-3`}>
- <p className="text-sm text-foreground-muted">
- Configure resources, API keys and users in the full admin interface.
- </p>
- <Button
- variant="outline"
- size="sm"
- onClick={() =>
- void rpc.switchServers.openGatewayPage({
- serverId: server.id,
- url: server.gatewayUrl,
- })
- }
- >
- <ExternalLink className="size-4" />
- Open admin interface
- </Button>
- </div>
- </>
- )}
+ return (
+ <div className={`${card} flex items-center justify-between gap-3`}>
+ <div className="flex min-w-0 items-center gap-3">
+ <span
+ aria-hidden
+ className="flex size-8 shrink-0 items-center justify-center rounded-full bg-background-tertiary text-sm font-medium text-foreground"
+ >
+ {initial}
+ </span>
+ <div className="min-w-0">
+ <p className="truncate text-sm font-medium text-foreground">{displayName}</p>
+ <p className="truncate text-xs text-foreground-muted">
+ Signed in{user?.role ? ` · ${user.role}` : ''}
+ </p>
+ </div>
+ </div>
+ <div className="flex shrink-0 items-center gap-2">
+ {user?.role && <Badge variant="secondary">{user.role}</Badge>}
+ <Button variant="outline" size="sm" onClick={() => void store.logout(serverId)}>
+ Sign out
+ </Button>
</div>
</div>
);
diff --git a/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsx b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsx
new file mode 100644
index 000000000..87652481c
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/features/switch-servers/workspace-switcher.tsx
@@ -0,0 +1,200 @@
+import { Check, ChevronsUpDown, Plus } from 'lucide-react';
+import { observer } from 'mobx-react-lite';
+import { useEffect } from 'react';
+import { useNavigate } from '@renderer/lib/layout/navigation-provider';
+import { useShowModal } from '@renderer/lib/modal/modal-provider';
+import { SwitchConsoleMark } from '@renderer/lib/switch-console-mark';
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuGroup,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@renderer/lib/ui/dropdown-menu';
+import { Spinner } from '@renderer/lib/ui/spinner';
+import { cn } from '@renderer/utils/utils';
+import type { SwitchServer } from '@shared/core/switch-servers/switch-servers';
+import { localServerStore } from './local-server-store';
+import { remoteServerStore } from './remote-server-store';
+import { serverIcon } from './server-icon';
+import {
+ ServerAvatar,
+ ServerDriftIndicator,
+ ServerStatusDot,
+ serverDrift,
+ serverPlacementLabel,
+ serverStatusLabel,
+ serverSubtitleLabel,
+} from './server-presentation';
+import { switchServersStore } from './switch-servers-store';
+
+/**
+ * The workspace switcher at the top of the sidebar.
+ *
+ * A server is a workspace: the sidebar, its sessions and everything under them
+ * are scoped to whichever one is active, so exactly one is on screen at a time
+ * and the rest live behind this control. Before it, all servers were listed
+ * side by side and the scoping was left to be inferred from a highlighted row.
+ *
+ * With no servers there is nothing to switch between, so it collapses to the
+ * one action that leads anywhere.
+ */
+export const WorkspaceSwitcher = observer(function WorkspaceSwitcher() {
+ const store = switchServersStore;
+ const { navigate } = useNavigate();
+ const showAddServerModal = useShowModal('addServerModal');
+
+ useEffect(() => {
+ void store.init();
+ void localServerStore.init();
+ void remoteServerStore.init();
+ const onFocus = () => void store.recoverStale();
+ window.addEventListener('focus', onFocus);
+ return () => {
+ window.removeEventListener('focus', onFocus);
+ localServerStore.dispose();
+ remoteServerStore.dispose();
+ };
+ }, [store]);
+
+ const active = store.activeServer;
+
+ if (!active) {
+ return (
+ <div className="px-2">
+ <LocalServerPendingButton />
+ {localServerStore.phase === 'stopped' && (
+ <button
+ type="button"
+ onClick={() => showAddServerModal({})}
+ className="flex w-full items-center gap-2 rounded-lg border border-border px-2.5 py-2 text-sm text-foreground-tertiary hover:bg-background-tertiary-1"
+ >
+ <Plus className="size-4 shrink-0 text-foreground-muted" />
+ Add a server
+ </button>
+ )}
+ </div>
+ );
+ }
+
+ const ActiveIcon = serverIcon(active);
+ const drift = serverDrift(active);
+
+ return (
+ <div className="px-2">
+ <DropdownMenu>
+ <DropdownMenuTrigger
+ render={
+ <button
+ type="button"
+ aria-label="Switch server"
+ className="flex w-full items-center gap-2 rounded-lg border border-border px-2 py-1.5 text-left hover:bg-background-tertiary-1"
+ >
+ <ServerAvatar server={active} size="md" />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-sm font-medium text-foreground">
+ {active.name}
+ </span>
+ <span className="flex items-center gap-1.5 text-xs text-foreground-muted">
+ <ActiveIcon className="size-3 shrink-0" />
+ <span className="truncate">{serverSubtitleLabel(active)}</span>
+ <ServerStatusDot server={active} />
+ {drift && <ServerDriftIndicator drift={drift} />}
+ </span>
+ </span>
+ <ChevronsUpDown className="size-3.5 shrink-0 text-foreground-muted" />
+ </button>
+ }
+ />
+ <DropdownMenuContent align="start" className="min-w-72">
+ <DropdownMenuGroup>
+ <DropdownMenuLabel className="text-xs font-medium text-foreground-passive">
+ Servers
+ </DropdownMenuLabel>
+ {store.servers.map((server) => (
+ <ServerMenuItem key={server.id} server={server} />
+ ))}
+ </DropdownMenuGroup>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onClick={() => showAddServerModal({})}>
+ <Plus className="size-4" />
+ Add server
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ {/* The welcome screen is what the app opens with before any server
+ exists; once one does, this is how it stays reachable. */}
+ <DropdownMenuItem onClick={() => navigate('home')}>
+ <SwitchConsoleMark size={16} />
+ About Switch
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ );
+});
+
+/**
+ * A managed local stack that is starting has no server record yet, so it would
+ * otherwise be invisible until it is healthy — and a failed setup invisible
+ * forever.
+ */
+const LocalServerPendingButton = observer(function LocalServerPendingButton() {
+ const showAddServerModal = useShowModal('addServerModal');
+ const phase = localServerStore.phase;
+ if (phase === 'stopped') return null;
+ const failed = phase === 'error';
+
+ return (
+ <button
+ type="button"
+ onClick={() => showAddServerModal({ mode: 'local' })}
+ className="flex w-full items-center gap-2 rounded-lg border border-border px-2.5 py-2 text-sm text-foreground-tertiary hover:bg-background-tertiary-1"
+ >
+ <span className="min-w-0 flex-1 truncate text-left">
+ {failed ? 'Local server (setup failed)' : 'Local Switch server'}
+ </span>
+ <span
+ aria-hidden
+ className={cn('size-1.5 shrink-0 rounded-full', failed ? 'bg-red-500' : 'bg-amber-500')}
+ />
+ {phase === 'starting' && <Spinner className="size-3.5 shrink-0" />}
+ </button>
+ );
+});
+
+const ServerMenuItem = observer(function ServerMenuItem({ server }: { server: SwitchServer }) {
+ const store = switchServersStore;
+ const { navigate } = useNavigate();
+ const Icon = serverIcon(server);
+ const placement = serverPlacementLabel(server);
+ const drift = serverDrift(server);
+ const isActive = store.activeServerId === server.id;
+
+ return (
+ <DropdownMenuItem
+ onClick={() => {
+ void store.setActive(server.id);
+ navigate('server', { serverId: server.id });
+ }}
+ >
+ <ServerAvatar server={server} size="sm" />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-sm text-foreground">{server.name}</span>
+ <span className="flex min-w-0 items-center gap-1.5 text-xs text-foreground-muted">
+ <Icon className="size-3 shrink-0" />
+ <span className="truncate">{serverStatusLabel(server)}</span>
+ {placement && (
+ <span className="shrink-0 rounded bg-background-tertiary px-1 py-px text-[10px] font-medium tracking-wide text-foreground-muted uppercase">
+ {placement}
+ </span>
+ )}
+ </span>
+ </span>
+ {drift && <ServerDriftIndicator drift={drift} />}
+ <ServerStatusDot server={server} />
+ {isActive && <Check className="size-3.5 shrink-0 text-foreground" />}
+ </DropdownMenuItem>
+ );
+});
diff --git a/console/apps/switch-console-desktop/src/renderer/index.css b/console/apps/switch-console-desktop/src/renderer/index.css
index 19d1d533f..000544b31 100644
--- a/console/apps/switch-console-desktop/src/renderer/index.css
+++ b/console/apps/switch-console-desktop/src/renderer/index.css
@@ -799,6 +799,19 @@
@apply bg-background text-foreground;
}
+ /* Tailwind's reset gives buttons the arrow cursor, on the reasoning that a
+ native app's controls do not use a hand. This app is full of controls that
+ look like nothing until you hover them — sidebar rows, icon buttons, menu
+ entries — so the hand is the only thing distinguishing what can be clicked
+ from what is only being displayed. Sits in `base` so any `cursor-*`
+ utility on the element still wins. */
+ button:not(:disabled),
+ summary,
+ [role='button']:not([aria-disabled='true']),
+ label[for] {
+ cursor: pointer;
+ }
+
::selection {
background-color: color-mix(in srgb, var(--selection) 35%, transparent);
color: var(--selection-foreground);
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/components/titlebar/titlebar-breadcrumb.tsx b/console/apps/switch-console-desktop/src/renderer/lib/components/titlebar/titlebar-breadcrumb.tsx
new file mode 100644
index 000000000..fa8bde2db
--- /dev/null
+++ b/console/apps/switch-console-desktop/src/renderer/lib/components/titlebar/titlebar-breadcrumb.tsx
@@ -0,0 +1,66 @@
+import type { ReactNode } from 'react';
+import { Fragment } from 'react';
+import { cn } from '@renderer/utils/utils';
+
+/**
+ * One step of a titlebar trail. `onClick` makes the step navigable; the last
+ * step is where you already are, so it never takes one.
+ */
+export type TitlebarCrumb = {
+ key: string;
+ icon?: ReactNode;
+ label: string;
+ onClick?: () => void;
+ /** How much of the label to show before truncating. Defaults to a shared cap. */
+ maxWidthClassName?: string;
+};
+
+/**
+ * The trail in the titlebar saying where you are — server, agent, room,
+ * session, in whatever depth the page actually knows.
+ *
+ * One component rather than one per page: the trail was hand-rolled four times
+ * over, in four shapes, and the pages had begun to disagree about the same
+ * objects — a room was "server / room" in one place and unlabelled in another.
+ */
+export function TitlebarBreadcrumb({ crumbs }: { crumbs: readonly TitlebarCrumb[] }) {
+ return (
+ <div className="flex min-w-0 items-center gap-1.5 px-2 text-sm">
+ {crumbs.map((crumb, index) => {
+ const isLast = index === crumbs.length - 1;
+ const content = (
+ <>
+ {crumb.icon}
+ <span className={cn('truncate', crumb.maxWidthClassName ?? 'max-w-56')}>
+ {crumb.label}
+ </span>
+ </>
+ );
+
+ return (
+ <Fragment key={crumb.key}>
+ {index > 0 && <span className="text-foreground-passive">/</span>}
+ {crumb.onClick && !isLast ? (
+ <button
+ type="button"
+ onClick={crumb.onClick}
+ className="flex min-w-0 items-center gap-1.5 text-foreground-muted hover:text-foreground"
+ >
+ {content}
+ </button>
+ ) : (
+ <span
+ className={cn(
+ 'flex min-w-0 items-center gap-1.5',
+ isLast ? 'text-foreground' : 'text-foreground-muted'
+ )}
+ >
+ {content}
+ </span>
+ )}
+ </Fragment>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/combobox.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/combobox.tsx
index e38284891..4b0b0b45a 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/combobox.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/combobox.tsx
@@ -153,7 +153,7 @@ function ComboboxItem({
<ComboboxPrimitive.Item
data-slot="combobox-item"
className={cn(
- "relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none not-data-selected:data-highlighted:bg-background-quaternary-1 data-selected:bg-background-quaternary-2 data-highlighted:text-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none not-data-selected:data-highlighted:bg-background-quaternary-1 data-selected:bg-background-quaternary-2 data-highlighted:text-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/context-menu.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/context-menu.tsx
index e6e77d824..52207b5c6 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/context-menu.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/context-menu.tsx
@@ -93,7 +93,7 @@ function ContextMenuItem({
data-inset={inset}
data-variant={variant}
className={cn(
- "group/context-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-background-2 focus:text-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",
+ "group/context-menu-item relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-background-2 focus:text-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",
className
)}
{...props}
@@ -118,7 +118,7 @@ function ContextMenuSubTrigger({
data-slot="context-menu-sub-trigger"
data-inset={inset}
className={cn(
- "flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "flex cursor-pointer items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
@@ -154,7 +154,7 @@ function ContextMenuCheckboxItem({
data-slot="context-menu-checkbox-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
checked={checked}
@@ -187,7 +187,7 @@ function ContextMenuRadioItem({
data-slot="context-menu-radio-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/dropdown-menu.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/dropdown-menu.tsx
index 0f7d3edc6..708a2c95e 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/dropdown-menu.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/dropdown-menu.tsx
@@ -85,7 +85,7 @@ function DropdownMenuItem({
data-inset={inset}
data-variant={variant}
className={cn(
- "group/dropdown-menu-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-foreground-destructive data-[variant=destructive]:focus:bg-background-destructive data-[variant=destructive]:focus:text-foreground-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
+ "group/dropdown-menu-item relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-[variant=destructive]:text-foreground-destructive data-[variant=destructive]:focus:bg-background-destructive data-[variant=destructive]:focus:text-foreground-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
className
)}
{...props}
@@ -110,7 +110,7 @@ function DropdownMenuSubTrigger({
data-slot="dropdown-menu-sub-trigger"
data-inset={inset}
className={cn(
- "flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-8 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
@@ -156,7 +156,7 @@ function DropdownMenuCheckboxItem({
data-slot="dropdown-menu-checkbox-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default data-checked:text-foreground data-checked:bg-background-quaternary-2 text-foreground-muted items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-foreground focus:**:text-muted-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-pointer data-checked:text-foreground data-checked:bg-background-quaternary-2 text-foreground-muted items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-foreground focus:**:text-muted-foreground data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
checked={checked}
@@ -192,7 +192,7 @@ function DropdownMenuRadioItem({
data-slot="dropdown-menu-radio-item"
data-inset={inset}
className={cn(
- "relative flex cursor-default data-checked:text-foreground data-checked:bg-background-quaternary-2 items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-foreground focus:**:text-foreground text-foreground-muted data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "relative flex cursor-pointer data-checked:text-foreground data-checked:bg-background-quaternary-2 items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-foreground focus:**:text-foreground text-foreground-muted data-inset:pl-8 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/label.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/label.tsx
index 7fecc947f..e5abcaa67 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/label.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/label.tsx
@@ -27,4 +27,25 @@ export function MicroLabel({ className, ...props }: React.ComponentProps<'label'
);
}
+/**
+ * The heading over a section of a panel — the sidebar's groups, the setup
+ * checklist.
+ *
+ * Set in the interface face rather than {@link MicroLabel}'s monospace, and
+ * not shouted: at this size caps read as noise rather than as hierarchy, and
+ * the monospace belongs to card and dialog headers.
+ */
+export function SectionLabel({ className, ...props }: React.ComponentProps<'label'>) {
+ return (
+ <label
+ data-slot="label"
+ className={cn(
+ 'cursor-default text-xs font-medium text-foreground-passive select-none',
+ className
+ )}
+ {...props}
+ />
+ );
+}
+
export { Label };
diff --git a/console/apps/switch-console-desktop/src/renderer/lib/ui/select.tsx b/console/apps/switch-console-desktop/src/renderer/lib/ui/select.tsx
index a63e9de69..2b2247245 100644
--- a/console/apps/switch-console-desktop/src/renderer/lib/ui/select.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/lib/ui/select.tsx
@@ -114,7 +114,7 @@ function SelectItem({ className, children, ...props }: SelectPrimitive.Item.Prop
<SelectPrimitive.Item
data-slot="select-item"
className={cn(
- "relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
+ "relative flex w-full cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-background-quaternary-1 focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
className
)}
{...props}
diff --git a/console/apps/switch-console-desktop/src/renderer/tests/browser/messaging-app-row.test.tsx b/console/apps/switch-console-desktop/src/renderer/tests/browser/messaging-app-row.test.tsx
index a73c3d77a..2a739f8a4 100644
--- a/console/apps/switch-console-desktop/src/renderer/tests/browser/messaging-app-row.test.tsx
+++ b/console/apps/switch-console-desktop/src/renderer/tests/browser/messaging-app-row.test.tsx
@@ -196,37 +196,16 @@ describe('the row menu', () => {
});
it('opens on a platform that cannot create channels at all', async () => {
- // Telegram. The explanatory line under the channel toggle was a menu
- // *label*, which Base UI requires to sit inside a group — so opening this
- // menu threw and took the page down with it. Every other case here has a
- // platform that supports channel creation, which is how it got through.
+ // Telegram. The explanation used to be a menu *label*, which Base UI
+ // requires to sit inside a group — so opening this menu threw and took the
+ // page down with it. Every other case here has a platform that supports
+ // channel creation, which is how it got through. The toggle has since moved
+ // out to a column of its own; the menu must still open.
const el = await render(
row({ bridge: bridge({ channelCreationSupported: false, canCreateChannels: false }) })
);
- expect(await openMenu(el)).toContain('Can create channels');
- });
-
- it('says a platform cannot create channels rather than just showing it off', async () => {
- // An unticked disabled box reads as "switched off", which is a different
- // claim from "this platform has no such thing".
- const el = await render(
- row({ bridge: bridge({ channelCreationSupported: false, canCreateChannels: false }) })
- );
- await openMenu(el);
-
- const menu = document.querySelector('[role="menu"]');
- expect(menu!.textContent).toContain('Slack cannot create channels from Switch');
- });
-
- it('leaves the channel toggle alone for a non-admin', async () => {
- const el = await render(row({ isAdmin: false }));
- await openMenu(el);
-
- const item = [...document.querySelectorAll('[role="menuitemcheckbox"]')].find((i) =>
- i.textContent?.includes('Can create channels')
- );
- expect(item!.getAttribute('data-disabled')).not.toBeNull();
+ expect(await openMenu(el)).toContain('Link my account…');
});
it('asks before disconnecting rather than doing it on the click', async () => {
@@ -244,3 +223,46 @@ describe('the row menu', () => {
expect(onDisconnect).toHaveBeenCalledTimes(1);
});
});
+
+/**
+ * Channel creation moved out of the row menu into a column of the table
+ * (CHOO-2158), so it can be read down the page rather than opened one row at a
+ * time. What it has to say did not change with the shape.
+ */
+describe('the channel-creation column', () => {
+ function channelSwitch(el: HTMLElement): HTMLElement {
+ const found = el.querySelector<HTMLElement>('[aria-label^="Let Switch create channels"]');
+ expect(found).not.toBeNull();
+ return found!;
+ }
+
+ it('puts the toggle on the row rather than behind the menu', async () => {
+ const el = await render(row({ isAdmin: true }));
+
+ expect(channelSwitch(el).getAttribute('aria-checked')).toBe('true');
+ expect(await openMenu(el)).not.toContain('Can create channels');
+ });
+
+ it('says a platform cannot create channels rather than just showing it off', async () => {
+ // An unticked disabled switch reads as "switched off", which is a different
+ // claim from "this platform has no such thing".
+ const el = await render(
+ row({ bridge: bridge({ channelCreationSupported: false, canCreateChannels: false }) })
+ );
+
+ expect(el.textContent).toContain('Not supported');
+ expect(el.textContent).not.toContain('Off');
+ });
+
+ it('leaves the toggle alone for a non-admin', async () => {
+ const el = await render(row({ isAdmin: false }));
+
+ expect(channelSwitch(el).getAttribute('data-disabled')).not.toBeNull();
+ });
+
+ it('lets an admin move it', async () => {
+ const el = await render(row({ isAdmin: true }));
+
+ expect(channelSwitch(el).getAttribute('data-disabled')).toBeNull();
+ });
+});
diff --git a/console/apps/switch-console-desktop/src/shared/core/providers/agent-provider-registry.ts b/console/apps/switch-console-desktop/src/shared/core/providers/agent-provider-registry.ts
index 701940328..ddff2443b 100644
--- a/console/apps/switch-console-desktop/src/shared/core/providers/agent-provider-registry.ts
+++ b/console/apps/switch-console-desktop/src/shared/core/providers/agent-provider-registry.ts
@@ -700,6 +700,17 @@ export function isValidProviderSessionId(providerId: string, providerSessionId:
return true;
}
+/**
+ * What a provider is called in the interface — "Claude Code", not the `claude`
+ * we key it by. An id this build does not know is returned as it stands: it
+ * came from a real agent row, and showing it is more use than showing nothing.
+ */
+export function providerDisplayName(id: string | null | undefined): string | null {
+ if (!id) return null;
+ if (!isValidProviderId(id)) return id;
+ return PROVIDER_MAP.get(id)?.name ?? id;
+}
+
export function getDescriptionForProvider(id: AgentProviderId): string | null {
return PROVIDER_MAP.get(id)?.description ?? null;
}