The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): keep gateway details contextual
David Dudok de Wit6e9e12075cf0
diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsxindex a490a2eaac2..4ef8ab9ec89 100644--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.test.tsx@@ -45,7 +45,7 @@ vi.mock('@/i18n', () => ({profiles: {switchConnectionFailed: (name: string) => `Could not connect to ${name}`,switchToConnection: (name: string) => `Switch to ${name}`,- connectGateway: 'Connect another Hermes gateway…'+ connectGateway: 'Manage gateways…'},settings: {connections: {@@ -154,7 +154,7 @@ describe('ConnectionSwitcher', () => {expect(selectConnection).toHaveBeenCalledWith('homelab')fireEvent.pointerDown(trigger, { button: 0, pointerType: 'mouse' })- fireEvent.click(screen.getByRole('menuitem', { name: 'Connect another Hermes gateway…' }))+ fireEvent.click(screen.getByRole('menuitem', { name: 'Manage gateways…' }))expect(onConnect).toHaveBeenCalledTimes(1)expect(selectConnection).toHaveBeenCalledTimes(1)})@@ -229,7 +229,7 @@ describe('ConnectionSwitcher', () => {})const search = screen.getByPlaceholderText('Search gateways…')- expect(screen.getByRole('menuitem', { name: 'Connect another Hermes gateway…' })).toBeTruthy()+ expect(screen.getByRole('menuitem', { name: 'Manage gateways…' })).toBeTruthy()expect(screen.getAllByRole('menuitemradio').map(item => item.textContent)).toEqual(['This device','Alpha',@@ -282,7 +282,7 @@ describe('ConnectionSwitcher', () => {fireEvent.change(screen.getByPlaceholderText('Search gateways…'), { target: { value: 'missing' } })expect(screen.getByText('No gateways match your search.')).toBeTruthy()- expect(screen.getByRole('menuitem', { name: 'Connect another Hermes gateway…' })).toBeTruthy()+ expect(screen.getByRole('menuitem', { name: 'Manage gateways…' })).toBeTruthy()expect(globalThis.document.querySelector('[data-slot="dropdown-menu-radio-group"]')?.className).toContain('h-48')})diff --git a/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx b/apps/desktop/src/app/chat/sidebar/connection-switcher.tsxindex 567fb93c03b..c0b4f861412 100644--- a/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx+++ b/apps/desktop/src/app/chat/sidebar/connection-switcher.tsx@@ -19,6 +19,7 @@ import { useI18n } from '@/i18n'import {CONNECTION_SEARCH_THRESHOLD,connectionMatchesQuery,+ connectionTooltip,sortConnectionsForDisplay} from '@/lib/connection-display'import { triggerHaptic } from '@/lib/haptics'@@ -194,10 +195,6 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {<DropdownMenuSeparator className="m-0" /></>)}- <DropdownMenuItem className={searchable ? dropdownMenuRow : undefined} onSelect={onConnect}>- <ConnectGatewayLabel label={t.profiles.connectGateway} />- </DropdownMenuItem>- <DropdownMenuSeparator className={searchable ? 'm-0' : undefined} /><DropdownMenuRadioGroupclassName={searchable@@ -227,6 +224,10 @@ export function ConnectionSwitcher({ onConnect }: { onConnect: () => void }) {)))}</DropdownMenuRadioGroup>+ <DropdownMenuSeparator className={searchable ? 'm-0' : undefined} />+ <DropdownMenuItem className={searchable ? dropdownMenuRow : undefined} onSelect={onConnect}>+ <ManageGatewaysLabel label={t.profiles.connectGateway} />+ </DropdownMenuItem></DropdownMenuContent></DropdownMenu></div>@@ -270,10 +271,10 @@ function ConnectionSwitcherTrigger({)}-function ConnectGatewayLabel({ label }: { label: string }) {+function ManageGatewaysLabel({ label }: { label: string }) {return (<span className="flex min-w-0 items-center gap-1.5 text-(--ui-text-secondary)">- <Codicon aria-hidden="true" name="plug" size="0.875rem" />+ <Codicon aria-hidden="true" name="settings-gear" size="0.875rem" /><span className="truncate">{label}</span></span>)@@ -303,7 +304,7 @@ function ConnectionGlyph({ connection }: { connection: DesktopRegistryConnectionfunction ConnectionLabel({ connection }: { connection: DesktopRegistryConnection }) {return (- <span className="flex min-w-0 flex-1 items-center gap-1 overflow-hidden" title={connection.label}>+ <span className="flex min-w-0 flex-1 items-center gap-1 overflow-hidden" title={connectionTooltip(connection)}><ConnectionGlyph connection={connection} /><span className="truncate">{connection.label}</span></span>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 324008803cc..bc2414284dc 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@@ -21,7 +21,7 @@ vi.mock('@/i18n', () => ({common: { cancel: 'Cancel' },profiles: {allProfiles: 'All profiles',- connectGateway: 'Connect another Hermes gateway…',+ connectGateway: 'Manage gateways…',failedLoadSoul: 'Failed to load SOUL.md',failedSaveSoul: 'Failed to save SOUL.md',importProfile: 'Import profile…',@@ -95,7 +95,7 @@ describe('ProfileRail multi-gateway entry point', () => {it('deep-links to the unified Settings → Gateways page from the rail', () => {render(<ProfileRail />)- const pill = screen.getByRole('button', { name: 'Connect another Hermes gateway…' })+ const pill = screen.getByRole('button', { name: 'Manage gateways…' })fireEvent.click(pill)expect(navigate).toHaveBeenCalledWith('/settings?tab=gateway')@@ -106,7 +106,7 @@ describe('ProfileRail multi-gateway entry point', () => {// The whole point is first-run discoverability: the pill must not be// gated behind multiProfile the way the default↔all toggle is.- expect(screen.getByRole('button', { name: 'Connect another Hermes gateway…' })).toBeTruthy()+ expect(screen.getByRole('button', { name: 'Manage gateways…' })).toBeTruthy()expect(screen.getByRole('button', { name: 'Manage profiles…' })).toBeTruthy()})@@ -115,7 +115,7 @@ describe('ProfileRail multi-gateway entry point', () => {render(<ProfileRail />)expect(screen.queryByRole('button', { name: 'default' })).toBeNull()- expect(screen.queryByRole('button', { name: 'Connect another Hermes gateway…' })).toBeNull()+ expect(screen.queryByRole('button', { name: 'Manage gateways…' })).toBeNull()expect(screen.getByRole('button', { name: 'Manage profiles…' })).toBeTruthy()})diff --git a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsxindex 98fd2dce5e8..4a0fffb0872 100644--- a/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx+++ b/apps/desktop/src/app/shell/hooks/use-statusbar-items.tsx@@ -48,7 +48,7 @@ import {} from '@/store/updates'import type { StatusResponse, UsageStats } from '@/types/hermes'-import { CRON_ROUTE, SETTINGS_ROUTE, WEBHOOKS_ROUTE } from '../../routes'+import { CRON_ROUTE, WEBHOOKS_ROUTE } from '../../routes'import type { StatusbarItem } from '../statusbar-controls'const EMPTY_USAGE: UsageStats = { calls: 0, input: 0, output: 0, total: 0 }@@ -386,34 +386,8 @@ export function useStatusbarItems({copy])- const connectionItem = useMemo<StatusbarItem | null>(() => {- if (connection?.mode !== 'remote' || !connection.remoteHost) {- return null- }-- const ssh = connection.remoteKind === 'ssh'- const cloud = connection.remoteKind === 'cloud'-- return {- className: cn(- 'px-2 -ml-1 font-medium',- ssh ? 'bg-primary text-primary-foreground' : 'bg-accent text-accent-foreground'- ),- icon: <Terminal className="size-3" />,- id: 'connection',- label: ssh- ? copy.connectionSsh(connection.remoteHost)- : cloud- ? copy.connectionCloud(connection.remoteHost)- : copy.connectionRemote(connection.remoteHost),- // Label already names the host — no "click to manage" tip lecture.- to: `${SETTINGS_ROUTE}?tab=gateway`- }- }, [connection?.mode, connection?.remoteHost, connection?.remoteKind, copy])-const coreLeftStatusbarItems = useMemo<readonly StatusbarItem[]>(() => [- ...(connectionItem ? [connectionItem] : []),{className: `w-7 justify-center px-0${commandCenterOpen ? ' bg-accent/55 text-foreground' : ''}`,icon: <Command className="size-3.5" />,@@ -525,7 +499,6 @@ export function useStatusbarItems({[agentsOpen,commandCenterOpen,- connectionItem,copy,currentCwd,fileMenu.copyPath,diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex e1bebe59de7..ad364fd8ea6 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -1772,7 +1772,7 @@ export const en: Translations = {switchToConnection: name => `Switch to ${name}`,switchConnectionFailed: name => `Could not connect to ${name}`,manageProfiles: 'Manage profiles…',- connectGateway: 'Connect another Hermes gateway…',+ connectGateway: 'Manage gateways…',actions: 'Actions',color: 'Color…',colorFor: 'Color',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex ea4284a485a..84ac8a0c91b 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -1959,7 +1959,7 @@ export const zh: Translations = {switchToConnection: name => `切换到 ${name}`,switchConnectionFailed: name => `无法连接到 ${name}`,manageProfiles: '管理配置档案…',- connectGateway: '连接另一个 Hermes 网关…',+ connectGateway: '管理网关…',actions: '操作',color: '颜色…',colorFor: '颜色',diff --git a/apps/desktop/src/lib/connection-display.test.ts b/apps/desktop/src/lib/connection-display.test.tsindex 74ab5803865..27b4c671ed8 100644--- a/apps/desktop/src/lib/connection-display.test.ts+++ b/apps/desktop/src/lib/connection-display.test.ts@@ -2,7 +2,12 @@ import { describe, expect, it } from 'vitest'import type { DesktopRegistryConnection } from '@/global'-import { connectionMatchesQuery, sortConnectionsForDisplay } from './connection-display'+import {+ connectionEndpoint,+ connectionMatchesQuery,+ connectionTooltip,+ sortConnectionsForDisplay+} from './connection-display'const connection = (id: string,@@ -51,4 +56,27 @@ describe('connection display helpers', () => {expect(connectionMatchesQuery(gateway, 'distant', ['Passerelle distante'])).toBe(true)expect(connectionMatchesQuery(gateway, 'homelab')).toBe(false)})++ it('keeps technical endpoints available on demand without exposing secrets', () => {+ const remote = {+ ...connection('work', 'Work gateway'),+ tokenPreview: 'sec...ret',+ tokenSet: true,+ url: 'https://work.example.test:9443'+ }+ const ssh = {+ ...connection('studio', 'Studio over SSH', 'ssh'),+ host: 'studio.example.test',+ keyPath: '/secret/key',+ port: 2222,+ user: 'hermes'+ }++ expect(connectionEndpoint(remote)).toBe('https://work.example.test:9443')+ expect(connectionTooltip(remote)).toBe('Work gateway\nhttps://work.example.test:9443')+ expect(connectionTooltip(remote)).not.toContain('sec...ret')+ expect(connectionEndpoint(ssh)).toBe('[email protected]:2222')+ expect(connectionTooltip(ssh)).not.toContain('/secret/key')+ expect(connectionTooltip(connection('local', 'This device', 'local'))).toBe('This device')+ })})diff --git a/apps/desktop/src/lib/connection-display.ts b/apps/desktop/src/lib/connection-display.tsindex 071e1360cc2..72e8cb23e44 100644--- a/apps/desktop/src/lib/connection-display.ts+++ b/apps/desktop/src/lib/connection-display.ts@@ -56,3 +56,27 @@ export function connectionMatchesQuery(return needles.every(needle => normalizedHaystack.includes(needle))}++/** Human-readable, non-secret endpoint for on-demand gateway details. */+export function connectionEndpoint(connection: DesktopRegistryConnection): null | string {+ if (connection.kind === 'ssh') {+ const host = connection.host?.trim()++ if (!host) {+ return null+ }++ const authority = `${connection.user?.trim() ? `${connection.user.trim()}@` : ''}${host}`++ return connection.port == null ? authority : `${authority}:${connection.port}`+ }++ return connection.url?.trim() || null+}++/** Full gateway identity for a hover tip without keeping technical routing in chrome. */+export function connectionTooltip(connection: DesktopRegistryConnection): string {+ const endpoint = connectionEndpoint(connection)++ return endpoint ? `${connection.label}\n${endpoint}` : connection.label+}