The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(desktop): clarify active and default connections
David Dudok de Wit0ab0ed54ff99
diff --git a/apps/desktop/src/app/settings/connections-registry.test.tsx b/apps/desktop/src/app/settings/connections-registry.test.tsxindex c03f85d6170..53ea1d50986 100644--- a/apps/desktop/src/app/settings/connections-registry.test.tsx+++ b/apps/desktop/src/app/settings/connections-registry.test.tsx@@ -2,6 +2,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/reimport { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { DesktopConnectionsRegistry } from '@/global'+import { $connection } from '@/store/session'import {ConnectionsRegistrySection,@@ -36,6 +37,17 @@ const registry: DesktopConnectionsRegistry = {}beforeEach(() => {+ $connection.set({+ baseUrl: 'http://homelab.lan:9119',+ connectionId: 'homelab',+ isFullscreen: false,+ logs: [],+ mode: 'remote',+ nativeOverlayWidth: 0,+ token: 'test-token',+ windowButtonPosition: null,+ wsUrl: 'ws://homelab.lan:9119/ws'+ })list.mockResolvedValue(registry)save.mockResolvedValue({ connection: registry.connections[1], ok: true, registry })remove.mockResolvedValue({ ok: true, registry: { ...registry, connections: [registry.connections[0]] } })@@ -48,17 +60,19 @@ beforeEach(() => {})afterEach(() => {+ $connection.set(null)cleanup()vi.clearAllMocks()})describe('ConnectionsRegistrySection', () => {- it('lists registered connections with primary + local pills', async () => {+ it('distinguishes the current connection from the registry primary', async () => {render(<ConnectionsRegistrySection />)await waitFor(() => expect(screen.getByText('Homelab')).toBeTruthy())// Label and the managed pill share the copy, so expect both instances.expect(screen.getAllByText('This device').length).toBeGreaterThan(0)+ expect(screen.getByText('Current')).toBeTruthy()expect(screen.getByText('Primary')).toBeTruthy()expect(list).toHaveBeenCalledTimes(1)})diff --git a/apps/desktop/src/app/settings/connections-registry.tsx b/apps/desktop/src/app/settings/connections-registry.tsxindex 6bc7479f1e2..8b385188793 100644--- a/apps/desktop/src/app/settings/connections-registry.tsx+++ b/apps/desktop/src/app/settings/connections-registry.tsx@@ -1,3 +1,4 @@+import { useStore } from '@nanostores/react'import { useCallback, useEffect, useState } from 'react'import { Button } from '@/components/ui/button'@@ -12,7 +13,7 @@ import type {import { useI18n } from '@/i18n'import { triggerHaptic } from '@/lib/haptics'import { Cloud, Globe, Loader2, Monitor, Pencil, Plus, RefreshCw, Terminal, Trash2 } from '@/lib/icons'-import { setConnectionsRegistry } from '@/store/connections'+import { $activeConnectionId, setConnectionsRegistry } from '@/store/connections'import { notify, notifyError } from '@/store/notifications'import { EmptyState, ListRow, Pill, SectionHeading } from './primitives'@@ -201,6 +202,7 @@ export function sameBackendPeerLabel(export function ConnectionsRegistrySection() {const { t } = useI18n()const s = t.settings.connections+ const activeConnectionId = useStore($activeConnectionId)const [registry, setRegistry] = useState<DesktopConnectionsRegistry | null>(null)const [loading, setLoading] = useState(true)const [editor, setEditor] = useState<EditorState | null>(null)@@ -466,6 +468,7 @@ export function ConnectionsRegistrySection() {) : (registry.connections.map(conn => {const Icon = KIND_ICONS[conn.kind]+ const isCurrent = activeConnectionId === conn.idconst isPrimary = registry.primary === conn.idconst busy = busyId === conn.id// Display-only: this connection is a second address for a backend@@ -530,7 +533,8 @@ export function ConnectionsRegistrySection() {<span className="flex items-center gap-2"><Icon className="size-4 shrink-0 text-muted-foreground" /><span className="truncate">{conn.label}</span>- {isPrimary && <Pill tone="primary">{s.primaryPill}</Pill>}+ {isCurrent && <Pill tone="primary">{s.currentPill}</Pill>}+ {isPrimary && <Pill>{s.primaryPill}</Pill>}{conn.kind === 'local' && <Pill>{s.managedPill}</Pill>}</span>}diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 54fe9e05b4b..fdd61711c26 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -707,6 +707,7 @@ export const en: Translations = {stagedNote:'Switch sources from the Sessions sidebar. Profiles, chats, messaging, and cron stay scoped to that source; Primary is the registry default and does not switch your current workspace.',loadFailed: 'Could not load connections',+ currentPill: 'Current',primaryPill: 'Primary',managedPill: 'This device',addConnection: 'Add connection',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 255b4aa5efe..429bb574514 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -593,6 +593,7 @@ export interface Translations {intro: stringstagedNote: stringloadFailed: string+ currentPill: stringprimaryPill: stringmanagedPill: stringaddConnection: stringdiff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex 017f380b25d..b6cba0cfc36 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -911,6 +911,7 @@ export const zh: Translations = {stagedNote:'可在“会话”侧边栏切换来源。配置档案、聊天、消息和定时任务始终限定在所选来源;“主连接”是注册表的默认值,不会切换当前工作区。',loadFailed: '无法加载连接',+ currentPill: '当前',primaryPill: '主连接',managedPill: '本机',addConnection: '添加连接',diff --git a/apps/desktop/src/store/connections.test.ts b/apps/desktop/src/store/connections.test.tsindex 5602cb605c8..0fce2649f14 100644--- a/apps/desktop/src/store/connections.test.ts+++ b/apps/desktop/src/store/connections.test.ts@@ -89,13 +89,13 @@ describe('connection registry cache', () => {expect($activeConnectionId.get()).toBeNull()})- it('uses the resolved descriptor identity for a primary gateway', () => {+ it('uses only the resolved descriptor identity for the active gateway', () => {setConnectionsRegistry({ ...registry, primary: 'homelab' })$connection.set({ connectionId: 'work-vps', mode: 'remote' })expect($activeConnectionId.get()).toBe('work-vps')$connection.set({ mode: 'remote' })- expect($activeConnectionId.get()).toBe('homelab')+ expect($activeConnectionId.get()).toBeNull()$connection.set({ connectionId: 'work-vps', mode: 'remote' })expect($activeConnectionId.get()).toBe('work-vps')diff --git a/apps/desktop/src/store/connections.ts b/apps/desktop/src/store/connections.tsindex 24080a043a7..076ecf14dc0 100644--- a/apps/desktop/src/store/connections.ts+++ b/apps/desktop/src/store/connections.ts@@ -18,12 +18,11 @@ const LAST_PROFILE_STORAGE_KEY = 'hermes.desktop.lastProfileByConnection'export const $connectionsRegistry = atom<DesktopConnectionsRegistry | null>(null)-// Use the resolved descriptor identity Electron publishes. The registry-// primary is only a compatibility fallback for older mains.-export const $activeConnectionId = computed(- [$connectionsRegistry, $connection],- (registry, connection) => connection?.connectionId ?? (connection ? (registry?.primary ?? null) : null)-)+// Use only the resolved descriptor identity Electron publishes. `primary`+// means the registry default, not necessarily the source this window is using;+// guessing it here would paint the wrong source as active for an unmatched v1+// route or while a legacy main is still resolving the descriptor.+export const $activeConnectionId = computed($connection, connection => connection?.connectionId ?? null)export const $hasMultipleConnections = computed($connectionsRegistry,