Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(control): --after-pr waits for a fresh read, and a new PR is looked up again
review2472ea693fc8
diff --git a/CLAUDE.md b/CLAUDE.mdindex 341b3694a..7c1f8f7a5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -3500,6 +3500,21 @@ command-bearing opens; this does not add a human-confirm dialog or change mobilea STALE board never passes `checks` (a push since the last read carries other checks) but maypass `merged` (irreversible). A board whose repository differs from the hold's is `blocked`,which holds rather than fires — that is also what makes a mid-switch board harmless.+ - **`checks` needs a read that STARTED after arming.** The host remembers "passed at head A"+ across a closed board, so pushing B and arming at once would otherwise fire on A. The hold+ stores `armedAt` on the HOST clock (`pullStatus().now`), the tracker publishes `readStartedAt`,+ and `checks` is `unknown` until `readStartedAt >= armedAt`. Two host changes carry it: a+ FOREGROUND read now notifies even when nothing changed (else an already-green PR's fresh read+ would never reach the renderer), and Canvas asks for one (`startFreshReadAsks`: at once, then at+ most 3 more, 35 s apart — the 30 s refresh floor or a read already in flight can swallow one).+ - **"No such PR" needs a snapshot refreshed after the question** (`lookupPullRequests`). A board's+ snapshot can be a minute old and `subscribe` starts no refresh when a board already holds it,+ so `gh pr create` then `open-* --after-pr` used to be told "does not exist — do not retry". A+ miss now asks for one refresh and looks again; absence is proven only when the snapshot's+ `lastSuccessfulRefreshAt` is at or after the host time read before that refresh. Columns come+ from the first page's `counts`, so a PR filed under a deleted column is still found, and a+ truncated harvest says so instead of "retry in a minute" forever. The spilled-prompt TTL+ (30 days) outlives the longest `--pr-deadline` (14 days), pinned by a test.- **Unknown is never satisfied, in both directions.** `launchesToFire` treats a caller that passesno PR context as CLOSED for a PR hold (the opposite of the setup gate, whose absent probe isopen for a restart reason that does not apply here), and a malformed persisted hold becomesdiff --git a/src/core/canvas-control-core.ts b/src/core/canvas-control-core.tsindex f4d031364..e486d083f 100644--- a/src/core/canvas-control-core.ts+++ b/src/core/canvas-control-core.ts@@ -98,8 +98,9 @@ function afterPrDocLines(): string[] {return ['Pull request waits (`--after-pr`, on `open-terminal` / `open-claude` / `open-agent`):','- `--after-pr <N:checks|N:merged>[,<N:cond>…]` also holds the launch until pull requests of this',- ' project\'s repository are ready. `checks` = the PR\'s checks passed at its CURRENT head commit (a new',- ' push starts the wait over, and a PR that reports no checks never passes); `merged` = the PR is merged.',+ ' project\'s repository are ready. `checks` = the PR\'s checks passed at its CURRENT head commit, on a',+ ' status read taken after you armed the wait (a new push starts the wait over, and a PR that reports',+ ' no checks never passes); `merged` = the PR is merged.',' It is ANDed with `--after` (and a worktree\'s setup wait), so "start the reviewer once CI is green',' AND the builder is done" is one open. Write the number bare (`1008:merged`): an unquoted leading',' `#` starts a shell comment and drops the rest of your line (`owner/repo#N:merged` works when quoted).',@@ -109,7 +110,9 @@ function afterPrDocLines(): string[] {' press ▶ on the node). Before it, a closed PR or failing checks keep it waiting, never fire it.','- Refused, with the reason: the pull request must exist in the repository this project\'s kanban board',' syncs with (not another repository; a PR closed without merging and `:checks` on a merged PR are',- ' refused, and a `:merged` wait on an already-merged PR is simply met); a project whose board is not',+ ' refused, and a `:merged` wait on an already-merged PR is simply met). A PR opened a moment ago is',+ ' looked up again after one refresh; `after-pr-unconfirmed` means it still could not be confirmed',+ ' (retry in a minute, unless the reply says the list is truncated). Also refused: a project whose board is not',' connected to GitHub, or whose GitHub sync is not approved on this machine; a relay tab.',' `--run-now` cannot be combined with `--after-pr`, and `open-terminal` needs `--cmd` for it.','- The status is the board\'s own GitHub sync, read on this machine: a merge is noticed on its next',diff --git a/src/core/github/pull-status-tracker.test.ts b/src/core/github/pull-status-tracker.test.tsindex 8c8cdd90f..16080d6a9 100644--- a/src/core/github/pull-status-tracker.test.ts+++ b/src/core/github/pull-status-tracker.test.ts@@ -65,6 +65,29 @@ describe('GitHubPullStatusTracker', () => {expect(board.repository).toBe('o/r')})+ it('says when the read behind the board STARTED, on the host clock (an --after-pr wait needs a read taken after it was armed)', async () => {+ const { subject, advance } = tracker(1_000)+ expect(subject.board(KEY).readStartedAt).toBeUndefined()+ await subject.read(KEY, 'user-1', 'heartbeat', async () => {+ advance(700) // the read takes time: the start is what counts, not the finish+ return read([facts(1)])+ })+ expect(subject.board(KEY).readStartedAt).toBe(1_000)+ expect(subject.board(KEY).observedAt).toBe(1_700)+ })++ it('a FOREGROUND read tells the boards even when nothing changed; a background one does not', async () => {+ // Someone asked for a fresh answer (the board's refresh, or a PR wait that needs a read taken+ // after it was armed): an unchanged answer is still an answer they are waiting for.+ const { subject, changes } = tracker()+ await subject.read(KEY, 'user-1', 'heartbeat', async () => read([facts(1)]))+ const before = changes.length+ await subject.read(KEY, 'user-1', 'heartbeat', async () => read([facts(1)]))+ expect(changes.length).toBe(before)+ await subject.read(KEY, 'user-1', 'foreground', async () => read([facts(1)]))+ expect(changes.length).toBe(before + 1)+ })+it('a failed read keeps the last snapshot and marks it stale instead of going blank', async () => {const { subject, changes } = tracker()await subject.read(KEY, 'user-1', 'heartbeat', async () => read([facts(1)]))diff --git a/src/core/github/pull-status-tracker.ts b/src/core/github/pull-status-tracker.tsindex 0e8b16433..b58daa32d 100644--- a/src/core/github/pull-status-tracker.ts+++ b/src/core/github/pull-status-tracker.ts@@ -45,6 +45,8 @@ export type PullReadReason = 'heartbeat' | 'foreground' | 'chase'type PullRepositoryState = {pulls: GitHubPullStatus[]observedAt?: number+ /** When the read behind `pulls` STARTED (host clock). A PR wait armed after it cannot trust it. */+ readStartedAt?: numberstale: booleanaccess: { ci: boolean; merge: boolean }truncated: boolean@@ -107,6 +109,7 @@ export class GitHubPullStatusTracker {now,pulls: state.pulls.map((pull) => ({ ...pull, closes: [...pull.closes] })),...(state.observedAt !== undefined ? { observedAt: state.observedAt } : {}),+ ...(state.readStartedAt !== undefined ? { readStartedAt: state.readStartedAt } : {}),stale: state.stale,access: { ...state.access },undecided: !!state.chase && state.chase.attempts < PULL_CHASE_MAX,@@ -214,7 +217,7 @@ export class GitHubPullStatusTracker {return Promise.resolve()}const generation = state.generation- const work = this.perform(key, state, generation, userId, run)+ const work = this.perform(key, state, generation, userId, run, reason)state.inFlight = workvoid work.finally(() => { if (state.inFlight === work) delete state.inFlight })return work@@ -225,8 +228,10 @@ export class GitHubPullStatusTracker {state: PullRepositoryState,generation: number,userId: string,- run: () => Promise<PullStatusRead>+ run: () => Promise<PullStatusRead>,+ reason: PullReadReason): Promise<void> {+ const startedAt = this.now()let result: PullStatusReadtry {result = await run()@@ -242,7 +247,7 @@ export class GitHubPullStatusTracker {if (code === 'insufficient-permission') {await this.publish(key, state, generation, {open: [], recent: [], access: { ci: false, merge: false }, truncated: false- }, userId)+ }, userId, startedAt, reason)return}const wasStale = state.stale@@ -253,7 +258,7 @@ export class GitHubPullStatusTracker {return}if (generation !== state.generation) return- await this.publish(key, state, generation, result, userId)+ await this.publish(key, state, generation, result, userId, startedAt, reason)}private async publish(@@ -261,7 +266,9 @@ export class GitHubPullStatusTracker {state: PullRepositoryState,generation: number,result: PullStatusRead,- userId: string+ userId: string,+ startedAt: number,+ reason: PullReadReason): Promise<void> {const memory = await this.memoryFor(key, state)if (generation !== state.generation) return@@ -309,13 +316,18 @@ export class GitHubPullStatusTracker {const chaseBefore = state.chasestate.pulls = pullsstate.observedAt = now+ state.readStartedAt = startedAtstate.stale = falsestate.owed = falsestate.access = { ...result.access }state.truncated = result.truncatedstate.chase = nextPullChase(state.chase, open, now)const chaseChanged = !!chaseBefore !== !!state.chase- if (changed.length || accessChanged || wasStale || chaseChanged) this.options.onChanged(key, changed)+ // A FOREGROUND read was asked for (the board's refresh, or a pull request wait that needs a read+ // taken after it was armed): its answer is news even when nothing in it changed.+ if (changed.length || accessChanged || wasStale || chaseChanged || reason === 'foreground') {+ this.options.onChanged(key, changed)+ }}private memoryFor(key: string, state: PullRepositoryState): Promise<PullMemory> {diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.tsindex 8d17e2a69..2b80bcb52 100644--- a/src/main/canvas-control-core.test.ts+++ b/src/main/canvas-control-core.test.ts@@ -1281,7 +1281,8 @@ describe('--after-pr: open a node that waits on a pull request', () => {it.each(bodies)('%s states what each condition means, the deadline and the refusals', (_name, body) => {const flat = body.replace(/\s+/g, ' ')// The two conditions, with #1008's own rules.- expect(flat).toContain('`checks` = the PR\'s checks passed at its CURRENT head commit')+ expect(flat).toContain('`checks` = the PR\'s checks passed at its CURRENT head commit, on a status read taken after you armed the wait')+ expect(flat).toContain('A PR opened a moment ago is looked up again after one refresh')expect(flat).toContain('a PR that reports no checks never passes')expect(flat).toContain('`merged` = the PR is merged')expect(flat).toContain('ANDed with `--after`')diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex ec1f59237..c222f9cca 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -513,7 +513,7 @@ import {LAUNCH_STALL_MS,type ArmedNode} from '../lib/pendingLaunch'-import { prHoldReports, prWaitReplyLine, resolvePrWaitFor, type PrWaitArmResult } from '../lib/prWait'+import { prHoldReports, prWaitReplyLine, resolvePrWaitFor, startFreshReadAsks, type PrWaitArmResult } from '../lib/prWait'import { RUN_NOW_AFTER_PR_REFUSAL } from '@shared/pr-wait'import { lookupPullRequests, pullBoardFor, useGitHubIssues } from '../state/githubIssues'import { usePullChase } from '../components/kanban/usePullAutoMove'@@ -2064,6 +2064,32 @@ export function Canvas() {)const prChaseNeeded = prChecksWaited && prBoardUndecidedusePullChase(api.githubIssues, prWatchProjectId, prChaseNeeded)+ // B2: a `checks` wait is judged only on a read that STARTED after it was armed — the host may still+ // remember "passed" for the head before a push made just before arming. While some wait lacks such+ // a read, ask the host for a foreground one (which answers even when nothing changed), a bounded+ // number of times: the refresh floor, or a read already in flight from before the arming, can+ // swallow a single ask.+ const prFreshReadWanted = useGitHubIssues((s) => {+ if (!prWatchProjectId) return false+ const board = pullBoardFor(s, prWatchProjectId)+ return nodesRef.current.some((n) => {+ const hold = (n.data.pendingLaunch as PendingLaunch | undefined)?.afterPr+ return (+ !!hold &&+ !hold.invalid &&+ hold.waits.some((w) => w.until === 'checks') &&+ (board?.readStartedAt === undefined || board.readStartedAt < hold.armedAt)+ )+ })+ })+ useEffect(() => {+ if (!prWatchProjectId || !prFreshReadWanted) return+ return startFreshReadAsks({+ ask: () => void api.githubIssues.refresh(prWatchProjectId).catch(() => undefined),+ setTimeout: (fn, ms) => window.setTimeout(fn, ms),+ clearTimeout: (timer) => window.clearTimeout(timer as number)+ })+ }, [api, prWatchProjectId, prFreshReadWanted])// Bumped to re-run the launch effect: after a refused delivery's backoff, and when a node// reports its session ready (`subscribeSessionReady` below).const [launchNudge, setLaunchNudge] = useState(0)@@ -10660,6 +10686,7 @@ export function Canvas() {(openProjectPre?.kanban?.columns ?? []).map((c) => c.id),numbers),+ hostNow: (id) => api.githubIssues.pullStatus(id).then((b) => b.now),now: () => Date.now()})if (!prWaitPre.ok) {@@ -11444,7 +11471,8 @@ export function Canvas() {cwd: coldCwd ?? null,after: coldAfterIds,projectId: owner.id,- ...(coldIssueRef ? { issue: formatIssueRef(coldIssueRef) } : {})+ ...(coldIssueRef ? { issue: formatIssueRef(coldIssueRef) } : {}),+ ...prResult}})returndiff --git a/src/renderer/canvas/control-after-pr.source.test.ts b/src/renderer/canvas/control-after-pr.source.test.tsindex 37206b4ab..7bef577a2 100644--- a/src/renderer/canvas/control-after-pr.source.test.ts+++ b/src/renderer/canvas/control-after-pr.source.test.ts@@ -78,6 +78,12 @@ describe('every open path attaches the wait through withPrHold', () => {expect(armAfter).toMatch(/withPrHold\(withLaunchBrief\(queueControlLaunch\(node, after, awaitSetupGroup\), promptFile\), prHoldPre\)/)})+ it('every dry run reports the wait in its result, the cold one included', () => {+ const cold = slice('if (canColdOpen(verb)) {', 'if (answersOffCanvas(verb) || answersFromStoredNodes(verb)) {')+ const dry = cold.slice(cold.indexOf('if (dryRun) {'), cold.indexOf('if (dryRun) {') + 3000)+ expect(dry).toMatch(/projectId: owner\.id,[\s\S]*\.\.\.prResult/)+ })+it('the cold open', () => {const cold = slice('if (canColdOpen(verb)) {', 'if (answersOffCanvas(verb) || answersFromStoredNodes(verb)) {')expect(cold).toMatch(/withPrHold\(/)@@ -105,6 +111,14 @@ describe('the launch loop judges the wait on the ACTIVE project’s pull requestexpect(sig).toContain("sig +=")})+ it('asks for a read taken after arming while a checks wait lacks one (B2), bounded', () => {+ const fresh = slice('const prFreshReadWanted = useGitHubIssues((s) => {', '// Bumped to re-run the launch effect')+ expect(fresh).toContain('board.readStartedAt < hold.armedAt')+ expect(fresh).toContain('startFreshReadAsks({')+ expect(fresh).toContain('api.githubIssues.refresh(prWatchProjectId)')+ expect(fresh).toMatch(/if \(!prWatchProjectId \|\| !prFreshReadWanted\) return/)+ })+it('keeps the host watch (and the checks chase) only while some node holds a PR wait', () => {const watch = slice('const prWatchNeeded =', 'usePullChase(')expect(watch).toContain('watchPulls(api.githubIssues,')diff --git a/src/renderer/lib/controlRouting.test.ts b/src/renderer/lib/controlRouting.test.tsindex 2e6c16d25..a2a1f6218 100644--- a/src/renderer/lib/controlRouting.test.ts+++ b/src/renderer/lib/controlRouting.test.ts@@ -474,7 +474,8 @@ it('lists a PR wait on the row, and EXPIRED once its deadline has passed (--afteconst hold = (deadlineAt: number) => ({repository: 'o/r',waits: [{ number: 7, until: 'checks' }, { number: 9, until: 'merged' }],- deadlineAt+ deadlineAt,+ armedAt: 0})const rows = storedNodeListing([diff --git a/src/renderer/lib/headlessRun.test.ts b/src/renderer/lib/headlessRun.test.tsindex 9e972867a..3d014c76e 100644--- a/src/renderer/lib/headlessRun.test.ts+++ b/src/renderer/lib/headlessRun.test.ts@@ -60,7 +60,7 @@ describe('planRunVerb', () => {// Armed with --after: the canvas fires it when its deps report done, not on mount.expect(planRunVerb({ ...onScreen, pending: { ...pending, after: ['dep-1'] } })).toBe('refuse-not-mounted')// Armed with --after-pr: it fires when the pull request is ready, not on mount.- const afterPr = { repository: 'o/r', waits: [{ number: 7, until: 'merged' as const }], deadlineAt: 1 }+ const afterPr = { repository: 'o/r', waits: [{ number: 7, until: 'merged' as const }], deadlineAt: 1, armedAt: 0 }expect(planRunVerb({ ...onScreen, pending: { ...pending, afterPr } })).toBe('refuse-not-mounted')// The plain, never-attempted, dependency-free launch does start on mount.expect(planRunVerb({ ...onScreen, pending })).toBe('wait-for-mount')diff --git a/src/renderer/lib/pendingLaunch.test.ts b/src/renderer/lib/pendingLaunch.test.tsindex bef19b6fd..adc5a7f3d 100644--- a/src/renderer/lib/pendingLaunch.test.ts+++ b/src/renderer/lib/pendingLaunch.test.ts@@ -347,7 +347,8 @@ describe('--after-pr: a PR wait is a third gate, ANDed with the deps and the setconst hold = (deadlineAt = NOW + 60_000) => ({repository: 'o/r',waits: [{ number: 7, until: 'merged' as const }],- deadlineAt+ deadlineAt,+ armedAt: 0})const prNode = (after: string[], deadlineAt?: number): ArmedNode => ({id: 'c',@@ -432,7 +433,7 @@ describe('--after-pr: a PR wait is a third gate, ANDed with the deps and the set})describe('withPrHold — one way every open path attaches a PR wait', () => {- const hold = { repository: 'o/r', waits: [{ number: 7, until: 'merged' as const }], deadlineAt: 9 }+ const hold = { repository: 'o/r', waits: [{ number: 7, until: 'merged' as const }], deadlineAt: 9, armedAt: 0 }it('adds the hold to a node that already holds its launch', () => {const node = { id: 'n', data: { pendingLaunch: { after: ['a'], command: 'c', attempted: false } } }expect(withPrHold(node, hold).data.pendingLaunch).toEqual({ after: ['a'], command: 'c', attempted: false, afterPr: hold })diff --git a/src/renderer/lib/prWait.test.ts b/src/renderer/lib/prWait.test.tsindex 46fcadc6f..8b63914bd 100644--- a/src/renderer/lib/prWait.test.ts+++ b/src/renderer/lib/prWait.test.ts@@ -7,15 +7,19 @@ import {prHoldSatisfied,prHoldSummary,resolvePrWaitFor,+ startFreshReadAsks,+ PR_FRESH_READ_ASKS,type PrLookup,type PrWaitArmDeps} from './prWait'const NOW = 1_000_000+const ARMED = NOW - 5_000const hold = (waits: PrWaitHold['waits'], deadlineAt = NOW + 3_600_000): PrWaitHold => ({repository: 'o/r',waits,- deadlineAt+ deadlineAt,+ armedAt: ARMED})const pull = (number: number, patch: Partial<GitHubPullStatus> = {}): GitHubPullStatus => ({number,@@ -30,11 +34,17 @@ const board = (pulls: GitHubPullStatus[], patch: Partial<GitHubPullBoard> = {}):repository: 'o/r',pulls,observedAt: NOW - 1000,+ readStartedAt: NOW - 2000,...patch})describe('evaluatePrWait — merged', () => {const w = { number: 7, until: 'merged' as const }+ it('a merge needs no fresh read: it cannot be undone, so an early read that says so is true', () => {+ const early = board([pull(7, { lifecycle: 'merged' })], { readStartedAt: ARMED - 60_000 })+ expect(evaluatePrWait(w, hold([w]), early).state).toBe('met')+ })+it('is met by a merged PR, even from a stale snapshot (a merge cannot be undone)', () => {expect(evaluatePrWait(w, hold([w]), board([pull(7, { lifecycle: 'merged' })])).state).toBe('met')expect(evaluatePrWait(w, hold([w]), board([pull(7, { lifecycle: 'merged' })], { stale: true })).state).toBe('met')@@ -57,6 +67,17 @@ describe('evaluatePrWait — checks (SUCCESS at the PR’s current head)', () =>expect(evaluatePrWait(w, h, board([pull(7, { ci: 'passed' })])).state).toBe('met')expect(evaluatePrWait(w, h, board([pull(7, { ci: 'passed', lifecycle: 'draft' })])).state).toBe('met')})+ it('does NOT trust a read that started before the wait was armed (B2): a push in between carries other checks', () => {+ // Board closed → author pushes head B → arm `N:checks` → the host still remembers "passed at A".+ const early = board([pull(7, { ci: 'passed' })], { readStartedAt: ARMED - 1 })+ const r = evaluatePrWait(w, h, early)+ expect(r.state).toBe('unknown')+ expect(r.detail).toMatch(/read taken after this wait was armed/)+ expect(evaluatePrWait(w, h, board([pull(7, { ci: 'passed' })], { readStartedAt: undefined })).state).toBe('unknown')+ // A read that started at or after arming is an answer.+ expect(evaluatePrWait(w, h, board([pull(7, { ci: 'passed' })], { readStartedAt: ARMED })).state).toBe('met')+ })+it('does NOT trust a stale snapshot: a push since the last read would carry other checks', () => {expect(evaluatePrWait(w, h, board([pull(7, { ci: 'passed' })], { stale: true })).state).toBe('unknown')})@@ -141,6 +162,7 @@ function deps(patch: Partial<PrWaitArmDeps> = {}): PrWaitArmDeps {new Map<number, PrLookup>(numbers.map((n) => [n, { found: true, lifecycle: 'open' }]))),now: () => NOW,+ hostNow: vi.fn(async () => 777),...patch}}@@ -156,11 +178,18 @@ describe('resolvePrWaitFor — the refusal matrix', () => {const r = await resolvePrWaitFor('7:checks', '2h', 'open-agent', deps())expect(r).toEqual({ok: true,- hold: { repository: 'o/r', waits: [{ number: 7, until: 'checks' }], deadlineAt: NOW + 2 * 3_600_000 },+ hold: { repository: 'o/r', waits: [{ number: 7, until: 'checks' }], deadlineAt: NOW + 2 * 3_600_000, armedAt: 777 },alreadyMerged: []})})+ it('records the arming time on the HOST clock, falling back to this one when the host cannot say', async () => {+ const r = await resolvePrWaitFor('7:checks', undefined, 'open-agent', deps({ hostNow: vi.fn(async () => undefined) }))+ expect(r.ok && r.hold?.armedAt).toBe(NOW)+ const t = await resolvePrWaitFor('7:checks', undefined, 'open-agent', deps({ hostNow: vi.fn(async () => { throw new Error('x') }) }))+ expect(t.ok && t.hold?.armedAt).toBe(NOW)+ })+it('a relay tab is refused by name', async () => {const r = await resolvePrWaitFor('7:merged', undefined, 'open-agent', deps({ project: { id: 'p', remote: true } }))expect(r).toMatchObject({ ok: false })@@ -224,6 +253,16 @@ describe('resolvePrWaitFor — the refusal matrix', () => {expect(!threw.ok && threw.error).toMatch(/^after-pr-unconfirmed:/)})+ it('a truncated harvest is named, and not told to retry — waiting never lists a PR it dropped', async () => {+ const r = await resolvePrWaitFor('7:merged', undefined, 'open-agent', deps({+ lookupPulls: vi.fn(async () => new Map<number, PrLookup>([[7, { found: false, complete: false, truncated: true }]]))+ }))+ expect(!r.ok && r.error).toMatch(/^after-pr-unconfirmed:/)+ expect(!r.ok && r.error).toMatch(/keeps fewer pull requests than o\/r has/)+ expect(!r.ok && r.error).toMatch(/do not retry/)+ expect(!r.ok && r.error).not.toMatch(/retry in a minute/)+ })+it('refuses a closed-unmerged PR, and checks on a merged one', async () => {const closed = await resolvePrWaitFor('7:merged', undefined, 'open-agent', deps({lookupPulls: vi.fn(async () => new Map<number, PrLookup>([[7, { found: true, lifecycle: 'closed' }]]))@@ -254,3 +293,43 @@ describe('resolvePrWaitFor — the refusal matrix', () => {expect(!r.ok && r.error).toMatch(/^open-agent: --after-pr must be/)})})++describe('startFreshReadAsks — one fresh read for a checks wait, asked a bounded number of times', () => {+ it('asks at once, then re-asks on the retry interval, and stops at the cap', () => {+ const timers: { fn: () => void; ms: number }[] = []+ const ask = vi.fn()+ const stop = startFreshReadAsks({+ ask,+ setTimeout: (fn, ms) => {+ timers.push({ fn, ms })+ return timers.length+ },+ clearTimeout: () => undefined+ })+ expect(ask).toHaveBeenCalledTimes(1)+ // The host's refresh floor is 30 s: a re-ask inside it would be swallowed.+ expect(timers[0].ms).toBeGreaterThan(30_000)+ // Fire every timer the helper arms, once each, until it stops arming new ones.+ for (let i = 0; i < timers.length && i < 20; i++) timers[i].fn()+ expect(ask).toHaveBeenCalledTimes(PR_FRESH_READ_ASKS)+ stop()+ })++ it('stop() cancels the pending re-ask', () => {+ let pending: (() => void) | undefined+ const cleared: unknown[] = []+ const ask = vi.fn()+ const stop = startFreshReadAsks({+ ask,+ setTimeout: (fn) => {+ pending = fn+ return 'timer'+ },+ clearTimeout: (t) => cleared.push(t)+ })+ stop()+ expect(cleared).toEqual(['timer'])+ expect(ask).toHaveBeenCalledTimes(1)+ void pending+ })+})diff --git a/src/renderer/lib/prWait.ts b/src/renderer/lib/prWait.tsindex 104e306e4..b90eaa225 100644--- a/src/renderer/lib/prWait.ts+++ b/src/renderer/lib/prWait.ts@@ -73,6 +73,11 @@ export function evaluatePrWait(if (!board.access.ci) return report('blocked', "this machine's GitHub token cannot read checks")switch (pull.ci) {case 'passed':+ // B2: the host may still remember "passed" for the head BEFORE a push made just before this+ // wait was armed. Only a read that STARTED at or after arming can speak for the current head.+ if (board.readStartedAt === undefined || board.readStartedAt < hold.armedAt) {+ return report('unknown', 'passed at an earlier read; waiting for a read taken after this wait was armed')+ }return board.stale? report('unknown', 'passed at the last read, but the latest status read failed'): report('met', 'checks passed')@@ -119,8 +124,10 @@ export function prHoldSummary(hold: PrWaitHold, board: GitHubPullBoard | undefin/** What the harvested issue list (the board's REST snapshot, #1008) knows about one number. */export type PrLookup =| { found: true; lifecycle: PullLifecycle }- /** `complete` = the snapshot is whole, so "not found" is an answer, not a gap. */- | { found: false; complete: boolean }+ /** `complete` = a whole snapshot refreshed after the question was asked, so "not found" is an+ * answer, not a gap. `truncated` = the harvest keeps fewer pull requests than the repository+ * has, so an old one it dropped will never be confirmed. */+ | { found: false; complete: boolean; truncated?: true }export interface PrWaitArmDeps {/** The project the node OPENS in (the one `issuePre` resolves against). */@@ -130,6 +137,8 @@ export interface PrWaitArmDeps {/** The GitHub host controller's answer for that project (configured, else detected). */controlStatus(projectId: string): Promise<{ repository?: string; approved: boolean } | null>lookupPulls(projectId: string, numbers: number[]): Promise<Map<number, PrLookup>>+ /** The host's clock (the one its pull request reads are stamped with); undefined = cannot say. */+ hostNow(projectId: string): Promise<number | undefined>now(): number}@@ -208,6 +217,15 @@ export async function resolvePrWaitFor(if (found && found.complete) {return { ok: false, error: `after-pr-unknown: ${repository} has no pull request #${spec.number} — do not retry` }}+ if (found && found.truncated) {+ return {+ ok: false,+ error:+ `after-pr-unconfirmed: pull request #${spec.number} is not in the list this machine keeps, and ` ++ `that list keeps fewer pull requests than ${repository} has, so an older one is never confirmed — ` ++ 'do not retry: wait on a recent pull request, or open without --after-pr'+ }+ }return {ok: false,error:@@ -233,9 +251,12 @@ export async function resolvePrWaitFor(waits.push({ number: spec.number, until: spec.until })}if (!waits.length) return { ok: true, alreadyMerged }+ // On the desktop the host IS this machine, so the fallback is the same clock; it only differs on+ // a surface that does not arm PR waits anyway.+ const armedAt = await deps.hostNow(project.id).catch(() => undefined) ?? deps.now()return {ok: true,- hold: { repository, waits, deadlineAt: deps.now() + deadline.ms },+ hold: { repository, waits, deadlineAt: deps.now() + deadline.ms, armedAt },alreadyMerged}}@@ -244,3 +265,35 @@ export async function resolvePrWaitFor(export function prWaitReplyLine(hold: PrWaitHold): string {return `waiting for ${formatPrWaits(hold)} in ${hold.repository} (until ${new Date(hold.deadlineAt).toISOString()})`}++/** How many times a `checks` wait asks for a read taken after it was armed, and how far apart:+ * just past the host's 30 s refresh floor, which silently swallows a request made inside it. */+export const PR_FRESH_READ_ASKS = 4+export const PR_FRESH_READ_RETRY_MS = 35_000++/**+ * Ask the host for one FOREGROUND read (`githubIssues.refresh`) while a `checks` wait has none taken+ * after it was armed (B2). Bounded: asked at once, then re-asked at most `PR_FRESH_READ_ASKS - 1`+ * times — a refresh inside the floor, or one that joined a read already in flight from before the+ * arming, does not produce the read this needs. The caller stops it as soon as a qualifying read+ * lands. Past the cap the wait keeps waiting on the ordinary heartbeat and chase; its deadline is+ * the way out, never a loop of our own.+ */+export function startFreshReadAsks(deps: {+ ask: () => void+ setTimeout: (fn: () => void, ms: number) => unknown+ clearTimeout: (timer: unknown) => void+}): () => void {+ let asked = 0+ let timer: unknown+ const next = (): void => {+ asked += 1+ deps.ask()+ timer = asked < PR_FRESH_READ_ASKS ? deps.setTimeout(next, PR_FRESH_READ_RETRY_MS) : undefined+ }+ next()+ return () => {+ if (timer !== undefined) deps.clearTimeout(timer)+ timer = undefined+ }+}diff --git a/src/renderer/state/githubIssues.test.ts b/src/renderer/state/githubIssues.test.tsindex b5176df7e..960dd8a2b 100644--- a/src/renderer/state/githubIssues.test.ts+++ b/src/renderer/state/githubIssues.test.ts@@ -289,47 +289,89 @@ describe('lookupPullRequests — does the board repository have these pull reque...pullPage(number, null).items[0],...patch})- const pg = (items: unknown[], extra: Record<string, unknown> = {}) => ({- items, counts: {}, partial: false, readOnly: true, lastSuccessfulRefreshAt: 1, ...extra- })-- it('finds a PR in any column, following pages, and reads its lifecycle', async () => {+ /** A fake host: one harvested list, its last refresh stamp and whether it is truncated. `refresh`+ * can land new items (a PR opened a minute ago) and move the stamp, or do nothing (the floor). */+ function host(init: { items: ReturnType<typeof item>[]; refreshedAt?: number; partial?: boolean }) {+ const state = { ...init, now: 1_000 }const client = api()+ vi.mocked(client.pullStatus).mockImplementation(async () => ({+ repository: 'o/r', now: state.now, pulls: [], stale: false, access: { ci: true, merge: true },+ undecided: false, truncated: false+ }))vi.mocked(client.query).mockImplementation(async (request) => {- if (request.columnId === 'done' && !request.cursor) return pg([item(17)], { nextCursor: '50' }) as never- if (request.columnId === 'done' && request.cursor === '50') {- return pg([item(7, { state: 'closed', pull: { draft: false, mergedAt: '2026-09-01T00:00:00Z' } })]) as never- }- return pg([]) as never+ const hits = state.items.filter((i) => String(i.number).includes(request.search ?? ''))+ const counts: Record<string, number> = {}+ for (const i of hits) counts[(i.columnId as string | null) ?? 'ungrouped'] = (counts[(i.columnId as string | null) ?? 'ungrouped'] ?? 0) + 1+ return {+ items: hits.filter((i) => i.columnId === request.columnId), counts, partial: !!state.partial, readOnly: true,+ ...(state.refreshedAt !== undefined ? { lastSuccessfulRefreshAt: state.refreshedAt } : {})+ } as never})- const found = await lookupPullRequests(client, 'p1', ['todo', 'done'], [7])- expect(found.get(7)).toEqual({ found: true, lifecycle: 'merged' })- expect(client.subscribe).toHaveBeenCalledTimes(1)- expect(client.unsubscribe).toHaveBeenCalledTimes(1)+ return { client, state }+ }++ it('finds a PR in a column the board no longer has — the counts name every column that holds a match', async () => {+ const { client } = host({ items: [item(7, { columnId: 'deleted-col' })], refreshedAt: 5 })+ const found = await lookupPullRequests(client, 'p1', ['todo'], [7])+ expect(found.get(7)).toEqual({ found: true, lifecycle: 'open' })+ expect(client.refresh).not.toHaveBeenCalled()})- it('reads open, draft and closed-unmerged too', async () => {- const client = api()- vi.mocked(client.query).mockResolvedValue(pg([- item(1),- item(2, { pull: { draft: true, mergedAt: null } }),- item(3, { state: 'closed', pull: { draft: false, mergedAt: null } })- ]) as never)- const found = await lookupPullRequests(client, 'p1', [], [1, 2, 3])- expect([1, 2, 3].map((n) => found.get(n))).toEqual([+ it('follows pages and reads every lifecycle', async () => {+ const { client } = host({+ items: [+ item(1),+ item(2, { pull: { draft: true, mergedAt: null } }),+ item(3, { state: 'closed', pull: { draft: false, mergedAt: null } }),+ item(4, { state: 'closed', pull: { draft: false, mergedAt: '2026-09-01T00:00:00Z' } })+ ],+ refreshedAt: 5+ })+ const found = await lookupPullRequests(client, 'p1', [], [1, 2, 3, 4])+ expect([1, 2, 3, 4].map((n) => found.get(n))).toEqual([{ found: true, lifecycle: 'open' },{ found: true, lifecycle: 'draft' },- { found: true, lifecycle: 'closed' }+ { found: true, lifecycle: 'closed' },+ { found: true, lifecycle: 'merged' }])+ expect(client.subscribe).toHaveBeenCalledTimes(1)+ expect(client.unsubscribe).toHaveBeenCalledTimes(1)})- it('only a whole, refreshed snapshot makes "not found" an answer', async () => {- const client = api()- vi.mocked(client.query).mockResolvedValue(pg([]) as never)+ it('B1: a PR opened after the last refresh is found by one refresh on the miss, not refused', async () => {+ // `gh pr create` → `open-claude --after-pr N:checks`: the board's snapshot predates the PR.+ const { client, state } = host({ items: [], refreshedAt: 5 })+ vi.mocked(client.refresh).mockImplementation(async () => {+ state.items = [item(1019)]+ state.refreshedAt = state.now+ })+ const found = await lookupPullRequests(client, 'p1', [], [1019])+ expect(found.get(1019)).toEqual({ found: true, lifecycle: 'open' })+ expect(client.refresh).toHaveBeenCalledTimes(1)+ })++ it('"not found" is an answer only from a refresh that started after this call', async () => {+ const { client, state } = host({ items: [], refreshedAt: 5 })+ vi.mocked(client.refresh).mockImplementation(async () => { state.refreshedAt = state.now })expect((await lookupPullRequests(client, 'p1', [], [9])).get(9)).toEqual({ found: false, complete: true })- vi.mocked(client.query).mockResolvedValue(pg([], { partial: true }) as never)- expect((await lookupPullRequests(client, 'p1', [], [9])).get(9)).toEqual({ found: false, complete: false })- vi.mocked(client.query).mockResolvedValue(pg([], { lastSuccessfulRefreshAt: undefined }) as never)- expect((await lookupPullRequests(client, 'p1', [], [9])).get(9)).toEqual({ found: false, complete: false })+ })++ it('an OLD snapshot proves nothing: no refresh landed (the floor), an older one landed, or it failed', async () => {+ const floored = host({ items: [], refreshedAt: 5 })+ expect((await lookupPullRequests(floored.client, 'p1', [], [9])).get(9)).toEqual({ found: false, complete: false })+ const inFlight = host({ items: [], refreshedAt: 5 })+ vi.mocked(inFlight.client.refresh).mockImplementation(async () => { inFlight.state.refreshedAt = 900 })+ expect((await lookupPullRequests(inFlight.client, 'p1', [], [9])).get(9)).toEqual({ found: false, complete: false })+ const failed = host({ items: [], refreshedAt: 5 })+ vi.mocked(failed.client.refresh).mockRejectedValue(new Error('offline'))+ expect((await lookupPullRequests(failed.client, 'p1', [], [9])).get(9)).toEqual({ found: false, complete: false })+ })++ it('a truncated harvest says so: an old PR it dropped will never be confirmed by waiting', async () => {+ const { client, state } = host({ items: [], refreshedAt: 5, partial: true })+ vi.mocked(client.refresh).mockImplementation(async () => { state.refreshedAt = state.now })+ expect((await lookupPullRequests(client, 'p1', [], [9])).get(9)).toEqual({+ found: false, complete: false, truncated: true+ })})})diff --git a/src/renderer/state/githubIssues.ts b/src/renderer/state/githubIssues.tsindex 81d411e18..93b6f80d1 100644--- a/src/renderer/state/githubIssues.ts+++ b/src/renderer/state/githubIssues.ts@@ -167,10 +167,19 @@ function lifecycleOf(item: GitHubIssuePage['items'][number]): PullLifecycle {/*** Does the board's repository have these pull requests, and where are they in their life? Read- * from the host's harvested issue list (#1008: pull requests ride the same REST snapshot), every- * column, following pages. Holding the host subscription for the duration makes the host read the- * repository first when nothing has yet in this app run. "Not found" is an ANSWER only from a whole,- * refreshed snapshot; anything less is `complete: false`, which a caller must not read as absence.+ * from the host's harvested issue list (#1008: pull requests ride the same REST snapshot). Holding+ * the host subscription for the duration makes the host read the repository first when nothing has+ * yet in this app run.+ *+ * Which columns: the first page's `counts` name every column that holds a match, so a PR the+ * mapping files under a column the board has since deleted is still found.+ *+ * "Not found" is an ANSWER only from a snapshot a refresh STARTED after this call produced (B1). A+ * snapshot from before it proves nothing — the headline flow is `gh pr create` then `open-* --after-pr`,+ * and the board's last refresh can be a minute old — so a miss asks for one refresh and looks again.+ * A refresh the floor swallowed, one already in flight from before the call, or one that failed+ * leaves `complete: false`, which a caller must not read as absence. A truncated harvest is named:+ * a PR it dropped is never listed however long one waits.*/export async function lookupPullRequests(api: GitHubIssuesApi,@@ -180,25 +189,58 @@ export async function lookupPullRequests(): Promise<Map<number, PrLookup>> {const release = await acquireHostSubscription(api, projectId)try {- const out = new Map<number, PrLookup>()- await Promise.all(numbers.map(async (number) => {- let complete = true- for (const columnId of [null, ...columns]) {+ type Search = { item?: GitHubIssuePage['items'][number]; synced: boolean; partial: boolean; refreshedAt?: number }+ const search = async (number: number): Promise<Search> => {+ const pageOf = (columnId: string | null, cursor?: string) => api.query({+ projectId, columnId, kind: 'pull', pageSize: 50, search: String(number), ...(cursor ? { cursor } : {})+ })+ const first = await pageOf(null)+ const found: Search = {+ synced: first.lastSuccessfulRefreshAt !== undefined,+ partial: first.partial,+ refreshedAt: first.lastSuccessfulRefreshAt+ }+ const fromCounts = Object.keys(first.counts).map((key) => (key === 'ungrouped' ? null : key))+ const columnIds = [...new Set<string | null>([null, ...columns, ...fromCounts])]+ for (const columnId of columnIds) {+ let page: GitHubIssuePage | undefined = columnId === null ? first : undefinedlet cursor: string | undefineddo {- const page = await api.query({- projectId, columnId, kind: 'pull', pageSize: 50, search: String(number), ...(cursor ? { cursor } : {})- })- if (page.partial || page.lastSuccessfulRefreshAt === undefined) complete = false+ page = page ?? await pageOf(columnId, cursor)+ if (page.partial) found.partial = true+ if (page.lastSuccessfulRefreshAt === undefined) found.synced = falseconst item = page.items.find((candidate) => candidate.number === number)- if (item) {- out.set(number, { found: true, lifecycle: lifecycleOf(item) })- return- }+ if (item) return { ...found, item }cursor = page.nextCursor+ page = undefined} while (cursor)}- out.set(number, { found: false, complete })+ return found+ }+ const out = new Map<number, PrLookup>()+ const first = await Promise.all(numbers.map(async (number) => [number, await search(number)] as const))+ const missed: number[] = []+ for (const [number, result] of first) {+ if (result.item) out.set(number, { found: true, lifecycle: lifecycleOf(result.item) })+ else missed.push(number)+ }+ if (!missed.length) return out+ // One refresh for every miss, then look again. The host's clock is read BEFORE it, so a snapshot+ // proves absence only if its refresh started at or after that moment.+ const since = await api.pullStatus(projectId).then((board) => board.now, () => undefined)+ const refreshed = await api.refresh(projectId).then(() => true, () => false)+ await Promise.all(missed.map(async (number) => {+ const result = await search(number)+ if (result.item) {+ out.set(number, { found: true, lifecycle: lifecycleOf(result.item) })+ return+ }+ const fresh = refreshed && since !== undefined && result.refreshedAt !== undefined &&+ result.refreshedAt >= since+ const truncated = result.synced && result.partial+ out.set(number, fresh && result.synced && !result.partial+ ? { found: false, complete: true }+ : { found: false, complete: false, ...(truncated ? { truncated: true as const } : {}) })}))return out} finally {diff --git a/src/renderer/state/workspace.test.ts b/src/renderer/state/workspace.test.tsindex 7ef6f34c4..a4f6690b7 100644--- a/src/renderer/state/workspace.test.ts+++ b/src/renderer/state/workspace.test.ts@@ -1205,7 +1205,7 @@ describe('pendingLaunch at the serializer seams (a held launch is hostile inputafter: ['b1'],command: 'claude',attempted: false,- afterPr: { repository: 'o/r', waits: [{ number: 7, until: 'checks' }], deadlineAt: 5 }+ afterPr: { repository: 'o/r', waits: [{ number: 7, until: 'checks' }], deadlineAt: 5, armedAt: 1 }}const flow = nodeStatesToFlow([state(hold)])expect(flow[0].data.pendingLaunch).toEqual(hold)diff --git a/src/shared/github-pull-status.ts b/src/shared/github-pull-status.tsindex 74d2966fd..0de00f361 100644--- a/src/shared/github-pull-status.ts+++ b/src/shared/github-pull-status.ts@@ -83,6 +83,9 @@ export interface GitHubPullBoard {pulls: GitHubPullStatus[]/** Epoch ms of the last read that succeeded. Absent = none yet in this app run. */observedAt?: number+ /** Epoch ms (host clock) when that read STARTED. A `--after-pr` `checks` wait armed later than+ * this cannot trust the read: a push in between carries other checks. */+ readStartedAt?: number/** The latest read failed: `pulls` is the last snapshot that succeeded, kept on purpose. */stale: boolean/** False = the token may not read checks (ci) / mergeability (merge): hide that region. */diff --git a/src/shared/pending-launch-shape.test.ts b/src/shared/pending-launch-shape.test.tsindex 75547af2f..7412c318b 100644--- a/src/shared/pending-launch-shape.test.ts+++ b/src/shared/pending-launch-shape.test.ts@@ -20,7 +20,7 @@ describe('normalizePendingLaunch — the held launch as a hostile project file ccommand: 'claude "go"',attempted: false,awaitSetupGroup: 'g1',- afterPr: { repository: 'o/r', waits: [{ number: 3, until: 'merged' as const }], deadlineAt: 99 }+ afterPr: { repository: 'o/r', waits: [{ number: 3, until: 'merged' as const }], deadlineAt: 99, armedAt: 1 }}expect(normalizePendingLaunch(hold)).toEqual(hold)})diff --git a/src/shared/pr-wait.test.ts b/src/shared/pr-wait.test.tsindex 7ab6b9384..f075224bc 100644--- a/src/shared/pr-wait.test.ts+++ b/src/shared/pr-wait.test.ts@@ -11,6 +11,7 @@ import {parseAfterPrArg,parsePrDeadlineArg} from './pr-wait'+import { LAUNCH_PROMPT_TTL_MS } from './launch-prompt'describe('parseAfterPrArg — the --after-pr grammar', () => {it('reads N:checks and N:merged', () => {@@ -148,7 +149,8 @@ describe('normalizePrWaitHold — a git-shared, hand-editable project file is hoconst good = {repository: 'eneskirca/nodeterm',waits: [{ number: 12, until: 'checks' }],- deadlineAt: 1_900_000_000_000+ deadlineAt: 1_900_000_000_000,+ armedAt: 1_800_000_000_000}it('absent stays absent', () => {@@ -172,6 +174,10 @@ describe('normalizePrWaitHold — a git-shared, hand-editable project file is ho['too many', { ...good, waits: Array.from({ length: PR_WAIT_MAX + 1 }, (_, i) => ({ number: i + 1, until: 'merged' })) }],['a NaN deadline', { ...good, deadlineAt: Number.NaN }],['a string deadline', { ...good, deadlineAt: '2030' }],+ // `checks` is judged against reads that started after this moment: without it a stale+ // "passed at the previous head" would count, so a hold that lacks it cannot be judged.+ ['no arming time', { ...good, armedAt: undefined }],+ ['a NaN arming time', { ...good, armedAt: Number.NaN }],['a hold already marked invalid', { ...good, invalid: true }]])('%s becomes the INVALID hold — present, never satisfied, never throws', (_label, value) => {// Dropping a malformed hold would let the node start on its `--after` deps alone, i.e. EARLY:@@ -185,7 +191,7 @@ describe('owner names GitHub really issued (a stored value is never narrower tha// and `foo--bar` (org) exist; `-foo` does not. A validator narrower than that would turn every// stored hold on such a repository invalid on load, and the next save would write it out that way.it.each(['john-/repo', 'Test-/x', 'hello--world/nodeterm', 'foo--bar/a.b_c-d'])('keeps a hold on %s', (repository) => {- const hold = { repository, waits: [{ number: 3, until: 'merged' }], deadlineAt: 5 }+ const hold = { repository, waits: [{ number: 3, until: 'merged' }], deadlineAt: 5, armedAt: 1 }expect(normalizePrWaitHold(hold)).toEqual(hold)expect(parseAfterPrArg(`${repository}#3:merged`)).toEqual({ok: true,@@ -194,12 +200,20 @@ describe('owner names GitHub really issued (a stored value is never narrower tha})it.each(['-foo/repo', 'o/-repo', 'o/..', 'o/.', 'a'.repeat(40) + '/r', 'o/r;x', 'o/r x'])('still refuses %s', (repository) => {- expect(normalizePrWaitHold({ repository, waits: [{ number: 3, until: 'merged' }], deadlineAt: 5 })).toEqual(+ expect(normalizePrWaitHold({ repository, waits: [{ number: 3, until: 'merged' }], deadlineAt: 5, armedAt: 1 })).toEqual(INVALID_PR_WAIT_HOLD)})})+describe('the deadline never outlives the prompt file a held launch reads (B3)', () => {+ it('a spilled prompt is kept longer than the longest --pr-deadline', () => {+ // A PR wait may hold a cold-opened node for up to 14 days; its spilled prompt must still be+ // there when it fires (and the delivery loop checks, for waits longer than any TTL).+ expect(LAUNCH_PROMPT_TTL_MS).toBeGreaterThan(PR_DEADLINE_MAX_MS + 7 * 86_400_000)+ })+})+describe('formatPrWaits', () => {it('names each pull request and its condition', () => {expect(diff --git a/src/shared/pr-wait.ts b/src/shared/pr-wait.tsindex b1198234e..3a1c0775a 100644--- a/src/shared/pr-wait.ts+++ b/src/shared/pr-wait.ts@@ -42,6 +42,10 @@ export interface PrWaitHold {waits: PrWait[]/** Epoch ms on this machine's clock. Past it the node never starts on its own (▶ still runs it). */deadlineAt: number+ /** Epoch ms on the HOST clock (the one GitHub status reads are stamped with) when the wait was+ * armed. `checks` is judged only on a read that started at or after it: the host may still+ * remember "passed" for the head before a push made just before arming. */+ armedAt: number/** A hold read from a project file that did not survive validation. Never satisfied. */invalid?: true}@@ -58,6 +62,7 @@ export const INVALID_PR_WAIT_HOLD: PrWaitHold = Object.freeze({repository: '',waits: [],deadlineAt: 0,+ armedAt: 0,invalid: true}) as PrWaitHold@@ -200,7 +205,8 @@ export function normalizePrWaitHold(value: unknown): PrWaitHold | undefined {waits.push({ number, until: until as PrWaitUntil })}if (typeof v.deadlineAt !== 'number' || !Number.isFinite(v.deadlineAt)) return INVALID_PR_WAIT_HOLD- return { repository: `${repo.owner}/${repo.repo}`, waits, deadlineAt: v.deadlineAt }+ if (typeof v.armedAt !== 'number' || !Number.isFinite(v.armedAt)) return INVALID_PR_WAIT_HOLD+ return { repository: `${repo.owner}/${repo.repo}`, waits, deadlineAt: v.deadlineAt, armedAt: v.armedAt }}/** "PR #12 checks, PR #13 merged" — the one wording for replies, the badge and `list`. */