fix(desktop): report remote plugin target profiles

This commit is contained in:
David Dudok de Wit
2026-08-14 19:26:23 +02:00
committed by Teknium
parent 27e4f09540
commit 496946ba8c
2 changed files with 56 additions and 2 deletions
@@ -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 =>
+23 -2
View File
@@ -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)
}
})
)