Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ThreadPullRequestReactor.test.ts

685 lines25.0 KB

1import {
2 CheckpointRef,
3 EventId,
4 GitManagerError,
5 ProjectId,
6 ProviderInstanceId,
7 ThreadId,
8 TurnId,
9 type OrchestrationCommand,
10 type OrchestrationEvent,
11 type OrchestrationProjectShell,
12 type OrchestrationShellSnapshot,
13 type OrchestrationThreadShell,
14 type PullRequestRef,
15 type PullRequestSummary,
16 type ThreadLinkedPullRequest,
17} from "@t3tools/contracts";
18import { describe, expect, it } from "@effect/vitest";
19import * as Crypto from "effect/Crypto";
20import * as Deferred from "effect/Deferred";
21import * as Effect from "effect/Effect";
22import * as FileSystem from "effect/FileSystem";
23import * as Layer from "effect/Layer";
24import * as PubSub from "effect/PubSub";
25import * as Queue from "effect/Queue";
26import * as Ref from "effect/Ref";
27import * as Stream from "effect/Stream";
28import { TestClock } from "effect/testing";
29​
30import { GitManager, type GitBranchPullRequest } from "../git/GitManager.ts";
31import { PullRequestService } from "../pullRequest/PullRequestService.ts";
32import { RepositoryIdentityResolver } from "../project/RepositoryIdentityResolver.ts";
33import { ServerActivation } from "../serverActivation.ts";
34import { OrchestrationEngineService } from "./Services/OrchestrationEngine.ts";
35import { ProjectionSnapshotQuery } from "./Services/ProjectionSnapshotQuery.ts";
36import * as ThreadPullRequestReactor from "./ThreadPullRequestReactor.ts";
37​
38const NOW = "2026-09-01T12:00:00.000Z";
39const PROJECT_ID = ProjectId.make("project");
40const REPOSITORY = "owner/repository";
41const REPOSITORY_KEY = `github.com/${REPOSITORY}`;
42type SyncCommand = Extract<OrchestrationCommand, { type: "thread.pull-request.sync" }>;
43​
44function reference(number: number): ThreadLinkedPullRequest {
45 return {
46 projectId: PROJECT_ID,
47 repository: REPOSITORY,
48 number,
49 url: `https://github.com/${REPOSITORY}/pull/${number}`,
50 };
52​
53function branchPullRequest(
54 number = 42,
55 state: GitBranchPullRequest["state"] = "open",
56): GitBranchPullRequest {
57 return {
58 ...reference(number),
59 title: "Branch pull request",
60 baseRef: "main",
61 headRef: "feature",
62 state,
63 updatedAt: NOW,
64 repositoryKey: REPOSITORY_KEY,
65 };
67​
68function summary(input: PullRequestRef, state: PullRequestSummary["state"]): PullRequestSummary {
69 return {
70 ...input,
71 provider: "github",
72 title: "Pull request",
73 url: reference(input.number).url,
74 state,
75 headBranch: "feature",
76 baseBranch: "main",
77 updatedAt: NOW,
78 };
80​
81function thread(
82 id: string,
83 overrides: Partial<OrchestrationThreadShell> = {},
84): OrchestrationThreadShell {
85 return {
86 id: ThreadId.make(id),
87 projectId: PROJECT_ID,
88 title: id,
89 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
90 runtimeMode: "full-access",
91 interactionMode: "default",
92 pullRequests: [],
93 branch: "feature",
94 worktreePath: null,
95 latestTurn: null,
96 createdAt: NOW,
97 updatedAt: NOW,
98 archivedAt: null,
99 settledOverride: null,
100 settledAt: null,
101 session: null,
102 latestUserMessageAt: NOW,
103 hasPendingApprovals: false,
104 hasPendingUserInput: false,
105 hasActionableProposedPlan: false,
106 ...overrides,
107 };
109​
110const project = {
111 id: PROJECT_ID,
112 title: "Project",
113 workspaceRoot: "/workspace/project",
114 repositoryIdentity: {
115 canonicalKey: REPOSITORY_KEY,
116 displayName: REPOSITORY,
117 rootPath: "/workspace/project",
118 locator: {
119 source: "git-remote",
120 remoteName: "origin",
121 remoteUrl: `git@github.com:${REPOSITORY}.git`,
122 },
123 },
124 defaultModelSelection: null,
125 scripts: [],
126 createdAt: NOW,
127 updatedAt: NOW,
128} satisfies OrchestrationProjectShell;
129​
130const makeHarness = Effect.fn("makeThreadPullRequestHarness")(function* (options: {
131 readonly threads: ReadonlyArray<OrchestrationThreadShell>;
132 readonly branchPullRequest?: GitManager["Service"]["branchPullRequest"];
133 readonly branchSupersededPullRequest?: GitManager["Service"]["branchSupersededPullRequest"];
134 readonly summary?: PullRequestService["Service"]["summary"];
135 readonly existingWorktrees?: ReadonlyArray<string>;
136 readonly project?: OrchestrationProjectShell;
137 readonly resolveRepositoryIdentity?: RepositoryIdentityResolver["Service"]["resolve"];
138}) {
139 const activation = yield* Deferred.make<void>();
140 const snapshots = yield* Ref.make<OrchestrationShellSnapshot>({
141 snapshotSequence: 1,
142 projects: [options.project ?? project],
143 threads: options.threads,
144 updatedAt: NOW,
145 });
146 const reads = yield* Queue.unbounded<void>();
147 const events = yield* PubSub.unbounded<OrchestrationEvent>();
148 const commands = yield* Ref.make<ReadonlyArray<SyncCommand>>([]);
149 const branchCalls = yield* Ref.make<
150 ReadonlyArray<{ readonly cwd: string; readonly branch: string; readonly refresh: boolean }>
151 >([]);
152 const summaryCalls = yield* Ref.make<ReadonlyArray<PullRequestRef>>([]);
153 let uuid = 0;
154 const dependencies = Layer.mergeAll(
155 Layer.mock(ProjectionSnapshotQuery)({
156 getShellSnapshot: () =>
157 Ref.get(snapshots).pipe(Effect.tap(() => Queue.offer(reads, undefined))),
158 }),
159 Layer.mock(GitManager)({
160 branchPullRequest: (input, readOptions) =>
161 Ref.update(branchCalls, (calls) => [
162 ...calls,
163 { ...input, refresh: readOptions?.refresh === true },
164 ]).pipe(
165 Effect.andThen(options.branchPullRequest?.(input, readOptions) ?? Effect.succeed(null)),
166 ),
167 branchSupersededPullRequest: (input) =>
168 options.branchSupersededPullRequest?.(input) ?? Effect.succeed(false),
169 }),
170 Layer.mock(PullRequestService)({
171 summary: (input, readOptions) =>
172 Ref.update(summaryCalls, (calls) => [...calls, input]).pipe(
173 Effect.andThen(
174 options.summary?.(input, readOptions) ?? Effect.succeed(summary(input, "open")),
175 ),
176 ),
177 }),
178 Layer.mock(RepositoryIdentityResolver)({
179 resolve:
180 options.resolveRepositoryIdentity ??
181 (() => Effect.succeed(options.project?.repositoryIdentity ?? project.repositoryIdentity)),
182 }),
183 Layer.mock(OrchestrationEngineService)({
184 subscribeDomainEvents: PubSub.subscribe(events).pipe(
185 Effect.map((subscription) => Stream.fromSubscription(subscription)),
186 ),
187 dispatch: (command) => {
188 if (command.type !== "thread.pull-request.sync") {
189 return Effect.die(`Unexpected command: ${command.type}`);
190 }
191 return Ref.update(commands, (current) => [...current, command]).pipe(
192 Effect.andThen(
193 Ref.updateAndGet(snapshots, (snapshot) => ({
194 ...snapshot,
195 snapshotSequence: snapshot.snapshotSequence + 1,
196 threads: snapshot.threads.map((current) =>
197 current.id === command.threadId
198 ? {
199 ...current,
200 branchPullRequest: command.branchPullRequest,
201 ...(command.linkedPullRequest !== undefined
202 ? { linkedPullRequest: command.linkedPullRequest }
203 : {}),
204 }
205 : current,
206 ),
207 })),
208 ),
209 Effect.map((snapshot) => ({ sequence: snapshot.snapshotSequence })),
210 );
211 },
212 }),
213 Layer.succeed(ServerActivation, Deferred.await(activation)),
214 Layer.succeed(
215 Crypto.Crypto,
216 Crypto.make({
217 randomBytes: (size) => new Uint8Array(size).fill(++uuid),
218 digest: (_algorithm, data) => Effect.succeed(data),
219 }),
220 ),
221 FileSystem.layerNoop({
222 exists: (path) => Effect.succeed(options.existingWorktrees?.includes(path) ?? false),
223 }),
224 );
225​
226 const start = Effect.fn("startThreadPullRequestHarness")(function* () {
227 const reactor = yield* ThreadPullRequestReactor.ThreadPullRequestReactor;
228 yield* reactor.start();
229 yield* Deferred.succeed(activation, undefined);
230 yield* Queue.take(reads);
231 yield* reactor.drain;
232 return reactor;
233 });
234​
235 return {
236 start,
237 reads,
238 snapshots,
239 commands,
240 branchCalls,
241 summaryCalls,
242 publish: (event: OrchestrationEvent) => PubSub.publish(events, event),
243 layer: ThreadPullRequestReactor.layer.pipe(Layer.provide(dependencies)),
244 };
245});
246​
247describe("ThreadPullRequestReactor", () => {
248 it.effect("discovers saved branch PRs without a client and shares branch lookups", () =>
249 Effect.scoped(
250 Effect.gen(function* () {
251 const fixture = yield* makeHarness({
252 threads: [
253 thread("first"),
254 thread("second"),
255 thread("archived", { archivedAt: NOW }),
256 thread("no-branch", { branch: null }),
257 ],
258 branchPullRequest: () => Effect.succeed(branchPullRequest()),
259 });
260 yield* Effect.gen(function* () {
261 const reactor = yield* fixture.start();
262 expect(yield* Ref.get(fixture.branchCalls)).toEqual([
263 { cwd: project.workspaceRoot, branch: "feature", refresh: false },
264 { cwd: project.workspaceRoot, branch: "feature", refresh: false },
265 ]);
266 expect((yield* Ref.get(fixture.commands)).map((command) => command.threadId)).toEqual([
267 "first",
268 "second",
269 ]);
270 expect((yield* Ref.get(fixture.snapshots)).threads[0]?.branchPullRequest).toEqual(
271 reference(42),
272 );
273​
274 yield* TestClock.adjust("1 minute");
275 yield* Queue.take(fixture.reads);
276 yield* reactor.drain;
277 expect(yield* Ref.get(fixture.commands)).toHaveLength(2);
278 }).pipe(Effect.provide(fixture.layer));
279 }),
280 ),
281 );
282​
283 it.effect("replaces terminal manual links but preserves open links and explicit unlink", () =>
284 Effect.scoped(
285 Effect.gen(function* () {
286 const fixture = yield* makeHarness({
287 threads: [
288 thread("merged", { linkedPullRequest: reference(1) }),
289 thread("closed", { linkedPullRequest: reference(2) }),
290 thread("open", { linkedPullRequest: reference(3) }),
291 thread("unlinked", { linkedPullRequest: null }),
292 ],
293 branchPullRequest: () => Effect.succeed(branchPullRequest()),
294 summary: (input) =>
295 Effect.succeed(
296 summary(
297 input,
298 input.number === 1 ? "merged" : input.number === 2 ? "closed" : "open",
299 ),
300 ),
301 });
302 yield* Effect.gen(function* () {
303 yield* fixture.start();
304 const snapshot = yield* Ref.get(fixture.snapshots);
305 expect(snapshot.threads.map((current) => current.linkedPullRequest)).toEqual([
306 reference(42),
307 reference(42),
308 reference(3),
309 null,
310 ]);
311 expect(
312 snapshot.threads.every((current) => current.branchPullRequest?.number === 42),
313 ).toBe(true);
314 }).pipe(Effect.provide(fixture.layer));
315 }),
316 ),
317 );
318​
319 it.effect.each(["session-first", "checkpoint-first"] as const)(
320 "refreshes discovery once after a turn ends with %s event ordering",
321 (order) =>
322 Effect.scoped(
323 Effect.gen(function* () {
324 const current = thread("turn-thread");
325 const detected = yield* Ref.make<GitBranchPullRequest | null>(null);
326 const fixture = yield* makeHarness({
327 threads: [current],
328 branchPullRequest: (_input, options) =>
329 options?.refresh
330 ? Ref.set(detected, branchPullRequest()).pipe(Effect.andThen(Ref.get(detected)))
331 : Ref.get(detected),
332 });
333 yield* Effect.gen(function* () {
334 const reactor = yield* fixture.start();
335 expect(yield* Ref.get(fixture.commands)).toHaveLength(0);
336 const sessionEvent: OrchestrationEvent = {
337 type: "thread.session-set",
338 sequence: 2,
339 eventId: EventId.make("turn-finished"),
340 aggregateKind: "thread",
341 aggregateId: current.id,
342 occurredAt: NOW,
343 commandId: null,
344 causationEventId: null,
345 correlationId: null,
346 metadata: {},
347 payload: {
348 threadId: current.id,
349 session: {
350 threadId: current.id,
351 status: "ready",
352 providerName: "Codex",
353 runtimeMode: "full-access",
354 activeTurnId: null,
355 lastError: null,
356 updatedAt: NOW,
357 },
358 },
359 };
360 const checkpointEvent: OrchestrationEvent = {
361 ...sessionEvent,
362 type: "thread.turn-diff-completed",
363 sequence: 3,
364 eventId: EventId.make("checkpoint-finished"),
365 payload: {
366 threadId: current.id,
367 turnId: TurnId.make("turn"),
368 checkpointTurnCount: 1,
369 checkpointRef: CheckpointRef.make("checkpoint"),
370 status: "ready",
371 files: [],
372 assistantMessageId: null,
373 completedAt: NOW,
374 },
375 };
376 const events =
377 order === "session-first"
378 ? [sessionEvent, checkpointEvent]
379 : [checkpointEvent, sessionEvent];
380 for (const event of events) {
381 yield* fixture.publish(event);
382 yield* Queue.take(fixture.reads);
383 yield* reactor.drain;
384 }
385 expect((yield* Ref.get(fixture.commands))[0]?.branchPullRequest).toEqual(reference(42));
386 expect(
387 (yield* Ref.get(fixture.branchCalls)).filter((call) => call.refresh),
388 ).toHaveLength(1);
389 }).pipe(Effect.provide(fixture.layer));
390 }),
391 ),
392 );
393​
394 it.effect("uses live worktrees and falls back to the project for removed worktrees", () =>
395 Effect.scoped(
396 Effect.gen(function* () {
397 const fixture = yield* makeHarness({
398 threads: [
399 thread("live", { worktreePath: "/workspace/worktree" }),
400 thread("removed", { worktreePath: "/workspace/removed" }),
401 ],
402 existingWorktrees: ["/workspace/worktree"],
403 branchPullRequest: () => Effect.succeed(branchPullRequest()),
404 });
405 yield* Effect.gen(function* () {
406 yield* fixture.start();
407 expect(new Set((yield* Ref.get(fixture.branchCalls)).map((call) => call.cwd))).toEqual(
408 new Set(["/workspace/project", "/workspace/worktree"]),
409 );
410 }).pipe(Effect.provide(fixture.layer));
411 }),
412 ),
413 );
414​
415 it.effect("retains only terminal PRs on shared checkouts and clears a removed branch", () =>
416 Effect.scoped(
417 Effect.gen(function* () {
418 const fixture = yield* makeHarness({
419 threads: [
420 thread("terminal", { branch: "main", branchPullRequest: reference(1) }),
421 thread("open", { branchPullRequest: reference(2) }),
422 thread("worktree", {
423 worktreePath: "/workspace/worktree",
424 branchPullRequest: reference(1),
425 }),
426 thread("cleared", {
427 branch: null,
428 branchPullRequest: reference(1),
429 linkedPullRequest: reference(3),
430 }),
431 ],
432 summary: (input) =>
433 Effect.succeed(summary(input, input.number === 1 ? "merged" : "open")),
434 });
435 yield* Effect.gen(function* () {
436 yield* fixture.start();
437 const snapshot = yield* Ref.get(fixture.snapshots);
438 expect(snapshot.threads.map((current) => current.branchPullRequest)).toEqual([
439 reference(1),
440 null,
441 null,
442 null,
443 ]);
444 expect(snapshot.threads[3]?.linkedPullRequest).toEqual(reference(3));
445 }).pipe(Effect.provide(fixture.layer));
446 }),
447 ),
448 );
449​
450 it.effect("clears a saved reference the branch outgrew and keeps the rest of its history", () =>
451 Effect.scoped(
452 Effect.gen(function* () {
453 const fixture = yield* makeHarness({
454 threads: [
455 // Created after the release merged, while `develop` still sat on
456 // that change request's head, so discovery attached it. The first
457 // turn then advanced the branch, and the lookup now rejects the
458 // match — restoring it here is what left the stale badge behind.
459 thread("outgrown", { branch: "develop", branchPullRequest: reference(3) }),
460 // Same shared checkout, but this reference is not the one the
461 // branch outgrew, so its historical badge still stands.
462 thread("historical", { branch: "develop", branchPullRequest: reference(9) }),
463 // An explicit link survives regardless of what the branch did.
464 thread("linked", {
465 branch: "develop",
466 branchPullRequest: reference(3),
467 linkedPullRequest: reference(7),
468 }),
469 ],
470 branchPullRequest: () => Effect.succeed(null),
471 branchSupersededPullRequest: ({ pullRequest }) =>
472 Effect.succeed(pullRequest.number === 3),
473 summary: (input) => Effect.succeed(summary(input, "merged")),
474 });
475 yield* Effect.gen(function* () {
476 yield* fixture.start();
477 const snapshot = yield* Ref.get(fixture.snapshots);
478 expect(snapshot.threads.map((current) => current.branchPullRequest)).toEqual([
479 null,
480 reference(9),
481 null,
482 ]);
483 expect(snapshot.threads[2]?.linkedPullRequest).toEqual(reference(7));
484 }).pipe(Effect.provide(fixture.layer));
485 }),
486 ),
487 );
488​
489 it.effect("keeps saved links on lookup failures and rejects a different repository", () =>
490 Effect.scoped(
491 Effect.gen(function* () {
492 const fixture = yield* makeHarness({
493 threads: [
494 thread("failed", { branch: "failed", branchPullRequest: reference(1) }),
495 thread("wrong-repository", {
496 branch: "wrong-repository",
497 branchPullRequest: reference(2),
498 }),
499 thread("healthy"),
500 ],
501 branchPullRequest: ({ cwd, branch }) =>
502 branch === "failed"
503 ? Effect.fail(
504 new GitManagerError({
505 operation: "branchPullRequest",
506 cwd,
507 detail: "Lookup failed",
508 }),
509 )
510 : Effect.succeed({
511 ...branchPullRequest(),
512 repositoryKey:
513 branch === "wrong-repository" ? "github.com/other/repository" : REPOSITORY_KEY,
514 }),
515 });
516 yield* Effect.gen(function* () {
517 yield* fixture.start();
518 expect(
519 (yield* Ref.get(fixture.snapshots)).threads.map((current) => current.branchPullRequest),
520 ).toEqual([reference(1), reference(2), reference(42)]);
521 expect(yield* Ref.get(fixture.commands)).toHaveLength(1);
522 }).pipe(Effect.provide(fixture.layer));
523 }),
524 ),
525 );
526​
527 it.effect.each(["settled", null] as const)(
528 "retries settled backfills and stops after success with settledOverride %s",
529 (settledOverride) =>
530 Effect.scoped(
531 Effect.gen(function* () {
532 const online = yield* Ref.make(false);
533 const fixture = yield* makeHarness({
534 threads: [
535 thread("backfill", { settledOverride, settledAt: NOW }),
536 thread("known", {
537 branch: "known",
538 settledOverride,
539 settledAt: NOW,
540 branchPullRequest: reference(1),
541 }),
542 ],
543 branchPullRequest: ({ cwd }) =>
544 Ref.get(online).pipe(
545 Effect.flatMap((connected) =>
546 connected
547 ? Effect.succeed(branchPullRequest(42, "merged"))
548 : Effect.fail(
549 new GitManagerError({
550 operation: "branchPullRequest",
551 cwd,
552 detail: "Offline",
553 }),
554 ),
555 ),
556 ),
557 });
558 yield* Effect.gen(function* () {
559 const reactor = yield* fixture.start();
560 expect(yield* Ref.get(fixture.commands)).toHaveLength(0);
561 yield* Ref.set(online, true);
562 yield* TestClock.adjust("1 minute");
563 yield* Queue.take(fixture.reads);
564 yield* reactor.drain;
565 expect((yield* Ref.get(fixture.commands))[0]?.threadId).toBe("backfill");
566 yield* TestClock.adjust("1 minute");
567 yield* Queue.take(fixture.reads);
568 yield* reactor.drain;
569 expect((yield* Ref.get(fixture.branchCalls)).map((call) => call.branch)).toEqual([
570 "feature",
571 "feature",
572 "feature",
573 ]);
574 }).pipe(Effect.provide(fixture.layer));
575 }),
576 ),
577 );
578​
579 it.effect("stops retrying a settled backfill after repeated lookup failures", () =>
580 Effect.scoped(
581 Effect.gen(function* () {
582 const fixture = yield* makeHarness({
583 threads: [thread("backfill", { settledOverride: "settled", settledAt: NOW })],
584 branchPullRequest: ({ cwd }) =>
585 Effect.fail(
586 new GitManagerError({ operation: "branchPullRequest", cwd, detail: "No gh" }),
587 ),
588 });
589 yield* Effect.gen(function* () {
590 const reactor = yield* fixture.start();
591 for (
592 let attempt = 1;
593 attempt < ThreadPullRequestReactor.BACKFILL_ATTEMPTS + 2;
594 attempt++
595 ) {
596 yield* TestClock.adjust("1 minute");
597 yield* Queue.take(fixture.reads);
598 yield* reactor.drain;
599 }
600 expect(yield* Ref.get(fixture.branchCalls)).toHaveLength(
601 ThreadPullRequestReactor.BACKFILL_ATTEMPTS,
602 );
603 expect(yield* Ref.get(fixture.commands)).toHaveLength(0);
604 }).pipe(Effect.provide(fixture.layer));
605 }),
606 ),
607 );
608​
609 it.effect("matches Azure SSH projects to HTTPS PRs with the provider repository selector", () =>
610 Effect.scoped(
611 Effect.gen(function* () {
612 const fixture = yield* makeHarness({
613 threads: [thread("azure")],
614 project: {
615 ...project,
616 repositoryIdentity: {
617 canonicalKey: "ssh.dev.azure.com/v3/org/project/repository",
618 displayName: "v3/org/project/repository",
619 name: "repository",
620 provider: "azure-devops",
621 rootPath: project.workspaceRoot,
622 locator: {
623 source: "git-remote",
624 remoteName: "origin",
625 remoteUrl: "git@ssh.dev.azure.com:v3/org/project/repository",
626 },
627 },
628 },
629 branchPullRequest: () =>
630 Effect.succeed({
631 ...branchPullRequest(),
632 repositoryKey: "dev.azure.com/org/project/_git/repository",
633 url: "https://dev.azure.com/org/project/_git/repository/pullrequest/42",
634 }),
635 });
636 yield* Effect.gen(function* () {
637 yield* fixture.start();
638 expect((yield* Ref.get(fixture.commands))[0]?.branchPullRequest).toEqual({
639 projectId: PROJECT_ID,
640 repository: "repository",
641 number: 42,
642 url: "https://dev.azure.com/org/project/_git/repository/pullrequest/42",
643 });
644 }).pipe(Effect.provide(fixture.layer));
645 }),
646 ),
647 );
648​
649 it.effect.each(["primary", "branch"] as const)(
650 "rejects the group's links if the %s remote changes during a summary read",
651 (changedRemote) =>
652 Effect.scoped(
653 Effect.gen(function* () {
654 const identity = yield* Ref.make(project.repositoryIdentity);
655 const detected = yield* Ref.make(branchPullRequest());
656 const fixture = yield* makeHarness({
657 threads: [thread("manual", { linkedPullRequest: reference(1) }), thread("automatic")],
658 branchPullRequest: () => Ref.get(detected),
659 resolveRepositoryIdentity: (_cwd, options) =>
660 options?.refresh ? Ref.get(identity) : Effect.succeed(project.repositoryIdentity),
661 summary: (input) =>
662 (changedRemote === "primary"
663 ? Ref.set(identity, {
664 ...project.repositoryIdentity,
665 canonicalKey: "github.com/other/repository",
666 displayName: "other/repository",
667 })
668 : Ref.set(detected, {
669 ...branchPullRequest(99),
670 repositoryKey: "github.com/other/repository",
671 url: "https://github.com/other/repository/pull/99",
672 })
673 ).pipe(Effect.as(summary(input, "merged"))),
674 });
675 yield* Effect.gen(function* () {
676 yield* fixture.start();
677 expect(yield* Ref.get(fixture.commands)).toEqual([]);
678 expect((yield* Ref.get(fixture.snapshots)).threads[0]?.linkedPullRequest).toEqual(
679 reference(1),
680 );
681 }).pipe(Effect.provide(fixture.layer));
682 }),
683 ),
684 );
685});