fix(desktop): notify when a profile switch fails instead of silently reverting - #89634
fix(desktop): notify when a profile switch fails instead of silently reverting#89634chelsealong wants to merge 1 commit into
Conversation
…reverting ensureGatewayProfile's fire-and-forget catch (used by selectProfile and newSessionInProfile) swallowed a failed descriptor lookup entirely: no atom is published, which is correct, but nothing told the user either. The rail's "waking up" overlay just vanished and the active profile stayed put with no explanation, which reads as a broken click (NousResearch#89622). Surface the failure via the existing notification system instead.
|
Closing — the seams this PR hardens were rewritten during the resolution of #89622, and the specific failure it surfaces no longer exists. Sequence on main: the atomic-publish series was reverted (#89785), profile switching was re-landed with fail-open semantics and an activation lease preventing mid-dial socket disposal (#89797), and the underlying release-build breakage turned out to be nanostores 1.4.0's On the current code a switch cannot silently decline (the decline path is gone), and descriptor-lookup failures are logged rather than swallowed. If you see a switch-failure UX gap remaining on latest main — e.g. a user-visible toast rather than a console warning — a fresh PR against the current seams would be welcome. Thanks for the work here; the silent-failure framing was correct and informed the final design. |
What does this PR do?
Fixes the desktop profile switcher silently failing: clicking a profile shows the "Waking up …" overlay, then it just disappears and nothing switches, with no error and no way to tell what happened.
Related Issue
Fixes #89622
Root Cause
selectProfile()/newSessionInProfile()(apps/desktop/src/store/profile.ts) callensureGatewayProfile(target)fire-and-forget (void ensureGatewayProfile(target)), andensureGatewayProfileitself swallows a failed descriptor lookup:That "publish nothing on failure" behavior is correct (it's what
#46651's regression test inprofile.test.tsalready locks in) — but it is also completely silent. WhenresolveConnectionForProfile/prepareGatewayForProfilereject (backend unreachable, profile deleted mid-dial, etc.), theChatSwapOverlay"waking up" indicator (driven by$gatewaySwapTarget, cleared in thefinallyregardless of outcome) just fades out,$activeGatewayProfilenever moves, and the caller never learns the switch was declined. From the user's side that reads exactly like #89622: "it says waking up... but it didn't actually switch."Changes Made
apps/desktop/src/store/profile.ts—ensureGatewayProfile's failure path now callsnotifyError()(the app's existing top-center toast) with a new translated message, so a failed switch is visibly reported instead of silently reverting.apps/desktop/src/i18n/types.ts,apps/desktop/src/i18n/en.ts,apps/desktop/src/i18n/zh.ts— add thecomposer.profileSwitchFailedstring (the two locales that declare the fullTranslationstype directly; the other locales fall back to English viadefineLocale).apps/desktop/src/store/profile.test.ts— new regression test assertingnotifyErrorfires with the failing error when the descriptor fetch rejects.How to Test
Commands run from
apps/desktop:Results:
src/store/profile.test.ts: 16 passed (15 pre-existing + 1 new).profile.tshunk reverted (git checkout HEAD~1 -- apps/desktop/src/store/profile.ts apps/desktop/src/i18n/en.ts apps/desktop/src/i18n/types.ts), the new testnotifies the user when a fire-and-forget switch fails (#89622)FAILS (expected "vi.fn()" to be called ... Number of calls: 0); all other tests in the file still pass.npm run typecheck: passed (tsc -p . --noEmit && tsc -p tsconfig.electron.json --noEmit && tsc -p tsconfig.e2e.json --noEmit).npm run lint: 0 errors, 129 pre-existing warnings (none in touched files).Checklist
Code
fix(scope):)Documentation & Housekeeping
Disclosure
This change was prepared with AI assistance (Claude Code), including root-cause analysis of the swallowed rejection path, the fix, and the regression test. All commands above were run and their real output is reported here.