The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): scope gateway context to Sessions
David Dudok de Witc41ec9c58830
diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsxindex 7ae606241fb..fe9ef7afd58 100644--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx@@ -161,6 +161,24 @@ describe('ConnectionSwitcher', () => {expect(selectConnection).toHaveBeenCalledTimes(1)})+ it('fits the shared statusbar slot without changing its gateway identity', () => {+ $connectionsRegistry.set(registry([connection('local', 'This device', 'local'), connection('homelab', 'Homelab')]))+ render(<ConnectionSwitcher compact onConnect={onConnect} />)++ const group = screen.getByRole('group', { name: 'Registered gateways' })+ const trigger = screen.getByRole('button', { name: 'Registered gateways: This device' })++ expect(group.className).toContain('h-full')+ expect(group.className).toContain('min-w-20')+ expect(group.className).toContain('max-w-40')+ expect(group.className).toContain('shrink')+ expect(group.className).toContain('overflow-hidden')+ expect(trigger.className).toContain('text-[0.6875rem]')+ expect(trigger.className).toContain('min-w-0')+ expect(trigger.className).toContain('overflow-hidden')+ expect(trigger.textContent).toContain('This device')+ })+it('keeps source controls stable while a remote is opening', () => {$connectionsRegistry.set(registry([connection('local', 'This device', 'local'), connection('homelab', 'Homelab')]))$pendingConnectionId.set('homelab')diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.tsxindex 87c81f610dd..9c7a398d763 100644--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx@@ -37,7 +37,7 @@ import {import { closeFindBar } from '@/store/find-in-page'import { notifyError } from '@/store/notifications'-export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {+export function ConnectionSwitcher({ compact = false, onConnect }: { compact?: boolean; onConnect: () => void }) {const { t } = useI18n()const registry = useStore($connectionsRegistry)const activeConnectionId = useStore($activeConnectionId)@@ -132,7 +132,7 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {<divaria-busy={pendingConnectionId !== null}aria-label={t.settings.connections.title}- className="min-w-20 max-w-[46%] shrink overflow-hidden"+ className={cn('min-w-20 shrink overflow-hidden', compact ? 'h-full max-w-40' : 'max-w-72')}data-slot="connection-switcher"role="group">@@ -149,6 +149,7 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {<DropdownMenuTrigger asChild><ConnectionSwitcherTriggeractiveConnection={activeConnection}+ compact={compact}pending={pendingConnectionId !== null}title={t.settings.connections.title}/>@@ -230,7 +231,10 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {)}</DropdownMenuRadioGroup><DropdownMenuSeparator className={searchable ? 'm-0' : undefined} />- <DropdownMenuItem className={searchable ? dropdownMenuRow : undefined} onSelect={onConnect}>+ <DropdownMenuItem+ className={searchable ? dropdownMenuRow : undefined}+ onSelect={onConnect}+ ><ManageGatewaysLabel label={t.profiles.connectGateway} /></DropdownMenuItem></DropdownMenuContent>@@ -241,12 +245,14 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {interface ConnectionMenuProps {activeConnection?: DesktopRegistryConnection+ compact: booleanpending: booleantitle: string}function ConnectionSwitcherTrigger({activeConnection,+ compact,pending,title,...triggerProps@@ -257,6 +263,7 @@ function ConnectionSwitcherTrigger({aria-label={activeConnection ? `${title}: ${activeConnection.label}` : title}className={cn('w-full min-w-0 justify-between overflow-hidden px-1 text-(--ui-text-secondary) data-[state=open]:bg-(--ui-control-active-background) data-[state=open]:text-foreground',+ compact && 'h-full min-h-0 rounded-none px-1.5 text-[0.6875rem] font-normal',triggerProps.className)}size="xs"diff --git a/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsx b/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsxindex bc2414284dc..5a0d2b0a938 100644--- a/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-rail-connect.test.tsx@@ -59,8 +59,6 @@ vi.mock('@/store/profile', () => ({vi.mock('@/store/connections', () => ({ $hasMultipleConnections: atom(false) }))-vi.mock('./connection-switcher', () => ({ ConnectionSwitcher: () => null }))-vi.mock('@/store/profile-share', () => ({runExportProfileFlow: vi.fn(),runImportProfileFlow: vi.fn()@@ -110,11 +108,11 @@ describe('ProfileRail multi-gateway entry point', () => {expect(screen.getByRole('button', { name: 'Manage profiles…' })).toBeTruthy()})- it('does not duplicate the default home when source buttons identify multiple single-profile backends', () => {+ it('keeps the active profile explicit when gateway identity moves to the statusbar', () => {hasMultipleConnections.set(true)render(<ProfileRail />)- expect(screen.queryByRole('button', { name: 'default' })).toBeNull()+ expect(screen.getByRole('button', { name: 'default' })).toBeTruthy()expect(screen.queryByRole('button', { name: 'Manage gateways…' })).toBeNull()expect(screen.getByRole('button', { name: 'Manage profiles…' })).toBeTruthy()})@@ -139,7 +137,7 @@ describe('ProfileRail multi-gateway entry point', () => {expect(screen.getByRole('button', { name: 'Profiles' })).toBeTruthy()})- it('stays shrinkable when source and condensed profile controls coexist', () => {+ it('stays shrinkable with many profiles and multiple gateways', () => {hasMultipleConnections.set(true)profiles.set([{ is_default: true, name: 'default' },diff --git a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsxindex 924bda27cdf..5b86c788f5c 100644--- a/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx+++ b/apps/desktop/src/app/chat/sidebar/profile-switcher.tsx@@ -78,7 +78,6 @@ import { DeleteProfileDialog } from '../../profiles/delete-profile-dialog'import { RenameProfileDialog } from '../../profiles/rename-profile-dialog'import { PROFILES_ROUTE, SETTINGS_ROUTE } from '../../routes'-import { ConnectionSwitcher } from './connection-switcher'import { useProfilePrewarm } from './use-profile-prewarm'import { useProfileRailRefreshOnActive } from './use-profile-rail-refresh-on-active'@@ -114,11 +113,9 @@ const stepThroughCells: Modifier = ({ containerNodeRect, draggingNodeRect, trans// Arc-Spaces-style profile rail at the sidebar foot: a default↔all toggle pinned// left, the colored named profiles scrolling between, and Manage pinned right.-// The active profile pops in its own color — the "where am I" cue. Single--// source users see the default home, "+", and Manage. With several sources, a-// named environment selector sits before a separator; square profile identities-// follow it. Colored named squares and the default↔all toggle only appear once-// a second profile exists on the active source.+// The active profile pops in its own color — the "where am I" cue. Gateway+// identity lives in the statusbar, so this strip remains entirely available to+// profiles regardless of how many backends are registered.export function ProfileRail() {const { t } = useI18n()const p = t.profiles@@ -243,8 +240,6 @@ export function ProfileRail() {return (<div aria-label={p.title} className="flex min-w-0 items-center gap-0.5" data-slot="profile-rail" role="group">- <ConnectionSwitcher onConnect={() => navigate(`${SETTINGS_ROUTE}?tab=connections`)} />- {multipleConnections && <span aria-hidden="true" className="mx-0.5 h-3.5 w-px bg-(--ui-stroke-tertiary)" />}{/* One button toggles default ↔ all: home face when scoped to a profile,layers face when showing everything. Pinned left like Manage is right.Hidden until a second profile exists. */}@@ -263,7 +258,7 @@ export function ProfileRail() {))}{/* Single-profile: the active default's home icon next to the create +. */}- {!multipleConnections && !multiProfile && defaultProfile && (+ {!multiProfile && defaultProfile && (<ProfilePillactiveglyph="home"diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsxindex 4a0fffb0872..65e770819fa 100644--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx@@ -1,6 +1,8 @@import { useStore } from '@nanostores/react'import { useMemo } from 'react'+import { useNavigate } from 'react-router'+import { ConnectionSwitcher } from '@/app/chat/sidebar/connection-switcher'import type { CommandCenterSection } from '@/app/command-center'import { useApprovalModeStatusbarItem } from '@/app/shell/approval-mode-menu'import { ContextUsagePanel } from '@/app/shell/context-usage-panel'@@ -48,7 +50,7 @@ import {} from '@/store/updates'import type { StatusResponse, UsageStats } from '@/types/hermes'-import { CRON_ROUTE, WEBHOOKS_ROUTE } from '../../routes'+import { CRON_ROUTE, SETTINGS_ROUTE, WEBHOOKS_ROUTE } from '../../routes'import type { StatusbarItem } from '../statusbar-controls'const EMPTY_USAGE: UsageStats = { calls: 0, input: 0, output: 0, total: 0 }@@ -92,6 +94,8 @@ export function useStatusbarItems({// the takeover store alone stays true behind a stacked sibling tab or a// minimized zone, which lit the button for a pane the user couldn't see.const terminalShowing = useStore($paneVisible('terminal'))+ const sessionsShowing = useStore($paneVisible('sessions'))+ const botsShowing = useStore($paneVisible('hermes-bots:pane'))const primaryBusy = useStore($busy)// Draft / primary composer atom — used only while the focused surface is the// primary (or a draft with no runtime slice yet). A focused TILE keeps its@@ -400,9 +404,16 @@ export function useStatusbarItems({toggleLabel: copy.toggleCommandCenter,variant: 'action'},+ {+ hidden: !sessionsShowing,+ id: 'gateway-switcher',+ lockedVisible: true,+ render: () => <StatusbarGatewaySwitcher />+ },{className: gatewayRestarting ? undefined : gatewayClassName,detail: gatewayRestarting ? copy.gatewayRestarting : gatewayDetail,+ hidden: botsShowing,icon: gatewayRestarting ? (<GlyphSpinner ariaLabel={copy.gatewayRestarting} className="size-3" />) : inferenceReady ? (@@ -498,6 +509,7 @@ export function useStatusbarItems({],[agentsOpen,+ botsShowing,commandCenterOpen,copy,currentCwd,@@ -512,6 +524,7 @@ export function useStatusbarItems({inferenceStatus?.reason,openAgents,projectName,+ sessionsShowing,subagentsFailed,subagentsRunning,toggleCommandCenter@@ -600,3 +613,9 @@ export function useStatusbarItems({return { leftStatusbarItems, statusbarItems }}++function StatusbarGatewaySwitcher() {+ const navigate = useNavigate()++ return <ConnectionSwitcher compact onConnect={() => navigate(`${SETTINGS_ROUTE}?tab=connections`)} />+}