The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): boot restore never overrides a live unnameable source
Brooklyn Nicholsond5463b3f4685
diff --git a/apps/desktop/src/store/connections.test.ts b/apps/desktop/src/store/connections.test.tsindex 111b22abb2b..59e840f16dd 100644--- a/apps/desktop/src/store/connections.test.ts+++ b/apps/desktop/src/store/connections.test.ts@@ -276,4 +276,19 @@ describe('selectConnection', () => {expect(ensureGatewayAgent).toHaveBeenCalledWith('homelab', 'default')expect($showAllProfiles.get()).toBe(false)})++ it('never re-homes a live connection the registry cannot name', async () => {+ // A window connected through the legacy v1 route carries an unqualified+ // descriptor, so resolvedConnectionId — and therefore $activeConnectionId+ // — is null. Restoring the registry primary over it would re-home a+ // working remote onto local a few seconds after boot.+ list.mockResolvedValueOnce({ ...registry, launchMode: 'primary', primary: 'local' })+ $connection.set({ mode: 'remote', profile: 'default', registryScoped: false })++ await initializeConnectionsRegistry()++ expect(ensureGatewayAgent).not.toHaveBeenCalled()+ expect(wipeSessionListsForGatewaySwitch).not.toHaveBeenCalled()+ expect($connection.get()?.mode).toBe('remote')+ })})diff --git a/apps/desktop/src/store/connections.ts b/apps/desktop/src/store/connections.tsindex b4a5ab2c6a1..472f5b59ec5 100644--- a/apps/desktop/src/store/connections.ts+++ b/apps/desktop/src/store/connections.ts@@ -126,6 +126,17 @@ export async function initializeConnectionsRegistry(): Promise<DesktopConnectionrestoreAttempted = true+ // Residual drift: a window can be live on a source the registry cannot name+ // (a v1-configured remote that reconciliation has not repaired yet, e.g. a+ // read-only userData that rejected the healed write). $activeConnectionId is+ // null there, so the preferred-id guard below would miss and "restore" the+ // registry primary over a connection that is already up and painting —+ // re-homing the user onto a different backend seconds after boot. The+ // registry has no claim on a source it does not know; leave the live one be.+ if ($connection.get() && $activeConnectionId.get() === null) {+ return registry+ }+const lastUsed = registry.connections.some(connection => connection.id === registry.lastUsed)? registry.lastUsed: registry.primary