@devries-cameron20 / t3code-1 / commits / f6a32dbc7f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): stop PR watch flapping while workflows await approval (#24599)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

shivam committed Nov 10, 2026 at 10:05 UTC f6a32dbc7f9047cce5e6a83062aa1b8031a03081
10 files changed +263 -30
apps/server/src/orchestration-v2/Orchestrator.ts
+6
@@ -4158,6 +4158,12 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4158 ...(existing.endedWatch?.owedChecks !== undefined && {
4159 owedChecks: existing.endedWatch.owedChecks,
4160 }),
4161 + ...(existing.endedWatch?.awaitingApproval !== undefined && {
4162 + awaitingApproval: existing.endedWatch.awaitingApproval,
4163 + }),
4164 + ...(existing.endedWatch?.approvalAnnounced !== undefined && {
4165 + approvalAnnounced: existing.endedWatch.approvalAnnounced,
4166 + }),
4167 ...(existing.endedWatch?.checksAwaitedSince !== undefined && {
4168 checksAwaitedSince: existing.endedWatch.checksAwaitedSince,
4169 }),
apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
+2
@@ -178,6 +178,8 @@ function watchesEqual(left: ThreadPullRequestWatch, right: ThreadPullRequestWatc
178 left.passed === right.passed &&
179 left.passedChecks.join("\n") === right.passedChecks.join("\n") &&
180 (left.owedChecks ?? []).join("\n") === (right.owedChecks ?? []).join("\n") &&
181 + (left.awaitingApproval ?? []).join("\n") === (right.awaitingApproval ?? []).join("\n") &&
182 + (left.approvalAnnounced ?? false) === (right.approvalAnnounced ?? false) &&
183 left.remarksThrough === right.remarksThrough &&
184 left.remarkIds.join("\n") === right.remarkIds.join("\n") &&
185 left.conflicting === right.conflicting &&
apps/server/src/orchestration-v2/pullRequestWatch.test.ts
+148
@@ -31,6 +31,8 @@ const watch = (overrides: Partial<ThreadPullRequestWatch> = {}): ThreadPullReque
31 ...overrides,
32 });
33
34 +const run = (id: number) => `https://github.com/o/r/actions/runs/${id}`;
35 +
36 const check = (name: string, status: PullRequestCheck["status"]): PullRequestCheck => ({
37 name,
38 status,
@@ -79,6 +81,136 @@ const remark = (
81 const noRemarks: ReadonlyArray<PullRequestComment> = [];
82
83 describe("evaluatePullRequestWatch", () => {
84 + it("waits for workflow approval once, through reads that miss it, until the run finishes", () => {
85 + const bot = check("bot", "success");
86 + const approval = { ...check("CI", "action-required"), url: run(1) };
87 + const gated = detail({ checks: [bot, approval] });
88 + const first = evaluatePullRequestWatch(watch(), gated, noRemarks);
89 + assert.deepEqual(first.changes, [{ kind: "checks-awaiting-approval", checks: [approval] }]);
90 +
91 + // GitHub's approval read can answer empty while the rest of the checks read fine.
92 + const missing = evaluatePullRequestWatch(first.next, detail({ checks: [bot] }), noRemarks);
93 + assert.deepEqual(missing.changes, []);
94 + assert.isFalse(missing.next.passed);
95 + assert.deepEqual(evaluatePullRequestWatch(missing.next, gated, noRemarks).changes, []);
96 + const later = { ...check("Preview", "action-required"), url: run(2) };
97 + assert.deepEqual(
98 + evaluatePullRequestWatch(missing.next, detail({ checks: [bot, approval, later] }), noRemarks)
99 + .changes,
100 + [],
101 + );
102 + const unnamed = { ...check("Docs", "action-required"), url: null };
103 + const named = detail({ checks: [bot, unnamed] });
104 + const alone = evaluatePullRequestWatch(watch(), named, noRemarks);
105 + assert.deepEqual(alone.changes, [{ kind: "checks-awaiting-approval", checks: [unnamed] }]);
106 + const placeholder = { ...unnamed, name: "Workflow approval status", placeholder: true };
107 + const unlisted = evaluatePullRequestWatch(
108 + alone.next,
109 + detail({ checks: [bot, placeholder] }),
110 + noRemarks,
111 + );
112 + assert.deepEqual(unlisted.changes, []);
113 + assert.isFalse(unlisted.next.passed);
114 + assert.deepEqual(evaluatePullRequestWatch(unlisted.next, named, noRemarks).changes, []);
115 + const dropped = evaluatePullRequestWatch(alone.next, detail({ checks: [bot] }), noRemarks);
116 + assert.deepEqual(dropped.changes, []);
117 + assert.isFalse(dropped.next.passed);
118 + assert.deepEqual(dropped.next.awaitingApproval, [unnamed.name]);
119 + assert.deepEqual(evaluatePullRequestWatch(dropped.next, named, noRemarks).changes, []);
120 + const namedPending = evaluatePullRequestWatch(
121 + dropped.next,
122 + detail({
123 + checks: [
124 + { ...bot, required: true },
125 + { ...unnamed, status: "pending" },
126 + ],
127 + }),
128 + noRemarks,
129 + );
130 + assert.deepEqual(namedPending.changes, []);
131 + assert.isFalse(namedPending.next.passed);
132 + const namedDone = detail({ checks: [bot, { ...unnamed, status: "success" }] });
133 + const namedFinished = evaluatePullRequestWatch(namedPending.next, namedDone, noRemarks);
134 + assert.deepEqual(namedFinished.changes, [{ kind: "checks-passed", count: 2, required: false }]);
135 + assert.deepEqual(namedFinished.next.awaitingApproval, []);
136 + assert.deepEqual(
137 + evaluatePullRequestWatch(namedFinished.next, namedDone, noRemarks).changes,
138 + [],
139 + );
140 + const pushed = detail({ headSha: "bbbbbbbbbb", checks: [bot] });
141 + assert.deepEqual(evaluatePullRequestWatch(missing.next, pushed, noRemarks).changes, [
142 + { kind: "checks-passed", count: 1, required: false },
143 + ]);
144 +
145 + // Approved, the run's jobs carry their own names under the run's URL.
146 + const job = { ...check("lint", "success"), url: `${run(1)}/job/7` };
147 + const pending = { ...check("test", "pending"), url: `${run(1)}/job/8` };
148 + const required = { ...bot, required: true };
149 + const running = evaluatePullRequestWatch(
150 + missing.next,
151 + detail({ checks: [required, job, pending] }),
152 + noRemarks,
153 + );
154 + assert.deepEqual(running.changes, []);
155 + assert.isFalse(running.next.passed);
156 + assert.deepEqual(running.next.awaitingApproval, [run(1)]);
157 + const overlap = evaluatePullRequestWatch(
158 + running.next,
159 + detail({ checks: [required, job, { ...pending, url: `${run(2)}/job/9` }] }),
160 + noRemarks,
161 + );
162 + assert.deepEqual(overlap.changes, []);
163 + assert.isFalse(overlap.next.passed);
164 + assert.deepEqual(overlap.next.awaitingApproval, [run(1)]);
165 + const unlinked = evaluatePullRequestWatch(
166 + overlap.next,
167 + detail({ checks: [required, job, { ...pending, url: null }] }),
168 + noRemarks,
169 + );
170 + assert.deepEqual(unlinked.changes, []);
171 + assert.isFalse(unlinked.next.passed);
172 + assert.deepEqual(unlinked.next.awaitingApproval, [run(1)]);
173 + const advisory = evaluatePullRequestWatch(
174 + unlinked.next,
175 + detail({ checks: [required, job, { ...pending, url: "https://ci.example/test" }] }),
176 + noRemarks,
177 + );
178 + assert.deepEqual(advisory.changes, [{ kind: "checks-passed", count: 1, required: true }]);
179 + assert.deepEqual(advisory.next.awaitingApproval, []);
180 + const completed = detail({ checks: [required, job, { ...pending, status: "success" }] });
181 + const finished = evaluatePullRequestWatch(unlinked.next, completed, noRemarks);
182 + assert.deepEqual(finished.changes, [{ kind: "checks-passed", count: 1, required: true }]);
183 + assert.deepEqual(finished.next.awaitingApproval, []);
184 + assert.deepEqual(evaluatePullRequestWatch(finished.next, completed, noRemarks).changes, []);
185 +
186 + const done = evaluatePullRequestWatch(missing.next, detail({ checks: [bot, job] }), noRemarks);
187 + assert.deepEqual(done.changes, [{ kind: "checks-passed", count: 2, required: false }]);
188 + });
189 +
190 + it("does not pass or fail while the host cannot tell whether workflows await approval", () => {
191 + const bot = check("bot", "success");
192 + const unknown = {
193 + ...check("Workflow approval status", "action-required"),
194 + url: null,
195 + placeholder: true,
196 + };
197 + const unread = evaluatePullRequestWatch(watch(), detail({ checks: [bot, unknown] }), noRemarks);
198 + assert.deepEqual(unread.changes, []);
199 + assert.isFalse(unread.next.passed);
200 + const read = evaluatePullRequestWatch(unread.next, detail({ checks: [bot] }), noRemarks);
201 + assert.deepEqual(read.changes, [{ kind: "checks-passed", count: 1, required: false }]);
202 + const blocked = evaluatePullRequestWatch(
203 + read.next,
204 + detail({ checks: [{ ...bot, status: "pending" }, unknown] }),
205 + noRemarks,
206 + );
207 + assert.isFalse(blocked.next.passed);
208 + assert.deepEqual(
209 + evaluatePullRequestWatch(blocked.next, detail({ checks: [bot] }), noRemarks).changes,
210 + [{ kind: "checks-passed", count: 1, required: false }],
211 + );
212 + });
213 +
214 it("reports each failure at once, even while another check never finishes", () => {
215 const bot = check("CodeRabbit", "pending");
216 const first = detail({ checks: [check("lint", "failure"), check("test", "pending"), bot] });
@@ -95,6 +227,13 @@ describe("evaluatePullRequestWatch", () => {
227
228 const pushed = detail({ ...second, headSha: "bbbbbbbbbb" });
229 assert.equal(evaluatePullRequestWatch(test.next, pushed, noRemarks).changes.length, 1);
230 +
231 + const approval = { ...check("CI", "action-required"), url: run(1) };
232 + const gated = detail({ checks: [approval, check("lint", "failure")] });
233 + assert.deepEqual(evaluatePullRequestWatch(watch(), gated, noRemarks).changes, [
234 + { kind: "checks-failed", failed: [check("lint", "failure")] },
235 + { kind: "checks-awaiting-approval", checks: [approval] },
236 + ]);
237 });
238
239 it("reports passed once the required checks pass, whatever the others do", () => {
@@ -429,6 +568,15 @@ describe("evaluatePullRequestWatch", () => {
568 assert.isTrue(anHourLater(legacy, detail({ checks: [] })).every((kinds) => kinds.length === 0));
569 const pushed = anHourLater(legacy, detail({ headSha: "bbbbbbbbbb", checks: [] }));
570 assert.deepEqual(pushed.flat(), ["no-checks"]);
571 + const unknown = detail({
572 + checks: [{ ...check("Workflow approval status", "action-required"), placeholder: true }],
573 + });
574 + assert.deepEqual(anHourLater(watch(), unknown).flat(), []);
575 + const unread = evaluate(watch(), unknown, noRemarks, 0);
576 + assert.deepEqual(
577 + evaluate(unread.next, detail({ checks: [] }), noRemarks, 60 * 60_000).changes,
578 + [{ kind: "no-checks", minutes: 60 }],
579 + );
580 });
581
582 it("never reports missing checks on a host where an empty list says nothing", () => {
apps/server/src/orchestration-v2/pullRequestWatch.ts
+71 -13
@@ -17,6 +17,7 @@ const SNIPPET_LENGTH = 200;
17 export type PullRequestWatchChange =
18 | { readonly kind: "checks-failed"; readonly failed: ReadonlyArray<PullRequestCheck> }
19 | { readonly kind: "checks-passed"; readonly count: number; readonly required: boolean }
20 + | { readonly kind: "checks-awaiting-approval"; readonly checks: ReadonlyArray<PullRequestCheck> }
21 | { readonly kind: "remarks"; readonly remarks: ReadonlyArray<PullRequestComment> }
22 | { readonly kind: "no-checks"; readonly minutes: number }
23 | { readonly kind: "conflicting" };
@@ -27,9 +28,12 @@ export interface PullRequestWatchReport {
28 readonly exhausted: boolean;
29 }
30
30 -// action-required is a finished check needing human input.
31 const isFailedCheck = (check: PullRequestCheck) =>
32 - check.status === "failure" || check.status === "cancelled" || check.status === "action-required";
32 + check.status === "failure" || check.status === "cancelled";
33 +
34 +// A GitHub Actions job's URL extends its workflow run's URL; their names need not match.
35 +const workflowRunOf = (url: string | null) => url?.match(/^.*\/actions\/runs\/\d+/)?.[0] ?? null;
36 +const approvalKey = (check: PullRequestCheck) => workflowRunOf(check.url) ?? check.name;
37
38 export function evaluatePullRequestWatch(
39 watch: ThreadPullRequestWatch,
@@ -50,15 +54,59 @@ export function evaluatePullRequestWatch(
54 let passed = headMoved ? false : watch.passed;
55 let passedChecks = headMoved ? [] : watch.passedChecks;
56 let owedChecks = headMoved ? [] : (watch.owedChecks ?? []);
53 - if (detail.checks.length > 0) {
54 - const failed = detail.checks.filter(isFailedCheck);
57 + let awaitingApproval = headMoved ? [] : (watch.awaitingApproval ?? []);
58 + let approvalAnnounced = headMoved ? false : (watch.approvalAnnounced ?? false);
59 + // An unavailable approval read cannot establish success or that no checks exist.
60 + const unread = detail.checks.some((check) => check.placeholder === true);
61 + const checks = detail.checks.filter((check) => check.placeholder !== true);
62 + const failed = checks.filter(isFailedCheck);
63 + const awaiting = checks.filter((check) => check.status === "action-required");
64 + if (checks.length > 0) {
65 const newlyFailed = failed.filter((check) => !failedChecks.includes(check.name));
66 if (newlyFailed.length > 0) changes.push({ kind: "checks-failed", failed: newlyFailed });
67 + if (!approvalAnnounced && awaiting.length > 0) {
68 + changes.push({ kind: "checks-awaiting-approval", checks: awaiting });
69 + approvalAnnounced = true;
70 + }
71 failedChecks = failed.map((check) => check.name);
72
59 - const required = detail.checks.filter((check) => check.required === true);
60 - const gate = required.length > 0 ? required : detail.checks;
61 - const passedNow = gate.every((check) => check.status !== "pending" && !isFailedCheck(check));
73 + // Approval reads can omit gated runs. Keep each hold until its jobs finish.
74 + const awaitingNow = [...new Set(awaiting.map(approvalKey))];
75 + const nameUnfinished = (name: string) => {
76 + const matching = checks.filter((check) => check.name === name);
77 + return (
78 + matching.length === 0 ||
79 + matching.some((check) => check.status === "pending" || check.status === "action-required")
80 + );
81 + };
82 + // GitHub deduplicates jobs across runs, so a visible pending job may hide one in an awaited run.
83 + // A pending check without a URL could be such a job; one with another host's URL cannot.
84 + const jobsPending = checks.some(
85 + (check) =>
86 + check.status === "pending" && (check.url === null || workflowRunOf(check.url) !== null),
87 + );
88 + const finished = new Set(
89 + jobsPending
90 + ? []
91 + : checks
92 + .filter((check) => check.status !== "action-required" && check.status !== "pending")
93 + .map((check) => workflowRunOf(check.url)),
94 + );
95 + awaitingApproval = [
96 + ...awaitingNow,
97 + ...awaitingApproval.filter(
98 + (key) =>
99 + !awaitingNow.includes(key) &&
100 + (workflowRunOf(key) === key ? !finished.has(key) : nameUnfinished(key)),
101 + ),
102 + ];
103 + }
104 + const required = checks.filter((check) => check.required === true);
105 + const gate = required.length > 0 ? required : checks;
106 + const passedNow =
107 + awaitingApproval.length === 0 &&
108 + gate.every((check) => check.status !== "pending" && !isFailedCheck(check));
109 + if (checks.length > 0 && !(unread && passedNow)) {
110 const gateNames = gate.map((check) => check.name);
111 const told = passed && passedChecks.length === 0 ? gateNames : passedChecks;
112 // Required checks can finish between sweeps; detect new names. With no required checks, ignore advisory gate growth.
@@ -67,23 +115,25 @@ export function evaluatePullRequestWatch(
115 // Only those are owed, so later advisory churn never wakes. One turned required is gate news.
116 const owed =
117 passedNow && passed
70 - ? detail.checks
118 + ? checks
119 .filter((check) => check.required !== true && owedChecks.includes(check.name))
120 .map((check) => check.name)
121 : [];
122 const settled =
75 - failed.length === 0 && detail.checks.every((check) => check.status !== "pending");
123 + failed.length === 0 &&
124 + awaitingApproval.length === 0 &&
125 + checks.every((check) => check.status !== "pending");
126 owedChecks = owed;
127 if (passedNow && (!passed || gateGrew)) {
128 changes.push({ kind: "checks-passed", count: gate.length, required: required.length > 0 });
129 owedChecks =
130 required.length > 0
81 - ? detail.checks
131 + ? checks
132 .filter((check) => check.required !== true && check.status === "pending")
133 .map((check) => check.name)
134 : [];
135 } else if (settled && owed.length > 0) {
86 - changes.push({ kind: "checks-passed", count: detail.checks.length, required: false });
136 + changes.push({ kind: "checks-passed", count: checks.length, required: false });
137 owedChecks = [];
138 }
139 passed = passedNow;
@@ -99,9 +149,9 @@ export function evaluatePullRequestWatch(
149 const awaitedBefore = headMoved
150 ? DateTime.formatIso(DateTime.makeUnsafe(now))
151 : (watch.checksAwaitedSince ?? null);
102 - checksAwaitedSince = detail.checks.length > 0 ? null : awaitedBefore;
152 + checksAwaitedSince = checks.length > 0 ? null : awaitedBefore;
153 const awaitedMs = checksAwaitedSince === null ? 0 : now - Date.parse(checksAwaitedSince);
104 - if (awaitedMs >= PULL_REQUEST_WATCH_NO_CHECKS_MS) {
154 + if (!unread && awaitedMs >= PULL_REQUEST_WATCH_NO_CHECKS_MS) {
155 changes.push({ kind: "no-checks", minutes: Math.round(awaitedMs / 60_000) });
156 checksAwaitedSince = null;
157 }
@@ -148,6 +198,8 @@ export function evaluatePullRequestWatch(
198 passed,
199 passedChecks,
200 owedChecks,
201 + awaitingApproval,
202 + approvalAnnounced,
203 remarksThrough,
204 remarkIds,
205 conflicting,
@@ -190,6 +242,11 @@ function changeLines(
242 ` - ${check.name}${check.status === "failure" ? "" : ` (${check.status})`}${check.url ? ` ${check.url}` : ""}`,
243 ),
244 ];
245 + case "checks-awaiting-approval":
246 + return [
247 + `- Checks are waiting for approval or action from a maintainer${context.commit}:`,
248 + ...listed(change.checks, (check) => ` - ${check.name}${check.url ? ` ${check.url}` : ""}`),
249 + ];
250 case "checks-passed":
251 return [
252 `- All ${change.count} ${change.required ? "required " : ""}${change.count === 1 ? "check" : "checks"} passed${context.commit}.`,
@@ -216,6 +273,7 @@ function changeLines(
273 const SUMMARY: Record<PullRequestWatchChange["kind"], string> = {
274 "checks-failed": "checks failed",
275 "checks-passed": "checks passed",
276 + "checks-awaiting-approval": "checks await approval",
277 remarks: "new comments",
278 "no-checks": "no checks reported",
279 conflicting: "merge conflict",
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+23 -16
@@ -3514,12 +3514,12 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3514 }),
3515 );
3516
3517 - it.effect("finishes owed checks once after pending sweeps, a restart, and a re-watch", () =>
3517 + it.effect.each(["pending", "action-required"] as const)("recovers %s watches", (initialStatus) =>
3518 Effect.gen(function* () {
3519 const orchestrator = yield* Orchestrator.OrchestratorV2;
3520 const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
3521 - const threadId = ThreadId.make("runtime-pull-request-watch-owed");
3522 - const projectId = ProjectId.make("pr-watch-owed-project");
3521 + const threadId = ThreadId.make(`runtime-pull-request-watch-owed-${initialStatus}`);
3522 + const projectId = ProjectId.make(`pr-watch-owed-project-${initialStatus}`);
3523 yield* seedProject({
3524 projectId,
3525 title: "Watch owed",
@@ -3531,7 +3531,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3531 type: "thread.create",
3532 createdBy: "user",
3533 creationSource: "web",
3534 - commandId: CommandId.make("pr-watch-owed-create"),
3534 + commandId: CommandId.make(`pr-watch-owed-create-${initialStatus}`),
3535 threadId,
3536 projectId,
3537 title: "Watch owed",
@@ -3544,7 +3544,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3544 const watch = (on: boolean, id: string) =>
3545 orchestrator.dispatch({
3546 type: "thread.pull-request.watch",
3547 - commandId: CommandId.make(`pr-watch-owed-${id}`),
3547 + commandId: CommandId.make(`pr-watch-owed-${initialStatus}-${id}`),
3548 threadId,
3549 host: "github.com",
3550 repository: "pingdotgg/t3code",
@@ -3554,7 +3554,10 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3554 });
3555 yield* watch(true, "start");
3556
3557 - let remainingStatus: "pending" | "success" = "pending";
3557 + let remainingStatus: "pending" | "action-required" | "success" = initialStatus;
3558 + const approval = initialStatus === "action-required";
3559 + const firstSummary = approval ? "#12: checks await approval" : "#12: checks passed";
3560 + const runUrl = "https://github.com/pingdotgg/t3code/actions/runs/123";
3561 const host = Layer.mergeAll(
3562 NodeServices.layer,
3563 NodeCrypto.layer,
@@ -3571,7 +3574,7 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3574 name,
3575 status: name === "test" ? remainingStatus : ("success" as const),
3576 description: null,
3574 - url: null,
3577 + url: name === "test" ? `${runUrl}/job/7` : null,
3578 required: name === "lint",
3579 })),
3580 })),
@@ -3596,38 +3599,42 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3599 yield* TestClock.adjust("10 minutes");
3600 yield* reactor.sweep;
3601 yield* worker.drain();
3599 - assert.deepEqual(yield* summaries, ["#12: checks passed"]);
3602 + assert.deepEqual(yield* summaries, [firstSummary]);
3603
3604 assert.deepEqual(
3602 - (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.owedChecks,
3603 - ["test"],
3605 + (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
3606 + approval ? "awaitingApproval" : "owedChecks"
3607 + ],
3608 + approval ? [runUrl] : ["test"],
3609 );
3610 // The fresh reactor reloads the nonempty obligation from the persisted watch.
3611 const restarted = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
3612 yield* restarted.sweep;
3613 yield* worker.drain();
3609 - assert.deepEqual(yield* summaries, ["#12: checks passed"]);
3614 + assert.deepEqual(yield* summaries, [firstSummary]);
3615
3616 // A new watch on the same pull request knows what the last one told.
3617 yield* watch(false, "stop");
3618 yield* watch(true, "again");
3619 yield* restarted.sweep;
3620 yield* worker.drain();
3616 - assert.deepEqual(yield* summaries, ["#12: checks passed"]);
3621 + assert.deepEqual(yield* summaries, [firstSummary]);
3622
3623 assert.deepEqual(
3619 - (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.owedChecks,
3620 - ["test"],
3624 + (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
3625 + approval ? "awaitingApproval" : "owedChecks"
3626 + ],
3627 + approval ? [runUrl] : ["test"],
3628 );
3629 remainingStatus = "success";
3630 yield* TestClock.adjust("10 minutes");
3631 yield* restarted.sweep;
3632 yield* worker.drain();
3626 - assert.deepEqual(yield* summaries, ["#12: checks passed", "#12: checks passed"]);
3633 + assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
3634 yield* TestClock.adjust("10 minutes");
3635 yield* restarted.sweep;
3636 yield* worker.drain();
3630 - assert.deepEqual(yield* summaries, ["#12: checks passed", "#12: checks passed"]);
3637 + assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
3638 assert.deepEqual(
3639 (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.owedChecks,
3640 [],
docs/user/source-control.md
+1 -1
@@ -319,7 +319,7 @@ review is terminal. An open or unsynced link keeps it active.
319
320 Ask the agent to watch, monitor, or babysit a pull request and it calls `watch_pull_request`. While
321 the thread is active, the server checks the pull request every two minutes and wakes the agent when a
322 -check fails, the required checks pass, someone else comments or reviews, or the branch starts to
322 +check fails or waits for a maintainer's approval, the required checks pass, someone else comments or reviews, or the branch starts to
323 conflict. Threads in a project that watch the same pull request share one check. On GitHub, a check
324 first asks whether anything changed and reads the pull request only when it did, which keeps
325 watching inside GitHub's rate limit. Comments from your own account do not wake it. Watching ends
packages/contracts/src/pullRequest.ts
+5
@@ -109,6 +109,11 @@ export const PullRequestCheck = Schema.Struct({
109 description: Schema.NullOr(Schema.String),
110 url: Schema.NullOr(Schema.String),
111 required: Schema.optional(Schema.Boolean),
112 + /**
113 + * Not a check: it stands for ones the host could not list, such as workflow runs awaiting
114 + * approval when that read fails, so nothing waits on it or counts it as passing.
115 + */
116 + placeholder: Schema.optional(Schema.Boolean),
117 });
118 export type PullRequestCheck = typeof PullRequestCheck.Type;
119
packages/contracts/src/threadPullRequest.ts
+4
@@ -89,6 +89,10 @@ export const ThreadPullRequestWatch = Schema.Struct({
89 ),
90 /** Checks still pending when required ones passed early, owed one wake once all settle. */
91 owedChecks: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
92 + /** Approval holds keyed by workflow run URL, or check name when no run URL is known. */
93 + awaitingApproval: Schema.optional(Schema.Array(TrimmedNonEmptyString)),
94 + /** The agent was told checks await approval on this head, so later ones stay quiet. */
95 + approvalAnnounced: Schema.optional(Schema.Boolean),
96 remarksThrough: IsoDateTime,
97 /** Reported remarks at remarksThrough, so late arrivals at that timestamp still count. */
98 remarkIds: Schema.Array(TrimmedNonEmptyString),
packages/source-control-github/src/server/GitHubPullRequestProvider.test.ts
+2
@@ -259,6 +259,7 @@ describe("gitHubViewerPermissions", () => {
259 status: "action-required",
260 description: "GitHub could not determine whether workflows are awaiting approval.",
261 url: null,
262 + placeholder: true,
263 });
264 for (const fingerprint of ["broad", "restricted", "broad"]) {
265 const scoped = yield* provider
@@ -519,6 +520,7 @@ it.effect("keeps an unsafe workflow approval scope visible as unknown", () =>
520 status: "action-required",
521 description: "GitHub could not determine whether workflows are awaiting approval.",
522 url: null,
523 + placeholder: true,
524 },
525 ]);
526 }).pipe(
packages/source-control-github/src/server/GitHubPullRequestProvider.ts
+1
@@ -190,6 +190,7 @@ function withWorkflowApprovals(
190 status: "action-required" as const,
191 description: "GitHub could not determine whether workflows are awaiting approval.",
192 url: null,
193 + placeholder: true,
194 },
195 ]
196 : []),