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
Merge branch 'feat/win-18-windows-update-path' into stack2-18
review0472c1043a49
diff --cc src/main/updater.no-channel.test.tsindex ad3eede12,f4aac7ecb..55beae52e--- a/src/main/updater.no-channel.test.ts+++ b/src/main/updater.no-channel.test.ts@@@ -266,9 -257,19 +266,19 @@@ describe('the unsigned Windows beta (macheck()await Promise.resolve()await Promise.resolve()- expect(channels()).toContain(IPC.appUpdateError)+ expect(channels().filter((c) => c === IPC.appUpdateError)).toHaveLength(1)})+ it('a silent check failure is recorded and logged as an actionable warning, not dropped', () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})+ updaterEvents['error']?.(new Error('HttpError: 404 "method: GET url: https://nodeterm.dev/updates/latest.yml"'))+ expect(channels()).not.toContain(IPC.appUpdateError)+ expect(lastUpdateCheck()).toMatchObject({ ok: false, message: expect.stringContaining('404') })+ expect(warn).toHaveBeenCalledWith('[updater]', expect.stringMatching(/update feed is missing/))+ updaterEvents['update-not-available']?.()+ expect(lastUpdateCheck()).toMatchObject({ ok: true })+ })+it('refuses restart-to-update in main: quitAndInstall never runs', () => {restart()expect(autoUpdater.quitAndInstall).not.toHaveBeenCalled()diff --cc src/main/updater.tsindex 386179fc2,64a800a52..996241e85--- a/src/main/updater.ts+++ b/src/main/updater.ts@@@ -13,33 -12,42 +13,60 @@@ import path from 'pathimport { autoUpdater } from 'electron-updater'import { IPC } from '../shared/ipc'import {+ installReadiness,+ MANUAL_UPDATE_MODE,mayQuitAndInstall,+ releaseNotesText,toUpdateAvailablePayload,updateDelivery} from '../shared/update-platform'+import {+ classifyUpdaterError,+ createUpdateGate,+ friendlyUpdateErrorMessage,+ nextDownloadRetryMs,+ type UpdateErrorOrigin+} from '../shared/update-gate'+import type { UpdateInstalling } from '../shared/types'import { getMainWindow, sendToMain } from './main-window'import { retainUntilDismissed } from './notifications'+import { requestRendererFlush } from './renderer-flush'+ import { consumeUpdateFailedMarker, describeUpdateInstallFailure } from './update-install-marker'const SIX_HOURS = 6 * 60 * 60 * 1000+ /** The outcome of the most recent feed check (any trigger). Recorded so a check-only build's+ * silent automatic failures are still observable — see the 'error' handler. */+ export interface UpdateCheckRecord {+ at: number+ ok: boolean+ message?: string+ }+ let lastCheck: UpdateCheckRecord | null = null+ export function lastUpdateCheck(): UpdateCheckRecord | null {+ return lastCheck+ }++ /**+ * One actionable log line for a failed check in a check-only build. A 404 on a `latest*.yml` is+ * the feed itself missing — the nodeterm.dev/updates mirror not serving that platform's file —+ * which is an ops fix, not a network blip, and reads like one in a device report. Pure; exported+ * for tests.+ */+ export function describeCheckFailure(message: string): string {+ const feedMissing = /\b404\b/.test(message) && /latest[\w.-]*\.yml/i.test(message)+ return feedMissing+ ? `update feed is missing this platform's latest*.yml (${message}); the passive update notice cannot fire until the update mirror serves it`+ : `update check failed: ${message}`+ }++/**+ * How long a restart-to-update may sit in `preparing` (macOS: Squirrel.Mac re-reading the zip and+ * verifying its signature) before we give up on THIS click. The update is not cancelled — Squirrel+ * keeps going and a later click (or the next quit) still installs it.+ */+export const PREPARE_TIMEOUT_MS = 5 * 60 * 1000+/*** The `nodeTermUpdates` marker a LOCAL package carries in its packaged package.json, injected by* the `dist*` scripts via electron-builder's `extraMetadata`. `release` does not set it, so a@@@ -102,13 -87,23 +129,21 @@@ export interface UpdaterHandle* reference is a DESTROYED window: touching it throws `TypeError: Object has been destroyed`. That* shipped — an update finishing downloading after a close→dock-reopen crashed the main process on* `win.isFocused()`.- *- * @param onBeforeRestart Run right before `quitAndInstall()`. Required so the caller can flip its- * "quitting" flag: `quitAndInstall()` closes all windows and only then calls `app.quit()`, but- * our `win.on('close')` hides the window (keeps the app alive) unless we're already quitting — so- * without this the window just hides, `app.quit()` never fires, and the update never installs.*/-export function initUpdater(onBeforeRestart?: () => void): void {+export function initUpdater(hooks: UpdaterHooks = {}): UpdaterHandle {const send = (channel: string, payload?: unknown) => sendToMain(channel, payload)+ const flushRenderer =+ hooks.flushRenderer ?? (() => requestRendererFlush(getMainWindow()?.webContents, ipcMain))+ const platform = process.platform+ // A self-update the installer refused on the way in (build/installer.nsh writes this note and+ // restarts the previous version). Read once and deleted; Windows only, a no-op elsewhere.+ const failedInstall = consumeUpdateFailedMarker({+ platform: process.platform,+ localAppData: process.env.LOCALAPPDATA+ })+ if (failedInstall) console.warn('[updater]', describeUpdateInstallFailure(failedInstall))+const updateMode = packagedUpdateMode()const delivery = updateDelivery({isPackaged: app.isPackaged,@@@ -254,29 -152,13 +289,34 @@@autoUpdater.autoDownload = !manualUpdatesautoUpdater.autoInstallOnAppQuit = !manualUpdates+ // The flow an error belongs to (classifyUpdaterError): who started the check, and whether a+ // download is running.+ let userFlow = false+ let downloading = false+ let downloadFailures = 0+ let retryTimer: ReturnType<typeof setTimeout> | undefined++ const recordCheck = (ok: boolean, message?: string): void => {+ lastCheck = { at: Date.now(), ok, ...(message === undefined ? {} : { message }) }+ }+autoUpdater.on('update-available', (info) => {+ recordCheck(true)- send(IPC.appUpdateAvailable, toUpdateAvailablePayload(info, manualUpdates))+ const d = gate.onAvailable(info.version, { userInitiated: userFlow })+ if (!d.download && restageNeeded && info.version === stagedVersion) {+ // Squirrel.Mac failed to stage this version: hand it the (cached) download again.+ restageNeeded = false+ downloading = true+ void autoUpdater.downloadUpdate().catch(() => undefined) // failures arrive as 'error'+ } else if (d.download) {+ // Newer than what is staged. autoDownload is off once something is staged (a re-check must+ // not re-download and re-stage the same zip), so this one is fetched on purpose.+ downloading = true+ void autoUpdater.downloadUpdate().catch(() => undefined) // failures arrive as 'error'+ } else if (!manualUpdates && autoUpdater.autoDownload) {+ downloading = true+ }+ if (d.forward) send(IPC.appUpdateAvailable, toUpdateAvailablePayload(info, manualUpdates))})autoUpdater.on('download-progress', (p) => {@@@ -336,81 -195,38 +376,93 @@@})autoUpdater.on('update-not-available', () => {+ recordCheck(true)+ downloading = false+ userFlow = falsesend(IPC.appUpdateNotAvailable)})+ // Squirrel.Mac (Electron's own autoUpdater — the singleton MacUpdater drives) reports when the+ // staged update is actually installable, and when staging failed. Elsewhere electron-updater+ // installs from the downloaded file itself and the native updater is not involved.+ if (platform === 'darwin' && nativeUpdater) {+ nativeUpdater.on('update-downloaded', () => {+ nativeReady = true+ nativeFailed = null+ if (restart.requested && restart.waitingForNative) void proceed()+ })+ nativeUpdater.on('error', (err: Error) => {+ const message = err?.message ?? String(err)+ console.error('[updater] native updater:', message)+ // Staging (not the install) failed: remember it so a click reports it at once, and re-stage+ // on the next check. Never re-stage from here directly — a persistent failure (a bad+ // signature) would loop download → stage → error with no one asking.+ const stagingFailed = stagedVersion !== null && !nativeReady+ if (stagingFailed) {+ nativeFailed = message+ restageNeeded = true+ }+ if (restart.requested) {+ abortRestart(message)+ // The user is waiting on this one: try staging again now, once per click.+ if (stagingFailed) requestRestage?.()+ }+ })+ }++ // A check-only build (`nodeTermUpdates=manual`, the unsigned Windows beta) downloads nothing, so- // every 'error' event it can emit is a CHECK failure — and electron-updater emits one for the- // silent launch/6h checks too. The beta previously showed nothing at all; an error card on every- // launch (offline, or a feed mirror that does not serve latest.yml yet) would be a regression- // for exactly the users this notice exists for. So there the event is not shown — but it is NOT- // silent either: it is recorded (`lastUpdateCheck`) and logged as one actionable warning, so a- // feed that 404s (the mirror not serving latest.yml) is visible in the debug log instead of- // looking like "no update yet". A user-initiated check still surfaces its failure through the- // catch below. Every other build keeps its historical behaviour.++ // every 'error' it sees outside a restart is a CHECK failure. Its silent launch/6h check failures++ // are not shown (classifyUpdaterError already keeps every auto-check off the card) — but they are++ // NOT silent either: recorded (`lastUpdateCheck`) and logged as one actionable warning, so a feed++ // that 404s (the mirror not serving latest.yml) reads as an ops fix in the debug log instead of++ // looking like "no update yet".+ const checkOnly = delivery === 'manual-install' && updateMode === MANUAL_UPDATE_MODE+++ // One owner for error reporting: this listener. electron-updater emits 'error' for every failed+ // check (manual and automatic alike) and download, so the manual handler below only logs its+ // rejection — answering there too used to put the same error up twice.autoUpdater.on('error', (err) => {- const message = err?.message ?? String(err)- recordCheck(false, message)- if (checkOnly) {- console.warn('[updater]', describeCheckFailure(message))+ const raw = err?.message ?? String(err)- console.error('[updater]', raw)+ // Once quitAndInstall ran, an error is the install failing. While still waiting on Squirrel+ // the native 'error' above is the authority — an unrelated background check failing in that+ // window must not cancel the user's restart.+ if (restart.requested && restart.beforeRestartRan) {++ console.error('[updater]', raw)+ abortRestart(raw)return}- console.error('[updater]', message)- send(IPC.appUpdateError, message)+ const origin: UpdateErrorOrigin = downloading+ ? userFlow+ ? 'manual-download'+ : 'auto-download'+ : userFlow+ ? 'manual-check'+ : 'auto-check'++ if (origin === 'auto-check' || origin === 'manual-check') recordCheck(false, raw)++ if (checkOnly && origin === 'auto-check') console.warn('[updater]', describeCheckFailure(raw))++ else console.error('[updater]', raw)+ const wasDownloading = downloading+ downloading = false+ userFlow = false+ if (classifyUpdaterError(origin) === 'surface') send(IPC.appUpdateError, friendlyUpdateErrorMessage(raw))+ // A failed background download is retried sooner than the next 6h tick (bounded backoff).+ // Check failures (offline at launch) keep the ordinary cadence, so we never hammer the feed.+ if (wasDownloading && origin === 'auto-download' && delivery === 'self-install') {+ const delay = nextDownloadRetryMs(++downloadFailures)+ if (retryTimer) clearTimeout(retryTimer)+ retryTimer = delay === null ? undefined : setTimeout(check, delay)+ }})- // Manual check from Settings; surfaces failures to the card.+ // Manual check from Settings / the required card; its outcome reaches the card through the+ // events above.ipcMain.on(IPC.appCheckForUpdates, () => {- autoUpdater.checkForUpdates().catch((err) => {- const message = err?.message ?? String(err)- console.error('[updater]', message)- send(IPC.appUpdateError, message)- })+ userFlow = true+ // Already staged: say so at once (a dismissed ready card comes back), and still look for a+ // newer release.+ const { echoDownloaded } = gate.onManualCheck()+ if (echoDownloaded) send(IPC.appUpdateDownloaded, { version: echoDownloaded })+ autoUpdater.checkForUpdates().catch(() => undefined) // reported by the 'error' listener})// Automatic checks: on launch and every six hours.