Skip to content

The agent that grows with you

fix(desktop): let a per-profile remote override win over the forced-local route (#90477)

SZWzzae81786580d1
diff --git a/apps/desktop/electron/connection-registry.test.ts b/apps/desktop/electron/connection-registry.test.ts
index f0af94e759b..491a7518f98 100644
--- a/apps/desktop/electron/connection-registry.test.ts
+++ b/apps/desktop/electron/connection-registry.test.ts
@@ -697,9 +697,22 @@ test('registry local route: v1 REMOTE global mode forces a genuinely-local backe
assert.notEqual(route.poolKey, backendScopeKey(LOCAL_CONNECTION_ID, 'default'))
})
-test('registry local route: a per-profile remote override also forces local', () => {
+test('registry local route: a per-profile remote override delegates to the override (#90477)', () => {
+ // The per-profile SSH/remote override is the authoritative route for that
+ // profile. Forcing local here made the roster list the profile via its
+ // override but open the thread in a local child — which fails when the
+ // profile exists only on the remote. The override must win.
const route = resolveRegistryLocalRoute('research', { profileRemoteOverride: true })
+ assert.deepEqual(route, { delegate: true, poolKey: 'research' })
+})
+
+test('registry local route: global remote keeps forced-local even when a profile override is absent', () => {
+ // Witness for the other half of the split: app-global remote mode still
+ // forces "This device" to spawn genuinely-local children (migration
+ // scenario above) — only the per-profile override delegates.
+ const route = resolveRegistryLocalRoute('research', { globalRemote: true })
+
assert.deepEqual(route, { delegate: false, poolKey: 'conn:local::research' })
})
diff --git a/apps/desktop/electron/connection-registry.ts b/apps/desktop/electron/connection-registry.ts
index 8f72948f65d..2875f53c66b 100644
--- a/apps/desktop/electron/connection-registry.ts
+++ b/apps/desktop/electron/connection-registry.ts
@@ -493,7 +493,17 @@ export function resolveRegistryLocalRoute(
): RegistryLocalRoute {
const profileKey = String(profile ?? '').trim() || 'default'
- if (opts.globalRemote || opts.profileRemoteOverride) {
+ // A per-profile SSH/remote override is an explicit per-profile routing
+ // decision: the override owns this profile's backend, so the 'local' entry
+ // must delegate to the legacy profile route (which resolves the override),
+ // not spawn a forced-local child. Forcing local here is the #90477 split:
+ // the roster lists the profile via its override, but opening the thread
+ // spawned a local backend that fails when the profile doesn't exist locally.
+ if (opts.profileRemoteOverride) {
+ return { delegate: true, poolKey: profileKey }
+ }
+
+ if (opts.globalRemote) {
return { delegate: false, poolKey: `${backendScopePrefix(LOCAL_CONNECTION_ID)}${profileKey}` }
}