Skip to content

The agent that grows with you

feat(desktop): sync-status IPC — receipts visible on the desktop

ethernetcd3c8f3090b2
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 72be6fcb1a8..931df474a6e 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -17608,6 +17608,32 @@ ipcMain.handle('hermes:version', async () => {
}
})
+/** The latest pm/venv/plugin-operation receipt — the machine-readable
+ * surface every medium reads (CLI: `hermes pm status`). Returned as one
+ * parsed JSON object: { kind, outcome, venv_rebuild, plugin_bisect,
+ * plugin_checks, ... } or null when no operation has run yet. The file
+ * lives at <HERMES_HOME>/logs/update_receipts/latest.json — written by
+ * pm syncs (bisect disables, failed rebuilds), plugin update checks,
+ * and (embedded) updates. */
+function readLatestSyncReceipt(): Record<string, unknown> | null {
+ const receiptPath = path.join(
+ HERMES_HOME,
+ 'logs',
+ 'update_receipts',
+ 'latest.json'
+ )
+ try {
+ const text = fs.readFileSync(receiptPath, 'utf8')
+ // tolerate a BOM (hermes writes plain, but editors touch configs)
+ const stripped = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text
+ return JSON.parse(stripped)
+ } catch {
+ return null
+ }
+}
+
+ipcMain.handle('hermes:sync-status', () => readLatestSyncReceipt())
+
/** Build provenance read from the install stamp — the same facts the CLI
* reports. Falls back to the bare app version when there's no stamp. */
function resolveHermesVersionInfo() {
diff --git a/apps/desktop/electron/preload.ts b/apps/desktop/electron/preload.ts
index 3062ef19b7b..e1fec035e47 100644
--- a/apps/desktop/electron/preload.ts
+++ b/apps/desktop/electron/preload.ts
@@ -496,6 +496,7 @@ contextBridge.exposeInMainWorld('hermesDesktop', {
return () => ipcRenderer.removeListener('hermes:bootstrap:event', listener)
},
getVersion: () => ipcRenderer.invoke('hermes:version'),
+ getSyncStatus: () => ipcRenderer.invoke('hermes:sync-status'),
getRemoteDisplayReason: () => ipcRenderer.invoke('hermes:get-remote-display-reason'),
uninstall: {
summary: () => ipcRenderer.invoke('hermes:uninstall:summary'),
diff --git a/apps/desktop/src/components/sync-status.test.ts b/apps/desktop/src/components/sync-status.test.ts
new file mode 100644
index 00000000000..e75fda0de6d
--- /dev/null
+++ b/apps/desktop/src/components/sync-status.test.ts
@@ -0,0 +1,89 @@
+import { describe, expect, test } from 'vitest'
+
+import type { DesktopSyncReceipt } from '@/global'
+
+import { deriveSyncStatusSummary } from './sync-status'
+
+describe('deriveSyncStatusSummary', () => {
+ test('null receipt degrades to nothing-to-show', () => {
+ const summary = deriveSyncStatusSummary(null)
+ expect(summary.headline).toBeNull()
+ expect(summary.level).toBe('ok')
+ expect(summary.disabledPlugins).toEqual([])
+ })
+
+ test('empty receipt degrades the same', () => {
+ const summary = deriveSyncStatusSummary({})
+ expect(summary.headline).toBeNull()
+ })
+
+ test('failed rebuild is the top signal (error level)', () => {
+ const receipt: DesktopSyncReceipt = {
+ kind: 'sync',
+ outcome: 'failed',
+ venv_rebuild: { ok: false, reason: 'uv sync exited 1: unsatisfiable' }
+ }
+ const summary = deriveSyncStatusSummary(receipt)
+ expect(summary.level).toBe('error')
+ expect(summary.headline).toContain('rebuild failed')
+ })
+
+ test('bisect disables surface as warn with reasons', () => {
+ const receipt: DesktopSyncReceipt = {
+ kind: 'sync',
+ outcome: 'bisected',
+ plugin_bisect: [
+ { plugin: 'bad-plug', action: 'disabled', reason: 'conflicts with core pin' },
+ { plugin: 'kept-plug', action: 'kept', reason: '' }
+ ]
+ }
+ const summary = deriveSyncStatusSummary(receipt)
+ expect(summary.level).toBe('warn')
+ expect(summary.disabledPlugins).toEqual([
+ { plugin: 'bad-plug', reason: 'conflicts with core pin' }
+ ])
+ expect(summary.headline).toContain('disabled')
+ })
+
+ test('needs-fixing beats updates in priority', () => {
+ const receipt: DesktopSyncReceipt = {
+ kind: 'plugin-check',
+ outcome: 'updates-available',
+ plugin_checks: [
+ {
+ name: 'plug',
+ needs_fixing: 'update_url mismatch: saved vs manifest'
+ },
+ { name: 'other', update_available: true, current: '1.0', latest: '2.0' }
+ ]
+ }
+ const summary = deriveSyncStatusSummary(receipt)
+ expect(summary.level).toBe('warn')
+ expect(summary.headline).toContain('update-url')
+ expect(summary.needsFixing).toHaveLength(1)
+ expect(summary.updatesAvailable).toEqual([
+ { name: 'other', current: '1.0', latest: '2.0' }
+ ])
+ })
+
+ test('plain updates-available is info, not warn', () => {
+ const receipt: DesktopSyncReceipt = {
+ kind: 'plugin-check',
+ outcome: 'updates-available',
+ plugin_checks: [{ name: 'plug', update_available: true, current: '1.0', latest: '1.1' }]
+ }
+ const summary = deriveSyncStatusSummary(receipt)
+ expect(summary.level).toBe('info')
+ expect(summary.headline).toContain('updates available')
+ })
+
+ test('unknown update_available (null) is not an update', () => {
+ const receipt: DesktopSyncReceipt = {
+ kind: 'plugin-check',
+ plugin_checks: [{ name: 'mystery', update_available: null, reason: 'not on PyPI' }]
+ }
+ const summary = deriveSyncStatusSummary(receipt)
+ expect(summary.updatesAvailable).toEqual([])
+ expect(summary.headline).toBeNull()
+ })
+})
diff --git a/apps/desktop/src/components/sync-status.ts b/apps/desktop/src/components/sync-status.ts
new file mode 100644
index 00000000000..402895007a3
--- /dev/null
+++ b/apps/desktop/src/components/sync-status.ts
@@ -0,0 +1,71 @@
+/**
+ * Derive display state from a pm receipt — the pure logic behind the
+ * sync-status surface. Receipts are optional-typed (older/newer receipts
+ * may lack sections), so every derive degrades gracefully to 'nothing
+ * to show' rather than throwing at the UI boundary.
+ */
+
+import type { DesktopSyncReceipt } from '@/global'
+
+/** One actionable line per surface: what needs attention + why. */
+export interface SyncStatusSummary {
+ /** null = nothing to show (healthy / no receipt / no sections). */
+ headline: string | null
+ level: 'ok' | 'info' | 'warn' | 'error'
+ /** Bisect decisions — always worth listing when present. */
+ disabledPlugins: Array<{ plugin: string; reason: string }>
+ /** check-updates needs-fixing entries (update_url mismatches). */
+ needsFixing: Array<{ plugin: string; reason: string }>
+ /** Updates the last check saw (name -> current -> latest). */
+ updatesAvailable: Array<{ name: string; current: string | null; latest: string | null }>
+}
+
+export function deriveSyncStatusSummary(
+ receipt: DesktopSyncReceipt | null
+): SyncStatusSummary {
+ const empty: SyncStatusSummary = {
+ headline: null,
+ level: 'ok',
+ disabledPlugins: [],
+ needsFixing: [],
+ updatesAvailable: []
+ }
+ if (!receipt) return empty
+
+ const disabledPlugins = (receipt.plugin_bisect ?? [])
+ .filter(d => d.action === 'disabled')
+ .map(d => ({ plugin: d.plugin, reason: d.reason }))
+
+ const checks = receipt.plugin_checks ?? []
+ const needsFixing = checks
+ .filter(c => c.needs_fixing)
+ .map(c => ({ plugin: c.name, reason: c.needs_fixing as string }))
+ const updatesAvailable = checks
+ .filter(c => c.update_available === true)
+ .map(c => ({ name: c.name, current: c.current ?? null, latest: c.latest ?? null }))
+
+ const rebuildFailed =
+ receipt.venv_rebuild != null && receipt.venv_rebuild.ok === false
+
+ let headline: string | null = null
+ let level: SyncStatusSummary['level'] = 'ok'
+ if (rebuildFailed) {
+ headline = 'Dependency rebuild failed — some plugins may be missing packages'
+ level = 'error'
+ } else if (needsFixing.length > 0) {
+ headline = `${needsFixing.length} plugin${
+ needsFixing.length === 1 ? '' : 's'
+ } need update-url review`
+ level = 'warn'
+ } else if (disabledPlugins.length > 0) {
+ headline = `${disabledPlugins.length} plugin${
+ disabledPlugins.length === 1 ? '' : 's'
+ } disabled by dependency conflicts`
+ level = 'warn'
+ } else if (updatesAvailable.length > 0) {
+ headline = `Plugin updates available (${updatesAvailable.length})`
+ level = 'info'
+ }
+
+ return { headline, level, disabledPlugins, needsFixing, updatesAvailable }
+}
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index c9e70d9d5d8..8f29d581ff2 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -504,6 +504,10 @@ declare global {
cancelBootstrap: () => Promise<{ ok: boolean; cancelled: boolean }>
onBootstrapEvent: (callback: (payload: DesktopBootstrapEvent) => void) => () => void
getVersion: () => Promise<DesktopVersionInfo>
+ /** The latest pm/venv/plugin-operation receipt (machine-readable):
+ * bisect disables, failed rebuilds, update-check results. null when
+ * no venv operation has run yet. */
+ getSyncStatus: () => Promise<DesktopSyncReceipt | null>
getRemoteDisplayReason?: () => Promise<string | null>
updates: {
check: () => Promise<DesktopUpdateStatus>
@@ -573,6 +577,32 @@ export interface HermesTerminalExit {
signal: string | null
}
+/** The pm receipt shape (pm/receipt.py schema 1) — one machine-readable
+ * surface for venv rebuilds, plugin bisects, and update checks. Fields
+ * are optional-typed: older/newer receipts may lack sections; readers
+ * must degrade gracefully (the derive-* module does). */
+export interface DesktopSyncReceipt {
+ schema?: number
+ kind?: string
+ outcome?: string
+ exit_code?: number
+ started_at?: string
+ finished_at?: string
+ steps?: Array<{ name: string; ok: boolean; detail?: string; at?: string }>
+ venv_rebuild?: { ok: boolean; reason?: string } | null
+ plugin_bisect?: Array<{ plugin: string; action: string; reason: string }>
+ plugin_checks?: Array<{
+ name: string
+ class?: string
+ current?: string | null
+ latest?: string | null
+ update_available?: boolean | null
+ needs_fixing?: string | null
+ reason?: string
+ }>
+ feature_list?: string[] | null
+}
+
export interface DesktopVersionInfo {
appVersion: string
electronVersion: string