Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(updater): a build with no update channel must not report "up to date"
enes55997fbd3745
diff --git a/src/main/updater.no-channel.test.ts b/src/main/updater.no-channel.test.tsnew file mode 100644index 000000000..a29122385--- /dev/null+++ b/src/main/updater.no-channel.test.ts@@ -0,0 +1,202 @@+// Issue #814: a Windows install's "check for updates" answered "you are up to date" on a build+// that has no update channel at all — no feed, no release job, `nodeTermUpdates=disabled`. The+// pure decision is pinned in `src/shared/update-platform.test.ts`; this pins the WIRING, because+// the defect lived there: the disabled branch of `initUpdater` wired exactly one behaviour, and+// that behaviour was the false sentence.+//+// It also pins the paths that must NOT move: dev stays quiet, macOS still self-installs, and a+// Linux .deb still degrades to the manual-download card.+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import fs from 'fs'+import os from 'os'+import path from 'path'+import { IPC } from '../shared/ipc'++const { ipcOn, ipcHandle, sent, appMock } = vi.hoisted(() => ({+ ipcOn: {} as Record<string, (...a: unknown[]) => void>,+ ipcHandle: {} as Record<string, (...a: unknown[]) => unknown>,+ sent: [] as Array<{ channel: string; payload?: unknown }>,+ appMock: { isPackaged: true, appPath: '', getVersion: () => '0.3.7' }+}))++vi.mock('electron', () => ({+ app: {+ get isPackaged() {+ return appMock.isPackaged+ },+ getAppPath: () => appMock.appPath,+ getVersion: () => appMock.getVersion()+ },+ ipcMain: {+ on: (ch: string, fn: (...a: unknown[]) => void) => {+ ipcOn[ch] = fn+ },+ handle: (ch: string, fn: (...a: unknown[]) => unknown) => {+ ipcHandle[ch] = fn+ }+ },+ Notification: Object.assign(function () {}, { isSupported: () => false })+}))++// `vi.mock` factories are hoisted above every const, so the double the factory returns has to be+// hoisted with them.+const { updaterEvents, autoUpdater } = vi.hoisted(() => {+ const events: Record<string, (...a: unknown[]) => void> = {}+ return {+ updaterEvents: events,+ autoUpdater: {+ autoDownload: true,+ autoInstallOnAppQuit: true,+ checkForUpdates: vi.fn(() => Promise.resolve(null)),+ quitAndInstall: vi.fn(),+ on: (ev: string, fn: (...a: unknown[]) => void) => {+ events[ev] = fn+ }+ }+ }+})+vi.mock('electron-updater', () => ({ autoUpdater }))+vi.mock('./main-window', () => ({+ getMainWindow: () => null,+ sendToMain: (channel: string, payload?: unknown) => sent.push({ channel, payload })+}))+vi.mock('./notifications', () => ({ retainUntilDismissed: () => {} }))++import { initUpdater } from './updater'++/** Write the packaged package.json `initUpdater` reads its marker out of. */+function packageWith(marker: string | undefined): void {+ appMock.appPath = fs.mkdtempSync(path.join(os.tmpdir(), 'nt-updater-'))+ fs.writeFileSync(+ path.join(appMock.appPath, 'package.json'),+ JSON.stringify(marker === undefined ? { name: 'x' } : { name: 'x', nodeTermUpdates: marker })+ )+}++function setPlatform(platform: string): void {+ Object.defineProperty(process, 'platform', { value: platform, configurable: true })+}++const realPlatform = process.platform+const realAppImage = process.env.APPIMAGE++beforeEach(() => {+ vi.useFakeTimers()+ for (const k of Object.keys(ipcOn)) delete ipcOn[k]+ for (const k of Object.keys(ipcHandle)) delete ipcHandle[k]+ for (const k of Object.keys(updaterEvents)) delete updaterEvents[k]+ sent.length = 0+ autoUpdater.checkForUpdates.mockClear()+ autoUpdater.autoDownload = true+ autoUpdater.autoInstallOnAppQuit = true+ appMock.isPackaged = true+ delete process.env.APPIMAGE+})++afterEach(() => {+ vi.useRealTimers()+ setPlatform(realPlatform)+ if (realAppImage === undefined) delete process.env.APPIMAGE+ else process.env.APPIMAGE = realAppImage+})++const check = (): void => ipcOn[IPC.appCheckForUpdates]?.()+const channels = (): string[] => sent.map((s) => s.channel)++describe('a packaged build with no update channel', () => {+ beforeEach(() => {+ setPlatform('win32')+ packageWith('disabled')+ initUpdater()+ })++ it('does NOT answer a manual check with "up to date"', () => {+ check()+ expect(channels()).not.toContain(IPC.appUpdateNotAvailable)+ })++ it('says it has no channel instead', () => {+ check()+ expect(channels()).toEqual([IPC.appUpdateNoChannel])+ })++ it('still touches no network — the card is the whole behaviour change', () => {+ check()+ expect(autoUpdater.checkForUpdates).not.toHaveBeenCalled()+ vi.advanceTimersByTime(7 * 60 * 60 * 1000)+ expect(autoUpdater.checkForUpdates).not.toHaveBeenCalled()+ })++ it('reports the same on every platform — the marker decides, not the OS', () => {+ for (const platform of ['darwin', 'linux', 'win32']) {+ sent.length = 0+ setPlatform(platform)+ packageWith('disabled')+ initUpdater()+ check()+ expect(channels()).toEqual([IPC.appUpdateNoChannel])+ }+ })+})++describe('the paths that must not move', () => {+ it('dev (unpackaged) stays quiet: a manual check still answers "up to date"', () => {+ appMock.isPackaged = false+ packageWith(undefined)+ initUpdater()+ check()+ expect(channels()).toEqual([IPC.appUpdateNotAvailable])+ expect(autoUpdater.checkForUpdates).not.toHaveBeenCalled()+ })++ it('macOS release: self-installs and checks the feed, as before', () => {+ setPlatform('darwin')+ packageWith(undefined)+ initUpdater()+ expect(autoUpdater.autoDownload).toBe(true)+ expect(autoUpdater.autoInstallOnAppQuit).toBe(true)+ expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1)+ check()+ expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(2)+ expect(channels()).not.toContain(IPC.appUpdateNoChannel)+ updaterEvents['update-available']?.({ version: '9.9.9', releaseNotes: 'n' })+ expect(sent.at(-1)).toEqual({+ channel: IPC.appUpdateAvailable,+ payload: { version: '9.9.9', notes: 'n', manual: false }+ })+ })++ it('Linux .deb: still the manual-download card, never the no-channel one', () => {+ setPlatform('linux')+ packageWith(undefined)+ initUpdater()+ expect(autoUpdater.autoDownload).toBe(false)+ expect(autoUpdater.autoInstallOnAppQuit).toBe(false)+ updaterEvents['update-available']?.({ version: '9.9.9' })+ expect(sent.at(-1)).toEqual({+ channel: IPC.appUpdateAvailable,+ payload: { version: '9.9.9', notes: '', manual: true }+ })+ expect(channels()).not.toContain(IPC.appUpdateNoChannel)+ })++ it('Linux AppImage: still self-installs', () => {+ setPlatform('linux')+ process.env.APPIMAGE = '/tmp/nodeterm.AppImage'+ packageWith(undefined)+ initUpdater()+ expect(autoUpdater.autoDownload).toBe(true)+ updaterEvents['update-available']?.({ version: '9.9.9' })+ expect(sent.at(-1)).toEqual({+ channel: IPC.appUpdateAvailable,+ payload: { version: '9.9.9', notes: '', manual: false }+ })+ })++ it('an unreadable packaged package.json still behaves like a release', () => {+ setPlatform('darwin')+ appMock.appPath = path.join(os.tmpdir(), 'nt-updater-missing')+ initUpdater()+ expect(autoUpdater.checkForUpdates).toHaveBeenCalledTimes(1)+ })+})diff --git a/src/main/updater.ts b/src/main/updater.tsindex 9f148c5e2..cd05602ab 100644--- a/src/main/updater.ts+++ b/src/main/updater.ts@@ -11,11 +11,7 @@ import path from 'path'// electron-vite v5's CJS interop.import { autoUpdater } from 'electron-updater'import { IPC } from '../shared/ipc'-import {- isManualUpdatePlatform,- shouldEnableUpdater,- toUpdateAvailablePayload-} from '../shared/update-platform'+import { toUpdateAvailablePayload, updateDelivery } from '../shared/update-platform'import { getMainWindow, sendToMain } from './main-window'import { retainUntilDismissed } from './notifications'@@ -31,9 +27,12 @@ const SIX_HOURS = 6 * 60 * 60 * 1000* never published there and logged a 404 on `latest*.yml` every six hours.** The trade-off, stated plainly: a `dist*` package can no longer smoke-test the updater wiring- * itself — a manual check there now answers "up to date" without going near the network. The old- * behaviour at least proved the wiring was live, at the cost of a recurring 404 in every local- * build's log. Verifying the real feed is the job of a `release` package, which carries no marker.+ * itself — a manual check there does not go near the network. The old behaviour at least proved+ * the wiring was live, at the cost of a recurring 404 in every local build's log. Verifying the+ * real feed is the job of a `release` package, which carries no marker.+ *+ * The marker is therefore also what `no-channel` means at runtime (see `updateDelivery`): such a+ * build now SAYS it has no channel instead of claiming to be up to date, which is issue #814.*/function packagedUpdateMode(): unknown {if (!app.isPackaged) return undefined@@ -71,17 +70,33 @@ export function initUpdater(onBeforeRestart?: () => void): void {autoUpdater.quitAndInstall()})- if (!shouldEnableUpdater(app.isPackaged, packagedUpdateMode())) {- // Dev and explicitly local/unsigned packages have no update channel. A manual check reports- // "up to date" for feedback; automatic networking and updater event wiring stay disabled.- ipcMain.on(IPC.appCheckForUpdates, () => send(IPC.appUpdateNotAvailable))+ const delivery = updateDelivery({+ isPackaged: app.isPackaged,+ updateMode: packagedUpdateMode(),+ platform: process.platform,+ hasAppImage: !!process.env.APPIMAGE+ })++ if (delivery === 'dev' || delivery === 'no-channel') {+ // Neither can reach a feed, so automatic networking and updater event wiring stay off — but+ // the two answer a MANUAL check differently, because only one of them has a user to mislead.+ //+ // `no-channel` is a packaged app someone installed (a Windows build today: no signed release+ // job, no `latest.yml`). Telling them "up to date" is a statement this build is structurally+ // unable to make — it was issue #814's actual complaint, read by the reporter as a dead+ // button. It now says it has no channel and points at the download page.+ //+ // `dev` keeps the old quiet "up to date": `npm run dev` has no install to be wrong about.+ ipcMain.on(IPC.appCheckForUpdates, () =>+ send(delivery === 'no-channel' ? IPC.appUpdateNoChannel : IPC.appUpdateNotAvailable)+ )return}// A Linux .deb/.rpm install (no APPIMAGE env) cannot self-install and would re-download the// full AppImage every 6h only to throw on install. Degrade to a manual-download link: don't// auto-download; surface update-available with `manual: true` so the card shows a Download link.- const manualUpdates = isManualUpdatePlatform(process.platform, !!process.env.APPIMAGE)+ const manualUpdates = delivery === 'manual-install'autoUpdater.autoDownload = !manualUpdatesautoUpdater.autoInstallOnAppQuit = !manualUpdatesdiff --git a/src/preload/index.ts b/src/preload/index.tsindex 3b7207706..4a9cdc968 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -441,6 +441,11 @@ const api: NodeTerminalApi = {ipcRenderer.on(IPC.appUpdateNotAvailable, handler)return () => ipcRenderer.removeListener(IPC.appUpdateNotAvailable, handler)},+ onNoChannel: (listener) => {+ const handler = () => listener()+ ipcRenderer.on(IPC.appUpdateNoChannel, handler)+ return () => ipcRenderer.removeListener(IPC.appUpdateNoChannel, handler)+ },check: () => ipcRenderer.send(IPC.appCheckForUpdates),getVersion: () => ipcRenderer.invoke(IPC.appGetVersion),getPolicy: () => ipcRenderer.invoke(IPC.appUpdatePolicy),diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.tsindex 8608e1080..30ba698dd 100644--- a/src/renderer/bridge/stubs.ts+++ b/src/renderer/bridge/stubs.ts@@ -217,6 +217,9 @@ export function buildStubApi(): Omit<onProgress: noopUnsub,onError: noopUnsub,onNotAvailable: noopUnsub,+ // Server Edition has no updater at all (initUpdater runs only in src/main) and a browser+ // tab cannot self-install, so there is no channel state to report either way.+ onNoChannel: noopUnsub,check: noop,getVersion: U('updates.getVersion'),// Boot path awaits this and reads `p.mandatory` UNGUARDED (UpdateCard.tsx), so the olddiff --git a/src/renderer/components/UpdateCard.no-channel.test.tsx b/src/renderer/components/UpdateCard.no-channel.test.tsxnew file mode 100644index 000000000..920cc1a2a--- /dev/null+++ b/src/renderer/components/UpdateCard.no-channel.test.tsx@@ -0,0 +1,113 @@+// @vitest-environment jsdom+// Issue #814: the card must show the no-channel state as its own card — the manual-download+// MECHANISM (one card, one link to the download page), a different sentence. And the two states+// it sits between must be untouched: "up to date" still means we looked, and the Linux .deb card+// still names its version.+import { act } from 'react'+import { createRoot } from 'react-dom/client'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { UpdateCard } from './UpdateCard'++;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true++type Fire = (...a: unknown[]) => void+const fire: Record<string, Fire> = {}+const sub = (name: string) => (listener: Fire) => {+ fire[name] = listener+ return () => delete fire[name]+}++let container: HTMLDivElement+let root: ReturnType<typeof createRoot>+const opened: string[] = []++beforeEach(() => {+ for (const k of Object.keys(fire)) delete fire[k]+ opened.length = 0+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {+ updates: {+ onAvailable: sub('available'),+ onDownloaded: sub('downloaded'),+ onProgress: sub('progress'),+ onError: sub('error'),+ onNotAvailable: sub('notAvailable'),+ onNoChannel: sub('noChannel'),+ getPolicy: () => Promise.resolve({ minSupported: null, mandatory: false }),+ check: () => {},+ restart: () => {}+ }+ }+ window.open = ((url: string) => {+ opened.push(url)+ return null+ }) as typeof window.open+ container = document.createElement('div')+ document.body.appendChild(container)+ act(() => {+ root = createRoot(container)+ root.render(<UpdateCard />)+ })+})++afterEach(() => {+ act(() => root.unmount())+ container.remove()+ vi.useRealTimers()+})++const text = (): string => container.textContent ?? ''++describe('the no-channel card', () => {+ beforeEach(() => act(() => fire.noChannel()))++ it('says the build has no channel and points at the download page', () => {+ expect(text()).toContain('No update channel')+ expect(text()).toContain('This build has no update channel')+ expect(text()).toContain('Download the latest installer to update.')+ })++ it('never claims the user is up to date', () => {+ expect(text()).not.toContain('up to date')+ expect(text()).not.toContain('latest version')+ })++ it('offers the download page through the same link the manual card uses', () => {+ const btn = [...container.querySelectorAll('button')].find(+ (b) => b.textContent === 'Open download page'+ )+ expect(btn).toBeTruthy()+ act(() => btn!.click())+ expect(opened).toEqual(['https://nodeterm.dev/releases'])+ })++ it('stays put — no auto-dismiss timer, unlike the up-to-date toast', () => {+ vi.useFakeTimers()+ act(() => {+ vi.advanceTimersByTime(30_000)+ })+ expect(text()).toContain('No update channel')+ })++ it('is dismissible, and nothing else remains', () => {+ const close = container.querySelector<HTMLButtonElement>('button[aria-label="Dismiss"]')+ expect(close).toBeTruthy()+ act(() => close!.click())+ expect(container.textContent).toBe('')+ })+})++describe('the states either side of it are unchanged', () => {+ it('"not available" still renders the up-to-date card', () => {+ act(() => fire.notAvailable())+ expect(text()).toContain("You're up to date")+ expect(text()).toContain('nodeterm is on the latest version.')+ expect(text()).not.toContain('No update channel')+ })++ it('a Linux .deb update still names its version on the manual card', () => {+ act(() => fire.available({ version: '0.3.8', notes: '', manual: true }))+ expect(text()).toContain('Update available')+ expect(text()).toContain('nodeterm v0.3.8 is available. Download it to update.')+ expect(text()).not.toContain('No update channel')+ })+})diff --git a/src/renderer/components/UpdateCard.tsx b/src/renderer/components/UpdateCard.tsxindex 5da6e818d..98953370b 100644--- a/src/renderer/components/UpdateCard.tsx+++ b/src/renderer/components/UpdateCard.tsx@@ -1,5 +1,6 @@import { useEffect, useRef, useState } from 'react'import { IconClose } from './icons'+import { noSelfInstallCopy } from '@shared/update-platform'import type { UpdateProgress } from '@shared/types'// The full updater lifecycle as one status union, driving a fixed bottom-right card.@@ -11,6 +12,10 @@ type Status =| { kind: 'available'; version: string; percent: number }// A .deb/.rpm Linux install can't self-install — show a manual download link, no progress/restart.| { kind: 'manual'; version: string }+ // This build has no update channel at all, so no version is known and none ever will be+ // (issue #814). Same mechanism as `manual` — one card, one download link — different sentence,+ // because "we cannot look" is not "we looked and you are current".+ | { kind: 'noChannel' }| { kind: 'downloaded'; version: string }| { kind: 'upToDate' }| { kind: 'required'; minSupported: string | null }@@ -48,6 +53,11 @@ export function UpdateCard(): JSX.Element | null {4000)})+ const offNoChannel = window.nodeTerminal.updates.onNoChannel(() => {+ // Never auto-hides, unlike `upToDate`: this card carries the only action the user has.+ setStatus((s) => (s.kind === 'required' ? s : { kind: 'noChannel' }))+ setMinimized(false)+ })const offError = window.nodeTerminal.updates.onError((message) => {setStatus({ kind: 'error', message })setMinimized(false)@@ -57,6 +67,7 @@ export function UpdateCard(): JSX.Element | null {offProgress()offDownloaded()offNotAvailable()+ offNoChannel()offError()if (upToDateTimer.current) window.clearTimeout(upToDateTimer.current)}@@ -136,7 +147,9 @@ export function UpdateCard(): JSX.Element | null {: status.kind === 'available'? 'Downloading Update': status.kind === 'manual'- ? 'Update available'+ ? noSelfInstallCopy('manual-install', status.version).title+ : status.kind === 'noChannel'+ ? noSelfInstallCopy('no-channel').title: status.kind === 'downloaded'? 'Update ready': status.kind === 'upToDate'@@ -148,6 +161,7 @@ export function UpdateCard(): JSX.Element | null {const canMinimize = status.kind === 'available' || status.kind === 'downloaded'const canDismiss =status.kind === 'manual' ||+ status.kind === 'noChannel' ||status.kind === 'downloaded' ||status.kind === 'upToDate' ||status.kind === 'error'@@ -188,10 +202,19 @@ export function UpdateCard(): JSX.Element | null {{status.kind === 'manual' && (<><p className="update-card__body">- nodeterm v{status.version} is available. Download it to update.+ {noSelfInstallCopy('manual-install', status.version).body}</p><button className="update-card__btn" onClick={openReleases}>- Download+ {noSelfInstallCopy('manual-install', status.version).action}+ </button>+ </>+ )}++ {status.kind === 'noChannel' && (+ <>+ <p className="update-card__body">{noSelfInstallCopy('no-channel').body}</p>+ <button className="update-card__btn" onClick={openReleases}>+ {noSelfInstallCopy('no-channel').action}</button></>)}diff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex 14e1fc4f0..debe9416f 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -242,6 +242,8 @@ export const IPC = {appUpdateProgress: 'app:update-progress',appUpdateError: 'app:update-error',appUpdateNotAvailable: 'app:update-not-available',+ /** This build has no update channel at all (issue #814) — distinct from "up to date". */+ appUpdateNoChannel: 'app:update-no-channel',appCheckForUpdates: 'app:check-for-updates',appGetVersion: 'app:get-version',appUserDataDir: 'app:user-data-dir',diff --git a/src/shared/types.ts b/src/shared/types.tsindex 76fabebbf..2099e0ea9 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -2289,6 +2289,12 @@ export interface UpdateApi {onError(listener: (message: string) => void): () => void/** No newer version is available (also the dev no-op reply to check()). Returns unsubscribe. */onNotAvailable(listener: () => void): () => void+ /**+ * This build has no update channel and can never learn whether a newer version exists+ * (issue #814). Deliberately separate from `onNotAvailable`: "we looked and you are current"+ * and "we cannot look" are different facts with different remedies. Returns unsubscribe.+ */+ onNoChannel(listener: () => void): () => void/** Trigger a manual update check. */check(): void/** The running app version. */diff --git a/src/shared/update-platform.test.ts b/src/shared/update-platform.test.tsindex cd1ea2647..7d52d270d 100644--- a/src/shared/update-platform.test.ts+++ b/src/shared/update-platform.test.ts@@ -3,8 +3,10 @@ import fs from 'fs'import path from 'path'import {isManualUpdatePlatform,+ noSelfInstallCopy,shouldEnableUpdater,- toUpdateAvailablePayload+ toUpdateAvailablePayload,+ updateDelivery} from './update-platform'describe('isManualUpdatePlatform', () => {@@ -83,3 +85,110 @@ describe('toUpdateAvailablePayload', () => {).toBe('')})})+++/**+ * Issue #814: a Windows build carries `nodeTermUpdates=disabled` (no signed release job, no+ * `latest.yml`), so the updater never wires a feed — and the one thing that branch DID wire was a+ * manual check answering "up to date". These pin the three delivery paths apart, and pin that the+ * macOS and Linux release paths are untouched by the new one.+ */+describe('updateDelivery', () => {+ const pkgd = { isPackaged: true, updateMode: undefined as unknown, hasAppImage: false }++ it('a packaged build with updates switched off has NO CHANNEL — it is not up to date', () => {+ expect(updateDelivery({ ...pkgd, updateMode: 'disabled', platform: 'win32' })).toBe('no-channel')+ })++ it('decides no-channel from the build marker, never from the platform name', () => {+ // The same marker on every platform: `dist`, `dist:linux` and `dist:win` all set it, and the+ // day a Windows RELEASE ships with a feed it carries no marker and takes the ordinary path+ // below with nothing to edit here.+ for (const platform of ['win32', 'darwin', 'linux']) {+ expect(updateDelivery({ ...pkgd, updateMode: 'disabled', platform })).toBe('no-channel')+ }+ })++ it('a future signed Windows release self-installs, by carrying no marker', () => {+ expect(updateDelivery({ ...pkgd, platform: 'win32' })).toBe('self-install')+ })++ it('macOS is unchanged: a release self-installs', () => {+ expect(updateDelivery({ ...pkgd, platform: 'darwin' })).toBe('self-install')+ expect(updateDelivery({ ...pkgd, platform: 'darwin', hasAppImage: true })).toBe('self-install')+ })++ it('Linux is unchanged: .deb/.rpm stays manual, AppImage stays self-installing', () => {+ expect(updateDelivery({ ...pkgd, platform: 'linux' })).toBe('manual-install')+ expect(updateDelivery({ ...pkgd, platform: 'linux', hasAppImage: true })).toBe('self-install')+ })++ it('dev stays its own state — quiet, not a no-channel card in every `npm run dev`', () => {+ for (const platform of ['win32', 'darwin', 'linux']) {+ expect(updateDelivery({ isPackaged: false, updateMode: undefined, platform, hasAppImage: false })).toBe('dev')+ // Even with the marker a dist build would carry, an unpackaged run is dev first.+ expect(updateDelivery({ isPackaged: false, updateMode: 'disabled', platform, hasAppImage: false })).toBe('dev')+ }+ })++ it('stays composed from the two primitives — no second definition to drift', () => {+ for (const platform of ['win32', 'darwin', 'linux']) {+ for (const hasAppImage of [false, true]) {+ for (const updateMode of [undefined, 'enabled', 'disabled']) {+ const d = updateDelivery({ isPackaged: true, updateMode, platform, hasAppImage })+ expect(d === 'no-channel').toBe(!shouldEnableUpdater(true, updateMode))+ if (d !== 'no-channel') {+ expect(d === 'manual-install').toBe(isManualUpdatePlatform(platform, hasAppImage))+ }+ }+ }+ }+ })+})++describe('noSelfInstallCopy', () => {+ const manual = noSelfInstallCopy('manual-install', '0.3.8')+ const none = noSelfInstallCopy('no-channel')++ it('the Linux .deb sentence is byte-identical to the one that shipped', () => {+ expect(manual).toEqual({+ title: 'Update available',+ body: 'nodeterm v0.3.8 is available. Download it to update.',+ action: 'Download'+ })+ })++ it('the no-channel card names the reason and the remedy, and claims no version', () => {+ expect(none.title).toBe('No update channel')+ expect(none.body).toBe(+ 'This build has no update channel, so it cannot tell you when a new version is out. ' ++ 'Download the latest installer to update.'+ )+ expect(none.action).toBe('Open download page')+ })++ it('never says "up to date", and never promises a self-install', () => {+ const words = `${none.title} ${none.body} ${none.action}`.toLowerCase()+ expect(words).not.toContain('up to date')+ expect(words).not.toContain('latest version')+ expect(words).not.toContain('restart')+ expect(words).not.toContain('install itself')+ })++ it('the two reasons never collapse into one sentence — the remedies differ', () => {+ expect(none.title).not.toBe(manual.title)+ expect(none.body).not.toBe(manual.body)+ // `manual` knows which version is out; `no-channel` structurally cannot.+ expect(manual.body).toContain('0.3.8')+ expect(none.body).not.toMatch(/\bv?\d+\.\d+/)+ })++ it('names no platform — the state decides the copy, not an OS typed into a string', () => {+ for (const copy of [manual, none]) {+ const words = `${copy.title} ${copy.body} ${copy.action}`.toLowerCase()+ for (const os of ['windows', 'win32', 'macos', 'linux', 'deb', 'rpm']) {+ expect(words).not.toContain(os)+ }+ }+ })+})diff --git a/src/shared/update-platform.ts b/src/shared/update-platform.tsindex 8434ff01b..998d4e78c 100644--- a/src/shared/update-platform.ts+++ b/src/shared/update-platform.ts@@ -31,3 +31,77 @@ export function toUpdateAvailablePayload(manual}}++/**+ * How this build can receive an update. Three delivery paths plus dev, because the REMEDY the+ * user needs differs and the card must not blur them:+ *+ * - `self-install` there is a feed and electron-updater can relaunch the new binary: macOS+ * dmg/zip, a Linux AppImage, and a Windows release once one is signed and+ * published. The ordinary download-progress → "Restart to update" flow.+ * - `manual-install` there IS a feed, but this install cannot self-install (Linux .deb/.rpm: no+ * APPIMAGE, so quitAndInstall throws). We know which version is out; the user+ * installs that package themselves.+ * - `no-channel` there is no feed AT ALL — the build was packaged with updates switched off+ * (`nodeTermUpdates=disabled`, which every `dist*` script sets, and which a+ * Windows build carries today because Windows has no signed release job or+ * `latest.yml`). This build can never learn that a newer version exists, so a+ * check must say so and point at the download page. Reporting "up to date"+ * here — what shipped before issue #814 — is a false statement, not feedback.+ * - `dev` unpackaged. Deliberately keeps the old quiet "up to date" reply: a developer+ * running `npm run dev` is not a user who can be misled about their install.+ *+ * `no-channel` is decided by the BUILD MARKER, never by a platform name. That is what makes the+ * first Windows release with a real channel show the ordinary path with nothing to edit here.+ */+export type UpdateDelivery = 'self-install' | 'manual-install' | 'no-channel' | 'dev'++export function updateDelivery(opts: {+ isPackaged: boolean+ updateMode: unknown+ platform: string+ hasAppImage: boolean+}): UpdateDelivery {+ if (!opts.isPackaged) return 'dev'+ // Composed from the two primitives above rather than re-deciding either — one definition of+ // "has a feed" and one of "can self-install", so the wiring and the copy cannot drift apart.+ if (!shouldEnableUpdater(opts.isPackaged, opts.updateMode)) return 'no-channel'+ return isManualUpdatePlatform(opts.platform, opts.hasAppImage) ? 'manual-install' : 'self-install'+}++/** What the update card says when this build will not install the update by itself. */+export interface NoSelfInstallCopy {+ title: string+ body: string+ /** Label of the button that opens the download page. */+ action: string+}++/**+ * The two "you install it yourself" sentences, side by side so neither can quietly become the+ * other. They are NOT interchangeable: `manual-install` names a version we actually saw on the+ * feed and asks the user to install that package; `no-channel` knows no version at all and can+ * only send the user to look. Swapping them sends someone to the wrong place.+ *+ * `manual-install`'s wording is the one Linux .deb/.rpm installs have always shown — keep it+ * byte-identical, it is the pinned no-change path.+ */+export function noSelfInstallCopy(+ delivery: 'manual-install' | 'no-channel',+ version?: string+): NoSelfInstallCopy {+ if (delivery === 'manual-install') {+ return {+ title: 'Update available',+ body: `nodeterm v${version ?? ''} is available. Download it to update.`,+ action: 'Download'+ }+ }+ return {+ title: 'No update channel',+ body:+ 'This build has no update channel, so it cannot tell you when a new version is out. ' ++ 'Download the latest installer to update.',+ action: 'Open download page'+ }+}