The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a pool/profile backend blocked by a held update gets the blocked screen
Teknium01fcc6ec6f0e
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex a4de7acc409..de1e9a54d68 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -604,8 +604,10 @@ import {heldWaitMessage,HOLD_SCREEN_GRACE_MS,liveMarkerProbe,+ PRIMARY_HOLD_OWNER,requestHoldRecheck,- startAnywayLogLine+ startAnywayLogLine,+ UpdateHoldBoard} from './update-marker-gate'import { updateConnectionsBeforeLocal } from './update-order'import {@@ -3108,6 +3110,9 @@ interface UpdateHoldWire {// The hold the boot screen currently shows; the IPC handlers below act on it// only (a Start anyway for a hold the user never saw is refused).let currentUpdateHold: HeldState | null = null+// Every wait blocked past the grace: the primary boot and each pool/profile+// backend (R8 M6). The screen shows the primary's, else the first pool one.+const updateHoldBoard = new UpdateHoldBoard()function updateHoldWire(state: HeldState): UpdateHoldWire {return {@@ -3120,7 +3125,16 @@ function updateHoldWire(state: HeldState): UpdateHoldWire {}}-function clearUpdateHold() {+function clearUpdateHold(owner = PRIMARY_HOLD_OWNER) {+ updateHoldBoard.clear(owner)+ const shown = updateHoldBoard.shown()++ if (shown) {+ renderUpdateHold(shown, false)++ return+ }+if (!currentUpdateHold && !bootProgressState.updateHold) {return}@@ -3129,7 +3143,13 @@ function clearUpdateHold() {updateBootProgress({ updateHold: null })}-function showUpdateHold(state: HeldState) {+// A pool/profile wait publishes only the hold (its boot is not the window's).+function showUpdateHold(state: HeldState, owner = PRIMARY_HOLD_OWNER) {+ updateHoldBoard.set(owner, state)+ renderUpdateHold(updateHoldBoard.shown()!, owner === PRIMARY_HOLD_OWNER)+}++function renderUpdateHold(state: HeldState, bootPhase: boolean) {const previous = currentUpdateHoldconst sameHold = previous?.holdId === state.holdId && previous.verdict === state.verdict@@ -3146,6 +3166,13 @@ function showUpdateHold(state: HeldState) {}currentUpdateHold = state++ if (!bootPhase) {+ updateBootProgress({ updateHold: updateHoldWire(state) })++ return+ }+updateBootProgress({phase: 'backend.update-held',// Logged by updateBootProgress: only when what holds the install changes,@@ -12448,32 +12475,54 @@ async function runPoolBackendStart({let poolAnnounced = falselet poolHoldLogged: string | null = null-- // A blocking hold never ages out here either (R8 D3). Pool backends have- // no boot screen of their own: the primary window's Start anyway (scoped- // to the same marker body) releases this wait too.+ let poolHeld: HeldState | null = null+ let poolBlockedSince: number | null = null+ const holdOwner = `pool:${poolKey}`++ // A blocking hold never ages out here either (R8 D3). Past the grace it is+ // published on the window's blocked screen like the primary's (R8 M6): a+ // remote primary, or one that booted before the hold appeared, never+ // shows one of its own. Check again / Start anyway act on its hold id.const poolGateDeps = updateGateDeps(undefined, state => {+ poolHeld = state+if (state.blocking && poolHoldLogged !== state.holdId) {poolHoldLogged = state.holdIdrememberLog(`[updates] pool backend start for profile "${profile}" blocked: update marker ${state.verdict}, ` +- `hold ${state.holdId}; waiting for the hold to end or a Start anyway on the boot screen`+ `hold ${state.holdId}; waiting for the hold to end or a Start anyway on the blocked screen`)}})- await waitForUpdateClearance(poolGateDeps, {- signal: localBackendLifecycle.signal,- isCancelled: (): boolean => backendPool.get(poolKey) !== entry,- onWaitTick: reason => {- if (!poolAnnounced) {- poolAnnounced = true- rememberLog(`[updates] update in progress (${reason}); deferring pool backend start for profile "${profile}"`)- }- },- pollMs: UPDATE_WAIT_POLL_MS,- timeoutMs: UPDATE_WAIT_TIMEOUT_MS- })+ try {+ await waitForUpdateClearance(poolGateDeps, {+ signal: localBackendLifecycle.signal,+ isCancelled: (): boolean => backendPool.get(poolKey) !== entry,+ onWaitTick: reason => {+ if (!poolAnnounced) {+ poolAnnounced = true+ rememberLog(+ `[updates] update in progress (${reason}); deferring pool backend start for profile "${profile}"`+ )+ }++ const heldNow: HeldState | null = poolHeld+ poolHeld = null+ poolBlockedSince = reason === 'marker' && heldNow?.blocking ? (poolBlockedSince ?? Date.now()) : null++ if (heldNow && poolBlockedSince !== null && Date.now() - poolBlockedSince >= HOLD_SCREEN_GRACE_MS) {+ showUpdateHold(heldNow, holdOwner)+ } else {+ clearUpdateHold(holdOwner)+ }+ },+ pollMs: UPDATE_WAIT_POLL_MS,+ timeoutMs: UPDATE_WAIT_TIMEOUT_MS+ })+ } finally {+ clearUpdateHold(holdOwner)+ }}profileDeletionGate.assertCanStart(profile)diff --git a/apps/desktop/electron/update-marker-gate.test.ts b/apps/desktop/electron/update-marker-gate.test.tsindex 0abb1d68068..ad8aa4ec092 100644--- a/apps/desktop/electron/update-marker-gate.test.ts+++ b/apps/desktop/electron/update-marker-gate.test.ts@@ -17,8 +17,10 @@ import {type HeldState,heldWaitMessage,liveMarkerProbe,+ PRIMARY_HOLD_OWNER,requestHoldRecheck,- resetHoldStateForTests+ resetHoldStateForTests,+ UpdateHoldBoard} from './update-marker-gate'import { cleanupMarkerFixtures, deadPid, liveOwner, minutesAgo, tmpHome } from './update-marker.test-helpers'import { runMarkerHelper } from './updater/marker-helper'@@ -271,6 +273,29 @@ describe.skipIf(process.platform === 'win32')('gate over a dead marker (R6)', ()})})+test("a pool/profile hold reaches the screen when the primary shows none; the primary's own clear never drops it (R8 M6)", () => {+ const state = (holdId: string): HeldState => ({+ verdict: 'held',+ ownerPid: 7,+ livePid: null,+ holdId,+ since: 1,+ checkedAt: 2,+ blocking: true+ })++ const board = new UpdateHoldBoard()+ assert.equal(board.shown(), null)+ board.set('pool:work', state('p'))+ assert.equal(board.shown()?.holdId, 'p', 'a remote primary / an already-booted primary: the pool hold is shown')+ board.set(PRIMARY_HOLD_OWNER, state('m'))+ assert.equal(board.shown()?.holdId, 'm', 'the primary boot wait wins')+ board.clear(PRIMARY_HOLD_OWNER)+ assert.equal(board.shown()?.holdId, 'p', 'clearing the primary leaves the pool hold on screen')+ board.clear('pool:work')+ assert.equal(board.shown(), null)+})+test('without a protocol-2 script the gate judges dead = not running and deletes nothing', async () => {const home = tmpHome('gate-legacy')const body = `${await deadPid()}\n${minutesAgo(1)}\n`diff --git a/apps/desktop/electron/update-marker-gate.ts b/apps/desktop/electron/update-marker-gate.tsindex 6a539628bc5..e77ddd8158d 100644--- a/apps/desktop/electron/update-marker-gate.ts+++ b/apps/desktop/electron/update-marker-gate.ts@@ -118,6 +118,31 @@ export function markerHoldId(raw: Buffer, file?: { ino: number; mtimeMs: numberreturn hash.digest('hex').slice(0, 16)}+/**+ * The blocked screen's holds, one per blocked wait: the primary boot wait+ * (`PRIMARY_HOLD_OWNER`) and each pool/profile backend wait. The primary's+ * own hold wins; otherwise the first blocked pool wait is shown, so a hold+ * only a profile backend meets (a remote primary, or a hold that appeared+ * after boot) still gets a screen with its ways out (review R8 M6).+ */+export const PRIMARY_HOLD_OWNER = 'primary'++export class UpdateHoldBoard {+ private readonly holds = new Map<string, HeldState>()++ set(owner: string, state: HeldState): void {+ this.holds.set(owner, state)+ }++ clear(owner: string): void {+ this.holds.delete(owner)+ }++ shown(): HeldState | null {+ return this.holds.get(PRIMARY_HOLD_OWNER) ?? this.holds.values().next().value ?? null+ }+}+/*** The user confirmed "Start anyway" over this exact held marker body. The* caller logs the override; the marker is left in place.diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsxindex b8746037932..81454803121 100644--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx@@ -558,6 +558,42 @@ describe('primary failure foreground isolation', () => {expect($desktopBoot.get().error).toBeNull()expect($desktopBoot.get().visible).toBe(false)})++ it('a hold published after boot (a pool/profile backend) still reaches the blocked screen (R8 M6)', async () => {+ const desktop = fakeDesktop()++ ;(window as { hermesDesktop?: unknown }).hermesDesktop = desktop+ render(<Harness />)+ await flushAsync()+ expect($gatewayState.get()).toBe('open')++ const hold = {+ holdId: 'a1b2c3d4e5f60718',+ verdict: 'held' as const,+ ownerPid: 4242,+ since: Date.now() - 6_000,+ checkedAt: Date.now(),+ logPath: '/x/logs/update.log'+ }++ const progress = {+ error: null,+ fakeMode: false,+ message: 'Hermes is ready',+ phase: 'backend.ready',+ progress: 100,+ retryable: false,+ running: false,+ timestamp: Date.now()+ }++ act(() => desktop.emitBootProgress({ ...progress, updateHold: hold }))+ expect($desktopBoot.get().updateHold).toEqual(hold)+ expect($desktopBoot.get().phase).not.toBe('backend.ready')+ act(() => desktop.emitBootProgress({ ...progress, updateHold: null }))+ expect($desktopBoot.get().updateHold).toBeNull()+ })+it('ignores a boot snapshot superseded by a newer progress event', async () => {const snapshot = deferred<Awaited<ReturnType<ReturnType<typeof fakeDesktop>['getBootProgress']>>>()const connection = deferred<typeof primaryConn>()diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.tsindex e9ddcef5adb..89a3534ea28 100644--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts@@ -26,6 +26,7 @@ import { BACKEND_BOOT_WAIT_TIMEOUT_MS, RECONNECT_ATTEMPT_TIMEOUT_MS, withTimeoutimport {$desktopBoot,applyDesktopBootProgress,+ applyDesktopUpdateHold,completeDesktopBoot,failDesktopBoot,resumeDesktopBootForRetry,@@ -931,6 +932,12 @@ export function useGatewayBoot({// ticket-mint / host-unreachable failures must stay in the reconnect loop// (otherwise a 1–3 min blip bricks reading/drafting behind "couldn't start").if ($gatewaySwitching.get() || bootCompleted || bootFailed) {+ // The blocked-update screen is not a boot step: a pool/profile backend+ // can meet a hold after the primary booted (R8 M6).+ if (payload.updateHold !== undefined) {+ applyDesktopUpdateHold(payload.updateHold)+ }+if (payload.error && shouldApplyPostBootProgressError(payload.error)) {primaryReauthError = payload.errordiff --git a/apps/desktop/src/store/boot.ts b/apps/desktop/src/store/boot.tsindex c8937fe0dc4..a0422dc7aa0 100644--- a/apps/desktop/src/store/boot.ts+++ b/apps/desktop/src/store/boot.ts@@ -1,6 +1,6 @@import { atom } from 'nanostores'-import type { DesktopBootProgress } from '@/global'+import type { DesktopBootProgress, DesktopUpdateHold } from '@/global'import { translateNow } from '@/i18n'export interface DesktopBootState extends DesktopBootProgress {@@ -46,6 +46,11 @@ export function applyDesktopBootProgress(progress: DesktopBootProgress) {})}+/** The blocked-update screen's hold alone, outside the boot steps (R8 M6). */+export function applyDesktopUpdateHold(hold: DesktopUpdateHold | null) {+ $desktopBoot.set({ ...$desktopBoot.get(), updateHold: hold })+}+export function setDesktopBootStep(step: {phase: stringmessage: string