Skip to content

Commit 52e41a6

Browse files
committed
test(server): verify merge queue removal wakes persist
1 parent 8340738 commit 52e41a6

2 files changed

Lines changed: 118 additions & 0 deletions

File tree

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

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3296,6 +3296,103 @@ it.layer(layerTest)("OrchestrationV2LayerLive lifecycle", (it) => {
32963296
}),
32973297
);
32983298

3299+
it.effect("persists each merge queue removal wake across reactor restarts", () =>
3300+
Effect.gen(function* () {
3301+
const orchestrator = yield* Orchestrator.OrchestratorV2;
3302+
const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
3303+
const threadId = ThreadId.make("queue-removal-watch");
3304+
const projectId = ProjectId.make("queue-removal-project");
3305+
yield* seedProject({
3306+
projectId,
3307+
title: "Queue removal",
3308+
workspaceRoot: "/workspace/watch",
3309+
defaultModelSelection: null,
3310+
createdAt: "2026-10-01T00:00:00.000Z",
3311+
});
3312+
yield* orchestrator.dispatch({
3313+
type: "thread.create",
3314+
createdBy: "user",
3315+
creationSource: "web",
3316+
commandId: CommandId.make("queue-removal-create"),
3317+
threadId,
3318+
projectId,
3319+
title: "Queue removal",
3320+
modelSelection,
3321+
runtimeMode: "full-access",
3322+
interactionMode: "default",
3323+
branch: null,
3324+
worktreePath: null,
3325+
});
3326+
yield* orchestrator.dispatch({
3327+
type: "thread.pull-request.watch",
3328+
commandId: CommandId.make("queue-removal-start"),
3329+
threadId,
3330+
host: "github.com",
3331+
repository: "pingdotgg/t3code",
3332+
number: 7,
3333+
watching: true,
3334+
link: { url: "https://github.com/pingdotgg/t3code/pull/7", source: "agent" },
3335+
});
3336+
let removal: PullRequestDetail["mergeQueueRemoval"];
3337+
const host = Layer.mergeAll(
3338+
NodeServices.layer,
3339+
Layer.mock(PullRequestService.PullRequestService)({
3340+
watchFingerprint: () =>
3341+
Effect.succeed({ status: removal?.id ?? "green", remarks: "none" }),
3342+
invalidate: () => Effect.void,
3343+
detail: () =>
3344+
Effect.succeed({
3345+
...watchedPullRequestDetail({ projectId, number: 7, at: "2026-10-02T12:00:00.000Z" }),
3346+
checks: [{ name: "lint", status: "success", description: null, url: null }],
3347+
...(removal === undefined ? {} : { mergeQueueRemoval: removal }),
3348+
}),
3349+
activity: () =>
3350+
Effect.succeed({
3351+
comments: [],
3352+
commentCount: 0,
3353+
commentsTruncated: false,
3354+
reviewThreads: [],
3355+
commits: [],
3356+
}),
3357+
}),
3358+
);
3359+
const reactor = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
3360+
yield* reactor.sweep;
3361+
yield* worker.drain();
3362+
removal = {
3363+
id: "first",
3364+
removedAt: "2999-01-01T00:00:00Z",
3365+
reason: "Required checks failed",
3366+
};
3367+
yield* reactor.sweep;
3368+
yield* worker.drain();
3369+
const persisted = (yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch;
3370+
assert.equal(persisted?.mergeQueueRemovalId, "first");
3371+
const restarted = yield* PullRequestWatchReactor.make.pipe(Effect.provide(host));
3372+
yield* restarted.sweep;
3373+
yield* worker.drain();
3374+
removal = { ...removal, id: "second" };
3375+
yield* restarted.sweep;
3376+
yield* worker.drain();
3377+
yield* restarted.sweep;
3378+
yield* worker.drain();
3379+
const { messages } = yield* orchestrator.getThreadRecords(threadId, ["messages"]);
3380+
const removals = messages.filter(
3381+
(message) => message.notification?.summary === "#7: removed from merge queue",
3382+
);
3383+
assert.lengthOf(removals, 2);
3384+
for (const message of removals) {
3385+
assert.equal(message.notification?.outcome, "failed");
3386+
assert.include(message.text, "Required checks failed");
3387+
}
3388+
assert.equal(
3389+
(yield* orchestrator.getThreadShell(threadId))?.pullRequests?.[0]?.watch
3390+
?.mergeQueueRemovalId,
3391+
"second",
3392+
);
3393+
}),
3394+
);
3395+
32993396
it.effect.each([
33003397
"single page",
33013398
"paginated",

‎apps/server/src/pullRequest/PullRequestService.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,27 @@ it.effect(
27642764
}),
27652765
);
27662766

2767+
it.effect("preserves merge queue removal details from the provider", () =>
2768+
Effect.gen(function* () {
2769+
const removal = { id: "RMQE_1", removedAt: "2026-07-02T00:00:00Z", reason: "CI failed" };
2770+
const service = yield* makeService({
2771+
projects: [project({ id: "p1", title: "web", workspaceRoot: "/a", repository: "acme/web" })],
2772+
providers: [
2773+
fakePullRequestProvider(SourceControlProviderKind.make("github"), {
2774+
getChangeRequest: () =>
2775+
Effect.succeed({ ...hostedChangeRequest("body"), mergeQueueRemoval: removal }),
2776+
}),
2777+
],
2778+
});
2779+
const detail = yield* service.detail({
2780+
projectId: "p1" as ProjectId,
2781+
repository: "acme/web",
2782+
number: 1,
2783+
});
2784+
assert.deepStrictEqual(detail.mergeQueueRemoval, removal);
2785+
}),
2786+
);
2787+
27672788
it.effect("notifies linked threads when detail changes draft status in either direction", () =>
27682789
Effect.gen(function* () {
27692790
let isDraft = true;

0 commit comments

Comments
 (0)