fix(desktop): restore profile/agent switching in release builds (nanostores 1.4.2) - #89690
Conversation
…stores 1.4.2) nanostores 1.4.0-1.4.1 annotate batch() @__NO_SIDE_EFFECTS__. Rollup (via vite build) honors that and erases a result-unused batch(...) call as dead code -- callback included. Since d57f94a/053eb7aab/4e520f085 moved the gateway-switch publication (activate() + + ) inside batch(), packaged desktop builds lost the entire publication: clicking a profile in the rail did nothing at all. Dev builds and vitest run unminified, so only the packaged app broke. nanostores 1.4.2 removes the annotation from batch() (it stays on the creation functions, where it is correct). Bump all three pinned copies (apps/desktop, apps/bootstrap-installer, ui-tui) and add a regression test asserting the installed nanostores never re-annotates batch.
|
I independently reproduced this release-build failure on current The remote gateway was healthy and reachable, OAuth session validation and WebSocket ticket issuance succeeded, and the profile-scoped WebSocket connected successfully. Despite that, the Desktop connection remained on the previous target and the switch ended with the generic “did not become active” error. Instrumenting the switch path showed that the target descriptor resolved correctly, but the production bundle omitted the entire callback passed to This is therefore independently confirmed as a production tree-shaking regression rather than a gateway, authentication, or profile-discovery failure. |
|
One additional cross-PR note: #89797 is complementary rather than a replacement for this change. #89797 fixes the mid-dial pruning race and introduces atomic profile/connection publication, but its current head still pins For the complete fix, both changes are needed: #89797 for reliable activation under pruning, and this PR for preserving the publication transaction in packaged builds. |
|
Merged via #89875 with your commit cherry-picked and authorship preserved — thank you for an outstanding find. Diagnosing this from a minified bundle diff was exactly the evidence that settled it: we reproduced the |
What does this PR do?
🔴 Critical production breakage: in packaged (minified) desktop builds, switching profiles or connection-scoped agents does nothing at all — clicking a profile in the rail is a silent no-op.
Root cause: nanostores 1.4.0–1.4.1 annotate
batch()with/* @__NO_SIDE_EFFECTS__ */. Rollup (viavite build) honors that annotation and erases any result-unusedbatch(...)call as dead code — including its callback. Sinced57f94a33/053eb7aab/4e520f085moved the gateway-switch publication (activate()+$activeGatewayProfile.set()+setConnection()) insidebatch(() => { ... }), the entire publication is missing from release bundles:Dev builds and vitest run unminified, which is why this only shows up in the packaged app.
Fix: bump nanostores to 1.4.2, which removes the
@__NO_SIDE_EFFECTS__annotation frombatch()(it remains on the creation functions likeatom/computed, where it is correct). All three pinned copies are bumped (apps/desktop,apps/bootstrap-installer,ui-tui). No source changes to app code are needed.A regression test (
apps/desktop/src/store/nanostores-batch-guard.test.ts) asserts the installed nanostores never re-introduces a purity annotation onbatch, so a future downgrade or re-annotation fails CI instead of silently shipping a dead profile switcher.Related Issue
Fixes # — (no existing issue found; happy to file one if preferred)
Type of Change
Changes Made
apps/desktop/package.json,apps/bootstrap-installer/package.json,ui-tui/package.json: nanostores1.4.0→1.4.2package-lock.json: matching lock entries (surgical, no other churn)apps/desktop/src/store/nanostores-batch-guard.test.ts(new): regression guard against the annotation returningHow to Test
cd apps/desktop && npm ci && npm run build— then inspect the minified bundle: the gateway-switch publication survives (s(() => { n() && (X.set(t), e && Jt(e)) })now present after thePromise.allin the profile chunk; previously the block was erased entirely).npx vitest run src/store/— all 37 tests pass, including the atomic-publication tests from4e520f085and the new guard test.npm run pack, launchedrelease/linux-unpacked/Hermes, pressedCtrl+Shift+]twice — active profile cycledcetcworker → hermes-wsl → quantifyand the sidebar session list followed each switch. Before the fix the same steps were a no-op.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests pass — N/A (desktop TS change only; ran the desktop vitest suite instead: 37/37 pass)Documentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
Verification log from the packaged Linux build (keyboard profile cycling; before the fix this produced no state change):