Skip to content

The agent that grows with you

fix(desktop): route remote sub-profiles through the primary's remote gateway

Ayush Nangia15dd3bf5863e
diff --git a/apps/desktop/electron/connection-config.ts b/apps/desktop/electron/connection-config.ts
index 0fbfdabc6fa..c71163c9ce3 100644
--- a/apps/desktop/electron/connection-config.ts
+++ b/apps/desktop/electron/connection-config.ts
@@ -481,6 +481,10 @@ export interface ProfileRouteOptions {
globalRemote?: boolean
primaryProfile?: null | string
profileRemoteOverride?: boolean
+ /** The primary profile's own backend resolves to a remote host. */
+ primaryRemoteActive?: boolean
+ /** A stored per-profile entry exists for this profile (local or remote). */
+ ownEntry?: boolean
}
export interface ProfileBackendRoute {
@@ -528,6 +532,14 @@ function resolveProfileBackendRoute(profile, opts: ProfileRouteOptions = {}): Pr
return { backend: 'primary', descriptorProfile: scopedProfile, scopePath: true }
}
+ if (opts.primaryRemoteActive && !opts.ownEntry) {
+ // The primary profile's own backend is a remote gateway (per-profile
+ // override or env) and this sub-profile has no stored entry of its own.
+ // Route through that gateway with profile scoping instead of spawning a
+ // fresh local backend that shares nothing but the name (#88296).
+ return { backend: 'primary', descriptorProfile: scopedProfile, scopePath: true }
+ }
+
return { backend: 'pool', descriptorProfile: null, scopePath: false }
}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 4c1ea389a59..e1da6f7fbf1 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -9482,6 +9482,7 @@ function primaryProfileKey() {
function profileRouteOptions(profile) {
const config = readDesktopConnectionConfig()
const sshOverride = profileSshOverride(config, profile)
+ const key = connectionScopeKey(profile) || primaryProfileKey()
return {
// A desktop profile can be only a client-side routing alias. Keep backend
@@ -9489,7 +9490,14 @@ function profileRouteOptions(profile) {
backendProfile: sshOverride?.remoteProfile,
globalRemote: globalRemoteActive(),
primaryProfile: primaryProfileKey(),
- profileRemoteOverride: Boolean(profileRemoteOverride(config, profile) || sshOverride)
+ profileRemoteOverride: Boolean(profileRemoteOverride(config, profile) || sshOverride),
+ // The primary profile's own backend resolves to a remote host (its
+ // per-profile override, env, or global). Unknown sub-profiles on that
+ // gateway must route THROUGH it, not spawn local backends (#88296).
+ primaryRemoteActive: primaryBackendIsRemote(),
+ // A stored per-profile entry (local or remote) — pins this profile to
+ // its own backend; absent entries inherit the primary's remote.
+ ownEntry: Boolean((readDesktopConnectionConfig().profiles || {})[key])
}
}