- {/* Cloud creation is deliberately absent: a dialable cloud entry
- comes from the Hermes Cloud sign-in/discovery flow (Settings →
- Gateway), not a hand-typed URL. Migrated/discovered cloud
- entries remain editable (kind buttons are disabled on edit). */}
- {(editor.kind === 'cloud' ? (['cloud'] as const) : (['remote', 'ssh'] as const)).map(kind => (
+ {/* Kind is fixed once created (buttons disable on edit). On create
+ every kind is offered; Local is disabled while the managed
+ local entry exists (the registry holds at most one). */}
+ {(editor.id ? ([editor.kind] as const) : (['local', 'cloud', 'remote', 'ssh'] as const)).map(kind => (
{kindMeta[editor.kind].desc}
+ {!editor.id && hasLocal ?
{s.localAddHint}
: null}
+ {!editor.id && editor.kind === 'cloud' ? (
+
{s.cloudAddHint}
+ ) : null}
setEditor({ ...editor, url: e.target.value })}
+ onChange={e => {
+ setDupeError(null)
+ setEditor({ ...editor, url: e.target.value })
+ }}
placeholder="http://homelab.lan:9119"
value={editor.url}
/>
@@ -509,7 +645,10 @@ export function ConnectionsSettings() {
setEditor({ ...editor, host: e.target.value })}
+ onChange={e => {
+ setDupeError(null)
+ setEditor({ ...editor, host: e.target.value })
+ }}
placeholder="user@host:22"
value={editor.host}
/>
@@ -518,8 +657,10 @@ export function ConnectionsSettings() {
/>
)}
+ {dupeError ? {dupeError}
: null}
+
-
)
}
diff --git a/apps/desktop/src/app/settings/connections-settings.test.tsx b/apps/desktop/src/app/settings/connections-settings.test.tsx
deleted file mode 100644
index a5c4ba2006..0000000000
--- a/apps/desktop/src/app/settings/connections-settings.test.tsx
+++ /dev/null
@@ -1,102 +0,0 @@
-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-
-import type { DesktopConnectionsRegistry } from '@/global'
-
-import { ConnectionsSettings } from './connections-settings'
-
-const list = vi.fn()
-const save = vi.fn()
-const remove = vi.fn()
-const setPrimary = vi.fn()
-const test = vi.fn()
-
-const registry: DesktopConnectionsRegistry = {
- connections: [
- { id: 'local', kind: 'local', label: 'This device', tokenPreview: null, tokenSet: false },
- {
- authMode: 'token',
- id: 'homelab',
- kind: 'remote',
- label: 'Homelab',
- tokenPreview: '...abc123',
- tokenSet: true,
- url: 'http://homelab.lan:9119'
- }
- ],
- primary: 'local',
- secureTokenStorage: true,
- version: 2
-}
-
-beforeEach(() => {
- list.mockResolvedValue(registry)
- save.mockResolvedValue({ connection: registry.connections[1], ok: true, registry })
- remove.mockResolvedValue({ ok: true, registry: { ...registry, connections: [registry.connections[0]] } })
- setPrimary.mockResolvedValue({ ok: true, registry: { ...registry, primary: 'homelab' } })
- test.mockResolvedValue({ ok: true, reachable: true })
- Object.defineProperty(window, 'hermesDesktop', {
- configurable: true,
- value: { connections: { list, remove, save, setPrimary, test } }
- })
-})
-
-afterEach(() => {
- cleanup()
- vi.clearAllMocks()
-})
-
-describe('ConnectionsSettings', () => {
- it('lists registered connections with primary + local pills', 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('Primary')).toBeTruthy()
- expect(list).toHaveBeenCalledTimes(1)
- })
-
- it('opens the add-connection editor and saves with a required label', async () => {
- render()
-
- await waitFor(() => expect(screen.getByText('Homelab')).toBeTruthy())
- fireEvent.click(screen.getByText('Add connection'))
-
- // Save is disabled until a label is present.
- const saveButton = screen.getByText('Save connection').closest('button')!
- expect(saveButton.disabled).toBe(true)
-
- fireEvent.change(screen.getByPlaceholderText('Homelab'), { target: { value: 'Spark box' } })
- fireEvent.change(screen.getByPlaceholderText('http://homelab.lan:9119'), {
- target: { value: 'http://spark.lan:9119' }
- })
- expect(saveButton.disabled).toBe(false)
- fireEvent.click(saveButton)
-
- await waitFor(() => expect(save).toHaveBeenCalledTimes(1))
- expect(save.mock.calls[0][0]).toMatchObject({
- kind: 'remote',
- label: 'Spark box',
- url: 'http://spark.lan:9119'
- })
- })
-
- it('makes a non-primary connection primary', async () => {
- render()
-
- await waitFor(() => expect(screen.getByText('Homelab')).toBeTruthy())
- fireEvent.click(screen.getByText('Make primary'))
-
- await waitFor(() => expect(setPrimary).toHaveBeenCalledWith('homelab'))
- })
-
- it('tests a connection through the bridge', async () => {
- render()
-
- await waitFor(() => expect(screen.getByText('Homelab')).toBeTruthy())
- fireEvent.click(screen.getAllByText('Test')[0])
-
- await waitFor(() => expect(test).toHaveBeenCalled())
- })
-})
diff --git a/apps/desktop/src/app/settings/gateway-settings.tsx b/apps/desktop/src/app/settings/gateway-settings.tsx
index 14aeb1aa71..d578637ca4 100644
--- a/apps/desktop/src/app/settings/gateway-settings.tsx
+++ b/apps/desktop/src/app/settings/gateway-settings.tsx
@@ -28,6 +28,7 @@ import { cn } from '@/lib/utils'
import { notify, notifyError, readableError } from '@/store/notifications'
import { $profiles, refreshActiveProfile } from '@/store/profile'
+import { ConnectionsRegistrySection } from './connections-registry'
import { CONTROL_TEXT } from './constants'
import { EmptyState, ListRow, Pill, SettingsContent, SettingsSkeleton } from './primitives'
import { enrichSelectedSshHost, selectSshHost } from './ssh-host-selection'
@@ -135,23 +136,6 @@ function ModeCard({
)
}
-function ScopeChip({ active, label, onSelect }: { active: boolean; label: string; onSelect: () => void }) {
- return (
-
- {label}
-
- )
-}
-
// `embedded` trims the page chrome for reuse inside the boot-failure recovery
// card: the outer title/intro, the "Save for next restart" action, and the
// Diagnostics row are redundant there (the card owns its header + a single
@@ -1072,25 +1056,46 @@ export function GatewaySettings({ embedded = false }: { embedded?: boolean } = {
)}
+ {/* Per-profile gateway overrides: an explicit subsection (not an ambient
+ page-scope chip row) — pick which target the connection controls
+ below edit: the default connection or one named profile's override. */}
{namedProfiles.length > 0 ? (
-
+
- {g.appliesTo}
-
-
- setScope(null)} />
- {namedProfiles.map(profile => (
- setScope(profile.name)}
- />
- ))}
+ {g.profileOverridesTitle}
- {scope === null ? g.defaultConnection : g.profileConnection(scope)}
+ {g.profileOverridesDesc}
+
{g.overrideEditing}
+ ) : (
+ setScope(null)} size="sm" variant="outline">
+ {g.overrideEdit}
+
+ )
+ }
+ description={g.defaultConnection}
+ title={g.allProfiles}
+ />
+ {namedProfiles.map(profile => (
+ {g.overrideEditing}
+ ) : (
+ setScope(profile.name)} size="sm" variant="outline">
+ {g.overrideEdit}
+
+ )
+ }
+ description={scope === profile.name ? g.profileConnection(profile.name) : g.overrideSelectHint}
+ key={profile.name}
+ title={profile.name}
+ />
+ ))}
) : null}
@@ -1573,6 +1578,11 @@ export function GatewaySettings({ embedded = false }: { embedded?: boolean } = {
)}
+ {/* Unified Gateways page: the full connections registry (add/edit/delete
+ named agent sources) lives on this page now, below the window
+ connection controls. Hidden in the embedded (boot-recovery) form. */}
+ {embedded ? null :