Skip to content

The agent that grows with you

fix(desktop): hovering an SSH bot never dials the tunnel or spawns a remote backend

bblicke13d9ddb725e24
diff --git a/apps/desktop/src/store/profile.test.ts b/apps/desktop/src/store/profile.test.ts
index 179a072ea54..9e0488d73d6 100644
--- a/apps/desktop/src/store/profile.test.ts
+++ b/apps/desktop/src/store/profile.test.ts
@@ -9,16 +9,19 @@ import type { ProfileInfo } from '@/types/hermes'
const ensureGatewayForProfile = vi.fn(async (_profile: string) => undefined)
const ensureGatewayForAgent = vi.fn(async () => undefined)
const openGatewayForProfile = vi.fn(async (_profile: string) => undefined)
+const openGatewayForAgent = vi.fn(async (_connectionId: null | string, _profile: string) => undefined)
const openSecondaryCount = vi.fn(() => 0)
const $gateway = atom<unknown>({ id: 'live-socket', connectionState: 'open' })
const resetStarmapGraph = vi.fn()
vi.mock('@/store/gateway', () => ({
$gateway,
+ activeGatewayConnectionId: () => null,
// Activation now verifies the socket's route before publishing the profile.
activeGatewayProfileKey: () => ensureGatewayForProfile.mock.lastCall?.[0] ?? $activeGatewayProfile.get(),
ensureGatewayForAgent,
ensureGatewayForProfile,
+ openGatewayForAgent,
openGatewayForProfile,
openSecondaryCount
}))
@@ -46,6 +49,7 @@ const {
} = await import('./profile')
const { $poolLimits } = await import('@/store/pool-limits')
+const { $connectionsRegistry } = await import('@/store/connection-registry-state')
const { $connection } = await import('./session')
const { invalidateProfileScopedQueries } = await import('@/lib/query-client')
@@ -173,6 +177,27 @@ describe('prewarmProfileBackend (hover-intent pool spawn)', () => {
expect(openGatewayForProfile).not.toHaveBeenCalled()
})
+ // #89756: SSH sources are connect-on-demand — a hover-warm on an SSH row
+ // dialed the tunnel and spawned an isolated remote backend per bot.
+ it('never dials an SSH registry source; a same-box Remote gateway still warms', () => {
+ openGatewayForAgent.mockClear()
+ $connectionsRegistry.set({
+ version: 2,
+ primary: 'shell',
+ secureTokenStorage: true,
+ connections: [
+ { id: 'shell', kind: 'ssh', label: 'Shell', host: 'box', tokenSet: false, tokenPreview: '' },
+ { id: 'gateway', kind: 'remote', label: 'Gateway', url: 'http://box:8642', tokenSet: true, tokenPreview: '…' }
+ ]
+ })
+
+ prewarmProfileBackend('dax', 'shell')
+ prewarmProfileBackend('dax', 'gateway')
+
+ expect(openGatewayForAgent.mock.calls).toEqual([['gateway', 'dax']])
+ expect(openGatewayForProfile).not.toHaveBeenCalled()
+ })
+
it('throttles repeat pre-warms for the same profile within the interval', () => {
prewarmProfileBackend('warm-throttle-a')
prewarmProfileBackend('warm-throttle-a')
diff --git a/apps/desktop/src/store/profile.ts b/apps/desktop/src/store/profile.ts
index c1805f5e5f5..b118c9c0002 100644
--- a/apps/desktop/src/store/profile.ts
+++ b/apps/desktop/src/store/profile.ts
@@ -15,6 +15,7 @@ import {
storedStringRecord
} from '@/lib/storage'
import { withTimeout } from '@/lib/with-timeout'
+import { $connectionsRegistry } from '@/store/connection-registry-state'
import { invalidateCronModelImpactScopeState } from '@/store/cron-model-impact-scope'
import {
$gateway,
@@ -490,6 +491,10 @@ const PREWARM_MIN_INTERVAL_MS = 60_000
const prewarmedAt = new Map<string, number>()
+function registryConnectionKind(connectionId: string): string | undefined {
+ return $connectionsRegistry.get()?.connections.find(entry => entry.id === connectionId)?.kind
+}
+
export function prewarmProfileBackend(name: string, connectionId: null | string = null): void {
const key = normalizeProfileKey(name)
const connection = (connectionId ?? '').trim() || null
@@ -502,6 +507,14 @@ export function prewarmProfileBackend(name: string, connectionId: null | string
return
}
+ // SSH sources are connect-on-demand (#89756): dialing one bootstraps the
+ // tunnel and spawns `hermes -p <profile> serve --isolated` on the remote
+ // box, so a hover sweep across the roster spawned one isolated backend per
+ // bot and knocked the primary chat over. Only an explicit open may dial SSH.
+ if (connection && registryConnectionKind(connection) === 'ssh') {
+ return
+ }
+
const now = Date.now()
if (now - (prewarmedAt.get(scope) ?? 0) < PREWARM_MIN_INTERVAL_MS) {
diff --git a/website/docs/user-guide/multi-connection-desktop.md b/website/docs/user-guide/multi-connection-desktop.md
index 644d2b0cfb9..d1c465309f7 100644
--- a/website/docs/user-guide/multi-connection-desktop.md
+++ b/website/docs/user-guide/multi-connection-desktop.md
@@ -255,7 +255,8 @@ that live on one gateway.
Remote gateways are opened only when selected; there is no periodic fleet
polling.
- Hovering an agent pre-warms its backend so the switch doesn't pay a cold
- boot.
+ boot. SSH agents are the exception: hovering never dials the tunnel or
+ starts a remote backend — only opening one does.
- The **Capabilities** page (Skills / Tools / MCP) has a matching scope: its
**Configuring** selector lists every `(profile, device)` agent from the
union roster, and picking one reads and writes **that machine's** skills,