Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(updater): the badge does the real auto-update, not just a manual download (Option B)

Chaitanya Giri2096c1d372df
diff --git a/src/renderer/src/components/UpdateBadge.tsx b/src/renderer/src/components/UpdateBadge.tsx
index f68cf60c..3c0cdd6e 100644
--- a/src/renderer/src/components/UpdateBadge.tsx
+++ b/src/renderer/src/components/UpdateBadge.tsx
@@ -67,6 +67,8 @@ export function UpdateBadge() {
if (!st || st === 'not-available' || st === 'idle' || st === 'just-updated') setCheckedOk(true);
}
}
+ else if (view.action === 'download') await window.cth.updateDownload();
+ else if (view.action === 'restart') await window.cth.updateRestartAndInstall();
else if (view.action === 'manual' && status) {
// The click IS the download. Auto-update lives in Settings.
const url = manualDownloadUrl(status, window.cth.platform, window.cth.arch);
@@ -131,7 +133,7 @@ export function UpdateBadge() {
</button>
{/* Hover card: what the click does and what to do with the file, for this OS. */}
- {pending && hover && !started && (
+ {view.action === 'manual' && hover && !started && (
<div
role="tooltip"
className="cth-titlebar-nodrag"
diff --git a/src/shared/updateState.ts b/src/shared/updateState.ts
index 6cb5b863..ad2e7665 100644
--- a/src/shared/updateState.ts
+++ b/src/shared/updateState.ts
@@ -158,6 +158,23 @@ export function describeUpdate(status: UpdateStatus | null, currentVersion: stri
}
const pending = pendingVersion(status, v);
if (pending) {
+ // When the native updater has staged the update, the badge drives the SAME
+ // auto-update the Settings pane does: restart to install once it is
+ // downloaded, or kick the download while it is 'available'. Manual download
+ // is reserved for 'available-manual', the notify-only fallback where the
+ // native updater could NOT fetch it, so the user replaces the app by hand.
+ if (status?.state === 'downloaded') {
+ return {
+ label: `v${pending} · restart`, action: 'restart', tone: 'ready', busy: false,
+ title: `Click to restart and install v${pending}`
+ };
+ }
+ if (status?.state === 'available') {
+ return {
+ label: `v${pending} · update`, action: 'download', tone: 'ready', busy: false,
+ title: `Downloading v${pending} in the background; click to start it if it has not begun`
+ };
+ }
const why = status?.state === 'available-manual' && status.reason
? ` (this install could not update itself: ${status.reason})` : '';
return {
diff --git a/test/update-state.test.cjs b/test/update-state.test.cjs
index b75ecc89..048680ec 100644
--- a/test/update-state.test.cjs
+++ b/test/update-state.test.cjs
@@ -87,16 +87,16 @@ test('every actionable state offers the action its label promises', () => {
check({ state: 'not-available' }, { action: 'check', label: 'latest' });
check({ state: 'checking' }, { action: 'none', busy: true });
- check({ state: 'available', version: '0.3.7' }, { action: 'manual', busy: false });
+ check({ state: 'available', version: '0.3.7' }, { action: 'download', busy: false });
check({ state: 'downloading', version: '0.3.7', percent: 42 }, { action: 'none', busy: true });
- check({ state: 'downloaded', version: '0.3.7' }, { action: 'manual', busy: false });
+ check({ state: 'downloaded', version: '0.3.7' }, { action: 'restart', busy: false });
check({ state: 'available-manual', version: '0.3.7', url: 'https://x' }, { action: 'manual' });
check({ state: 'error', message: 'boom' }, { action: 'check' });
});
test('labels name the version so the badge is self-explanatory', () => {
assert.match(describeUpdate({ state: 'available', version: '0.3.7' }, '0.3.6').label, /0\.3\.7/);
- assert.match(describeUpdate({ state: 'downloaded', version: '0.3.7' }, '0.3.6').label, /download/i);
+ assert.match(describeUpdate({ state: 'downloaded', version: '0.3.7' }, '0.3.6').label, /restart/i);
assert.match(describeUpdate({ state: 'downloading', version: '0.3.7', percent: 42.4 }, '0.3.6').label, /42%/);
});