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(updates): ask the app whether it's up to date, from Settings

Chaitanya Girie6cfac435274
diff --git a/src/renderer/src/components/FullscreenTerminal.tsx b/src/renderer/src/components/FullscreenTerminal.tsx
index 680d544e..8a4eaa11 100644
--- a/src/renderer/src/components/FullscreenTerminal.tsx
+++ b/src/renderer/src/components/FullscreenTerminal.tsx
@@ -9,6 +9,7 @@ import { AgentControlStrip } from './AgentControlStrip';
import { CommandCenterPanel } from './CommandCenterPanel';
import { Icon } from './Icon';
import { SpritePortrait } from './SpritePortrait';
+import { PORTRAIT_W } from '@/scene/office/portraitArt';
import { RealtimeMichaelToggle } from './RealtimeMichaelToggle';
import { CostHud } from '@/realtime/CostHud';
import { useStore, type Agent } from '@/store/store';
@@ -34,11 +35,20 @@ const ROSTER_COLLAPSED_KEY = 'cth.fullscreen.rosterCollapsed';
* to the name however far the terminal is zoomed. */
function rosterScale(zoom: number) {
const clamp = (n: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, Math.round(n)));
+ // The portrait is sized in SPRITE steps, not free pixels. The art is an 18×28
+ // pixel stamp: widening the tile alone just pads it (which is what the old
+ // `clamp(zoom * 1.2, 18, 40)` did past 18px — a bigger frame around the same
+ // small figure), and a scale like 1.37× renders some pixel rows one device
+ // pixel tall and others two. Half-steps double every other row cleanly, so
+ // that is the grid the size moves on. Floor is 1.5× — 1× was too small to
+ // tell two hires apart at a glance, which is the tile's whole job.
+ const portraitScale = Math.min(2.5, Math.max(1.5, Math.round(zoom * 0.11 * 2) / 2));
return {
name: clamp(zoom * 0.48, 7, 14),
group: clamp(zoom * 0.45, 7, 13),
note: clamp(zoom * 0.68, 10, 20),
- portrait: clamp(zoom * 1.2, 18, 40)
+ portraitScale,
+ portrait: Math.round(PORTRAIT_W * portraitScale)
};
}
@@ -634,9 +644,9 @@ function SidebarRow({
display: 'flex', alignItems: 'flex-start', justifyContent: 'center',
overflow: 'hidden'
}}>
- {/* Sprites only scale by whole pixels — doubling past the point where
- 1× would leave a stamp adrift in an oversized frame. */}
- <SpritePortrait character={agent.character} scale={scale.portrait >= 32 ? 2 : 1} />
+ {/* The sprite is drawn at exactly the tile's width, so the figure
+ grows with the tile instead of floating in it. */}
+ <SpritePortrait character={agent.character} scale={scale.portraitScale} />
</div>
<div style={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 3 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }}>
diff --git a/src/renderer/src/components/SettingsModal.tsx b/src/renderer/src/components/SettingsModal.tsx
index 213a96be..86104808 100644
--- a/src/renderer/src/components/SettingsModal.tsx
+++ b/src/renderer/src/components/SettingsModal.tsx
@@ -12,6 +12,7 @@ import {
} from '@shared/triggers';
import { PixelPanel } from './PixelPanel';
import { PixelButton } from './PixelButton';
+import { UpdatesSection } from './UpdatesSection';
import { Icon } from './Icon';
import { OfficeThemePicker } from './OfficeThemePicker';
import { McpDefaultsSettings } from './McpDefaultsSettings';
@@ -857,6 +858,14 @@ export function SettingsModal({ config, onClose, initialSection }: SettingsModal
{/* GENERAL */}
{activeSection === 'General' && (
<>
+ {/* Updates — first, because "am I on the latest?" is the
+ question people open Settings to answer, and the
+ toolbar chip says nothing at all when the answer is
+ yes. */}
+ <UpdatesSection />
+
+ <div style={{ height: 1, background: 'var(--cth-ink-300)' }} />
+
{/* Home folder */}
<div>
<div style={{
diff --git a/src/renderer/src/components/SpritePortrait.tsx b/src/renderer/src/components/SpritePortrait.tsx
index 1bb20154..a521b3d1 100644
--- a/src/renderer/src/components/SpritePortrait.tsx
+++ b/src/renderer/src/components/SpritePortrait.tsx
@@ -7,7 +7,10 @@ const FRAME_H = PORTRAIT_H;
export interface SpritePortraitProps {
character: OfficeCharacterName;
- scale?: number; // integer
+ /** Pixels per source pixel. Whole numbers are exact; half-steps (1.5, 2.5)
+ * double every other row, which pixel art survives. The blit runs with
+ * smoothing off, so nothing here is ever interpolated. */
+ scale?: number;
background?: string;
}
@@ -35,14 +38,21 @@ export function SpritePortrait({
return () => { cancelled = true; void cancelled; };
}, [character, scale, background]);
+ // A fractional scale can land on a fractional pixel count; the canvas
+ // attributes are integers either way, so round once and use the same number
+ // for the backing store and the CSS box (a mismatch is what makes pixel art
+ // blurry).
+ const w = Math.round(FRAME_W * scale);
+ const h = Math.round(FRAME_H * scale);
+
return (
<canvas
ref={canvasRef}
- width={FRAME_W * scale}
- height={FRAME_H * scale}
+ width={w}
+ height={h}
style={{
- width: FRAME_W * scale,
- height: FRAME_H * scale,
+ width: w,
+ height: h,
imageRendering: 'pixelated'
}}
/>
diff --git a/src/renderer/src/components/UpdatesSection.tsx b/src/renderer/src/components/UpdatesSection.tsx
new file mode 100644
index 00000000..ee1e5b92
--- /dev/null
+++ b/src/renderer/src/components/UpdatesSection.tsx
@@ -0,0 +1,85 @@
+/**
+ * Settings → General → "Updates".
+ *
+ * The toolbar already carries an update chip (UpdateBadge), but a chip that
+ * stays blank when everything is fine is not somewhere you go to *ask* — and
+ * "is there a new version?" is exactly the question people open Settings with.
+ * This block always answers it: the version you're on, whether it's the latest,
+ * and one button that names what pressing it does.
+ *
+ * Same status stream as the badge, same reducer, same states — only the wording
+ * differs (`describeUpdateSettings` vs `describeUpdate`), so the two can never
+ * disagree about what is installed.
+ */
+import { useCallback, useEffect, useState } from 'react';
+import { describeUpdateSettings, reduceStatus, type UpdateStatus } from '@shared/updateState';
+import { PixelButton } from './PixelButton';
+
+declare const __APP_VERSION__: string;
+
+export function UpdatesSection() {
+ const [status, setStatus] = useState<UpdateStatus | null>(null);
+ const [busy, setBusy] = useState(false);
+
+ useEffect(() => {
+ // Subscribe before pulling: main may have emitted while this modal was
+ // closed, and `update:current` re-serves the last known state.
+ 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(() => { /* older main without the handler — the push channel still works */ });
+ return off;
+ }, []);
+
+ const view = describeUpdateSettings(status, __APP_VERSION__);
+
+ const onClick = useCallback(async () => {
+ 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') {
+ await window.cth.updateOpenRelease(status?.state === 'available-manual' ? status.url : undefined);
+ }
+ } catch { /* the emitted status carries the failure — nothing to do here */ }
+ setBusy(false);
+ }, [view.action, busy, status]);
+
+ return (
+ <div>
+ <div style={{
+ fontFamily: 'var(--cth-font-display)', fontSize: 8, lineHeight: '12px',
+ color: 'var(--cth-ink-500)', textTransform: 'uppercase', marginBottom: 10
+ }}>
+ Updates
+ </div>
+ <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 12 }}>
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 2, minWidth: 0 }}>
+ <span style={{
+ fontSize: 13, lineHeight: '20px', color: 'var(--cth-ink-900)',
+ // Only an actionable state earns emphasis; "you're up to date" is
+ // information, not a call to action.
+ fontWeight: view.tone === 'ready' ? 600 : 400
+ }}>
+ {view.headline}
+ </span>
+ <span style={{ fontSize: 12, lineHeight: '16px', color: 'var(--cth-ink-500)' }}>
+ {view.detail}
+ </span>
+ </div>
+ {view.button && (
+ <PixelButton
+ variant={view.tone === 'ready' ? 'primary' : 'secondary'}
+ size="sm"
+ onClick={() => { void onClick(); }}
+ disabled={busy || view.busy}
+ >
+ {view.button}
+ </PixelButton>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/src/shared/updateState.ts b/src/shared/updateState.ts
index f1d8e7eb..7e86b4d8 100644
--- a/src/shared/updateState.ts
+++ b/src/shared/updateState.ts
@@ -140,3 +140,87 @@ export function describeUpdate(status: UpdateStatus | null, currentVersion: stri
return { label: null, action: 'check', tone: 'idle', busy: false, title: `v${v} — click to check for updates` };
}
}
+
+/** 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;
+ /** One sentence of explanation. Carries the verbatim error when there is one. */
+ detail: string;
+ /** Primary button label, or null while the updater is mid-flight and there is
+ * nothing useful to press. */
+ button: string | null;
+ action: UpdateAction;
+ busy: boolean;
+ tone: 'idle' | 'busy' | 'ready' | 'warn';
+}
+
+/**
+ * What the Settings → General "Updates" block shows and does.
+ *
+ * Separate from `describeUpdate` on purpose. The toolbar chip has room for two
+ * words and has to stay quiet when nothing is happening, so its idle state says
+ * nothing at all; Settings is where someone goes *to ask*, so every state gets a
+ * full sentence and — outside the two mid-flight states — a button. The states
+ * and the transitions between them are shared, which is the part that has to
+ * stay in sync.
+ */
+export function describeUpdateSettings(
+ status: UpdateStatus | null,
+ currentVersion: string
+): UpdateSettingsView {
+ const v = currentVersion;
+ switch (status?.state) {
+ case 'checking':
+ return {
+ headline: `You're on v${v}`,
+ detail: 'Checking for a newer release…',
+ button: null, action: 'none', busy: true, tone: 'busy'
+ };
+ case 'available':
+ return {
+ headline: `v${status.version} is available`,
+ detail: `You're on v${v}. Download it now — you'll be asked to restart once it's ready.`,
+ button: `Download v${status.version}`, action: 'download', busy: false, tone: 'ready'
+ };
+ case 'downloading':
+ return {
+ headline: `Downloading v${status.version}`,
+ detail: `${clampPercent(status.percent)}% done. You can keep working; the restart is yours to trigger.`,
+ button: null, action: 'none', busy: true, tone: 'busy'
+ };
+ case 'downloaded':
+ return {
+ headline: `v${status.version} is ready to install`,
+ detail: `Restart Munder Difflin to finish updating from v${v}.`,
+ button: 'Restart to update', action: 'restart', busy: false, tone: 'ready'
+ };
+ case 'available-manual':
+ return {
+ headline: `v${status.version} is available`,
+ detail: status.reason
+ ? `This install can't update itself (${status.reason}) — download it from the release page.`
+ : `This install can't update itself — download it from the release page.`,
+ button: 'Open release page', action: 'open-release', busy: false, tone: 'warn'
+ };
+ case 'error':
+ return {
+ headline: 'Update check failed',
+ detail: `${status.message} (you're on v${v}).`,
+ button: 'Try again', action: 'check', busy: false, tone: 'warn'
+ };
+ case 'not-available':
+ return {
+ headline: `v${v} is the latest version`,
+ detail: "You're already up to date — nothing to install.",
+ button: 'Check again', action: 'check', busy: false, tone: 'idle'
+ };
+ case 'idle':
+ default:
+ return {
+ headline: `You're on v${v}`,
+ detail: 'Updates are checked automatically every 6 hours. Check now if you want to be sure.',
+ button: 'Check for updates', action: 'check', busy: false, tone: 'idle'
+ };
+ }
+}
diff --git a/test/update-state.test.cjs b/test/update-state.test.cjs
index 59c3a9d0..fbb683f1 100644
--- a/test/update-state.test.cjs
+++ b/test/update-state.test.cjs
@@ -112,3 +112,79 @@ test('the underlying failure reaches the tooltip instead of being swallowed', ()
);
assert.match(manual.title, /ENOTFOUND github\.com/);
});
+
+// ---------------------------------------------------------------------------
+// Settings → General "Updates" block (v0.3.9)
+//
+// The toolbar chip stays silent when nothing is happening, which is right for a
+// chip and useless for someone who opened Settings *to ask*. These lock in the
+// two things that make the block worth having: every state says something, and
+// the states you can act on hand you a button that names the action.
+// ---------------------------------------------------------------------------
+
+const { describeUpdateSettings } = loadTs('src/shared/updateState.ts');
+
+test('every update state produces a headline and a sentence', () => {
+ const states = [
+ null,
+ { state: 'idle' },
+ { state: 'checking' },
+ { state: 'not-available' },
+ { state: 'available', version: '0.4.0' },
+ { state: 'downloading', version: '0.4.0', percent: 12 },
+ { state: 'downloaded', version: '0.4.0' },
+ { state: 'available-manual', version: '0.4.0', url: 'https://x' },
+ { state: 'error', message: 'ENOTFOUND github.com' }
+ ];
+ for (const s of states) {
+ const v = describeUpdateSettings(s, '0.3.9');
+ assert.ok(v.headline.length > 0, `no headline for ${s?.state ?? 'null'}`);
+ assert.ok(v.detail.length > 0, `no detail for ${s?.state ?? 'null'}`);
+ }
+});
+
+test('idle and up-to-date both offer a check, and say which version you are on', () => {
+ const idle = describeUpdateSettings({ state: 'idle' }, '0.3.9');
+ assert.equal(idle.action, 'check');
+ assert.match(idle.button, /check for updates/i);
+ assert.match(idle.headline, /0\.3\.9/);
+
+ const latest = describeUpdateSettings({ state: 'not-available' }, '0.3.9');
+ assert.equal(latest.action, 'check');
+ assert.match(latest.headline, /0\.3\.9 is the latest/i);
+ assert.match(latest.detail, /up to date/i);
+});
+
+test('a staged update offers the restart, and names the version it installs', () => {
+ const done = describeUpdateSettings({ state: 'downloaded', version: '0.4.0' }, '0.3.9');
+ assert.equal(done.action, 'restart');
+ assert.match(done.button, /restart to update/i);
+ assert.equal(done.tone, 'ready');
+ assert.match(done.headline, /0\.4\.0/);
+});
+
+test('an available update offers the download, not the restart', () => {
+ const avail = describeUpdateSettings({ state: 'available', version: '0.4.0' }, '0.3.9');
+ assert.equal(avail.action, 'download');
+ assert.match(avail.button, /download v0\.4\.0/i);
+});
+
+test('the two mid-flight states have no button to press', () => {
+ assert.equal(describeUpdateSettings({ state: 'checking' }, '0.3.9').button, null);
+ assert.equal(describeUpdateSettings({ state: 'downloading', version: '0.4.0', percent: 42.4 }, '0.3.9').button, null);
+ assert.match(describeUpdateSettings({ state: 'downloading', version: '0.4.0', percent: 42.4 }, '0.3.9').detail, /42%/);
+ assert.equal(describeUpdateSettings({ state: 'checking' }, '0.3.9').busy, true);
+});
+
+test('failures reach Settings verbatim, same as the tooltip', () => {
+ const err = describeUpdateSettings({ state: 'error', message: 'ENOTFOUND github.com' }, '0.3.9');
+ assert.match(err.detail, /ENOTFOUND github\.com/);
+ assert.equal(err.action, 'check');
+
+ const manual = describeUpdateSettings(
+ { state: 'available-manual', version: '0.4.0', url: 'https://x', reason: 'win-portable' },
+ '0.3.9'
+ );
+ assert.match(manual.detail, /win-portable/);
+ assert.equal(manual.action, 'open-release');
+});