fix(desktop): keep sleep/wake reconnect on the primary backend (salvage of #74552) - #87872
Merged
Conversation
teknium1
enabled auto-merge (rebase)
August 16, 2026 17:54
Contributor
૮ >ﻌ< ა ci reviewrunning on 30f3d00 — fix(apps): dial primary sleep/wake reconnect at window backe waiting for more jobs to start…
|
Closed
13 tasks
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.
Summary
Salvages #74552 by @fangliquanflq: stops Desktop sleep/wake (and any primary WebSocket drop) from rewiring the window-owned primary chat socket to the currently active secondary profile's backend.
Fixes #74551.
Changes
apps/desktop/src/app/gateway/hooks/use-gateway-boot.tsattemptReconnectnow dials the window-owned primary backend with no-argdesktop.getConnection()(matching boot and softSwitch at the other two call sites), instead ofdesktop.getConnection($activeGatewayProfile.get())which retargeted the primary socket at a secondary profile's backend after a live swap.publish(conn)is gated onisActivePrimary(), so a background-profile view no longer inherits the primary descriptor (mode/baseUrl) and breaks image.attach / fs / media routing ([Bug] Desktop (a376ca0): image upload fails on remote profile — "image not found: <local_path>" #46651).reconnectSecondaryGateways()registry path —reconnectNow()(wired to power-resume,online, andvisibilitychange) already calls it before nudging the primary loop, so all wake signals funnel through the fixed path; no sibling site carries the wrong-profile lookup.apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsxcoderwith its own backend, drop the primary socket, assert the reconnect never queriescoder's descriptor, redials the primarywsUrl, and leaves the active secondary's$connectionuntouched.fakeDesktop()(per-profile connection descriptors) plus store resets inbeforeEach/afterEach.Cherry-picked onto current main with one test-file conflict (main's #71873 project-dir seeding test landed in the same region); resolved by keeping both tests. The fix required no adaptation to #87600's
ensureGatewayAgent/mutex work — the reconnect loop's seam is unchanged and the new test passes against the post-#87600 store shape.Validation
npx vitest run src/app/gateway/hooks/use-gateway-boot.test.tsxnpm run check:lint(apps/desktop: tsc ×3 + eslint)python3 scripts/audit_pr_attribution.py --fixCredit
Authored by @fangliquanflq — cherry-picked from #74552 with authorship preserved (
fangliquanflq <fangliquan@qq.com>).Infographic