From a787bfeab971463b72bfad5d817abfe94605c9c8 Mon Sep 17 00:00:00 2001 From: royzhrxy-glitch Date: Wed, 19 Aug 2026 11:30:20 +0800 Subject: [PATCH] fix(desktop): restore profile/agent switching in release builds (nanostores 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 d57f94a33/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. --- apps/bootstrap-installer/package.json | 2 +- apps/desktop/package.json | 2 +- .../src/store/nanostores-batch-guard.test.ts | 31 +++++++++++++++++++ package-lock.json | 12 +++---- ui-tui/package.json | 2 +- 5 files changed, 40 insertions(+), 9 deletions(-) create mode 100644 apps/desktop/src/store/nanostores-batch-guard.test.ts diff --git a/apps/bootstrap-installer/package.json b/apps/bootstrap-installer/package.json index 5e72fb283f..c385f9b108 100644 --- a/apps/bootstrap-installer/package.json +++ b/apps/bootstrap-installer/package.json @@ -32,7 +32,7 @@ "clsx": "2.1.1", "katex": "0.16.47", "lucide-react": "0.577.0", - "nanostores": "1.4.0", + "nanostores": "1.4.2", "radix-ui": "1.6.7", "react": "19.2.7", "react-dom": "19.2.7", diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 300c4582ab..b3f55444c0 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -130,7 +130,7 @@ "katex": "0.16.47", "mermaid": "11.16.1", "motion": "12.42.2", - "nanostores": "1.4.0", + "nanostores": "1.4.2", "node-pty": "1.1.0", "radix-ui": "1.6.7", "react": "19.2.7", diff --git a/apps/desktop/src/store/nanostores-batch-guard.test.ts b/apps/desktop/src/store/nanostores-batch-guard.test.ts new file mode 100644 index 0000000000..06f94adc0e --- /dev/null +++ b/apps/desktop/src/store/nanostores-batch-guard.test.ts @@ -0,0 +1,31 @@ +/** + * Regression guard: the desktop's gateway-switch publication runs inside + * nanostores' batch(). nanostores 1.4.0–1.4.1 annotated batch() with + * `/* @__NO_SIDE_EFFECTS__ *\/`, which let production bundlers (Rollup, via + * `vite build`) erase result-unused batch(...) calls — callback included — + * deleting the entire publication from release builds and freezing + * profile/agent switching there. Dev builds and vitest run unminified, so + * only the packaged app broke. nanostores 1.4.2 removed the annotation; + * this test fails if the installed version ever carries it again. + */ +import { readFileSync } from 'node:fs' +import { createRequire } from 'node:module' +import path from 'node:path' + +import { describe, expect, it } from 'vitest' + +const require = createRequire(import.meta.url) + +describe('nanostores batch()', () => { + it('is not annotated @__NO_SIDE_EFFECTS__ — bundlers would erase its calls', () => { + const nanostoresEntry = require.resolve('nanostores') + const atomSource = readFileSync(path.join(path.dirname(nanostoresEntry), 'atom/index.js'), 'utf8') + + // Capture any block comment immediately preceding the batch export. + const match = atomSource.match(/(\/\*(?:[^*]|\*(?!\/))*\*\/\s*)?export const batch\b/) + + expect(match, 'nanostores atom/index.js should export const batch').toBeTruthy() + expect(match![1] ?? '').not.toContain('__NO_SIDE_EFFECTS') + expect(match![1] ?? '').not.toContain('__PURE__') + }) +}) diff --git a/package-lock.json b/package-lock.json index 507d5ee0b7..c50dd25d73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "clsx": "2.1.1", "katex": "0.16.47", "lucide-react": "0.577.0", - "nanostores": "1.4.0", + "nanostores": "1.4.2", "radix-ui": "1.6.7", "react": "19.2.7", "react-dom": "19.2.7", @@ -116,7 +116,7 @@ "katex": "0.16.47", "mermaid": "11.16.1", "motion": "12.42.2", - "nanostores": "1.4.0", + "nanostores": "1.4.2", "node-pty": "1.1.0", "radix-ui": "1.6.7", "react": "19.2.7", @@ -14527,9 +14527,9 @@ } }, "node_modules/nanostores": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/nanostores/-/nanostores-1.4.0.tgz", - "integrity": "sha512-i0tloweeudshAEuddpDxcg9Ik6pkPfVsHIgKyf143JrgG7/MOh0+q7BypdLXZPoOP7fOYt1eTcwGkyiVmhJFkA==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/nanostores/-/nanostores-1.4.2.tgz", + "integrity": "sha512-Wxv8Roefr2nqtiRG0bnaFlpYqpIVtOEeJZHaH+4nGgOK1/7n6OHOuHCb/bhqrNQgZM8fyd0s1PqhdrJc9Ib44g==", "funding": [ { "type": "github", @@ -19127,7 +19127,7 @@ "@hermes/shared": "file:../apps/shared", "@nanostores/react": "1.1.0", "ink-text-input": "6.0.0", - "nanostores": "1.4.0", + "nanostores": "1.4.2", "react": "19.2.7", "undici": "6.28.0", "unicode-animations": "1.0.3" diff --git a/ui-tui/package.json b/ui-tui/package.json index f1d0bbe36b..977dbe4c35 100644 --- a/ui-tui/package.json +++ b/ui-tui/package.json @@ -23,7 +23,7 @@ "@hermes/shared": "file:../apps/shared", "@nanostores/react": "1.1.0", "ink-text-input": "6.0.0", - "nanostores": "1.4.0", + "nanostores": "1.4.2", "react": "19.2.7", "undici": "6.28.0", "unicode-animations": "1.0.3"