Skip to content

The agent that grows with you

fix(desktop): boot-time source restore keeps the All-profiles preference (#93197)

ClintonEmok4fea0f04be23
diff --git a/apps/desktop/src/store/connections.test.ts b/apps/desktop/src/store/connections.test.ts
index b483fec3919..111b22abb2b 100644
--- a/apps/desktop/src/store/connections.test.ts
+++ b/apps/desktop/src/store/connections.test.ts
@@ -253,4 +253,27 @@ describe('selectConnection', () => {
expect($pendingConnectionId.get()).toBeNull()
expect(setLastUsed).not.toHaveBeenCalled()
})
+
+ it('boot-time restore leaves "All profiles" browse mode on (#93197)', async () => {
+ // Fresh boot: nothing active yet, registry restores last-used. The
+ // persisted showAllProfiles=true must survive the silent restore.
+ list.mockResolvedValueOnce({ ...registry, lastUsed: 'homelab', launchMode: 'last-used' })
+ $showAllProfiles.set(true)
+
+ await initializeConnectionsRegistry()
+
+ expect(ensureGatewayAgent).toHaveBeenCalledWith('homelab', 'default')
+ expect($showAllProfiles.get()).toBe(true)
+ })
+
+ it('a user-initiated source switch still collapses "All profiles"', async () => {
+ setConnectionsRegistry(registry)
+ $connection.set({ connectionId: 'local', mode: 'local' })
+ $showAllProfiles.set(true)
+
+ await selectConnection('homelab')
+
+ expect(ensureGatewayAgent).toHaveBeenCalledWith('homelab', 'default')
+ expect($showAllProfiles.get()).toBe(false)
+ })
})
diff --git a/apps/desktop/src/store/connections.ts b/apps/desktop/src/store/connections.ts
index c97c07ce117..b4a5ab2c6a1 100644
--- a/apps/desktop/src/store/connections.ts
+++ b/apps/desktop/src/store/connections.ts
@@ -158,6 +158,12 @@ export async function selectConnection(connectionId: string): Promise<void> {
return
}
+ // A user-initiated source switch collapses "All profiles" browse mode: the
+ // picker is a concrete-source action. The silent boot-time restore (below,
+ // from initializeConnectionsRegistry) is not — it must leave the persisted
+ // browse-mode preference alone so it survives restart (#93197).
+ const restoreOnBoot = pendingTarget === null && $activeConnectionId.get() === null
+
const currentConnectionId = $activeConnectionId.get()
const currentProfile = normalizeProfileKey($activeGatewayProfile.get())
const targetProfile = normalizeProfileKey($lastProfileByConnection.get()[connectionId] ?? 'default')
@@ -207,7 +213,11 @@ export async function selectConnection(connectionId: string): Promise<void> {
if (revision === switchRevision) {
await rememberConnection(connectionId)
wipeSessionListsForGatewaySwitch()
- $showAllProfiles.set(false)
+
+ if (!restoreOnBoot) {
+ $showAllProfiles.set(false)
+ }
+
$newChatProfile.set(targetProfile)
requestFreshSession()
await refreshActiveProfile()