Skip to content

The agent that grows with you

fix(desktop): preserve profile overrides on local source picks

cmoiccool7d6bf56c7bea
diff --git a/apps/desktop/src/store/profile-select-source.test.ts b/apps/desktop/src/store/profile-select-source.test.ts
index 0bbc1ef7a0f..8fe01691121 100644
--- a/apps/desktop/src/store/profile-select-source.test.ts
+++ b/apps/desktop/src/store/profile-select-source.test.ts
@@ -61,6 +61,15 @@ describe('selectProfile', () => {
await vi.waitFor(() => expect(ensureGatewayForProfile).toHaveBeenCalledWith('ops'))
expect(ensureGatewayForAgent).not.toHaveBeenCalled()
})
+
+ it('keeps the legacy profile-only path when the explicit local source is live', async () => {
+ activeGatewayConnectionId.mockReturnValue('local')
+
+ selectProfile('override-profile')
+
+ await vi.waitFor(() => expect(ensureGatewayForProfile).toHaveBeenCalledWith('override-profile'))
+ expect(ensureGatewayForAgent).not.toHaveBeenCalled()
+ })
})
describe('newSessionInProfile', () => {
@@ -72,4 +81,13 @@ describe('newSessionInProfile', () => {
await vi.waitFor(() => expect(ensureGatewayForAgent).toHaveBeenCalledWith('mini', 'designer'))
expect(ensureGatewayForProfile).not.toHaveBeenCalled()
})
+
+ it('keeps the legacy profile-only path for a new chat on the explicit local source', async () => {
+ activeGatewayConnectionId.mockReturnValue('local')
+
+ newSessionInProfile('override-profile')
+
+ await vi.waitFor(() => expect(ensureGatewayForProfile).toHaveBeenCalledWith('override-profile'))
+ expect(ensureGatewayForAgent).not.toHaveBeenCalled()
+ })
})
diff --git a/apps/desktop/src/store/profile.ts b/apps/desktop/src/store/profile.ts
index 3a7a50caa14..fbe7eca4841 100644
--- a/apps/desktop/src/store/profile.ts
+++ b/apps/desktop/src/store/profile.ts
@@ -639,17 +639,17 @@ export function selectProfile(name: string): void {
}
// Route a profile pick at the source the user is LOOKING at. $profiles is the
-// active gateway's list, so a pick made while a registry source is live names
-// one of THAT source's profiles. Sending it through the profile-only path
-// resolves the descriptor with a bare name (getConnection(profile)), which the
-// main process answers against the primary — so picking "researcher" on a
-// remote source opened a local backend of the same name and dropped the user
-// back home, making the pick look like it never took. A null connection id
-// means the primary is live, which is exactly the legacy path.
+// active gateway's list, so a pick made while a remote registry source is live
+// names one of THAT source's profiles and must keep its connection id. The
+// primary and explicit "local" source stay on the legacy profile-only path so
+// the main process can resolve a per-profile remote override before falling
+// back to a local backend.
function activateOnCurrentSource(target: string): Promise<void> {
const connectionId = activeGatewayConnectionId()
- return connectionId ? ensureGatewayAgent(connectionId, target) : ensureGatewayProfile(target)
+ return connectionId && connectionId !== 'local'
+ ? ensureGatewayAgent(connectionId, target)
+ : ensureGatewayProfile(target)
}
// Start a fresh session in `name` WITHOUT collapsing the "All profiles" browse