Skip to content

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.

fix(update-card): a reloaded renderer asks for the staged update

reviewabe7d2fb5b85
diff --git a/CLAUDE.md b/CLAUDE.md
index 2daa0d6a7..43e45f74a 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -9434,6 +9434,10 @@ Rules a refactor must not undo (pure + tested: `shared/update-gate.ts`, `rendere
through Squirrel). The gate forwards and notifies **once per version**; once staged, `autoDownload`
goes off and only a strictly newer release is downloaded (`downloadUpdate()` on purpose). The card
never downgrades `downloaded`/`required`, never un-minimizes on a repeat, respects a dismissed version.
+ Two consequences that must stay paired with that: a renderer loading after the one-time
+ announcement (⌘R, a recreated window) asks `updates.getStaged()` on mount, and a **failed
+ Squirrel.Mac staging run is re-staged** on the next check (or a Restart click — once per click,
+ never in a loop from the error itself), because with `autoDownload` off nothing else would.
- **macOS `update-downloaded` fires BEFORE Squirrel.Mac has the update** (MacUpdater dispatches, then
asks the native updater to fetch + verify the zip). Until Electron's own `autoUpdater` emits
`update-downloaded`, `quitAndInstall()` only queues a listener. So a click there sends
diff --git a/src/preload/index.ts b/src/preload/index.ts
index f1a036534..2bd9ad684 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -520,6 +520,7 @@ const api: NodeTerminalApi = {
check: () => ipcRenderer.send(IPC.appCheckForUpdates),
getVersion: () => ipcRenderer.invoke(IPC.appGetVersion),
getPolicy: () => ipcRenderer.invoke(IPC.appUpdatePolicy),
+ getStaged: () => ipcRenderer.invoke(IPC.appGetStagedUpdate),
restart: () => ipcRenderer.send(IPC.appRestartToUpdate),
prepareInspect: () => ipcRenderer.invoke(IPC.appUpdatePrepInspect),
prepareShutdownHost: () => ipcRenderer.invoke(IPC.appUpdatePrepShutdown),
diff --git a/src/renderer/bridge/stubs.ts b/src/renderer/bridge/stubs.ts
index c3b9cd351..e8304d417 100644
--- a/src/renderer/bridge/stubs.ts
+++ b/src/renderer/bridge/stubs.ts
@@ -248,6 +248,8 @@ export function buildStubApi(): Omit<
onNoChannel: noopUnsub,
// No self-install in a browser, so there is never an install in progress to report.
onInstalling: noopUnsub,
+ // Nothing is ever staged in a browser.
+ getStaged: () => Promise.resolve(null),
check: noop,
getVersion: U('updates.getVersion'),
// Boot path awaits this and reads `p.mandatory` UNGUARDED (UpdateCard.tsx), so the old
diff --git a/src/renderer/components/UpdateCard.flow.test.tsx b/src/renderer/components/UpdateCard.flow.test.tsx
index 2a25f415f..6c1e30ca5 100644
--- a/src/renderer/components/UpdateCard.flow.test.tsx
+++ b/src/renderer/components/UpdateCard.flow.test.tsx
@@ -23,6 +23,7 @@ let container: HTMLDivElement
let root: ReturnType<typeof createRoot>
let policies: Array<UpdatePolicy | Error>
let version: string
+let staged: { version: string; notes: string } | null
const restart = vi.fn()
const check = vi.fn()
@@ -42,6 +43,7 @@ beforeEach(() => {
check.mockClear()
policies = []
version = '0.5.0'
+ staged = null
usePendingUpdate.setState({ pending: null })
try {
window.localStorage.clear()
@@ -58,6 +60,7 @@ beforeEach(() => {
onNoChannel: sub('noChannel'),
onInstalling: sub('installing'),
getVersion: () => Promise.resolve(version),
+ getStaged: () => Promise.resolve(staged),
getPolicy: vi.fn(() => {
const next = policies.shift() ?? { minSupported: null, mandatory: false }
return next instanceof Error ? Promise.reject(next) : Promise.resolve(next)
@@ -227,3 +230,20 @@ describe('updated to vX', () => {
expect(window.localStorage.getItem(LAST_SEEN_VERSION_KEY)).toBe('0.5.0')
})
})
+
+describe('a renderer that loads after the one-time announcement', () => {
+ it('asks main for the staged update and shows the ready card (⌘R / recreated window)', async () => {
+ staged = { version: '0.6.0', notes: '- Faster restarts' }
+ mount()
+ await flush()
+ expect(text()).toContain('Update ready')
+ expect(text()).toContain('Faster restarts')
+ expect(usePendingUpdate.getState().pending).toEqual({ kind: 'downloaded', version: '0.6.0' })
+ })
+
+ it('nothing staged: stays silent', async () => {
+ mount()
+ await flush()
+ expect(text()).toBe('')
+ })
+})
diff --git a/src/renderer/components/UpdateCard.tsx b/src/renderer/components/UpdateCard.tsx
index d17e11223..b4d8db49c 100644
--- a/src/renderer/components/UpdateCard.tsx
+++ b/src/renderer/components/UpdateCard.tsx
@@ -64,7 +64,20 @@ export function UpdateCard(): JSX.Element | null {
u.onError((message) => dispatch({ type: 'error', message })),
u.onInstalling((s) => dispatch({ type: 'installing', phase: s.phase, version: s.version }))
]
- return () => offs.forEach((off) => off())
+ // Already staged before this renderer loaded (⌘R, a recreated window): main announced it once
+ // and will not repeat it, so ask. A repeat of what the card shows is a no-op in the reducer.
+ let live = true
+ Promise.resolve()
+ .then(() => u.getStaged?.())
+ .then((s) => {
+ if (live && s && typeof s.version === 'string')
+ dispatch({ type: 'downloaded', version: s.version, notes: s.notes || undefined })
+ })
+ .catch(() => {})
+ return () => {
+ live = false
+ offs.forEach((off) => off())
+ }
}, [])
// "You're up to date" is a toast, not a card that stays.
diff --git a/src/shared/ipc.ts b/src/shared/ipc.ts
index 8f39d64c1..346eb77c8 100644
--- a/src/shared/ipc.ts
+++ b/src/shared/ipc.ts
@@ -348,6 +348,8 @@ export const IPC = {
appUpdatePrepQuit: 'app:update-prep-quit',
/** main → renderer: restart-to-update was accepted; `{phase:'preparing'|'restarting', version}`. */
appUpdateInstalling: 'app:update-installing',
+ /** renderer → main (invoke): the update already staged this run, `{version, notes}` or null. */
+ appGetStagedUpdate: 'app:get-staged-update',
/** main → renderer: write any pending canvas edits now (payload: request id). Quit / restart. */
appFlushRequest: 'app:flush-request',
/** renderer → main: the flush for that request id settled. */
diff --git a/src/shared/types.ts b/src/shared/types.ts
index bafed0ac3..663d38652 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -2895,6 +2895,11 @@ export interface UpdateApi {
onNoChannel(listener: () => void): () => void
/** Restart-to-update was accepted and is preparing / restarting. Returns unsubscribe. */
onInstalling(listener: (s: UpdateInstalling) => void): () => void
+ /**
+ * The update main already staged this run (announced once), or null. A renderer that loads after
+ * that one-time `onDownloaded` — ⌘R, a window recreated after a crash — asks on mount.
+ */
+ getStaged(): Promise<{ version: string; notes: string } | null>
/** Trigger a manual update check. */
check(): void
/** The running app version. */