The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 09:30 UTC
fix(server): wake no-checks PR watches at the configured deadline (#25437)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Oct 31, 2026 at 03:46 UTC
9bf3d559fd891aa2d3d86c2f9b64c8ec87b91fe5
3 files changed
+124
-4
apps/server/src/orchestration-v2/PullRequestWatchReactor.ts
+16
-3
@@ -34,7 +34,11 @@ import * as PullRequestService from "../pullRequest/PullRequestService.ts";
34
import { forkParked } from "../serverActivation.ts";
35
import * as Orchestrator from "./Orchestrator.ts";
36
import * as ProjectionStore from "./ProjectionStore.ts";
37
-import { evaluatePullRequestWatch, pullRequestWatchMessage } from "./pullRequestWatch.ts";
37
+import {
38
+ evaluatePullRequestWatch,
39
+ PULL_REQUEST_WATCH_NO_CHECKS_MS,
40
+ pullRequestWatchMessage,
41
+} from "./pullRequestWatch.ts";
42
43
/** Checks take minutes; faster sweeps waste the account's shared host quota. */
44
const SWEEP_MINUTES = 2;
@@ -139,19 +143,28 @@ function planRead(
143
if (last === undefined || group.targets.some((target) => !last.watches.has(watchKey(target)))) {
144
return { detail: true, activity: true };
145
}
146
+ // Nothing on the host changes when the no-checks deadline passes, so it alone prompts a read.
147
+ const checksDue = group.targets.some(
148
+ ({ watch }) =>
149
+ watch.checksAwaitedSince != null &&
150
+ now - Date.parse(watch.checksAwaitedSince) >= PULL_REQUEST_WATCH_NO_CHECKS_MS,
151
+ );
152
if (fingerprint === null) {
153
const read =
154
last.inFlight ||
155
!last.remarksComplete ||
156
last.fingerprint !== group.fingerprint ||
157
now - last.at >= QUIET_REREAD_MS;
148
- return { detail: read, activity: read };
158
+ return { detail: read || checksDue, activity: read };
159
}
160
const activity =
161
last.remarks !== fingerprint.remarks ||
162
!last.remarksComplete ||
163
now - last.at >= FINGERPRINT_REREAD_MS;
154
- return { detail: activity || last.status !== fingerprint.status || last.inFlight, activity };
164
+ return {
165
+ detail: activity || checksDue || last.status !== fingerprint.status || last.inFlight,
166
+ activity,
167
+ };
168
}
169
170
function watchesEqual(left: ThreadPullRequestWatch, right: ThreadPullRequestWatch): boolean {
apps/server/src/orchestration-v2/pullRequestWatch.ts
+1
-1
@@ -10,7 +10,7 @@ import * as DateTime from "effect/DateTime";
10
/** Bounds consecutive comment-only wakes to stop bot reply loops; check, conflict, or push news resets it. */
11
export const PULL_REQUEST_WATCH_WAKE_LIMIT = 10;
12
/** How long a head may go without any check before the agent is told none reported. */
13
-const PULL_REQUEST_WATCH_NO_CHECKS_MS = 15 * 60_000;
13
+export const PULL_REQUEST_WATCH_NO_CHECKS_MS = 15 * 60_000;
14
const LISTED_ITEMS = 10;
15
const SNIPPET_LENGTH = 200;
16
apps/server/src/orchestration-v2/runtimeLayer.test.ts
+107
@@ -3755,6 +3755,113 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
3755
}),
3756
);
3757
3758
+ it.effect.each([true, false])(
3759
+ "reads a quiet head when its no-checks notice comes due (fingerprint: %s)",
3760
+ (fingerprinted) =>
3761
+ Effect.gen(function* () {
3762
+ const orchestrator = yield* Orchestrator.OrchestratorV2;
3763
+ const threadId = ThreadId.make(`runtime-pull-request-watch-due-${fingerprinted}`);
3764
+ const projectId = ProjectId.make(`pr-watch-due-project-${fingerprinted}`);
3765
+ yield* seedProject({
3766
+ projectId,
3767
+ title: "Watch no-checks deadline",
3768
+ workspaceRoot: "/workspace/watch-due",
3769
+ defaultModelSelection: null,
3770
+ createdAt: "2026-10-01T00:00:00.000Z",
3771
+ });
3772
+ yield* orchestrator.dispatch({
3773
+ type: "thread.create",
3774
+ createdBy: "user",
3775
+ creationSource: "web",
3776
+ commandId: CommandId.make(`pr-watch-due-create-${fingerprinted}`),
3777
+ threadId,
3778
+ projectId,
3779
+ title: "Watch no-checks deadline",
3780
+ modelSelection,
3781
+ runtimeMode: "full-access",
3782
+ interactionMode: "default",
3783
+ branch: null,
3784
+ worktreePath: null,
3785
+ });
3786
+ const key = { host: "github.com", repository: "pingdotgg/t3code", number: 14 };
3787
+ yield* orchestrator.dispatch({
3788
+ type: "thread.pull-request.watch",
3789
+ commandId: CommandId.make(`pr-watch-due-start-${fingerprinted}`),
3790
+ threadId,
3791
+ ...key,
3792
+ watching: true,
3793
+ link: { url: "https://github.com/pingdotgg/t3code/pull/14", source: "agent" },
3794
+ });
3795
+
3796
+ let reads = 0;
3797
+ const host = Layer.mergeAll(
3798
+ NodeServices.layer,
3799
+ Layer.mock(PullRequestService.PullRequestService)({
3800
+ // The host reports the same fingerprint throughout, so only the deadline can prompt a read.
3801
+ watchFingerprint: () =>
3802
+ Effect.succeed(fingerprinted ? { status: "quiet", remarks: "none" } : null),
3803
+ invalidate: () => Effect.void,
3804
+ detail: () =>
3805
+ Effect.sync(() => {
3806
+ reads++;
3807
+ return {
3808
+ ...watchedPullRequestDetail({
3809
+ projectId,
3810
+ number: 14,
3811
+ at: "2026-10-02T12:00:00.000Z",
3812
+ }),
3813
+ headSha: "6074dd48ff",
3814
+ checks: [],
3815
+ };
3816
+ }),
3817
+ activity: () =>
3818
+ Effect.succeed({
3819
+ comments: [],
3820
+ commentCount: 0,
3821
+ commentsTruncated: false,
3822
+ reviewThreads: [],
3823
+ commits: [],
3824
+ }),
3825
+ }),
3826
+ );
3827
+ const wakes = Effect.map(
3828
+ orchestrator.getThreadRecords(threadId, ["messages"]),
3829
+ ({ messages }) =>
3830
+ messages.filter((message) => message.text.includes("No checks have reported")),
3831
+ );
3832
+ const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
3833
+ const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
3834
+ const sweep = reactor.sweep.pipe(Effect.andThen(worker.drain()));
3835
+
3836
+ yield* sweep;
3837
+ yield* TestClock.adjust("10 minutes");
3838
+ yield* sweep;
3839
+ assert.lengthOf(yield* wakes, 0);
3840
+
3841
+ yield* TestClock.adjust("6 minutes");
3842
+ yield* sweep;
3843
+ const told = yield* wakes;
3844
+ assert.lengthOf(told, 1);
3845
+ assert.include(told[0]!.text, "after 16 minutes");
3846
+
3847
+ // The notice clears the deadline, so the watch returns to its quiet cadence.
3848
+ const readsAfterNotice = reads;
3849
+ yield* TestClock.adjust("2 minutes");
3850
+ yield* sweep;
3851
+ assert.equal(reads, readsAfterNotice);
3852
+ assert.lengthOf(yield* wakes, 1);
3853
+
3854
+ yield* orchestrator.dispatch({
3855
+ type: "thread.pull-request.watch",
3856
+ commandId: CommandId.make(`pr-watch-due-end-${fingerprinted}`),
3857
+ threadId,
3858
+ ...key,
3859
+ watching: false,
3860
+ });
3861
+ yield* worker.drain();
3862
+ }),
3863
+ );
3864
+
3865
// regression: #21155 watching a pull request again repeated news the thread already got
3866
it.effect("watching a dismissed stack layer again keeps what its last watch told", () =>
3867
Effect.gen(function* () {