Skip to content

Commit f452f47

Browse files
committed
test(server): keep watch parameterization diff focused
1 parent 60b59d6 commit f452f47

1 file changed

Lines changed: 119 additions & 121 deletions

File tree

‎apps/server/src/orchestration-v2/runtimeLayer.test.ts‎

Lines changed: 119 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,134 +2767,132 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
27672767
}),
27682768
);
27692769

2770-
it.effect.each(["pending", "action-required"] as const)(
2771-
"finishes %s checks once after sweeps, a restart, and a re-watch",
2772-
(initialStatus) =>
2773-
Effect.gen(function* () {
2774-
const orchestrator = yield* Orchestrator.OrchestratorV2;
2775-
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
2776-
const threadId = ThreadId.make(`runtime-pull-request-watch-owed-${initialStatus}`);
2777-
const projectId = ProjectId.make(`pr-watch-owed-project-${initialStatus}`);
2778-
yield* seedProject({
2779-
projectId,
2780-
title: "Watch owed",
2781-
workspaceRoot: "/workspace/watch-owed",
2782-
defaultModelSelection: null,
2783-
createdAt: "2026-10-01T00:00:00.000Z",
2784-
});
2785-
yield* orchestrator.dispatch({
2786-
type: "thread.create",
2787-
createdBy: "user",
2788-
creationSource: "web",
2789-
commandId: CommandId.make(`pr-watch-owed-create-${initialStatus}`),
2770+
it.effect.each(["pending", "action-required"] as const)("recovers %s watches", (initialStatus) =>
2771+
Effect.gen(function* () {
2772+
const orchestrator = yield* Orchestrator.OrchestratorV2;
2773+
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
2774+
const threadId = ThreadId.make(`runtime-pull-request-watch-owed-${initialStatus}`);
2775+
const projectId = ProjectId.make(`pr-watch-owed-project-${initialStatus}`);
2776+
yield* seedProject({
2777+
projectId,
2778+
title: "Watch owed",
2779+
workspaceRoot: "/workspace/watch-owed",
2780+
defaultModelSelection: null,
2781+
createdAt: "2026-10-01T00:00:00.000Z",
2782+
});
2783+
yield* orchestrator.dispatch({
2784+
type: "thread.create",
2785+
createdBy: "user",
2786+
creationSource: "web",
2787+
commandId: CommandId.make(`pr-watch-owed-create-${initialStatus}`),
2788+
threadId,
2789+
projectId,
2790+
title: "Watch owed",
2791+
modelSelection,
2792+
runtimeMode: "full-access",
2793+
interactionMode: "default",
2794+
branch: null,
2795+
worktreePath: null,
2796+
});
2797+
const watch = (on: boolean, id: string) =>
2798+
orchestrator.dispatch({
2799+
type: "thread.pull-request.watch",
2800+
commandId: CommandId.make(`pr-watch-owed-${initialStatus}-${id}`),
27902801
threadId,
2791-
projectId,
2792-
title: "Watch owed",
2793-
modelSelection,
2794-
runtimeMode: "full-access",
2795-
interactionMode: "default",
2796-
branch: null,
2797-
worktreePath: null,
2802+
host: "github.com",
2803+
repository: "pingdotgg/t3code",
2804+
number: 12,
2805+
watching: on,
2806+
link: { url: "https://github.com/pingdotgg/t3code/pull/12", source: "agent" },
27982807
});
2799-
const watch = (on: boolean, id: string) =>
2800-
orchestrator.dispatch({
2801-
type: "thread.pull-request.watch",
2802-
commandId: CommandId.make(`pr-watch-owed-${initialStatus}-${id}`),
2803-
threadId,
2804-
host: "github.com",
2805-
repository: "pingdotgg/t3code",
2806-
number: 12,
2807-
watching: on,
2808-
link: { url: "https://github.com/pingdotgg/t3code/pull/12", source: "agent" },
2809-
});
2810-
yield* watch(true, "start");
2811-
2812-
let remainingStatus: "pending" | "action-required" | "success" = initialStatus;
2813-
const approval = initialStatus === "action-required";
2814-
const firstSummary = approval ? "#12: checks await approval" : "#12: checks passed";
2815-
const runUrl = "https://github.com/pingdotgg/t3code/actions/runs/123";
2816-
const host = Layer.mergeAll(
2817-
NodeServices.layer,
2818-
Layer.mock(PullRequestService.PullRequestService)({
2819-
detail: () =>
2820-
Effect.sync(() => ({
2821-
...watchedPullRequestDetail({
2822-
projectId,
2823-
number: 12,
2824-
at: "2026-10-02T12:00:00.000Z",
2825-
}),
2826-
headSha: "ad70160aaa",
2827-
checks: ["lint", "test"].map((name) => ({
2828-
name,
2829-
status: name === "test" ? remainingStatus : ("success" as const),
2830-
description: null,
2831-
url: name === "test" ? `${runUrl}/job/7` : null,
2832-
required: name === "lint",
2833-
})),
2834-
})),
2835-
activity: () =>
2836-
Effect.succeed({
2837-
comments: [],
2838-
commentCount: 0,
2839-
commentsTruncated: false,
2840-
reviewThreads: [],
2841-
commits: [],
2808+
yield* watch(true, "start");
2809+
2810+
let remainingStatus: "pending" | "action-required" | "success" = initialStatus;
2811+
const approval = initialStatus === "action-required";
2812+
const firstSummary = approval ? "#12: checks await approval" : "#12: checks passed";
2813+
const runUrl = "https://github.com/pingdotgg/t3code/actions/runs/123";
2814+
const host = Layer.mergeAll(
2815+
NodeServices.layer,
2816+
Layer.mock(PullRequestService.PullRequestService)({
2817+
detail: () =>
2818+
Effect.sync(() => ({
2819+
...watchedPullRequestDetail({
2820+
projectId,
2821+
number: 12,
2822+
at: "2026-10-02T12:00:00.000Z",
28422823
}),
2843-
}),
2844-
);
2845-
const summaries = Effect.map(
2846-
orchestrator.getThreadRecords(threadId, ["messages"]),
2847-
({ messages }) => messages.flatMap((message) => message.notification?.summary ?? []),
2848-
);
2824+
headSha: "ad70160aaa",
2825+
checks: ["lint", "test"].map((name) => ({
2826+
name,
2827+
status: name === "test" ? remainingStatus : ("success" as const),
2828+
description: null,
2829+
url: name === "test" ? `${runUrl}/job/7` : null,
2830+
required: name === "lint",
2831+
})),
2832+
})),
2833+
activity: () =>
2834+
Effect.succeed({
2835+
comments: [],
2836+
commentCount: 0,
2837+
commentsTruncated: false,
2838+
reviewThreads: [],
2839+
commits: [],
2840+
}),
2841+
}),
2842+
);
2843+
const summaries = Effect.map(
2844+
orchestrator.getThreadRecords(threadId, ["messages"]),
2845+
({ messages }) => messages.flatMap((message) => message.notification?.summary ?? []),
2846+
);
28492847

2850-
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
2851-
yield* reactor.sweep;
2852-
yield* worker.drain();
2853-
yield* TestClock.adjust("10 minutes");
2854-
yield* reactor.sweep;
2855-
yield* worker.drain();
2856-
assert.deepEqual(yield* summaries, [firstSummary]);
2848+
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
2849+
yield* reactor.sweep;
2850+
yield* worker.drain();
2851+
yield* TestClock.adjust("10 minutes");
2852+
yield* reactor.sweep;
2853+
yield* worker.drain();
2854+
assert.deepEqual(yield* summaries, [firstSummary]);
28572855

2858-
assert.deepEqual(
2859-
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
2860-
approval ? "awaitingApproval" : "owedChecks"
2861-
],
2862-
approval ? [runUrl] : ["test"],
2863-
);
2864-
// The fresh reactor reloads the nonempty obligation from the persisted watch.
2865-
const restarted = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
2866-
yield* restarted.sweep;
2867-
yield* worker.drain();
2868-
assert.deepEqual(yield* summaries, [firstSummary]);
2856+
assert.deepEqual(
2857+
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
2858+
approval ? "awaitingApproval" : "owedChecks"
2859+
],
2860+
approval ? [runUrl] : ["test"],
2861+
);
2862+
// The fresh reactor reloads the nonempty obligation from the persisted watch.
2863+
const restarted = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
2864+
yield* restarted.sweep;
2865+
yield* worker.drain();
2866+
assert.deepEqual(yield* summaries, [firstSummary]);
28692867

2870-
// A new watch on the same pull request knows what the last one told.
2871-
yield* watch(false, "stop");
2872-
yield* watch(true, "again");
2873-
yield* restarted.sweep;
2874-
yield* worker.drain();
2875-
assert.deepEqual(yield* summaries, [firstSummary]);
2868+
// A new watch on the same pull request knows what the last one told.
2869+
yield* watch(false, "stop");
2870+
yield* watch(true, "again");
2871+
yield* restarted.sweep;
2872+
yield* worker.drain();
2873+
assert.deepEqual(yield* summaries, [firstSummary]);
28762874

2877-
assert.deepEqual(
2878-
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
2879-
approval ? "awaitingApproval" : "owedChecks"
2880-
],
2881-
approval ? [runUrl] : ["test"],
2882-
);
2883-
remainingStatus = "success";
2884-
yield* TestClock.adjust("10 minutes");
2885-
yield* restarted.sweep;
2886-
yield* worker.drain();
2887-
assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
2888-
yield* TestClock.adjust("10 minutes");
2889-
yield* restarted.sweep;
2890-
yield* worker.drain();
2891-
assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
2892-
assert.deepEqual(
2893-
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.owedChecks,
2894-
[],
2895-
);
2896-
yield* watch(false, "end");
2897-
}),
2875+
assert.deepEqual(
2876+
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.[
2877+
approval ? "awaitingApproval" : "owedChecks"
2878+
],
2879+
approval ? [runUrl] : ["test"],
2880+
);
2881+
remainingStatus = "success";
2882+
yield* TestClock.adjust("10 minutes");
2883+
yield* restarted.sweep;
2884+
yield* worker.drain();
2885+
assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
2886+
yield* TestClock.adjust("10 minutes");
2887+
yield* restarted.sweep;
2888+
yield* worker.drain();
2889+
assert.deepEqual(yield* summaries, [firstSummary, "#12: checks passed"]);
2890+
assert.deepEqual(
2891+
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch?.owedChecks,
2892+
[],
2893+
);
2894+
yield* watch(false, "end");
2895+
}),
28982896
);
28992897

29002898
// regression: #21155 watching a pull request again repeated news the thread already got

0 commit comments

Comments
 (0)