Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

fix(desktop): show update download progress and a restart button

leepokai3d712d431819
diff --git a/apps/desktop/src/main/tray.ts b/apps/desktop/src/main/tray.ts
index 79eb66ce..74e7959c 100644
--- a/apps/desktop/src/main/tray.ts
+++ b/apps/desktop/src/main/tray.ts
@@ -3,6 +3,7 @@ import { app, clipboard, Menu, nativeImage, shell, Tray as ElectronTray } from '
import type { TraySummary, WindowCommand } from '../shared/ipc'
import type { HostController } from './host-controller'
import type { Updates } from './updates'
+import { updateAction } from '../shared/update-action'
import { setShowInDock, showInDock } from './dock'
import { identity } from './environment'
import { islandSupported, type Island } from './island'
@@ -159,7 +160,7 @@ export class Tray {
const { updates } = this.deps
const u = updates.state
const items: Electron.MenuItemConstructorOptions[] = [
- { label: u.availableVersion ? `Update to ${u.availableVersion}…` : 'Check for Updates…', enabled: u.supported || u.staged, click: () => updates.check() },
+ { ...updateAction(u), click: () => updates.check() },
]
// The release waits until paired iPhones can get the app it needs.
if (u.waitingForApp) items.push({ label: `Waiting for iPhone app ${u.waitingForApp} to pass App Store review`, enabled: false })
diff --git a/apps/desktop/src/main/updates.ts b/apps/desktop/src/main/updates.ts
index 6d9a7fd4..2b0e80e0 100644
--- a/apps/desktop/src/main/updates.ts
+++ b/apps/desktop/src/main/updates.ts
@@ -1,5 +1,6 @@
import { EventEmitter } from 'node:events'
-import { app, BrowserWindow, ipcMain, powerMonitor } from 'electron'
+import { join } from 'node:path'
+import { app, BrowserWindow, ipcMain, powerMonitor, shell } from 'electron'
import electronUpdater, { type UpdateInfo } from 'electron-updater'
import { isBelow, parseVersion } from '../shared/compat'
import type { UpdateState } from '../shared/ipc'
@@ -21,7 +22,9 @@ export class Updates extends EventEmitter {
supported: enabled,
checking: false,
availableVersion: null,
+ downloadPercent: null,
staged: false,
+ installing: false,
autoCheck: prefs.get('updatesAutoCheck') !== false,
// On unless turned off: installs still wait until Codync is idle.
autoDownload: prefs.get('updatesAutoDownload') !== false,
@@ -32,7 +35,6 @@ export class Updates extends EventEmitter {
private userInitiated = false
private preparing: Promise<boolean> | null = null
private prepared = false
- private installing = false
private updateGeneration = 0
private appStoreVersion: string | null = null
@@ -51,16 +53,26 @@ export class Updates extends EventEmitter {
for (const w of windows()) w.webContents.send('updates:change', this.state)
})
if (!enabled) return
+ // macOS relaunches the updated app from the background, behind the app in front, and ignores
+ // `app.focus` there (cooperative activation); opening its own bundle brings it forward.
+ if (prefs.get('updateRelaunchInFront') === true) {
+ prefs.set('updateRelaunchInFront', false)
+ if (process.platform === 'darwin') void shell.openPath(join(app.getPath('exe'), '../../..'))
+ }
autoUpdater.autoDownload = false
autoUpdater.autoInstallOnAppQuit = true
autoUpdater.on('checking-for-update', () => this.set({ checking: true, error: null }))
autoUpdater.on('update-not-available', () => this.checked({ availableVersion: null }))
autoUpdater.on('update-available', (info) => void this.available(info))
+ autoUpdater.on('download-progress', ({ percent }) => {
+ const rounded = Math.floor(percent)
+ if (this.state.downloadPercent !== null && rounded !== this.state.downloadPercent) this.set({ downloadPercent: rounded })
+ })
+ // Ready to install: the person restarts from the Updates page, or it installs once idle.
autoUpdater.on('update-downloaded', (info) => {
- this.set({ staged: true, availableVersion: info.version })
- if (this.userInitiated) void this.install()
- else this.installWhenIdle()
+ this.set({ staged: true, downloadPercent: null, availableVersion: info.version })
+ this.installWhenIdle()
})
autoUpdater.on('error', (error) => this.failed(error))
@@ -98,14 +110,14 @@ export class Updates extends EventEmitter {
private failed(error: unknown) {
this.updateGeneration++
- this.installing = false
+ prefs.set('updateRelaunchInFront', false)
// A preparation still stopping the host restores it after stop completes.
if (this.prepared) {
this.prepared = false
this.host.resumeAfterCancelledUpdate()
}
const message = error instanceof Error ? error.message : String(error)
- this.checked({ error: this.userInitiated || this.state.staged ? message : null })
+ this.checked({ downloadPercent: null, installing: false, error: this.userInitiated || this.state.staged ? message : null })
this.userInitiated = false
}
@@ -118,9 +130,11 @@ export class Updates extends EventEmitter {
void autoUpdater.checkForUpdates().catch(() => {})
}
+ /** Checks, downloads, or once a release is staged, restarts into it. */
check() {
if (!enabled) return
- if (this.state.staged) return void this.install()
+ if (this.state.staged) return void this.install(true)
+ if (this.state.downloadPercent !== null) return
this.userInitiated = true
this.set({ error: null })
void autoUpdater.checkForUpdates().catch(() => {})
@@ -148,7 +162,10 @@ export class Updates extends EventEmitter {
this.userInitiated = false
return
}
- if (this.userInitiated || this.state.autoDownload) void autoUpdater.downloadUpdate().catch(() => {})
+ if (this.userInitiated || this.state.autoDownload) {
+ this.set({ downloadPercent: 0 })
+ void autoUpdater.downloadUpdate().catch(() => {})
+ }
}
/** The local host's `minApp` and whether an iPhone is paired with it. */
@@ -171,7 +188,7 @@ export class Updates extends EventEmitter {
if (!this.state.autoDownload || BrowserWindow.getFocusedWindow() || powerMonitor.getSystemIdleTime() < 600) return
if (!(await this.host.isIdleForUpdate())) return
clearInterval(timer)
- void this.install()
+ void this.install(false)
}, 30_000)
}
@@ -199,12 +216,14 @@ export class Updates extends EventEmitter {
return this.preparing
}
- private async install() {
- if (this.installing) return
- this.installing = true
+ /** `inFront`: the person chose to restart, so the relaunched app comes forward. */
+ private async install(inFront: boolean) {
+ if (this.state.installing) return
+ this.set({ installing: true })
try {
- if (await this.prepare()) autoUpdater.quitAndInstall(true, true)
- else this.installing = false
+ if (!(await this.prepare())) return this.set({ installing: false })
+ if (inFront) prefs.set('updateRelaunchInFront', true)
+ autoUpdater.quitAndInstall(true, true)
} catch (error) {
this.failed(error)
}
diff --git a/apps/desktop/src/renderer/components/Controls.tsx b/apps/desktop/src/renderer/components/Controls.tsx
index c1bd8e06..28040867 100644
--- a/apps/desktop/src/renderer/components/Controls.tsx
+++ b/apps/desktop/src/renderer/components/Controls.tsx
@@ -214,3 +214,12 @@ export function Pill({ children, fill = 'var(--background)', outlined = false, s
</span>
)
}
+
+/** Determinate progress (`value` 0...1): a thin capsule track that fills from the left. */
+export function ProgressBar({ value, label }: { value: number; label: string }) {
+ return (
+ <div className="progress-track" role="progressbar" aria-label={label} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(value * 100)}>
+ <div className="progress-fill" style={{ transform: `scaleX(${value})` }} />
+ </div>
+ )
+}
diff --git a/apps/desktop/src/renderer/components/controls.css b/apps/desktop/src/renderer/components/controls.css
index 851ff262..9818ed9b 100644
--- a/apps/desktop/src/renderer/components/controls.css
+++ b/apps/desktop/src/renderer/components/controls.css
@@ -235,3 +235,17 @@
padding: 5px 9px;
border-radius: 10px;
}
+
+.progress-track {
+ width: 100%;
+ height: 4px;
+ border-radius: 999px;
+ background: var(--bubble-user);
+ overflow: hidden;
+}
+.progress-fill {
+ height: 100%;
+ background: var(--accent-fill);
+ transform-origin: left;
+ transition: transform var(--layout);
+}
diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.ts
index 2d3682b2..c423d3cc 100644
--- a/apps/desktop/src/renderer/demo/bridge.ts
+++ b/apps/desktop/src/renderer/demo/bridge.ts
@@ -18,7 +18,7 @@ const snapshot: HostSnapshot = {
}
const account: AccountState = { ready: true, configured: false, busy: false, error: null, user: null, cloudURL: null }
const updates: UpdateState = {
- supported: false, checking: false, availableVersion: null, staged: false,
+ supported: false, checking: false, availableVersion: null, downloadPercent: null, staged: false, installing: false,
autoCheck: false, autoDownload: false, lastCheck: null, error: null, waitingForApp: null,
}
diff --git a/apps/desktop/src/renderer/views/UpdateButton.tsx b/apps/desktop/src/renderer/views/UpdateButton.tsx
new file mode 100644
index 00000000..9e1f0edb
--- /dev/null
+++ b/apps/desktop/src/renderer/views/UpdateButton.tsx
@@ -0,0 +1,24 @@
+import { useEffect, useState } from 'react'
+import type { UpdateState } from '@shared/ipc'
+import { updateAction } from '@shared/update-action'
+import { Button } from '../components/Controls'
+
+/** The app's update state, kept live. */
+export function useUpdates() {
+ const [updates, setUpdates] = useState<UpdateState | null>(null)
+ useEffect(() => {
+ void window.codync.updates.state().then(setUpdates)
+ return window.codync.updates.onChange(setUpdates)
+ }, [])
+ return updates
+}
+
+/** Check, update, download progress, then Restart to update: whatever the update state offers. */
+export function UpdateButton({ updates, kind = 'secondary' }: { updates: UpdateState; kind?: 'primary' | 'secondary' }) {
+ const action = updateAction(updates)
+ return (
+ <Button kind={updates.staged ? 'primary' : kind} onClick={() => window.codync.updates.check()} disabled={!action.enabled}>
+ {action.label}
+ </Button>
+ )
+}
diff --git a/apps/desktop/src/renderer/views/UpdateNeededCard.tsx b/apps/desktop/src/renderer/views/UpdateNeededCard.tsx
index 5c53eeb1..89207f13 100644
--- a/apps/desktop/src/renderer/views/UpdateNeededCard.tsx
+++ b/apps/desktop/src/renderer/views/UpdateNeededCard.tsx
@@ -3,6 +3,7 @@ import { Button } from '../components/Controls'
import { Icon } from '../components/Icon'
import { font } from '../lib/fonts'
import { useApp, useStore } from '../store/context'
+import { UpdateButton, useUpdates } from './UpdateButton'
/** The words every client uses for a version mismatch (iOS, the TUI and this app). */
export const updateNeededText = {
@@ -30,29 +31,26 @@ export const updateNeededText = {
export function UpdateNeededCard() {
const app = useApp()
const store = useStore()
+ const updates = useUpdates()
const mismatch = store.mismatch
if (!mismatch) return null
- // This app updates itself; on macOS and Windows this computer's own host is put back on the
- // app's bundled copy. Linux has no bundled host, so the card says how to update it instead.
- const action: [string, () => void] | null =
- mismatch.kind === 'updateApp'
- ? ['Update Codync', () => window.codync.updates.check()]
- : store === app.local && !app.host.dev && window.codync.platform !== 'linux'
- ? [`Update ${store.hostName}`, () => window.codync.host.restart()]
- : null
+ // This app updates itself (its download and restart, as in Settings); on macOS and Windows this
+ // computer's own host is put back on the app's bundled copy. Linux has no bundled host, so the
+ // card says how to update it instead.
+ const updatesApp = mismatch.kind === 'updateApp'
+ const restartsHost = !updatesApp && store === app.local && !app.host.dev && window.codync.platform !== 'linux'
+ const button = updatesApp
+ ? updates && <UpdateButton updates={updates} kind="primary" />
+ : restartsHost && <Button onClick={() => window.codync.host.restart()}>{`Update ${store.hostName}`}</Button>
return (
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 12, padding: 14, background: 'var(--surface)', borderRadius: 16 }}>
<Icon name="arrow.down.circle" size={15} color="var(--warning)" />
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, flex: 1, minWidth: 0 }}>
<div style={{ ...font('subheadline', 'semibold'), color: 'var(--text)' }}>{updateNeededText.title(mismatch, store.hostName)}</div>
<div style={{ ...font('footnote'), color: 'var(--secondary)' }}>
- {updateNeededText.detail(mismatch, store.hostName, store.hostVersion?.version, store.hello?.os, action === null)}
+ {updateNeededText.detail(mismatch, store.hostName, store.hostVersion?.version, store.hello?.os, !updatesApp && !restartsHost)}
</div>
- {action ? (
- <Button onClick={action[1]} style={{ marginTop: 4, alignSelf: 'flex-start' }}>
- {action[0]}
- </Button>
- ) : null}
+ {button ? <div style={{ marginTop: 4, alignSelf: 'flex-start' }}>{button}</div> : null}
</div>
</div>
)
diff --git a/apps/desktop/src/renderer/views/settings/SettingsView.tsx b/apps/desktop/src/renderer/views/settings/SettingsView.tsx
index 7cd9b4d1..8738c90c 100644
--- a/apps/desktop/src/renderer/views/settings/SettingsView.tsx
+++ b/apps/desktop/src/renderer/views/settings/SettingsView.tsx
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react'
-import type { UpdateState } from '@shared/ipc'
import { islandLabel } from '@shared/island'
-import { Button, CardForm, CardSection, ChoicePicker, IconButton, Switch, ValueRow } from '../../components/Controls'
+import { Button, CardForm, CardSection, ChoicePicker, IconButton, ProgressBar, Switch, ValueRow } from '../../components/Controls'
import { Icon } from '../../components/Icon'
import { useDismiss } from '../../components/Overlay'
import { font } from '../../lib/fonts'
@@ -10,6 +9,7 @@ import { DEFAULT_TEXT_SIZE, prefs, TEXT_SIZES, usePref } from '../../lib/prefs'
import { useAccount } from '../../store/account'
import { StoreContext, useApp } from '../../store/context'
import { ComputerBadge } from '../ComputerBadge'
+import { UpdateButton, useUpdates } from '../UpdateButton'
import { ComputersView } from './ComputersView'
import { errorText, isMac, thisMac } from './parts'
import { UsageLimits } from './UsageLimits'
@@ -210,11 +210,7 @@ function UsageLimitsList() {
/** The app's update check and preferences, the same as the menu bar's Updates menu. */
function UpdateSettings() {
- const [updates, setUpdates] = useState<UpdateState | null>(null)
- useEffect(() => {
- void window.codync.updates.state().then(setUpdates)
- return window.codync.updates.onChange(setUpdates)
- }, [])
+ const updates = useUpdates()
if (!updates) return null
const footer = !updates.supported
? 'Updates are available in release builds.'
@@ -231,11 +227,16 @@ function UpdateSettings() {
<ValueRow key="version" label="Version" detail={lastChecked}>
<span style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<span>{window.codync.appVersion}</span>
- <Button kind="secondary" onClick={() => window.codync.updates.check()} disabled={!updates.supported && !updates.staged}>
- {updates.availableVersion ? `Update to ${updates.availableVersion}` : 'Check for updates'}
- </Button>
+ <UpdateButton updates={updates} />
</span>
</ValueRow>,
+ ...(updates.downloadPercent !== null
+ ? [
+ <div key="progress" className="settings-row settings-appear">
+ <ProgressBar value={updates.downloadPercent / 100} label={`Downloading Codync ${updates.availableVersion ?? ''}`} />
+ </div>,
+ ]
+ : []),
<Switch key="check" on={updates.autoCheck} onChange={(on) => window.codync.updates.setAutoCheck(on)} disabled={!updates.supported}>
Automatically check for updates
</Switch>,
diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.ts
index 7a9360e3..20ebae07 100644
--- a/apps/desktop/src/shared/ipc.ts
+++ b/apps/desktop/src/shared/ipc.ts
@@ -74,8 +74,12 @@ export interface UpdateState {
supported: boolean
checking: boolean
availableVersion: string | null
+ /** Downloading: percent done (0–100); null when nothing is downloading. */
+ downloadPercent: number | null
/** Downloaded and ready: installs on restart. */
staged: boolean
+ /** Restarting into the staged release (the host stops first). */
+ installing: boolean
autoCheck: boolean
autoDownload: boolean
lastCheck: number | null
diff --git a/apps/desktop/src/shared/test-support/updater.ts b/apps/desktop/src/shared/test-support/updater.ts
index 435b2ea1..e4ef59d9 100644
--- a/apps/desktop/src/shared/test-support/updater.ts
+++ b/apps/desktop/src/shared/test-support/updater.ts
@@ -1,4 +1,5 @@
import { EventEmitter } from 'node:events'
+import path from 'node:path'
import * as compat from '../compat.ts'
import type { UpdateState } from '../ipc.ts'
import { loadMainModule, settle } from './main-module.ts'
@@ -13,6 +14,7 @@ interface UpdatesInstance extends EventEmitter {
export function updaterFixture(options: { packaged?: boolean; main?: boolean; prefs?: Record<string, unknown> } = {}) {
const calls = { check: 0, download: 0, install: 0, prepare: 0, resume: 0, quit: 0, fetch: 0 }
+ const opened: string[] = []
const preferences = new Map(Object.entries(options.prefs ?? {}))
const timers = new Map<number, { callback: () => unknown; ms: number }>()
let nextTimer = 0
@@ -33,6 +35,7 @@ export function updaterFixture(options: { packaged?: boolean; main?: boolean; pr
const app = Object.assign(new EventEmitter(), {
isPackaged: options.packaged ?? true,
quit: () => { calls.quit++ },
+ getPath: () => '/Applications/Codync.app/Contents/MacOS/Codync',
})
const handlers = new Map<string, (...args: unknown[]) => unknown>()
const ipc = Object.assign(new EventEmitter(), {
@@ -61,13 +64,15 @@ export function updaterFixture(options: { packaged?: boolean; main?: boolean; pr
}
const { Updates } = loadMainModule<{ Updates: new (host: unknown) => UpdatesInstance }>('updates', {
'node:events': { EventEmitter },
- electron: { app, ipcMain: ipc, BrowserWindow: { getFocusedWindow: () => behavior.focused }, powerMonitor: { getSystemIdleTime: () => behavior.idleSeconds } },
+ 'node:path': path,
+ electron: { app, ipcMain: ipc, shell: { openPath: async (target: string) => { opened.push(target); return '' } }, BrowserWindow: { getFocusedWindow: () => behavior.focused }, powerMonitor: { getSystemIdleTime: () => behavior.idleSeconds } },
'electron-updater': { autoUpdater: updater },
'../shared/compat': compat,
'./account': { isMainEnvironment: () => options.main ?? true },
'./host-controller': { prefs: { get: (key: string) => preferences.get(key), set: (key: string, value: unknown) => preferences.set(key, value) } },
}, {
Date: class extends Date { static override now() { return now } },
+ process: { platform: 'darwin' },
setTimeout: timer, setInterval: timer, clearInterval: (id: number) => timers.delete(id),
fetch: async () => {
calls.fetch++
@@ -85,5 +90,5 @@ export function updaterFixture(options: { packaged?: boolean; main?: boolean; pr
}
await settle()
}
- return { updates, app, ipc, handlers, updater, calls, behavior, preferences, sent, timers, emit, tick, advance: (ms: number) => { now += ms } }
+ return { updates, app, ipc, handlers, updater, calls, opened, behavior, preferences, sent, timers, emit, tick, advance: (ms: number) => { now += ms } }
}
diff --git a/apps/desktop/src/shared/update-action.ts b/apps/desktop/src/shared/update-action.ts
new file mode 100644
index 00000000..1090e9c1
--- /dev/null
+++ b/apps/desktop/src/shared/update-action.ts
@@ -0,0 +1,10 @@
+import type { UpdateState } from './ipc'
+
+/** The one update action every surface offers (Settings, the update card, the menu bar). */
+export function updateAction(u: UpdateState): { label: string; enabled: boolean } {
+ if (u.installing) return { label: 'Restarting…', enabled: false }
+ if (u.staged) return { label: 'Restart to update', enabled: true }
+ if (u.downloadPercent !== null) return { label: `Downloading… ${u.downloadPercent}%`, enabled: false }
+ if (u.checking) return { label: 'Checking…', enabled: false }
+ return { label: u.availableVersion ? `Update to ${u.availableVersion}` : 'Check for updates', enabled: u.supported }
+}
diff --git a/apps/desktop/src/shared/updates.test.ts b/apps/desktop/src/shared/updates.test.ts
index 365a65d5..498b239b 100644
--- a/apps/desktop/src/shared/updates.test.ts
+++ b/apps/desktop/src/shared/updates.test.ts
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict'
import test from 'node:test'
import { EventEmitter } from 'node:events'
import { QuitLifecycle } from '../main/quit-lifecycle.ts'
+import { updateAction } from './update-action.ts'
import { deferred, settle } from './test-support/main-module.ts'
import { updaterFixture } from './test-support/updater.ts'
@@ -18,31 +19,51 @@ for (const options of [{ packaged: false }, { main: false }]) {
})
}
-test('manual check broadcasts checking, release, staged states to every window', async () => {
+test('manual check downloads with progress, then waits for Restart to update', async () => {
const f = updaterFixture()
const stopped = deferred()
f.behavior.prepare = () => stopped.promise
f.ipc.emit('updates:check')
assert.equal(f.updates.state.checking, true)
+ assert.equal(updateAction(f.updates.state).label, 'Checking…')
assert.equal(f.handlers.get('updates:state')?.(), f.updates.state)
await f.emit('update-available', release)
assert.equal(f.calls.download, 1)
assert.equal(f.updates.state.availableVersion, release.version)
assert.equal(f.updates.state.checking, false)
+ assert.equal(f.updates.state.downloadPercent, 0, 'the download shows at once')
+ await f.emit('download-progress', { percent: 42.7 })
+ assert.deepEqual(updateAction(f.updates.state), { label: 'Downloading… 42%', enabled: false })
+ f.updates.check()
+ assert.equal(f.calls.check, 1, 'a click while downloading does nothing')
await f.emit('update-downloaded', release)
assert.equal(f.updates.state.staged, true)
- assert.equal(f.calls.prepare, 1)
- assert.equal(f.calls.install, 0, 'must wait until the host stops')
+ assert.equal(f.updates.state.downloadPercent, null)
+ assert.deepEqual(updateAction(f.updates.state), { label: 'Restart to update', enabled: true })
+ assert.equal(f.calls.prepare, 0, 'a finished download never quits on its own')
for (const window of [0, 1]) {
const states = f.sent.filter((s) => s.window === window)
assert.ok(states.every((s) => s.channel === 'updates:change'))
assert.ok(states.some((s) => s.state.checking))
- assert.ok(states.some((s) => s.state.availableVersion === release.version))
+ assert.ok(states.some((s) => s.state.downloadPercent === 42))
assert.ok(states.some((s) => s.state.staged))
}
+ f.updates.check()
+ assert.equal(f.calls.prepare, 1)
+ assert.equal(f.updates.state.installing, true)
+ assert.equal(updateAction(f.updates.state).label, 'Restarting…')
+ assert.equal(f.calls.install, 0, 'must wait until the host stops')
stopped.resolve()
await settle()
assert.equal(f.calls.install, 1)
+ assert.equal(f.preferences.get('updateRelaunchInFront'), true)
+})
+
+test('the app relaunched by a chosen restart opens its own bundle once to come forward', () => {
+ const relaunched = updaterFixture({ prefs: { updateRelaunchInFront: true } })
+ assert.deepEqual(relaunched.opened, ['/Applications/Codync.app'])
+ assert.equal(relaunched.preferences.get('updateRelaunchInFront'), false)
+ assert.deepEqual(updaterFixture().opened, [])
})
test('latest version records the last check without downloading or stopping the host', async () => {
@@ -58,8 +79,9 @@ test('latest version records the last check without downloading or stopping the
test('host stop failure preserves the staged release, reports an error and permits retry', async () => {
const f = updaterFixture()
f.behavior.prepare = async () => { throw new Error('stop failed') }
- f.updates.check()
await f.emit('update-downloaded', release)
+ f.updates.check()
+ await settle()
assert.equal(f.calls.install, 0)
assert.equal(f.calls.resume, 1)
assert.equal(f.updates.state.error, 'Update paused: stop failed')
@@ -75,11 +97,14 @@ test('host stop failure preserves the staged release, reports an error and permi
test('installer error restarts the stopped host and retry prepares it again', async () => {
const f = updaterFixture()
- f.updates.check()
await f.emit('update-downloaded', release)
+ f.updates.check()
+ await settle()
await f.emit('error', new Error('signature rejected'))
assert.equal(f.calls.resume, 1)
assert.equal(f.updates.state.error, 'signature rejected')
+ assert.equal(f.updates.state.installing, false)
+ assert.equal(f.preferences.get('updateRelaunchInFront'), false)
f.updates.check()
await settle()
assert.equal(f.calls.prepare, 2)
@@ -242,8 +267,8 @@ test('an updater error during host shutdown cancels installation and restores th
const f = updaterFixture()
const stopped = deferred()
f.behavior.prepare = () => stopped.promise
- f.updates.check()
await f.emit('update-downloaded', release)
+ f.updates.check()
await f.emit('error', new Error('invalid archive'))
stopped.resolve()
await settle()
@@ -255,8 +280,9 @@ test('an updater error during host shutdown cancels installation and restores th
test('a synchronous installer failure restores the host and permits retry', async () => {
const f = updaterFixture()
f.behavior.install = () => { throw new Error('installer unavailable') }
- f.updates.check()
await f.emit('update-downloaded', release)
+ f.updates.check()
+ await settle()
assert.equal(f.calls.resume, 1)
assert.equal(f.updates.state.error, 'installer unavailable')
f.behavior.install = () => {}
@@ -296,8 +322,9 @@ test('manual installation crosses the native quit boundary after stopping the ho
closed = true
f.app.emit('before-quit', { preventDefault: () => assert.fail('host has already stopped') })
}
- f.updates.check()
await f.emit('update-downloaded', release)
+ f.updates.check()
+ await settle()
assert.equal(closed, false)
stopped.resolve()
await settle()
diff --git a/docs/design/ui-conventions.md b/docs/design/ui-conventions.md
index d3a166a1..037cabcd 100644
--- a/docs/design/ui-conventions.md
+++ b/docs/design/ui-conventions.md
@@ -23,10 +23,14 @@ tray menu; the TUI uses a text action and status message. Neither has this App S
reminder card, so its decorative icon treatment is iPhone-only.
Release update controls live in the tray's Settings → Updates submenu; the chat
-window's Settings has the same controls on its Updates page (**Check for updates**,
-which becomes **Update to <version>** once a release is found). The TUI action list
-has **Check for updates**. Download and install go through electron-updater
-(`apps/desktop/src/main/updates.ts`); there is no separate update window.
+window's Settings has the same controls on its Updates page. One action carries the
+whole flow (`apps/desktop/src/shared/update-action.ts`, the same label in the tray, the
+Updates page and the update-needed card): **Check for updates** → **Update to <version>**
+→ **Downloading… N%** (the Updates page adds a progress bar) → **Restart to update** →
+**Restarting…**. A finished download never quits the app on its own; the person restarts,
+or it installs once idle. The TUI action list has **Check for updates**. Download and
+install go through electron-updater (`apps/desktop/src/main/updates.ts`); there is no
+separate update window.
The tray menu is Electron's native `Menu` (`apps/desktop/src/main/tray.ts`), the only system menu in the desktop app. Its commands, submenus, checkboxes, usage-icon radio items, separators and keyboard navigation use system styling. Do not add custom cards, hover backgrounds, icon buttons or a window-style menu panel here.
diff --git a/docs/guides/updates.md b/docs/guides/updates.md
index 14198706..b8d2e589 100644
--- a/docs/guides/updates.md
+++ b/docs/guides/updates.md
@@ -12,6 +12,13 @@ and installation (both on by default). The chat window's Settings has the same *
action on its Updates page. Only packaged `main` builds update: `npm run dev` and builds made
with `tools/account-config.mjs dev` never replace themselves with a release.
+A check the person starts downloads right away and shows **Downloading… N%** with a
+progress bar. A finished download never quits the app by itself: the button becomes
+**Restart to update**, and choosing it shows **Restarting…** while the host stops and the
+installer takes over. The relaunched app comes to the front (macOS doesn't activate an app
+the installer relaunches from the background, so a one-shot `updateRelaunchInFront`
+preference asks for it).
+
The app checks daily (hourly while a release waits for the iPhone app, below).
Automatic installation waits until no Codync window is focused, there has been no
keyboard/mouse input for ten minutes, and the local host reports that it is idle.
@@ -30,9 +37,7 @@ it is enabled. Ordinary Quit keeps the host running when no update is staged.
The desktop window's close-to-background handler also listens to Electron's native
`before-quit-for-update` event. On macOS, `quitAndInstall()` closes windows before
`app.before-quit`, so waiting for the latter blocks installation after the host has
-already stopped. If an older release is stuck on **Update to …** after downloading,
-choose **Codync → Quit Codync**: the staged installer can finish and relaunch the app.
-This lifecycle fix is desktop-only; iOS uses the App Store, and the terminal client
+already stopped. This lifecycle fix is desktop-only; iOS uses the App Store, and the terminal client
uses the independent host updater without Electron windows.
Installation requests are single-flight while the host stops and the installer
@@ -42,7 +47,7 @@ the host and leaves the staged release available to retry.
### Recovering from a failed update
-If **Update to …** appears to do nothing, first quit Codync completely (on macOS,
+If **Restart to update** appears to do nothing, first quit Codync completely (on macOS,
**Codync → Quit Codync**, not just the window's close button). A downloaded update
may finish installing when the old app exits. Reopen Codync if it does not relaunch,
then check the version in **Settings → Updates**.
@@ -105,9 +110,9 @@ quit event ordering has a separate regression test and an updater integration te
The macOS and Windows bundled-host branches and Linux's externally managed host
branch run against simulated OS boundaries. These tests do not replace a signed
-release upgrade on each OS, nor do they verify download progress rendering: the
-current Updates page exposes checking, available/staged and error states but has
-no download percentage or installation progress UI yet.
+release upgrade on each OS. They cover the state the UI renders (checking, download
+percentage, staged, restarting, errors) and the labels of the shared update action,
+not the rendering itself.
The release workflow publishes `latest-mac.yml` and `latest-linux*.yml` with the
app archives. macOS build versions follow the marketing version; the iOS build
diff --git a/docs/reference/compatibility.md b/docs/reference/compatibility.md
index a63d2d97..85efe9d2 100644
--- a/docs/reference/compatibility.md
+++ b/docs/reference/compatibility.md
@@ -108,7 +108,7 @@ trails them (App Store review), so nudging a computer from it would only be nois
| Client | This app is behind |
|---|---|
| iPhone | Card at the top of the bot list (App Store version from the lookup), *Update* opens the App Store |
-| Desktop | *Update to <version>* in the menu bar's Settings → Updates and on the Settings Updates page |
+| Desktop | *Update to <version>*, then *Restart to update*, on the update card, in the menu bar's Settings → Updates and on the Settings Updates page |
| Terminal client | — (it is the host binary) |
### Wire shape snapshot