Skip to content

The agent that grows with you

fix(desktop): report remote plugin target profiles

David Dudok de Wit496946ba8cc6
diff --git a/apps/desktop/electron/plugin-profile-routes.test.ts b/apps/desktop/electron/plugin-profile-routes.test.ts
index 3d507099ee0..88fd021543d 100644
--- a/apps/desktop/electron/plugin-profile-routes.test.ts
+++ b/apps/desktop/electron/plugin-profile-routes.test.ts
@@ -115,6 +115,39 @@ describe('buildOpaqueProfileRoutes', () => {
expect(new Set(routes.map(route => route.connectionId))).toHaveLength(1)
})
+ it('reports the backend root for a per-profile URL alias', async () => {
+ const routes = await buildOpaqueProfileRoutes({
+ getProfileConfig: profile =>
+ profile === 'barry'
+ ? config({ mode: 'remote', remoteUrl: 'https://tower.example' })
+ : config(),
+ globalConfig: config(),
+ installationId: 'install-a-secret',
+ primaryProfile: 'default',
+ profileNames: ['default', 'barry'],
+ resolveSsh: vi.fn()
+ })
+
+ expect(routes[1]).toMatchObject({ profile: 'barry', targetProfile: 'default' })
+ })
+
+ it('reports an explicit backend profile inherited from global SSH', async () => {
+ const routes = await buildOpaqueProfileRoutes({
+ getProfileConfig: () => config(),
+ globalConfig: config({
+ mode: 'ssh',
+ sshHost: 'gateway',
+ sshRemoteProfile: 'remote-primary'
+ }),
+ installationId: 'install-a-secret',
+ primaryProfile: 'default',
+ profileNames: ['default', 'desktop-alias'],
+ resolveSsh: vi.fn(async () => ({ hostname: 'gateway.example', port: 22, user: 'hermes' }))
+ })
+
+ expect(routes.map(route => route.targetProfile)).toEqual(['remote-primary', 'remote-primary'])
+ })
+
it('keeps cloud organizations on one service URL in distinct groups', async () => {
const routes = await buildOpaqueProfileRoutes({
getProfileConfig: profile =>
diff --git a/apps/desktop/electron/plugin-profile-routes.ts b/apps/desktop/electron/plugin-profile-routes.ts
index 69582f06545..a6229260994 100644
--- a/apps/desktop/electron/plugin-profile-routes.ts
+++ b/apps/desktop/electron/plugin-profile-routes.ts
@@ -96,6 +96,28 @@ function opaqueConnectionId(scope: string, installationId: string): string {
return `connection-${digest.slice(0, 24)}`
}
+function backendTargetProfile(scoped: ProfileRouteConfig, globalConfig: ProfileRouteConfig, profile: string): string {
+ if (scoped.mode === 'ssh') {
+ return normalizeProfile(scoped.sshRemoteProfile || profile)
+ }
+
+ // A per-profile URL/cloud override selects a standalone remote backend. It
+ // does not forward the Desktop alias as a backend profile scope, so that
+ // backend answers as its own root profile.
+ if (scoped.mode === 'remote' || scoped.mode === 'cloud') {
+ return 'default'
+ }
+
+ // An inherited global SSH route may explicitly pin the remote process to a
+ // differently named profile. Without that pin, Desktop profile names remain
+ // the backend profile scope, like inherited URL/cloud connections.
+ if (globalConfig.mode === 'ssh' && globalConfig.sshRemoteProfile) {
+ return normalizeProfile(globalConfig.sshRemoteProfile)
+ }
+
+ return profile
+}
+
/**
* Resolve Desktop routing profiles at the Electron boundary and return only
* keyed, credential-free descriptors to the renderer/plugin runtime.
@@ -132,8 +154,7 @@ export async function buildOpaqueProfileRoutes({
connectionId: opaqueConnectionId(scope.key, installationId),
mode: scope.mode,
profile,
- targetProfile:
- scoped.mode === 'ssh' ? normalizeProfile(scoped.sshRemoteProfile || profile) : profile
+ targetProfile: backendTargetProfile(scoped, globalConfig, profile)
}
})
)