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(update): auto-update from GitHub releases — download in background, restart to apply

Chaitanya Giribd653863d164
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 27666f28..fdccf557 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -76,7 +76,7 @@ jobs:
run: |
cd dist
# hash only the distributable artifacts, not blockmaps/yml
- files=$(ls *.dmg *.exe *.AppImage 2>/dev/null || true)
+ files=$(ls *.dmg *.zip *.exe *.AppImage 2>/dev/null || true)
[ -z "$files" ] && { echo "no artifacts to hash"; exit 0; }
if command -v sha256sum >/dev/null 2>&1; then
sha256sum $files > "SHA256SUMS-${{ matrix.os }}.txt"
@@ -89,10 +89,16 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-dist
+ # zip + latest*.yml + blockmaps feed electron-updater (auto-update):
+ # latest-mac.yml points Squirrel.Mac at the zip; nsis/AppImage use
+ # latest.yml/latest-linux.yml + blockmaps for differential download.
path: |
dist/*.dmg
+ dist/*.zip
dist/*.exe
dist/*.AppImage
+ dist/*.blockmap
+ dist/latest*.yml
dist/SHA256SUMS-*.txt
if-no-files-found: warn
@@ -111,7 +117,7 @@ jobs:
- name: Flatten + merge checksums
run: |
mkdir -p release
- find artifacts -type f \( -name '*.dmg' -o -name '*.exe' -o -name '*.AppImage' \) -exec cp {} release/ \;
+ find artifacts -type f \( -name '*.dmg' -o -name '*.zip' -o -name '*.exe' -o -name '*.AppImage' -o -name '*.blockmap' -o -name 'latest*.yml' \) -exec cp {} release/ \;
cat artifacts/*/SHA256SUMS-*.txt > release/SHA256SUMS.txt 2>/dev/null || true
ls -la release
@@ -123,6 +129,9 @@ jobs:
fail_on_unmatched_files: false
files: |
release/*.dmg
+ release/*.zip
release/*.exe
release/*.AppImage
+ release/*.blockmap
+ release/latest*.yml
release/SHA256SUMS.txt
diff --git a/electron-builder.yml b/electron-builder.yml
index 1baf75fc..c0302a7c 100644
--- a/electron-builder.yml
+++ b/electron-builder.yml
@@ -2,6 +2,15 @@ appId: in.munderdiffl.app
productName: Munder Difflin
copyright: Copyright © 2026 Chaitanya Giri
+# Where electron-updater looks for new versions (latest*.yml + assets on GitHub
+# releases). The release workflow still uploads assets itself (--publish never);
+# this block only stamps app-update.yml into the packaged app so the updater
+# knows which repo to poll.
+publish:
+ provider: github
+ owner: chaitanyagiri
+ repo: munder-difflin
+
# Notarize + staple after signing, but only when APPLE_* creds are in the env
# (the hook no-ops otherwise, so contributor builds still work). Root-level hook.
afterSign: build/notarize.cjs
@@ -92,10 +101,14 @@ mac:
# To sign: install your "Developer ID Application" cert into the keychain.
# (Override with CSC_LINK=<path-to.p12> + CSC_KEY_PASSWORD for CI.)
# Notarization happens in the root-level `afterSign` hook (top of this file).
+ # dmg is what humans download; zip is what Squirrel.Mac (electron-updater)
+ # actually updates from — latest-mac.yml points at it. Both universal.
target:
- target: dmg
arch: [universal]
- artifactName: Munder-Difflin-${version}-mac-${arch}.dmg
+ - target: zip
+ arch: [universal]
+ artifactName: Munder-Difflin-${version}-mac-${arch}.${ext}
dmg:
title: Munder Difflin ${version}
diff --git a/package-lock.json b/package-lock.json
index 6373f1ad..58c5d580 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -29,6 +29,7 @@
"@xterm/xterm": "^5.5.0",
"better-sqlite3": "^11.10.0",
"commit-graph": "^2.4.0",
+ "electron-updater": "^6.8.9",
"localtunnel": "^2.0.2",
"monaco-editor": "^0.52.2",
"node-pty": "^1.0.0",
@@ -3427,7 +3428,6 @@
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
- "dev": true,
"license": "Python-2.0"
},
"node_modules/array-buffer-byte-length": {
@@ -5250,6 +5250,82 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/electron-updater": {
+ "version": "6.8.9",
+ "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.9.tgz",
+ "integrity": "sha512-ZhVxM9iGONUpZGI1FxdMRgJjUFXi7AYGVa5PwKlO1tV1/4zDxQmfKpXOHVztKrd6L9rLcFjERvi1Mf2vxyTkig==",
+ "license": "MIT",
+ "dependencies": {
+ "builder-util-runtime": "9.7.0",
+ "fs-extra": "^10.1.0",
+ "js-yaml": "^4.1.0",
+ "lazy-val": "^1.0.5",
+ "lodash.escaperegexp": "^4.1.2",
+ "lodash.isequal": "^4.5.0",
+ "semver": "~7.7.3",
+ "tiny-typed-emitter": "^2.1.0"
+ }
+ },
+ "node_modules/electron-updater/node_modules/builder-util-runtime": {
+ "version": "9.7.0",
+ "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz",
+ "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==",
+ "license": "MIT",
+ "dependencies": {
+ "debug": "^4.3.4",
+ "sax": "^1.2.4"
+ },
+ "engines": {
+ "node": ">=12.0.0"
+ }
+ },
+ "node_modules/electron-updater/node_modules/fs-extra": {
+ "version": "10.1.0",
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
+ "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
+ "license": "MIT",
+ "dependencies": {
+ "graceful-fs": "^4.2.0",
+ "jsonfile": "^6.0.1",
+ "universalify": "^2.0.0"
+ },
+ "engines": {
+ "node": ">=12"
+ }
+ },
+ "node_modules/electron-updater/node_modules/jsonfile": {
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
+ "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
+ "license": "MIT",
+ "dependencies": {
+ "universalify": "^2.0.0"
+ },
+ "optionalDependencies": {
+ "graceful-fs": "^4.1.6"
+ }
+ },
+ "node_modules/electron-updater/node_modules/semver": {
+ "version": "7.7.4",
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz",
+ "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==",
+ "license": "ISC",
+ "bin": {
+ "semver": "bin/semver.js"
+ },
+ "engines": {
+ "node": ">=10"
+ }
+ },
+ "node_modules/electron-updater/node_modules/universalify": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
+ "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">= 10.0.0"
+ }
+ },
"node_modules/electron-vite": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/electron-vite/-/electron-vite-2.3.0.tgz",
@@ -7023,7 +7099,6 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
- "dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
@@ -7111,7 +7186,6 @@
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz",
"integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==",
- "dev": true,
"license": "MIT"
},
"node_modules/lazystream": {
@@ -7266,6 +7340,12 @@
"license": "MIT",
"peer": true
},
+ "node_modules/lodash.escaperegexp": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz",
+ "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==",
+ "license": "MIT"
+ },
"node_modules/lodash.flatten": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz",
@@ -7274,6 +7354,13 @@
"license": "MIT",
"peer": true
},
+ "node_modules/lodash.isequal": {
+ "version": "4.5.0",
+ "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
+ "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
+ "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.",
+ "license": "MIT"
+ },
"node_modules/lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
@@ -9055,7 +9142,6 @@
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.6.0.tgz",
"integrity": "sha512-6R3J5M4AcbtLUdZmRv2SygeVaM7IhrLXu9BmnOGmmACak8fiUtOsYNWUS4uK7upbmHIBbLBeFeI//477BKLBzA==",
- "dev": true,
"license": "BlueOak-1.0.0",
"engines": {
"node": ">=11.0.0"
@@ -9824,6 +9910,12 @@
"node": ">=12"
}
},
+ "node_modules/tiny-typed-emitter": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz",
+ "integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==",
+ "license": "MIT"
+ },
"node_modules/tmp": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz",
diff --git a/package.json b/package.json
index 24a7332d..e9d1d1b3 100644
--- a/package.json
+++ b/package.json
@@ -46,6 +46,7 @@
"@xterm/xterm": "^5.5.0",
"better-sqlite3": "^11.10.0",
"commit-graph": "^2.4.0",
+ "electron-updater": "^6.8.9",
"localtunnel": "^2.0.2",
"monaco-editor": "^0.52.2",
"node-pty": "^1.0.0",
diff --git a/src/main/config.ts b/src/main/config.ts
index d462ed86..bc563f92 100644
--- a/src/main/config.ts
+++ b/src/main/config.ts
@@ -239,6 +239,11 @@ export interface HarnessConfig {
* AC). Default OFF: the honest default is "survive sleep + catch up once on
* resume" (see the powerMonitor 'resume' handler), not "stay awake". */
strongKeepalive?: boolean;
+ /** Auto-update from GitHub releases (v0.3.4). Default ON. Packaged builds
+ * check on boot + every ~6h, download in the background, and show a
+ * "restart to update" toast — installation is always user-initiated. OFF
+ * disables checking entirely. (Mirrored in preload + renderer config.) */
+ autoUpdate?: boolean;
/** Multi-window "floors": expose a New Floor action that opens additional
* windows, each an independent office with isolated renderer state (its own
* session partition) and per-window PTY routing. OFF by default (opt-in) —
@@ -360,6 +365,7 @@ const DEFAULTS: HarnessConfig = {
missions: [OPS_STANDUP_MISSION],
notifications: false,
strongKeepalive: false,
+ autoUpdate: true,
multiWindow: true,
tvShowOffices: false,
officeTheme: 'office',
diff --git a/src/main/index.ts b/src/main/index.ts
index d1d71f12..71ae1ab9 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -10,6 +10,7 @@ import { join, resolve, sep, basename, dirname } from 'node:path';
import { request as httpsRequest } from 'node:https';
import { PtyManager, type SpawnOptions } from './pty';
import { resolveCommand as resolveCliCommand } from './shellEnv';
+import { initAutoUpdater } from './updater';
import {
readConfig, writeConfig, resetConfig, ensureHarnessHome, ensureClaudePermissionsAccepted,
modelForRole, OPS_STANDUP_MISSION, HEARTBEAT_MISSION, COMPACT_MAINTENANCE_MISSION, type HarnessConfig, type ScheduledMission
@@ -3835,6 +3836,11 @@ app.whenReady().then(() => {
// Guarded: a DB failure (e.g. a bad native build) must degrade to defaults,
// never block app startup.
try { persist.open(); } catch (e) { console.error('[db] open failed:', e); }
+ // Auto-update from GitHub releases (packaged builds only; gated on the
+ // `autoUpdate` config flag). Download-in-background + restart-to-apply toast;
+ // never restarts on its own. Falls back to a notify-only releases/latest
+ // check where native updating isn't possible (win-portable, dev-ish builds).
+ initAutoUpdater(() => liveWebContents());
// Bootstrap the hive (if harnessHome is configured) and start the message router.
bootstrapHiveServices();
// Survive sleep/lock. macOS freezes libuv timers during true system sleep, so a
diff --git a/src/main/updater.ts b/src/main/updater.ts
new file mode 100644
index 00000000..e1eb1437
--- /dev/null
+++ b/src/main/updater.ts
@@ -0,0 +1,177 @@
+import { app, ipcMain, shell } from 'electron';
+import type { WebContents } from 'electron';
+import { request as httpsRequest } from 'node:https';
+import { readConfig } from './config';
+
+/**
+ * Auto-update from GitHub releases (v0.3.4).
+ *
+ * Primary path: electron-updater against the `publish` block in
+ * electron-builder.yml — the release workflow uploads latest*.yml + zip +
+ * blockmaps, macOS builds are Developer ID signed + notarized, so Squirrel.Mac
+ * (zip), NSIS, and AppImage all update natively. Downloads happen in the
+ * background; installation is ALWAYS user-initiated ("Restart to update" toast
+ * → `update:restartAndInstall`). The app never restarts on its own.
+ *
+ * Fallback path (win-portable exe, unsigned/dev-ish builds, or any updater
+ * error): a plain `releases/latest` poll — semver-compare against the running
+ * version and show a notify-only toast linking the release page. Same pattern
+ * as the landing page's REL upgrade fetch, with the same modest cache so we
+ * stay far from the unauthenticated 60/hr rate limit.
+ *
+ * Everything is gated on the `autoUpdate` HarnessConfig flag (default ON,
+ * Settings → General) and on `app.isPackaged` — dev runs never poll.
+ */
+
+const REPO = 'chaitanyagiri/munder-difflin';
+const CHECK_INTERVAL_MS = 6 * 60 * 60 * 1000; // 6h
+const FALLBACK_CACHE_MS = 60 * 60 * 1000; // 1h between releases/latest polls
+
+export type UpdateStatus =
+ | { state: 'downloaded'; version: string; notes?: string }
+ | { state: 'available-manual'; version: string; url: string };
+
+let sendTo: (() => WebContents | null) | null = null;
+let started = false;
+let fallbackActive = false;
+let lastFallbackCheck = 0;
+/** Remembered so a toast dismissed by a reload can be re-served on checkNow. */
+let lastStatus: UpdateStatus | null = null;
+
+function emit(status: UpdateStatus): void {
+ lastStatus = status;
+ try { sendTo?.()?.send('update:status', status); } catch { /* window tore down */ }
+}
+
+function autoUpdateEnabled(): boolean {
+ const cfg = readConfig();
+ return cfg.autoUpdate !== false; // default ON
+}
+
+/** `1.2.3` -> [1,2,3]; returns null for anything that doesn't look like semver. */
+function parseVersion(v: string): number[] | null {
+ const m = v.trim().replace(/^v/, '').match(/^(\d+)\.(\d+)\.(\d+)/);
+ return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
+}
+
+function isNewer(candidate: string, current: string): boolean {
+ const a = parseVersion(candidate);
+ const b = parseVersion(current);
+ if (!a || !b) return false;
+ for (let i = 0; i < 3; i++) {
+ if (a[i] !== b[i]) return a[i] > b[i];
+ }
+ return false;
+}
+
+/** Notify-only check against releases/latest (no download). Never throws. */
+function fallbackCheck(force = false): void {
+ const now = Date.now();
+ if (!force && now - lastFallbackCheck < FALLBACK_CACHE_MS) return;
+ lastFallbackCheck = now;
+ try {
+ const req = httpsRequest(
+ {
+ hostname: 'api.github.com',
+ path: `/repos/${REPO}/releases/latest`,
+ method: 'GET',
+ headers: { 'User-Agent': 'munder-difflin-updater', Accept: 'application/vnd.github+json' },
+ timeout: 10_000
+ },
+ (res) => {
+ let body = '';
+ res.setEncoding('utf8');
+ res.on('data', (d) => { body += d; if (body.length > 262_144) req.destroy(); });
+ res.on('end', () => {
+ try {
+ const rel = JSON.parse(body) as { tag_name?: string; html_url?: string };
+ const tag = rel.tag_name ?? '';
+ if (tag && isNewer(tag, app.getVersion())) {
+ emit({
+ state: 'available-manual',
+ version: tag.replace(/^v/, ''),
+ url: rel.html_url ?? `https://github.com/${REPO}/releases/latest`
+ });
+ }
+ } catch { /* malformed body — try again next interval */ }
+ });
+ }
+ );
+ req.on('timeout', () => req.destroy());
+ req.on('error', () => { /* offline — try again next interval */ });
+ req.end();
+ } catch { /* never let the fallback take the app down */ }
+}
+
+async function nativeCheck(): Promise<void> {
+ if (fallbackActive) { fallbackCheck(); return; }
+ try {
+ const { autoUpdater } = await import('electron-updater');
+ await autoUpdater.checkForUpdates();
+ } catch {
+ fallbackActive = true;
+ fallbackCheck();
+ }
+}
+
+/**
+ * Start the updater. Call once from app.whenReady with an accessor for the
+ * primary window's webContents. Safe to call in dev (no-ops).
+ */
+export function initAutoUpdater(getWebContents: () => WebContents | null): void {
+ sendTo = getWebContents;
+
+ // IPC surface is registered unconditionally so the renderer can always call it.
+ ipcMain.handle('update:restartAndInstall', async () => {
+ try {
+ const { autoUpdater } = await import('electron-updater');
+ autoUpdater.quitAndInstall();
+ return { ok: true };
+ } catch (e) {
+ return { ok: false, error: e instanceof Error ? e.message : String(e) };
+ }
+ });
+ ipcMain.handle('update:checkNow', async () => {
+ if (!app.isPackaged) return { ok: false, error: 'dev build' };
+ if (lastStatus) emit(lastStatus); // re-serve a pending status to a fresh window
+ await nativeCheck();
+ return { ok: true };
+ });
+ ipcMain.handle('update:openRelease', (_evt, url: unknown) => {
+ const href = typeof url === 'string' ? url : `https://github.com/${REPO}/releases/latest`;
+ // Only ever open the project's releases page — this is not a generic opener.
+ if (!href.startsWith(`https://github.com/${REPO}/`)) return { ok: false };
+ void shell.openExternal(href);
+ return { ok: true };
+ });
+
+ if (!app.isPackaged) return;
+ if (started) return;
+ started = true;
+
+ void (async () => {
+ try {
+ const { autoUpdater } = await import('electron-updater');
+ autoUpdater.autoDownload = true;
+ autoUpdater.autoInstallOnAppQuit = false; // install ONLY on explicit restart
+ autoUpdater.on('update-downloaded', (info) => {
+ emit({ state: 'downloaded', version: info.version, notes: typeof info.releaseNotes === 'string' ? info.releaseNotes : undefined });
+ });
+ autoUpdater.on('error', (err) => {
+ // Portable exe / missing metadata / offline: degrade to notify-only.
+ console.warn('[updater] native update failed; falling back to notify-only:', err?.message ?? err);
+ fallbackActive = true;
+ fallbackCheck();
+ });
+ } catch (e) {
+ console.warn('[updater] electron-updater unavailable; notify-only mode:', e);
+ fallbackActive = true;
+ }
+
+ const tick = (): void => { if (autoUpdateEnabled()) void nativeCheck(); };
+ // First check shortly after boot (don't compete with spawn/startup I/O),
+ // then every CHECK_INTERVAL_MS.
+ setTimeout(tick, 30_000);
+ setInterval(tick, CHECK_INTERVAL_MS);
+ })();
+}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index 3f772fc2..ded67b57 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -266,6 +266,8 @@ export interface HarnessConfig {
/** Opt-in strong keep-alive (prevent-display-sleep). Mirrors main + renderer
* HarnessConfig so updateConfig({ strongKeepalive }) is typed across the bridge. */
strongKeepalive?: boolean;
+ /** Auto-update from GitHub releases (default ON; Settings → General). */
+ autoUpdate?: boolean;
slackEnabled?: boolean;
slackSigningSecret?: string;
slackBotToken?: string;
@@ -1118,7 +1120,30 @@ const api = {
/** Mirror the roster to disk. Debounced by the caller; main keeps the previous
* contents as a backup and refuses a first write that would empty a full file. */
rosterWrite: (snap: RosterSnapshot): Promise<{ ok: boolean; skipped?: string; error?: string }> =>
- ipcRenderer.invoke('roster:write', snap)
+ ipcRenderer.invoke('roster:write', snap),
+
+ // ─── Auto-update (v0.3.4) ───────────────────────────────────────────────────
+ /** Push channel from main's updater: either a downloaded update waiting for a
+ * restart, or (fallback/notify-only installs) a newer release to link to. */
+ onUpdateStatus: (
+ cb: (status:
+ | { state: 'downloaded'; version: string; notes?: string }
+ | { state: 'available-manual'; version: string; url: string }) => void
+ ): (() => void) => {
+ const listener = (_e: IpcRendererEvent, payload: Parameters<typeof cb>[0]) => cb(payload);
+ ipcRenderer.on('update:status', listener);
+ return () => ipcRenderer.removeListener('update:status', listener);
+ },
+ /** Quit and install the downloaded update — only ever called from the toast's
+ * explicit "restart to update" button. */
+ updateRestartAndInstall: (): Promise<{ ok: boolean; error?: string }> =>
+ ipcRenderer.invoke('update:restartAndInstall'),
+ /** Manual re-check (also re-serves a pending status to a fresh window). */
+ updateCheckNow: (): Promise<{ ok: boolean; error?: string }> =>
+ ipcRenderer.invoke('update:checkNow'),
+ /** Open the project's releases page for a notify-only update. */
+ updateOpenRelease: (url?: string): Promise<{ ok: boolean }> =>
+ ipcRenderer.invoke('update:openRelease', url)
};
contextBridge.exposeInMainWorld('cth', api);
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 7541a79c..6dd9a605 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -13,6 +13,7 @@ import { OnboardingWizard } from '@/components/OnboardingWizard';
import { HivePicker } from '@/components/HivePicker';
import { QuitWarningModal, type ClosingTimeState } from '@/components/QuitWarningModal';
import { CompletionToast } from '@/realtime/CompletionToast';
+import { UpdateToast } from '@/components/UpdateToast';
import { SettingsModal } from '@/components/SettingsModal';
import { PixelPanel } from '@/components/PixelPanel';
import { PixelButton } from '@/components/PixelButton';
@@ -212,6 +213,9 @@ export function App() {
{/* rt-12: global fixed-overlay toast for voice-Michael completions ("Oscar
finished X"). Self-positions bottom-right; renders null until one arrives. */}
<CompletionToast />
+ {/* v0.3.4: background-update toast ("restart to update"); renders null until
+ main's updater pushes a status. */}
+ <UpdateToast />
{/* Title bar */}
<div
className="cth-titlebar-drag"
diff --git a/src/renderer/src/components/SettingsModal.tsx b/src/renderer/src/components/SettingsModal.tsx
index a12080c1..2943030a 100644
--- a/src/renderer/src/components/SettingsModal.tsx
+++ b/src/renderer/src/components/SettingsModal.tsx
@@ -257,6 +257,15 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
} catch { setAutoCompactOn(!next); }
};
+ // ─── Auto-update (default ON; gates main's updater checks entirely) ────────
+ const [autoUpdateOn, setAutoUpdateOn] = useState<boolean>(config.autoUpdate !== false);
+ const toggleAutoUpdate = async () => {
+ const next = !autoUpdateOn;
+ setAutoUpdateOn(next);
+ try { await window.cth.updateConfig({ autoUpdate: next }); }
+ catch { setAutoUpdateOn(!next); }
+ };
+
// --- Free Flow (voice dictation → message queue) ---
const setFreeflowEnabledStore = useStore((s) => s.setFreeflowEnabled);
const setHasGroqKeyStore = useStore((s) => s.setHasGroqKey);
@@ -769,6 +778,25 @@ export function SettingsModal({ config, onClose }: SettingsModalProps) {
{autoCompactOn ? 'on' : 'off'}
</PixelButton>
</div>
+ <div style={{ height: 10 }} />
+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
+ <span style={{ fontSize: 14, lineHeight: '20px', color: 'var(--cth-ink-900)' }}>
+ Auto-update
+ </span>
+ <span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' }}>
+ Check GitHub releases and download updates in the background;
+ you choose when to restart. Never restarts on its own.
+ </span>
+ </div>
+ <PixelButton
+ variant={autoUpdateOn ? 'primary' : 'secondary'}
+ size="sm"
+ onClick={toggleAutoUpdate}
+ >
+ {autoUpdateOn ? 'on' : 'off'}
+ </PixelButton>
+ </div>
</div>
<div style={{ height: 1, background: 'var(--cth-ink-300)' }} />
diff --git a/src/renderer/src/components/UpdateToast.tsx b/src/renderer/src/components/UpdateToast.tsx
new file mode 100644
index 00000000..9f68a8af
--- /dev/null
+++ b/src/renderer/src/components/UpdateToast.tsx
@@ -0,0 +1,90 @@
+/**
+ * Auto-update toast (v0.3.4) — the visual half of the background updater.
+ *
+ * Main's updater (src/main/updater.ts) downloads a new release in the
+ * background and pushes ONE of two states over `update:status`:
+ * - 'downloaded' → the update is staged; offer "restart to update".
+ * - 'available-manual' → this install can't self-update (win-portable,
+ * updater error); offer a link to the release page.
+ *
+ * Mirrors CompletionToast: self-contained + self-subscribing, mounted once in
+ * App.tsx, renders nothing when idle. Installation is ALWAYS user-initiated —
+ * "later" just hides the toast until the next app start (or the 6h re-check).
+ */
+import { useEffect, useState } from 'react';
+import { Icon } from '@/components/Icon';
+
+type UpdateStatus =
+ | { state: 'downloaded'; version: string; notes?: string }
+ | { state: 'available-manual'; version: string; url: string };
+
+export function UpdateToast() {
+ const [status, setStatus] = useState<UpdateStatus | null>(null);
+ const [busy, setBusy] = useState(false);
+
+ useEffect(() => window.cth.onUpdateStatus?.(setStatus), []);
+
+ if (!status) return null;
+
+ const restart = async () => {
+ setBusy(true);
+ try {
+ const res = await window.cth.updateRestartAndInstall();
+ if (!res.ok) setBusy(false); // stayed alive — let the user retry
+ } catch { setBusy(false); }
+ };
+
+ const buttonStyle: React.CSSProperties = {
+ padding: '3px 10px 1px',
+ background: 'var(--cth-mint-light, #d0f0e0)',
+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-900)',
+ fontFamily: 'var(--cth-font-ui)', fontSize: 13,
+ color: 'var(--cth-ink-900)', cursor: 'pointer', border: 'none'
+ };
+
+ return (
+ <div style={{
+ position: 'fixed', right: 16, bottom: 16, zIndex: 400,
+ maxWidth: 340,
+ background: 'var(--cth-cream-50)',
+ boxShadow: '0 0 0 2px var(--cth-ink-900), 4px 5px 0 0 rgba(26,19,32,0.25)',
+ padding: '10px 12px',
+ display: 'flex', flexDirection: 'column', gap: 8,
+ fontFamily: 'var(--cth-font-ui)'
+ }}>
+ <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
+ <Icon name="sparkle" />
+ <span style={{ fontSize: 14, color: 'var(--cth-ink-900)', fontWeight: 600 }}>
+ {status.state === 'downloaded'
+ ? `Update v${status.version} downloaded`
+ : `v${status.version} is available`}
+ </span>
+ </div>
+ <span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-700)' }}>
+ {status.state === 'downloaded'
+ ? 'Restart Munder Difflin whenever you like to apply it — nothing restarts on its own.'
+ : 'This install can’t update itself — grab the new build from the releases page.'}
+ </span>
+ <div style={{ display: 'flex', gap: 8, justifyContent: 'flex-end' }}>
+ <button
+ onClick={() => setStatus(null)}
+ style={{ ...buttonStyle, background: 'var(--cth-cream-100)' }}
+ >
+ later
+ </button>
+ {status.state === 'downloaded' ? (
+ <button onClick={restart} disabled={busy} style={buttonStyle}>
+ {busy ? 'restarting…' : 'restart to update'}
+ </button>
+ ) : (
+ <button
+ onClick={() => { void window.cth.updateOpenRelease(status.url); }}
+ style={buttonStyle}
+ >
+ open releases
+ </button>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/src/renderer/src/store/config.ts b/src/renderer/src/store/config.ts
index eb6e406b..5f355270 100644
--- a/src/renderer/src/store/config.ts
+++ b/src/renderer/src/store/config.ts
@@ -78,6 +78,8 @@ export interface HarnessConfig {
* while away (battery cost; best on AC). Default off = survive + catch up on
* resume. Mirrors the main-process field (src/main/config.ts). */
strongKeepalive?: boolean;
+ /** Auto-update from GitHub releases (default ON; Settings → General). */
+ autoUpdate?: boolean;
slackEnabled?: boolean;
slackSigningSecret?: string;
slackBotToken?: string;