diff --git a/apps/desktop/src/app/settings/connections-registry.test.tsx b/apps/desktop/src/app/settings/connections-registry.test.tsx
index c03f85d617..53ea1d5098 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/re
import { 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()
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.tsx
index 6bc7479f1e..8b38518879 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(null)
const [loading, setLoading] = useState(true)
const [editor, setEditor] = useState(null)
@@ -466,6 +468,7 @@ export function ConnectionsRegistrySection() {
) : (
registry.connections.map(conn => {
const Icon = KIND_ICONS[conn.kind]
+ const isCurrent = activeConnectionId === conn.id
const isPrimary = registry.primary === conn.id
const busy = busyId === conn.id
// Display-only: this connection is a second address for a backend
@@ -530,7 +533,8 @@ export function ConnectionsRegistrySection() {
{conn.label}
- {isPrimary && {s.primaryPill}}
+ {isCurrent && {s.currentPill}}
+ {isPrimary && {s.primaryPill}}
{conn.kind === 'local' && {s.managedPill}}
}
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index 54fe9e05b4..fdd61711c2 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.ts
index 255b4aa5ef..429bb57451 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -593,6 +593,7 @@ export interface Translations {
intro: string
stagedNote: string
loadFailed: string
+ currentPill: string
primaryPill: string
managedPill: string
addConnection: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index 017f380b25..b6cba0cfc3 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.ts
index 5602cb605c..0fce2649f1 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.ts
index 24080a043a..076ecf14dc 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(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,