The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: the boot wait's run correlation lives in update-handoff-report, not main.ts
Teknium8bb74e04137b
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 2f41dde722b..d5f85952349 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -602,7 +602,7 @@ import {UPDATE_WAIT_TIMEOUT_MS,waitForUpdateClearance} from './update-gate'-import { reportHandoffResult } from './update-handoff-report'+import { parkedRunReport } from './update-handoff-report'import type { UpdateHoldWire } from './update-hold-types'import {createUpdateHoldScreen,@@ -3027,9 +3027,7 @@ const showUpdateHold = updateHoldScreen.showasync function waitForUpdateToFinish() {let announced = falselet longWaitAnnounced = false- // Stable across heartbeat refreshes, including when first opened mid-update.- // Keep line 2 only for compatibility with older result producers.- let parkedRun: { startedAt: number | null; runId: string | null } = { startedAt: null, runId: null }+ const parkedRun = parkedRunReport()// A dead marker whose checkout a leftover process still holds (R6), or whose// ownership the helper could not establish (the blocked screen, R8 D3).const hold = holdTicker({ show: state => showUpdateHold(state), clear: () => clearUpdateHold() })@@ -3039,7 +3037,7 @@ async function waitForUpdateToFinish() {const gateDeps = updateGateDeps({onLiveMarker: marker => {- parkedRun = marker+ parkedRun.park(marker)overridden = false},onHeld: hold.onHeld,@@ -3103,10 +3101,8 @@ async function waitForUpdateToFinish() {// A detached update's result file is the only way the user learns it// failed: consumed once, here, where boot passes the update gate.- reportHandoffResult({+ parkedRun.report({hermesHome: HERMES_HOME,- expectedStartedAt: parkedRun.startedAt,- expectedRunId: parkedRun.runId,log: rememberLog,dialog,shell,diff --git a/apps/desktop/electron/update-handoff-report.test.ts b/apps/desktop/electron/update-handoff-report.test.tsnew file mode 100644index 00000000000..6c3e5131582--- /dev/null+++ b/apps/desktop/electron/update-handoff-report.test.ts@@ -0,0 +1,65 @@+import assert from 'node:assert/strict'+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'++import { test } from 'vitest'++import { handoffResultPath } from './handoff-result'+import { parkedRunReport } from './update-handoff-report'++function reportFor(home: string, park: (run: ReturnType<typeof parkedRunReport>) => void): string[] {+ const lines: string[] = []+ const run = parkedRunReport()+ park(run)+ run.report({+ hermesHome: home,+ log: line => lines.push(line),+ dialog: { showMessageBox: async () => ({ response: 2, checkboxChecked: false }) },+ shell: { showItemInFolder: () => undefined },+ openUpdates: () => undefined+ })++ return lines+}++function writeResult(home: string, runId: string) {+ const finished_at = Math.floor(Date.now() / 1000)+ fs.writeFileSync(+ handoffResultPath(home),+ JSON.stringify({+ ok: true,+ exit_code: 0,+ message: 'done',+ branch: 'main',+ run_id: runId,+ started_at: finished_at - 60,+ finished_at+ })+ )+}++test('the boot wait reports the result of the run it last parked on, across line-2 heartbeats', () => {+ const home = fs.mkdtempSync(path.join(os.tmpdir(), 'handoff-report-'))+ const now = Math.floor(Date.now() / 1000)++ writeResult(home, 'run-b')++ const heartbeat = reportFor(home, run => {+ run.park({ startedAt: now - 600, runId: 'run-b' })+ run.park({ startedAt: now, runId: 'run-b' }) // the script refreshed line 2 mid-wait+ })++ assert.ok(+ heartbeat.some(line => line.includes('finished OK')),+ heartbeat.join('\n')+ )++ writeResult(home, 'run-a')+ const foreign = reportFor(home, run => run.park({ startedAt: now, runId: 'run-b' }))+ assert.ok(+ foreign.some(line => line.includes('for run run-a, not run-b; discarded')),+ foreign.join('\n')+ )+ assert.equal(fs.existsSync(handoffResultPath(home)), false, 'a foreign result is still consumed')+})diff --git a/apps/desktop/electron/update-handoff-report.ts b/apps/desktop/electron/update-handoff-report.tsindex a616d8f4f4d..ffdb6334c71 100644--- a/apps/desktop/electron/update-handoff-report.ts+++ b/apps/desktop/electron/update-handoff-report.ts@@ -19,6 +19,30 @@ export interface HandoffReportHost {openUpdates: () => void}+/** The run identity a live marker carried when the boot gate saw it. */+export interface ParkedRun {+ startedAt: number | null+ runId: string | null+}++/**+ * The run a boot wait parked on: the result reported when the wait ends is+ * that run's, never an older one's. The run id is stable across the scripts'+ * line-2 heartbeat, including when the wait first saw the marker mid-update;+ * line 2 is kept only for older result producers that write no run id.+ */+export function parkedRunReport() {+ let parked: ParkedRun = { startedAt: null, runId: null }++ return {+ park: (marker: ParkedRun) => {+ parked = marker+ },+ report: (host: Omit<HandoffReportHost, 'expectedStartedAt' | 'expectedRunId'>) =>+ reportHandoffResult({ ...host, expectedStartedAt: parked.startedAt, expectedRunId: parked.runId })+ }+}+/*** The detached hand-off script (scripts/desktop-update/windows.ps1) runs hidden;* its result file is the ONLY way the user learns a detached update