fix(desktop): distinguish pooled profile backends - #85778
Closed
wdon wants to merge 1 commit into
Closed
Conversation
Collaborator
This was referenced Aug 14, 2026
8 tasks
Collaborator
OutThisLife
added a commit
that referenced
this pull request
Aug 14, 2026
…0.20.1 sharedPrimaryRoute() inferred "served by the shared primary backend" from the mere presence of connection.profile. But pooled backends (a local named profile, or a per-profile remote override) also carry `profile` so their WebSocket URL mints against the right backend. Both descriptors looked the same, so ensureGatewayForProfile() took the shared-primary branch for a pooled profile and never dialed its socket — Desktop stayed on the default profile's socket even though the sidebar (REST) listed the right sessions. Regression from #85665 (d16e236). Tag only the true shared-primary descriptor with an explicit `sharedPrimary: true` marker in ensureBackend() and check that marker instead of `profile`. Covers both the local-pool and remote-override routes — the whole bug class, not one path. Test asserts both sides of the invariant: a { profile, sharedPrimary: true } descriptor activates the primary socket without dialing, and a pooled descriptor carrying { profile } dials its own exact WebSocket URL. Supersedes #85750, #85778, #85932 Fixes #85777 Co-authored-by: Tigrannnnnnn <122704900+Tigrannnnnnn@users.noreply.github.com> Co-authored-by: Don Tuttle <11698271+wdon@users.noreply.github.com> Co-authored-by: plcunha <145560011+plcunha@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes local Desktop profile switching after pooled connection descriptors began carrying
profilefor WebSocket URL minting.sharedPrimaryRoute()inferred that any descriptor withprofilewas served by the shared primary backend. Local pooled descriptors also carryprofile, so a named local profile was misclassified and Desktop reused the default socket instead of opening the profile's persistent WebSocket.This change gives the shared-primary route an explicit
sharedPrimarymarker and checks that marker instead of overloadingprofilewith two meanings.Related Issue
Fixes #85777
Type of Change
Changes Made
apps/desktop/electron/main.ts: marks only profile-scoped primary descriptors assharedPrimary.apps/desktop/src/global.d.ts: types the explicit route discriminator.apps/desktop/src/store/gateway.ts: distinguishes shared-primary descriptors from profile-owned pooled descriptors.apps/desktop/src/store/gateway-shared-remote.test.ts: covers both sides of the routing invariant, including a pooled descriptor that carriesprofile.How to Test
defaultand local named profiles.defaultand select a named profile from the profile rail.defaultand confirm the primary socket is restored.Automated checks:
npm run typecheckpassed on the checkout used to build and validate the installed fix. After rebasing onto currentorigin/main(edb33be51), it is presently blocked by an unrelated baseline error insrc/app/chat/hooks/use-composer-actions.test.ts:294: the newComposerActionsScope.updatefield is missing from that test fixture. This PR does not modify that code.The rebuilt macOS package was installed locally and the reporter confirmed profile switching works after restart.
Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass — N/A: Desktop TypeScript-only change; focused Vitest coverage ran insteadDocumentation & Housekeeping
cli-config.yaml.example— N/A; no config changeCONTRIBUTING.mdorAGENTS.md— N/A; no workflow changeScreenshots / Logs
Before the fix, the named backend started and its one-shot startup probe connected, but no persistent WebSocket followed:
After rebuilding with this change and restarting Desktop, switching between
defaultand the local named profile works normally.