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.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(desktop): show update progress in the button
Chingiz Mammadov8ad227c6dce9
diff --git a/apps/desktop/src/main/tray.ts b/apps/desktop/src/main/tray.tsindex 79eb66ce..e9f99cb9 100644--- a/apps/desktop/src/main/tray.ts+++ b/apps/desktop/src/main/tray.ts@@ -1,6 +1,7 @@import { join } from 'node:path'import { app, clipboard, Menu, nativeImage, shell, Tray as ElectronTray } from 'electron'import type { TraySummary, WindowCommand } from '../shared/ipc'+import { updateMenuEnabled, updateMenuLabel } from '../shared/update-control'import type { HostController } from './host-controller'import type { Updates } from './updates'import { setShowInDock, showInDock } from './dock'@@ -159,7 +160,7 @@ export class Tray {const { updates } = this.depsconst u = updates.stateconst items: Electron.MenuItemConstructorOptions[] = [- { label: u.availableVersion ? `Update to ${u.availableVersion}…` : 'Check for Updates…', enabled: u.supported || u.staged, click: () => updates.check() },+ { label: updateMenuLabel(u), enabled: updateMenuEnabled(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.tsindex 6d9a7fd4..7daf4f38 100644--- a/apps/desktop/src/main/updates.ts+++ b/apps/desktop/src/main/updates.ts@@ -22,6 +22,7 @@ export class Updates extends EventEmitter {checking: false,availableVersion: null,staged: false,+ downloadPercent: null,autoCheck: prefs.get('updatesAutoCheck') !== false,// On unless turned off: installs still wait until Codync is idle.autoDownload: prefs.get('updatesAutoDownload') !== false,@@ -57,9 +58,13 @@ export class Updates extends EventEmitter {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', (progress: { percent?: number }) => this.reportProgress(progress.percent))autoUpdater.on('update-downloaded', (info) => {- this.set({ staged: true, availableVersion: info.version })- if (this.userInitiated) void this.install()+ // Automatic install restarts by itself. Without it, a finished download waits for Restart.+ const installNow = this.userInitiated && this.state.autoDownload+ this.userInitiated = false+ this.set({ staged: true, availableVersion: info.version, downloadPercent: null })+ if (installNow) void this.install()else this.installWhenIdle()})autoUpdater.on('error', (error) => this.failed(error))@@ -105,13 +110,13 @@ export class Updates extends EventEmitter {this.host.resumeAfterCancelledUpdate()}const message = error instanceof Error ? error.message : String(error)- this.checked({ error: this.userInitiated || this.state.staged ? message : null })+ this.checked({ error: this.userInitiated || this.state.staged ? message : null, downloadPercent: null })this.userInitiated = false}/** Daily, or hourly while a release waits for the iPhone app to pass review. */private scheduled() {- if (!this.state.autoCheck || this.state.checking || this.state.staged) return+ if (!this.state.autoCheck || this.state.checking || this.state.staged || this.state.downloadPercent !== null) returnconst interval = this.state.waitingForApp ? 3600_000 : 24 * 3600_000if (this.state.lastCheck && Date.now() - this.state.lastCheck < interval - 60_000) returnthis.userInitiated = false@@ -121,11 +126,19 @@ export class Updates extends EventEmitter {check() {if (!enabled) returnif (this.state.staged) return void this.install()+ if (this.state.downloadPercent !== null) returnthis.userInitiated = truethis.set({ error: null })void autoUpdater.checkForUpdates().catch(() => {})}+ private reportProgress(raw: number | undefined) {+ if (typeof raw !== 'number' || !Number.isFinite(raw) || this.state.staged) return+ const percent = Math.max(0, Math.min(100, Math.round(raw)))+ if (this.state.downloadPercent === percent) return+ this.set({ downloadPercent: percent })+ }+/*** A release that needs a newer iPhone app than the App Store has (still in review) waits,* so paired iPhones aren't asked for an update they can't get yet. Without an answer from@@ -148,7 +161,10 @@ export class Updates extends EventEmitter {this.userInitiated = falsereturn}- if (this.userInitiated || this.state.autoDownload) void autoUpdater.downloadUpdate().catch(() => {})+ if (this.userInitiated || this.state.autoDownload) {+ if (this.state.downloadPercent === null) this.set({ downloadPercent: 0 })+ void autoUpdater.downloadUpdate().catch(() => {})+ }}/** The local host's `minApp` and whether an iPhone is paired with it. */diff --git a/apps/desktop/src/renderer/demo/bridge.ts b/apps/desktop/src/renderer/demo/bridge.tsindex 7dc9b0a5..f3b06035 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, staged: false, downloadPercent: null,autoCheck: false, autoDownload: false, lastCheck: null, error: null, waitingForApp: null,}diff --git a/apps/desktop/src/renderer/views/settings/SettingsView.tsx b/apps/desktop/src/renderer/views/settings/SettingsView.tsxindex 7cd9b4d1..76545e5a 100644--- a/apps/desktop/src/renderer/views/settings/SettingsView.tsx+++ b/apps/desktop/src/renderer/views/settings/SettingsView.tsx@@ -1,5 +1,6 @@-import { useEffect, useState } from 'react'+import { useEffect, useState, type CSSProperties } from 'react'import type { UpdateState } from '@shared/ipc'+import { updateControl } from '@shared/update-control'import { islandLabel } from '@shared/island'import { Button, CardForm, CardSection, ChoicePicker, IconButton, Switch, ValueRow } from '../../components/Controls'import { Icon } from '../../components/Icon'@@ -231,9 +232,7 @@ 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>+ <UpdateAction updates={updates} /></span></ValueRow>,<Switch key="check" on={updates.autoCheck} onChange={(on) => window.codync.updates.setAutoCheck(on)} disabled={!updates.supported}>@@ -257,3 +256,32 @@ function UpdateSettings() {</CardForm>)}++function UpdateAction({ updates }: { updates: UpdateState }) {+ const control = updateControl(updates)+ if (control.kind === 'progress') return <UpdateProgress percent={control.percent} />+ const label = control.kind === 'restart' ? 'Restart' : control.kind === 'install' ? `Update to ${control.version}` : 'Check for updates'+ return (+ <span className="settings-appear" key={control.kind}>+ <Button+ kind="secondary"+ onClick={() => window.codync.updates.check()}+ disabled={updates.checking || (!updates.supported && !updates.staged)}+ style={control.kind === 'restart' ? { minWidth: 148 } : undefined}+ >+ {label}+ </Button>+ </span>+ )+}++function UpdateProgress({ percent }: { percent: number }) {+ const value = Math.max(0, Math.min(100, percent))+ return (+ <span className="update-progress settings-appear" role="progressbar" aria-valuenow={value} aria-valuemin={0} aria-valuemax={100} aria-label={`Downloading update, ${value}%`} style={{ '--update-percent': `${value}%` } as CSSProperties}>+ <span className="update-progress-fill" />+ <span className="update-progress-label">{value}%</span>+ <span className="update-progress-label on-fill" aria-hidden="true">{value}%</span>+ </span>+ )+}diff --git a/apps/desktop/src/renderer/views/settings/settings.css b/apps/desktop/src/renderer/views/settings/settings.cssindex 34bef5e4..852d6f17 100644--- a/apps/desktop/src/renderer/views/settings/settings.css+++ b/apps/desktop/src/renderer/views/settings/settings.css@@ -127,3 +127,39 @@min-height: 0;overflow: hidden;}++.update-progress {+ position: relative;+ display: inline-grid;+ place-items: center;+ min-width: 148px;+ height: 28px;+ border-radius: 999px;+ background: var(--bubble-user);+ overflow: hidden;+ font-size: calc(12px * var(--scale));+ font-weight: 500;+ font-variant-numeric: tabular-nums;+}+.update-progress-fill {+ position: absolute;+ left: 0;+ top: 0;+ bottom: 0;+ width: var(--update-percent);+ background: var(--accent-fill);+}+.update-progress-label {+ grid-area: 1 / 1;+ z-index: 1;+ color: var(--text);+}+.update-progress-label.on-fill {+ z-index: 2;+ justify-self: stretch;+ align-self: stretch;+ display: grid;+ place-items: center;+ color: var(--on-accent);+ clip-path: inset(0 calc(100% - var(--update-percent)) 0 0);+}diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.tsindex 21feb3b3..193a19b9 100644--- a/apps/desktop/src/shared/ipc.ts+++ b/apps/desktop/src/shared/ipc.ts@@ -75,6 +75,8 @@ export interface UpdateState {availableVersion: string | null/** Downloaded and ready: installs on restart. */staged: boolean+ /** 0-100 while a release is downloading. Null when no download is in progress. */+ downloadPercent: number | nullautoCheck: booleanautoDownload: booleanlastCheck: number | nulldiff --git a/apps/desktop/src/shared/update-control.test.ts b/apps/desktop/src/shared/update-control.test.tsnew file mode 100644index 00000000..3ee58278--- /dev/null+++ b/apps/desktop/src/shared/update-control.test.ts@@ -0,0 +1,54 @@+import assert from 'node:assert/strict'+import test from 'node:test'+import type { UpdateState } from './ipc.ts'+import { updateControl, updateMenuEnabled, updateMenuLabel } from './update-control.ts'++function state(partial: Partial<UpdateState>): UpdateState {+ return {+ supported: true,+ checking: false,+ availableVersion: null,+ staged: false,+ autoCheck: true,+ autoDownload: true,+ lastCheck: null,+ error: null,+ waitingForApp: null,+ downloadPercent: null,+ ...partial,+ }+}++test('an idle app offers a check', () => {+ assert.deepEqual(updateControl(state({})), { kind: 'check' })+ assert.equal(updateMenuLabel(state({})), 'Check for Updates…')+ assert.equal(updateMenuEnabled(state({})), true)+})++test('a found release offers install until the download starts', () => {+ const found = state({ availableVersion: '2.16.0' })+ assert.deepEqual(updateControl(found), { kind: 'install', version: '2.16.0' })+ assert.equal(updateMenuLabel(found), 'Update to 2.16.0…')+})++test('download percent replaces the action and the menu item cannot be clicked', () => {+ const downloading = state({ availableVersion: '2.16.0', downloadPercent: 42 })+ assert.deepEqual(updateControl(downloading), { kind: 'progress', percent: 42 })+ assert.equal(updateMenuLabel(downloading), 'Downloading 42%…')+ assert.equal(updateMenuEnabled(downloading), false)+})++test('a finished download asks for restart only when automatic install is off', () => {+ const manual = state({ availableVersion: '2.16.0', staged: true, autoDownload: false })+ assert.deepEqual(updateControl(manual), { kind: 'restart' })+ assert.equal(updateMenuLabel(manual), 'Restart to Update…')+ assert.equal(updateMenuEnabled(manual), true)+ const automatic = state({ availableVersion: '2.16.0', staged: true, autoDownload: true })+ assert.deepEqual(updateControl(automatic), { kind: 'install', version: '2.16.0' })+})++test('a development build can still restart a release that is already staged', () => {+ const staged = state({ supported: false, staged: true, autoDownload: false, availableVersion: '2.16.0' })+ assert.equal(updateMenuEnabled(staged), true)+ assert.equal(updateMenuEnabled(state({ supported: false })), false)+})diff --git a/apps/desktop/src/shared/update-control.ts b/apps/desktop/src/shared/update-control.tsnew file mode 100644index 00000000..38c85752--- /dev/null+++ b/apps/desktop/src/shared/update-control.ts@@ -0,0 +1,39 @@+import type { UpdateState } from './ipc'++/** What replaces Check for updates while a release is found, downloaded, or ready. */+export type UpdateControl =+ | { kind: 'progress'; percent: number }+ | { kind: 'restart' }+ | { kind: 'install'; version: string }+ | { kind: 'check' }++type UpdateSnapshot = Pick<UpdateState, 'downloadPercent' | 'staged' | 'autoDownload' | 'availableVersion' | 'supported'>++/** Progress wins, then Restart when a download is ready and automatic install is off. */+export function updateControl(state: UpdateSnapshot): UpdateControl {+ if (state.downloadPercent !== null) return { kind: 'progress', percent: state.downloadPercent }+ if (state.staged && !state.autoDownload) return { kind: 'restart' }+ if (state.availableVersion) return { kind: 'install', version: state.availableVersion }+ return { kind: 'check' }+}++/** Tray label. The menu is a system menu, so the percent is text rather than a capsule. */+export function updateMenuLabel(state: UpdateSnapshot): string {+ const control = updateControl(state)+ switch (control.kind) {+ case 'progress':+ return `Downloading ${control.percent}%…`+ case 'restart':+ return 'Restart to Update…'+ case 'install':+ return `Update to ${control.version}…`+ case 'check':+ return 'Check for Updates…'+ }+}++/** A download in progress is not clickable. A staged release can still restart. */+export function updateMenuEnabled(state: UpdateSnapshot): boolean {+ if (state.downloadPercent !== null) return false+ return state.supported || state.staged+}diff --git a/apps/desktop/src/shared/updates.test.ts b/apps/desktop/src/shared/updates.test.tsindex 365a65d5..fcd838fd 100644--- a/apps/desktop/src/shared/updates.test.ts+++ b/apps/desktop/src/shared/updates.test.ts@@ -90,8 +90,11 @@ test('download errors are visible for manual checks without restarting a runningconst f = updaterFixture()f.updates.check()await f.emit('update-available', release)+ await f.emit('download-progress', { percent: 15 })+ assert.equal(f.updates.state.downloadPercent, 15)await f.emit('error', new Error('network disconnected'))assert.equal(f.updates.state.error, 'network disconnected')+ assert.equal(f.updates.state.downloadPercent, null)assert.equal(f.updates.state.checking, false)assert.equal(f.calls.prepare + f.calls.resume + f.calls.install, 0)f.updates.check()@@ -99,6 +102,37 @@ test('download errors are visible for manual checks without restarting a runningassert.equal(f.calls.check, 2)})+test('manual download without automatic install reports percent and waits for restart', async () => {+ const f = updaterFixture({ prefs: { updatesAutoDownload: false } })+ f.updates.check()+ await f.emit('update-available', release)+ assert.equal(f.calls.download, 1)+ assert.equal(f.updates.state.downloadPercent, 0)+ const at42 = () => f.sent.filter((s) => s.state.downloadPercent === 42).length+ await f.emit('download-progress', { percent: 41.6 })+ assert.equal(f.updates.state.downloadPercent, 42)+ assert.equal(at42(), 2)+ await f.emit('download-progress', { percent: 42.4 })+ assert.equal(at42(), 2)+ await f.emit('update-downloaded', release)+ assert.equal(f.updates.state.staged, true)+ assert.equal(f.updates.state.downloadPercent, null)+ assert.equal(f.calls.prepare + f.calls.install, 0)+ f.updates.check()+ await settle()+ assert.equal(f.calls.install, 1)+})++test('a check while a download is in progress does not start another check', async () => {+ const f = updaterFixture({ prefs: { updatesAutoDownload: false } })+ f.updates.check()+ await f.emit('update-available', release)+ const checks = f.calls.check+ f.updates.check()+ assert.equal(f.calls.check, checks)+ assert.equal(f.updates.state.downloadPercent, 0)+})+test('normal Quit without a staged update leaves the host alone', () => {const f = updaterFixture()let prevented = falsediff --git a/docs/design/ui-conventions.md b/docs/design/ui-conventions.mdindex c12c2015..01f29950 100644--- a/docs/design/ui-conventions.md+++ b/docs/design/ui-conventions.md@@ -24,9 +24,14 @@ reminder card, so its decorative icon treatment is iPhone-only.Release update controls live in the tray's Settings → Updates submenu; the chatwindow'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.+which becomes **Update to <version>** once a release is found). Choosing that+replaces the button with a capsule that fills and shows the percent. When+**Automatically download and install** is off, the finished download becomes+**Restart** in the same place. The tray item shows that percent as text, because+it is a system menu. The TUI action list has **Check for updates** for the host+updater, which has no download capsule. Download and install of the desktop app+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.mdindex 14198706..fbbb3f1c 100644--- a/docs/guides/updates.md+++ b/docs/guides/updates.md@@ -9,8 +9,15 @@ Release builds update through electron-updater from GitHub releases(`apps/desktop/src/main/updates.ts`). Open **Settings → Updates** in the menu barto check for a release, turn scheduled checks off, or turn off automatic downloadsand installation (both on by default). The chat window's Settings has the same **Check for updates**-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.+action on its Updates page. Once a release is found, that action becomes **Update to <version>**.+Choosing it downloads the release in the button's place: the capsule fills and shows the percent.+With **Automatically download and install** on, Codync restarts into the update when the download+finishes (immediately if you started the check, or once the app is idle if the check was scheduled).+With it off, the capsule becomes **Restart**, and the update installs when you choose that or quit.+The menu bar item shows the same percent as text (**Downloading 42%…**, then **Restart to Update…**),+because a system menu cannot draw the capsule. The iPhone app updates from the App Store, and the+terminal client updates the host, so neither shows this download. Only packaged `main` builds update:+`npm run dev` and builds made with `tools/account-config.mjs dev` never replace themselves with a release.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 nodiff --git a/docs/reference/compatibility.md b/docs/reference/compatibility.mdindex a63d2d97..ccd7c60c 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>* in the menu bar's Settings → Updates and on the Settings Updates page. That button becomes a percent capsule while the release downloads, then *Restart* when automatic install is off || Terminal client | — (it is the host binary) |### Wire shape snapshot