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
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
feat(update): the title-bar badge is always the manual path; auto-update stays in Settings, which also offers the manual download
Chaitanya Giri62b0c0be9fa5
diff --git a/src/main/updater.ts b/src/main/updater.tsindex 7a960661..3aa245e2 100644--- a/src/main/updater.ts+++ b/src/main/updater.ts@@ -5,7 +5,7 @@ import { appendFileSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'import { join } from 'node:path';import { readConfig } from './config';import { DEFAULT_DROP_HTML } from '../shared/releaseDrop';-import { reduceStatus, clampPercent, isNewer, type UpdateStatus } from '../shared/updateState';+import { reduceStatus, clampPercent, isNewer, installerUrl, type UpdateStatus } from '../shared/updateState';/*** Auto-update from GitHub releases.@@ -377,7 +377,7 @@ export function initAutoUpdater(getWebContents: () => WebContents | null): void: SIMULATED_NOTES;emit(o.state === 'downloaded'? { state: 'downloaded', version, notes }- : { state: 'available-manual', version, notes, url: `https://github.com/${REPO}/releases/tag/v${version}`, downloadUrl: `https://github.com/${REPO}/releases/download/v${version}/Munder-Difflin-${version}-mac-${process.arch}.dmg` });+ : { state: 'available-manual', version, notes, url: `https://github.com/${REPO}/releases/tag/v${version}`, downloadUrl: installerUrl(version, process.platform, process.arch) });logLine(`SIMULATED ${o.state === 'downloaded' ? 'downloaded' : 'available-manual'} ${version} (dev only)`);return { ok: true };});@@ -392,7 +392,7 @@ export function initAutoUpdater(getWebContents: () => WebContents | null): voidconst notes = readFileSync(previewPath, 'utf8');const m = notes.match(/what[’']?s\s+new\s+in\s+v?(\d+\.\d+\.\d+)/i) ?? notes.match(/\bv(\d+\.\d+\.\d+)\b/);const version = m?.[1] ?? '9.9.9';- emit({ state: 'available-manual', version, notes, url: `https://github.com/${REPO}/releases/tag/v${version}`, downloadUrl: `https://github.com/${REPO}/releases/download/v${version}/Munder-Difflin-${version}-mac-${process.arch}.dmg` });+ emit({ state: 'available-manual', version, notes, url: `https://github.com/${REPO}/releases/tag/v${version}`, downloadUrl: installerUrl(version, process.platform, process.arch) });logLine(`SIMULATED available-manual ${version} from MD_DROP_PREVIEW=${previewPath} (dev only)`);} catch (e) {logLine(`MD_DROP_PREVIEW unreadable: ${errText(e)}`);diff --git a/src/preload/index.ts b/src/preload/index.tsindex 90e865f1..82605467 100644--- a/src/preload/index.ts+++ b/src/preload/index.ts@@ -1376,6 +1376,7 @@ const api = {ipcRenderer.invoke('update:openRelease', url),/** Which OS this window runs on, for platform-specific copy. */platform: process.platform as string,+ arch: process.arch as string,/** DEV ONLY — fabricate an update status so the toast can be inspected without* cutting a release. Refused (`{ok:false}`) in a packaged build; see the* handler in updater.ts. Call it from the devtools console:diff --git a/src/renderer/src/components/SettingsHeroCard.tsx b/src/renderer/src/components/SettingsHeroCard.tsxindex 9c16050e..08e92a1c 100644--- a/src/renderer/src/components/SettingsHeroCard.tsx+++ b/src/renderer/src/components/SettingsHeroCard.tsx@@ -26,6 +26,7 @@ import { useEffect, useState } from 'react';import { PixelButton } from './PixelButton';import { Icon } from './Icon';import { DEFAULT_HERO, type HeroPayload } from '@shared/heroPayload';+import { manualDownloadUrl, pendingVersion, reduceStatus, type UpdateStatus } from '@shared/updateState';const GITHUB_REPO_URL = 'https://github.com/chaitanyagiri/munder-difflin';const FOUNDERS_WALL_URL = 'https://munderdiffl.in/wall.html';@@ -36,6 +37,22 @@ export function SettingsHeroCard() {// Starts on the compiled-in defaults, so there is no empty frame or spinner// while the fetch is in flight — it just fills in if anything changed.const [hero, setHero] = useState<HeroPayload>(DEFAULT_HERO);+ /** Whatever release the updater knows about, so the card can offer the+ * manual download right where the version is shown. */+ const [status, setStatus] = useState<UpdateStatus | null>(null);+ useEffect(() => {+ const off = window.cth.onUpdateStatus?.((next) => setStatus((prev) => reduceStatus(prev, next)));+ void window.cth.updateCurrent?.().then((cur) => {+ if (cur) setStatus((prev) => reduceStatus(prev, cur));+ }).catch(() => { /* push channel still works */ });+ return off;+ }, []);+ const pending = version ? pendingVersion(status, version) : null;+ const downloadManually = () => {+ if (!status) return;+ const url = manualDownloadUrl(status, window.cth.platform, window.cth.arch);+ if (url) void window.cth.updateOpenRelease(url);+ };useEffect(() => {let alive = true;@@ -84,6 +101,18 @@ export function SettingsHeroCard() {padding: '2px 7px', background: 'var(--cth-mint-light)',boxShadow: 'inset 0 0 0 1px var(--cth-mint)', color: INK}}>{PLAN.label}</span>+ {pending && (+ <>+ <span style={{ flex: 1 }} />+ <span style={{ fontFamily: MONO, fontSize: 11, color: 'var(--cth-ink-700)' }}>+ v{pending} is out+ </span>+ <PixelButton variant="primary" size="sm" onClick={downloadManually}+ title="Download the installer and replace the app yourself. Auto-update is in Updates below.">+ download v{pending}+ </PixelButton>+ </>+ )}</div><div style={{ marginTop: 6, fontSize: 12.5, lineHeight: 1.5, color: 'var(--cth-ink-700)', maxWidth: '64ch' }}>{PLAN.blurb}diff --git a/src/renderer/src/components/UpdateBadge.tsx b/src/renderer/src/components/UpdateBadge.tsxindex 56ff6b41..6ab1a8ee 100644--- a/src/renderer/src/components/UpdateBadge.tsx+++ b/src/renderer/src/components/UpdateBadge.tsx@@ -13,7 +13,7 @@* is wiring and pixels.*/import { useCallback, useEffect, useState } from 'react';-import { describeUpdate, manualInstallSteps, reduceStatus, type UpdateStatus } from '@shared/updateState';+import { describeUpdate, manualDownloadUrl, manualInstallSteps, pendingVersion, reduceStatus, type UpdateStatus } from '@shared/updateState';import { PixelButton } from './PixelButton';declare const __APP_VERSION__: string;@@ -42,15 +42,14 @@ export function UpdateBadge() {if (view.action === 'none' || busy) return;setBusy(true);try {- if (view.action === 'restart') await window.cth.updateRestartAndInstall();- else if (view.action === 'download') await window.cth.updateDownload();- else if (view.action === 'check') await window.cth.updateCheckNow();- else if (view.action === 'open-release') {- // With a direct installer for this machine the click IS the download;- // the release page is only for installs the release has no asset for.- const manual = status?.state === 'available-manual' ? status : null;- await window.cth.updateOpenRelease(manual ? (manual.downloadUrl ?? manual.url) : undefined);- if (manual?.downloadUrl) setStarted(manual.version);+ if (view.action === 'check') await window.cth.updateCheckNow();+ 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);+ if (url) {+ await window.cth.updateOpenRelease(url);+ setStarted(pendingVersion(status, __APP_VERSION__));+ }}} catch { /* the emitted status carries the failure — nothing to do here */ }setBusy(false);@@ -65,7 +64,7 @@ export function UpdateBadge() {: view.tone === 'warn' ? 'var(--cth-amber-light, #f6e2b3)': 'transparent';- const manual = status?.state === 'available-manual' && status.downloadUrl ? status : null;+ const pending = pendingVersion(status, __APP_VERSION__);const steps = manualInstallSteps(window.cth.platform ?? 'darwin');const INK = 'var(--cth-ink-900)';@@ -107,7 +106,7 @@ export function UpdateBadge() {</button>{/* Hover card: what the click does and what to do with the file, for this OS. */}- {manual && hover && !started && (+ {pending && hover && !started && (<divrole="tooltip"className="cth-titlebar-nodrag"@@ -120,10 +119,10 @@ export function UpdateBadge() {}}><div style={{ fontFamily: 'var(--cth-font-mono, monospace)', fontWeight: 700, fontSize: 12.5 }}>- Click to download v{manual.version}+ Click to download v{pending}</div><div style={{ marginTop: 4, color: 'var(--cth-ink-700)' }}>- This build cannot update itself. Download the latest version and replace the app you have.+ Download the latest version and replace the app you have. Prefer the app to update itself? Settings → Updates.</div><div style={{marginTop: 8, fontFamily: 'var(--cth-font-mono, monospace)', fontSize: 9,diff --git a/src/renderer/src/components/UpdatesSection.tsx b/src/renderer/src/components/UpdatesSection.tsxindex 77ce1124..52d4708a 100644--- a/src/renderer/src/components/UpdatesSection.tsx+++ b/src/renderer/src/components/UpdatesSection.tsx@@ -13,7 +13,7 @@*/import { useCallback, useEffect, useMemo, useState } from 'react';import { summarizeReleaseNotes } from '@shared/releaseNotes';-import { describeUpdateSettings, reduceStatus, type UpdateStatus } from '@shared/updateState';+import { describeUpdateSettings, manualDownloadUrl, manualInstallSteps, pendingVersion, reduceStatus, type UpdateStatus } from '@shared/updateState';import { PixelButton } from './PixelButton';declare const __APP_VERSION__: string;@@ -33,6 +33,17 @@ export function UpdatesSection() {}, []);const view = describeUpdateSettings(status, __APP_VERSION__);+ /** The manual path is always on offer next to the automatic one. */+ const pending = pendingVersion(status, __APP_VERSION__);+ const [manualStarted, setManualStarted] = useState<string | null>(null);+ const steps = manualInstallSteps(window.cth.platform ?? 'darwin');+ const downloadManually = () => {+ if (!status) return;+ const url = manualDownloadUrl(status, window.cth.platform, window.cth.arch);+ if (!url) return;+ void window.cth.updateOpenRelease(url);+ setManualStarted(pending);+ };// Same digest the update toast renders (src/shared/releaseNotes.ts), for the// same reason: the release body is already in hand, and "what would I get?"@@ -79,8 +90,20 @@ export function UpdatesSection() {{view.detail}</span></div>- {view.button && (- <PixelButton+ <div style={{ display: 'flex', gap: 8, flexShrink: 0, alignItems: 'center' }}>+ {pending && (+ <PixelButton+ variant="secondary"+ size="sm"+ onClick={downloadManually}+ style={{ whiteSpace: 'nowrap' }}+ title={`Download the v${pending} installer and replace the app yourself`}+ >+ download manually+ </PixelButton>+ )}+ {view.button && (+ <PixelButtonvariant={view.tone === 'ready' ? 'primary' : 'secondary'}size="sm"onClick={() => { void onClick(); }}@@ -95,9 +118,23 @@ export function UpdatesSection() {style={{ flexShrink: 0, whiteSpace: 'nowrap' }}>{view.button}- </PixelButton>- )}+ </PixelButton>+ )}+ </div></div>+ {manualStarted && (+ <div style={{+ marginTop: 10, padding: '10px 12px', fontSize: 12, lineHeight: 1.5,+ color: 'var(--cth-ink-900)', background: 'var(--cth-paper-100)',+ border: '2px solid var(--cth-ink-900)'+ }}>+ <b>v{manualStarted} is downloading in your browser.</b> When it lands, quit this app, install+ the new version over the current one, open it and pick the same project. On {steps.os}:+ <ol style={{ margin: '4px 0 0', paddingLeft: 18, color: 'var(--cth-ink-700)' }}>+ {steps.steps.map((t) => <li key={t}>{t}</li>)}+ </ol>+ </div>+ )}{notes.length > 0 && (<ul style={{listStyle: 'none', margin: '8px 0 0', padding: 0,diff --git a/src/shared/updateState.ts b/src/shared/updateState.tsindex 425d6af8..3dc3d622 100644--- a/src/shared/updateState.ts+++ b/src/shared/updateState.ts@@ -31,7 +31,37 @@ export type UpdateStatus =| { state: 'just-updated'; version: string; notes?: string }| { state: 'error'; message: string };-export type UpdateAction = 'none' | 'check' | 'download' | 'restart' | 'open-release';+export type UpdateAction = 'none' | 'check' | 'download' | 'restart' | 'open-release' | 'manual';++export const REPO = 'chaitanyagiri/munder-difflin';++/** The installer for THIS machine in the release tagged v{version}, by the+ * names electron-builder.yml produces. Used when a status carries no+ * `downloadUrl` of its own (the native updater path never does). */+export function installerUrl(version: string, platform: string, arch: string): string {+ const v = version.replace(/^v/, '');+ const file = platform === 'darwin' ? `Munder-Difflin-${v}-mac-${arch}.dmg`+ : platform === 'win32' ? `Munder-Difflin-${v}-win-x64-setup.exe`+ : `Munder-Difflin-${v}-linux-x86_64.AppImage`;+ return `https://github.com/${REPO}/releases/download/v${v}/${file}`;+}++/** The newer release a status knows about, or null. Every state that names a+ * version newer than the running one counts, whatever the updater is doing+ * with it: the manual path is always on offer. */+export function pendingVersion(status: UpdateStatus | null, current: string): string | null {+ if (!status || !('version' in status)) return null;+ if (status.state === 'just-updated') return null;+ return isNewer(status.version, current) ? status.version : null;+}++/** Where a manual download of `status`'s release goes: the asset the release+ * itself named when it did, else the conventional installer URL. */+export function manualDownloadUrl(status: UpdateStatus, platform: string, arch: string): string | null {+ if (!('version' in status) || status.state === 'just-updated') return null;+ if (status.state === 'available-manual' && status.downloadUrl) return status.downloadUrl;+ return installerUrl(status.version, platform, arch);+}export interface UpdateBadgeView {/** Extra text beside the version, or null to show the version alone. */@@ -114,44 +144,37 @@ export function reduceStatus(prev: UpdateStatus | null, next: UpdateStatus): Upd*/export function describeUpdate(status: UpdateStatus | null, currentVersion: string): UpdateBadgeView {const v = currentVersion;+ // The title-bar badge is the MANUAL path, always: click downloads the+ // installer and the user replaces the app. Auto-update (download, restart)+ // lives in Settings -> Updates. So any state that names a newer release reads+ // the same here, whatever the background updater is doing with it.+ if (status?.state === 'downloading') {+ // Settings started the automatic download; the chip reports progress and+ // nothing else, so the two paths are not raced against each other.+ return {+ label: `downloading ${clampPercent(status.percent)}%`, action: 'none', tone: 'busy', busy: true,+ title: `Downloading v${status.version}… ${clampPercent(status.percent)}%`+ };+ }+ const pending = pendingVersion(status, v);+ if (pending) {+ const why = status?.state === 'available-manual' && status.reason+ ? ` (this install could not update itself: ${status.reason})` : '';+ return {+ label: `v${pending} · download`, action: 'manual', tone: 'ready', busy: false,+ title: `Click to download v${pending}, then replace the app you have${why}`+ };+ }switch (status?.state) {case 'checking':return { label: 'checking…', action: 'none', tone: 'busy', busy: true, title: `Checking for updates (you're on v${v})` };- case 'available':- return {- label: `v${status.version} ready to install`, action: 'download', tone: 'ready', busy: false,- title: `Version ${status.version} is available — click to download it`- };- case 'downloading':- return {- label: `downloading ${clampPercent(status.percent)}%`, action: 'none', tone: 'busy', busy: true,- title: `Downloading v${status.version}… ${clampPercent(status.percent)}%`- };- case 'downloaded':- return {- label: `restart to update to v${status.version}`, action: 'restart', tone: 'ready', busy: false,- title: `v${status.version} is downloaded and ready — click to restart and apply it`- };- case 'available-manual':- return status.downloadUrl- ? {- label: `v${status.version} · download`, action: 'open-release', tone: 'ready', busy: false,- title: `Click to download v${status.version}, then replace the app you have`- }- : {- label: `v${status.version} — get it manually`, action: 'open-release', tone: 'warn', busy: false,- title: status.reason- ? `This install couldn't update itself (${status.reason}) — click to open the release page`- : `This install can't update itself — click to open the release page`- };- case 'just-updated':- return { label: null, action: 'check', tone: 'idle', busy: false, title: `v${v} is the latest version — click to check again` };case 'error':return {label: 'update check failed', action: 'check', tone: 'warn', busy: false,title: `${status.message} — click to try again`};case 'not-available':+ case 'just-updated':return { label: null, action: 'check', tone: 'idle', busy: false, title: `v${v} is the latest version — click to check again` };case 'idle':default:@@ -159,7 +182,6 @@ export function describeUpdate(status: UpdateStatus | null, currentVersion: stri}}-/** The same status, rendered for Settings instead of the toolbar chip. */export interface UpdateSettingsView {/** Headline: the version that matters right now — yours, or the one waiting. */headline: string;diff --git a/test/update-state.test.cjs b/test/update-state.test.cjsindex dc4997bb..5091f8f3 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: null });check({ state: 'checking' }, { action: 'none', busy: true });- check({ state: 'available', version: '0.3.7' }, { action: 'download', busy: false });+ check({ state: 'available', version: '0.3.7' }, { action: 'manual', busy: false });check({ state: 'downloading', version: '0.3.7', percent: 42 }, { action: 'none', busy: true });- check({ state: 'downloaded', version: '0.3.7' }, { action: 'restart', busy: false });- check({ state: 'available-manual', version: '0.3.7', url: 'https://x' }, { action: 'open-release' });+ check({ state: 'downloaded', version: '0.3.7' }, { action: 'manual', 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, /restart/i);+ assert.match(describeUpdate({ state: 'downloaded', version: '0.3.7' }, '0.3.6').label, /download/i);assert.match(describeUpdate({ state: 'downloading', version: '0.3.7', percent: 42.4 }, '0.3.6').label, /42%/);});@@ -196,7 +196,7 @@ test('manual update with a direct installer reads as a download, not a page to h'0.4.4');assert.match(v.label, /download/);- assert.equal(v.action, 'open-release');+ assert.equal(v.action, 'manual');assert.equal(v.tone, 'ready');for (const p of ['darwin', 'win32', 'linux']) {const s = manualInstallSteps(p);