Open History to see the last commit
1import {
2 EnvironmentId,
3 ProjectId,
4 ProviderInstanceId,
5 ThreadId,
6 type OrchestrationV2ServerCommand as OrchestrationCommand,
7 PullRequestOperationError,
8 type OrchestrationProjectShell,
9 type PullRequestRef,
10 type PullRequestReviewGuideResult,
11 type ThreadPullRequestLink,
12 SourceControlProviderKind,
13} from "@t3tools/contracts";
14import { describe, expect, it } from "@effect/vitest";
15import * as Crypto from "effect/Crypto";
16import * as Effect from "effect/Effect";
17import * as Layer from "effect/Layer";
18import * as Option from "effect/Option";
19import * as Ref from "effect/Ref";
20import * as Stream from "effect/Stream";
21import type { Tool } from "effect/ai";
22
23import * as Orchestrator from "../../../orchestration-v2/Orchestrator.ts";
24import {
25 type PullRequestTestThread,
26 v2PullRequestThread,
27} from "../../../orchestration-v2/testkit/pullRequestFixtures.ts";
28import * as ProjectService from "../../../project/ProjectService.ts";
29import * as PullRequestReviewGuideService from "../../../pullRequest/PullRequestReviewGuideService.ts";
30import * as McpInvocationContext from "../../McpInvocationContext.ts";
31import * as McpToolAccess from "../../McpToolAccess.ts";
32import * as McpToolAccessTestkit from "../../McpToolAccess.testkit.ts";
33import { listThreadPullRequests } from "./handlers.ts";
34import * as PullRequestsHandlers from "./handlers.ts";
35import { PullRequestsToolkit } from "./tools.ts";
36
37const PROJECT_ID = ProjectId.make("project-1");
38const THREAD_ID = ThreadId.make("thread-1");
39
40const testCrypto = Crypto.make({
41 randomBytes: (size) => new Uint8Array(size).fill(7),
42 digest: (_algorithm, data) => Effect.succeed(data),
43});
44
45const invocation = (
46 capabilities: ReadonlyArray<McpInvocationContext.McpCapability>,
47): McpInvocationContext.McpInvocationScope => ({
48 environmentId: EnvironmentId.make("environment-1"),
49 requestNamespace: "provider-session-1",
50 thread: {
51 threadId: THREAD_ID,
52 providerSessionId: "provider-session-1",
53 providerInstanceId: ProviderInstanceId.make("codex"),
54 },
55 client: undefined,
56 capabilities: new Set(capabilities),
57 issuedAt: 1,
58});
59
60function makeProject(
61 repositoryIdentity: OrchestrationProjectShell["repositoryIdentity"] = {
62 canonicalKey: "github.com/t3tools/t3code",
63 locator: {
64 source: "git-remote",
65 remoteName: "origin",
66 remoteUrl: "git@github.com:T3Tools/T3Code.git",
67 },
68 provider: SourceControlProviderKind.make("github"),
69 displayName: "T3Tools/T3Code",
70 owner: "T3Tools",
71 name: "T3Code",
72 },
73): OrchestrationProjectShell {
74 return {
75 id: PROJECT_ID,
76 title: "Project",
77 workspaceRoot: "/workspace/project",
78 defaultModelSelection: null,
79 scripts: [],
80 repositoryIdentity,
81 createdAt: "2026-08-01T00:00:00.000Z",
82 updatedAt: "2026-08-01T00:00:00.000Z",
83 };
84}
85
86function makeThread(pullRequests: ReadonlyArray<ThreadPullRequestLink>): PullRequestTestThread {
87 return {
88 id: THREAD_ID,
89 projectId: PROJECT_ID,
90 title: "Thread",
91 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
92 runtimeMode: "full-access",
93 interactionMode: "default",
94 branch: null,
95 worktreePath: null,
96 pullRequests,
97 createdAt: "2026-08-01T00:00:00.000Z",
98 updatedAt: "2026-08-20T00:00:00.000Z",
99 archivedAt: null,
100 settledOverride: null,
101 settledAt: null,
102 latestUserMessageAt: "2026-08-20T00:00:00.000Z",
103 };
104}
105
106function makeLink(
107 number: number,
108 overrides: Partial<ThreadPullRequestLink> & {
109 readonly headBranch?: string;
110 readonly baseBranch?: string;
111 } = {},
112): ThreadPullRequestLink {
113 const { headBranch, baseBranch, ...rest } = overrides;
114 return {
115 host: "github.com",
116 repository: "t3tools/t3code",
117 number,
118 url: `https://github.com/t3tools/t3code/pull/${number}`,
119 source: "manual",
120 linkedAt: "2026-08-10T00:00:00.000Z",
121 snapshot:
122 headBranch === undefined
123 ? null
124 : {
125 state: "open",
126 title: `PR ${number}`,
127 headBranch,
128 baseBranch: baseBranch ?? "main",
129 isDraft: false,
130 updatedAt: null,
131 syncedAt: "2026-08-27T00:00:00.000Z",
132 },
133 stack: null,
134 ...rest,
135 };
136}
137
138interface HarnessOptions {
139 readonly thread?: PullRequestTestThread | null;
140 readonly project?: OrchestrationProjectShell | null;
141 readonly reject?: (command: OrchestrationCommand) => string | null;
142 readonly projects?: ReadonlyArray<OrchestrationProjectShell>;
143 readonly generate?: (
144 input: PullRequestRef,
145 ) => Effect.Effect<
146 PullRequestReviewGuideResult & { started: boolean },
147 PullRequestOperationError
148 >;
149}
150
151const NO_GUIDE: PullRequestReviewGuideResult = { guide: null, run: null, currentHeadSha: "head-1" };
152
153const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
154 options: HarnessOptions = {},
155) {
156 const commands = yield* Ref.make<ReadonlyArray<OrchestrationCommand>>([]);
157 const guideRequests = yield* Ref.make<ReadonlyArray<PullRequestRef>>([]);
158 const thread = options.thread === undefined ? makeThread([]) : options.thread;
159 const project = options.project === undefined ? makeProject() : options.project;
160 const dispatch: Orchestrator.OrchestratorV2Shape["dispatch"] = (command) =>
161 Effect.gen(function* () {
162 const rejection = options.reject?.(command) ?? null;
163 if (rejection !== null)
164 return yield* new Orchestrator.OrchestratorDispatchError({
165 commandId: command.commandId,
166 commandType: command.type,
167 cause: rejection,
168 });
169 yield* Ref.update(commands, (recorded) => [...recorded, command]);
170 return { sequence: 1, storedEvents: [] };
171 });
172 const layerDependencies = Layer.mergeAll(
173 Layer.mock(ProjectService.ProjectService)({
174 getShell: () => Effect.succeed(Option.fromNullishOr(project)),
175 listShells: () => Effect.succeed(options.projects ?? (project ? [project] : [])),
176 }),
177 Layer.mock(PullRequestReviewGuideService.PullRequestReviewGuideService)({
178 get: () => Effect.succeed(NO_GUIDE),
179 generate: (input) =>
180 Ref.update(guideRequests, (recorded) => [...recorded, input]).pipe(
181 Effect.andThen(
182 options.generate?.(input) ??
183 Effect.succeed({
184 ...NO_GUIDE,
185 run: {
186 _tag: "Running" as const,
187 headSha: "head-1",
188 startedAt: "2026-10-11T00:00:00.000Z",
189 },
190 started: true,
191 }),
192 ),
193 ),
194 }),
195 Layer.mock(Orchestrator.OrchestratorV2)({
196 getThreadShell: (id) =>
197 Effect.succeed(id === THREAD_ID && thread ? v2PullRequestThread(thread) : null),
198 dispatch,
199 }),
200 Layer.succeed(Crypto.Crypto, testCrypto),
201 McpToolAccessTestkit.liveThreadsLayer,
202 );
203 const toolkit = yield* PullRequestsToolkit.pipe(
204 Effect.provide(
205 McpToolAccess.HandlersLayer.layer(PullRequestsHandlers.layer).pipe(
206 Layer.provide(layerDependencies),
207 ),
208 ),
209 );
210 const call = <Name extends keyof typeof PullRequestsToolkit.tools>(
211 name: Name,
212 params: Parameters<typeof toolkit.handle<Name>>[1],
213 capabilities: ReadonlyArray<McpInvocationContext.McpCapability> = ["pull-requests"],
214 ) =>
215 toolkit.handle(name, params).pipe(
216 Stream.unwrap,
217 Stream.runCollect,
218 Effect.map(
219 (chunk) => chunk.at(-1)!.result as Tool.Success<(typeof PullRequestsToolkit.tools)[Name]>,
220 ),
221 Effect.provideService(McpInvocationContext.McpInvocationContext, invocation(capabilities)),
222 Effect.provide(layerDependencies),
223 );
224 return { commands, guideRequests, call };
225});
226
227describe("pull request toolkit handlers", () => {
228 it.effect("refuses a credential without the pull-requests capability", () =>
229 Effect.gen(function* () {
230 const harness = yield* makeHarness();
231 const error = yield* harness
232 .call("list_thread_pull_requests", {}, ["preview"])
233 .pipe(Effect.flip);
234 expect(error).toMatchObject({
235 _tag: "McpCapabilityUnavailableError",
236 capability: "pull-requests",
237 threadId: THREAD_ID,
238 });
239 expect(yield* Ref.get(harness.commands)).toEqual([]);
240 }),
241 );
242
243 it.effect("links by URL with source agent on the token's thread", () =>
244 Effect.gen(function* () {
245 const harness = yield* makeHarness();
246 const result = yield* harness.call("link_pull_request", {
247 url: "https://github.com/T3Tools/T3Code/pull/123/files",
248 });
249 expect(result).toEqual({
250 host: "github.com",
251 repository: "t3tools/t3code",
252 number: 123,
253 url: "https://github.com/T3Tools/T3Code/pull/123/files",
254 alreadyLinked: false,
255 });
256 expect(yield* Ref.get(harness.commands)).toMatchObject([
257 {
258 type: "thread.pull-request.link",
259 threadId: THREAD_ID,
260 host: "github.com",
261 repository: "t3tools/t3code",
262 number: 123,
263 source: "agent",
264 },
265 ]);
266 }),
267 );
268
269 it.effect("watching an unlinked pull request links it first", () =>
270 Effect.gen(function* () {
271 const harness = yield* makeHarness();
272 const result = yield* harness.call("watch_pull_request", {
273 url: "https://github.com/t3tools/t3code/pull/9",
274 });
275 expect(result).toMatchObject({ number: 9, watching: false, wasWatching: false });
276 expect(yield* Ref.get(harness.commands)).toMatchObject([
277 {
278 type: "thread.pull-request.watch",
279 number: 9,
280 watching: true,
281 link: { url: "https://github.com/t3tools/t3code/pull/9", source: "agent" },
282 },
283 ]);
284 }),
285 );
286
287 it.effect("refuses to watch a merged pull request and stops an existing watch", () =>
288 Effect.gen(function* () {
289 const watch = {
290 startedAt: "2026-08-20T00:00:00.000Z",
291 headSha: null,
292 failedChecks: [],
293 passed: false,
294 passedChecks: [],
295 remarksThrough: "2026-08-20T00:00:00.000Z",
296 remarkIds: [],
297 conflicting: false,
298 wakes: 0,
299 };
300 const merged = makeLink(1, { headBranch: "done" });
301 const harness = yield* makeHarness({
302 thread: makeThread([
303 { ...merged, snapshot: merged.snapshot && { ...merged.snapshot, state: "merged" } },
304 makeLink(2, { headBranch: "idle" }),
305 makeLink(3, { headBranch: "watched", watch }),
306 ]),
307 });
308 const error = yield* harness
309 .call("watch_pull_request", { repository: "t3tools/t3code", number: 1 })
310 .pipe(Effect.flip);
311 expect(error).toMatchObject({ _tag: "PullRequestNotOpenError", state: "merged" });
312 expect(
313 yield* harness.call("unwatch_pull_request", { repository: "t3tools/t3code", number: 3 }),
314 ).toMatchObject({ wasWatching: true });
315 expect(yield* Ref.get(harness.commands)).toMatchObject([
316 { type: "thread.pull-request.watch", number: 3, watching: false },
317 ]);
318 }),
319 );
320
321 it.effect("watches a pull request saved as closed, since it may have reopened", () =>
322 Effect.gen(function* () {
323 const closed = makeLink(1, { headBranch: "closed" });
324 const harness = yield* makeHarness({
325 thread: makeThread([
326 { ...closed, snapshot: closed.snapshot && { ...closed.snapshot, state: "closed" } },
327 ]),
328 });
329 yield* harness.call("watch_pull_request", { repository: "t3tools/t3code", number: 1 });
330 expect(yield* Ref.get(harness.commands)).toMatchObject([
331 { type: "thread.pull-request.watch", number: 1, watching: true },
332 ]);
333 }),
334 );
335
336 it.effect("refuses a watch from a subagent thread, whose parent owns the pull request", () =>
337 Effect.gen(function* () {
338 const harness = yield* makeHarness({
339 thread: {
340 ...makeThread([makeLink(1, { headBranch: "feature" })]),
341 lineage: {
342 rootThreadId: ThreadId.make("parent"),
343 parentThreadId: ThreadId.make("parent"),
344 relationshipToParent: "subagent",
345 },
346 },
347 });
348 const error = yield* harness
349 .call("watch_pull_request", { repository: "t3tools/t3code", number: 1 })
350 .pipe(Effect.flip);
351 expect(error).toMatchObject({ _tag: "PullRequestWatchFromSubagentError" });
352 expect(yield* Ref.get(harness.commands)).toEqual([]);
353 }),
354 );
355
356 it.effect("canonicalizes GitCafe links independently of the thread's project host", () =>
357 Effect.gen(function* () {
358 for (const host of ["git.cafe", "staging.git.cafe"]) {
359 for (const project of [makeProject(), makeProject(null)]) {
360 for (const target of [
361 { host, repository: "PingDotGG/T3Code", number: 21353 },
362 { url: `https://${host}/PingDotGG/T3Code/pull/21353` },
363 { url: `https://${host}/PingDotGG/T3Code/pulls/21353` },
364 ]) {
365 const harness = yield* makeHarness({ project });
366 const result = yield* harness.call("link_pull_request", target);
367 const url = `https://${host}/pingdotgg/t3code/pulls/21353`;
368 expect(result).toMatchObject({
369 host,
370 repository: "pingdotgg/t3code",
371 number: 21353,
372 url,
373 });
374 expect(yield* Ref.get(harness.commands)).toMatchObject([
375 {
376 type: "thread.pull-request.link",
377 host,
378 repository: "pingdotgg/t3code",
379 number: 21353,
380 url,
381 },
382 ]);
383 }
384 }
385 }
386 }),
387 );
388
389 it.effect("builds the URL in the project host's own shape", () =>
390 Effect.gen(function* () {
391 const harness = yield* makeHarness({
392 project: makeProject({
393 canonicalKey: "gitlab.com/group/sub/project",
394 locator: {
395 source: "git-remote",
396 remoteName: "origin",
397 remoteUrl: "git@gitlab.com:group/sub/project.git",
398 },
399 provider: SourceControlProviderKind.make("gitlab"),
400 displayName: "group/sub/project",
401 }),
402 });
403 const result = yield* harness.call("link_pull_request", {
404 repository: "group/sub/project",
405 number: 42,
406 });
407 expect(result.url).toBe("https://gitlab.com/group/sub/project/-/merge_requests/42");
408 expect(result.host).toBe("gitlab.com");
409 const other = yield* harness.call("link_pull_request", {
410 host: "gitlab.example.test",
411 repository: "team/repo",
412 number: 7,
413 });
414 expect(other.url).toBe("https://gitlab.example.test/team/repo/-/merge_requests/7");
415 const onGitHub = yield* harness.call("link_pull_request", {
416 host: "github.com",
417 repository: "acme/web",
418 number: 9,
419 });
420 expect(onGitHub.url).toBe("https://github.com/acme/web/pull/9");
421 }),
422 );
423
424 it.effect("links a URL but not a bare number when the project's host is unknown", () =>
425 Effect.gen(function* () {
426 const harness = yield* makeHarness({
427 project: makeProject({
428 canonicalKey: "scm.example.test/tfs/collection/project/_git/repo",
429 locator: {
430 source: "git-remote",
431 remoteName: "origin",
432 remoteUrl: "http://dummy:secret@scm.example.test:8080/tfs/Collection/Project/_git/Repo",
433 },
434 provider: SourceControlProviderKind.make("unknown"),
435 displayName: "tfs/collection/project/_git/repo",
436 }),
437 });
438 const error = yield* harness
439 .call("link_pull_request", { repository: "tfs/Collection/Project/_git/Repo", number: 124 })
440 .pipe(Effect.flip);
441 expect(error).toMatchObject({ _tag: "PullRequestUrlUnavailableError" });
442
443 const supplied = "https://scm.example.test/tfs/Collection/Project/_git/Repo/pullrequest/123";
444 const fromUrl = yield* harness.call("link_pull_request", { url: supplied });
445 expect(fromUrl).toEqual({
446 host: "scm.example.test",
447 repository: "tfs/collection/project/_git/repo",
448 number: 123,
449 url: supplied,
450 alreadyLinked: false,
451 });
452 expect(yield* Ref.get(harness.commands)).toMatchObject([
453 { type: "thread.pull-request.link", number: 123, url: supplied },
454 ]);
455 }),
456 );
457
458 it.effect("treats a duplicate link as alreadyLinked rather than an error", () =>
459 Effect.gen(function* () {
460 const harness = yield* makeHarness({
461 thread: makeThread([makeLink(123)]),
462 reject: (command) =>
463 command.type === "thread.pull-request.link" ? "already linked" : null,
464 });
465 const result = yield* harness.call("link_pull_request", {
466 url: "https://github.com/t3tools/t3code/pull/123",
467 });
468 expect(result.alreadyLinked).toBe(true);
469 }),
470 );
471
472 it.effect("unlinks a linked pull request and reports a missing one as wasLinked=false", () =>
473 Effect.gen(function* () {
474 const harness = yield* makeHarness({
475 thread: makeThread([makeLink(5)]),
476 reject: (command) =>
477 command.type === "thread.pull-request.unlink" && command.number !== 5
478 ? "not linked"
479 : null,
480 });
481 const linked = yield* harness.call("unlink_pull_request", {
482 repository: "t3tools/t3code",
483 number: 5,
484 });
485 expect(linked).toEqual({
486 host: "github.com",
487 repository: "t3tools/t3code",
488 number: 5,
489 wasLinked: true,
490 });
491 const missing = yield* harness.call("unlink_pull_request", {
492 url: "https://github.com/t3tools/t3code/pull/9",
493 });
494 expect(missing.wasLinked).toBe(false);
495 expect(yield* Ref.get(harness.commands)).toMatchObject([
496 { type: "thread.pull-request.unlink", number: 5 },
497 ]);
498 }),
499 );
500
501 it("reports an older Forgejo link's HTTP port when listing thread links", () => {
502 const result = listThreadPullRequests(
503 makeThread([
504 makeLink(42, {
505 host: "forge.example",
506 url: "http://forge.example:3000/t3tools/t3code/pulls/42",
507 }),
508 ]),
509 );
510 expect(result.pullRequests[0]?.host).toBe("forge.example:3000");
511 });
512
513 it.effect("lists visible links with host state and derived chain order", () =>
514 Effect.gen(function* () {
515 const harness = yield* makeHarness({
516 thread: makeThread([
517 makeLink(3, { headBranch: "feat-c", baseBranch: "feat-b", source: "agent" }),
518 makeLink(1, { headBranch: "feat-a", baseBranch: "main", source: "created" }),
519 makeLink(2, { headBranch: "feat-b", baseBranch: "feat-a", source: "agent" }),
520 makeLink(9, { source: "stack-dismissed" }),
521 makeLink(10),
522 ]),
523 });
524 const result = yield* harness.call("list_thread_pull_requests", {});
525 expect(result.pullRequests.map((entry) => entry.number)).toEqual([3, 1, 2, 10]);
526 expect(result.pullRequests[0]).toEqual({
527 host: "github.com",
528 repository: "t3tools/t3code",
529 number: 3,
530 url: "https://github.com/t3tools/t3code/pull/3",
531 source: "agent",
532 watching: false,
533 state: "open",
534 title: "PR 3",
535 headBranch: "feat-c",
536 baseBranch: "feat-b",
537 isDraft: false,
538 stack: { kind: "derived", position: 3, size: 3 },
539 });
540 expect(result.pullRequests[3]).toMatchObject({
541 number: 10,
542 state: null,
543 title: null,
544 headBranch: null,
545 stack: null,
546 });
547 expect(result.chains).toEqual([
548 { kind: "derived", numbers: [1, 2, 3] },
549 { kind: "derived", numbers: [10] },
550 ]);
551 }),
552 );
553});
554
555describe("listThreadPullRequests", () => {
556 it("reports a native stack position for each member", () => {
557 const stack = {
558 kind: "native" as const,
559 id: "stack-1",
560 number: 1,
561 url: "https://github.com/t3tools/t3code/stack/1",
562 base: "main",
563 layers: [
564 { number: 1, headBranch: "a", state: "open" as const },
565 { number: 2, headBranch: "b", state: "open" as const },
566 ],
567 };
568 const result = listThreadPullRequests({
569 pullRequests: [
570 makeLink(2, { stack, source: "stack" }),
571 makeLink(1, { stack, source: "created" }),
572 ],
573 });
574 expect(result.pullRequests.map((entry) => [entry.number, entry.stack])).toEqual([
575 [2, { kind: "native", position: 2, size: 2 }],
576 [1, { kind: "native", position: 1, size: 2 }],
577 ]);
578 expect(result.chains).toEqual([{ kind: "native", numbers: [1, 2] }]);
579 });
580
581 it("gives pull requests built on the same one the same position", () => {
582 const result = listThreadPullRequests({
583 pullRequests: [
584 makeLink(1, { headBranch: "feat-a", baseBranch: "main" }),
585 makeLink(2, { headBranch: "feat-b", baseBranch: "feat-a" }),
586 makeLink(3, { headBranch: "feat-c", baseBranch: "feat-a" }),
587 ],
588 });
589 expect(result.pullRequests.map((entry) => [entry.number, entry.stack])).toEqual([
590 [1, { kind: "derived", position: 1, size: 3 }],
591 [2, { kind: "derived", position: 2, size: 3 }],
592 [3, { kind: "derived", position: 2, size: 3 }],
593 ]);
594 expect(result.chains).toEqual([{ kind: "derived", numbers: [1, 2, 3] }]);
595 });
596});
597
598describe("pull request guide tools", () => {
599 it.effect(
600 "writes guides through the project whose checkout is each pull request's repository",
601 () =>
602 Effect.gen(function* () {
603 const other = {
604 ...makeProject({
605 canonicalKey: "github.com/acme/web",
606 locator: {
607 source: "git-remote",
608 remoteName: "origin",
609 remoteUrl: "git@github.com:acme/web.git",
610 },
611 provider: SourceControlProviderKind.make("github"),
612 displayName: "acme/web",
613 owner: "acme",
614 name: "web",
615 }),
616 id: ProjectId.make("project-web"),
617 };
618 const harness = yield* makeHarness({ projects: [makeProject(), other] });
619 const result = yield* harness.call("write_pull_request_guides", {
620 pullRequests: [
621 { url: "https://github.com/acme/web/pull/7" },
622 { repository: "t3tools/t3code", number: 12 },
623 { url: "https://github.com/someone/else/pull/1" },
624 ],
625 });
626 expect(
627 result.guides.map((guide) => [guide.repository, guide.number, guide.outcome]),
628 ).toEqual([
629 ["acme/web", 7, "started"],
630 ["t3tools/t3code", 12, "started"],
631 ["someone/else", 1, "failed"],
632 ]);
633 expect(result.guides[2]?.detail).toContain("No project in this environment");
634 expect(
635 (yield* Ref.get(harness.guideRequests)).map((ref) => [ref.projectId, ref.number]),
636 ).toEqual([
637 ["project-web", 7],
638 [PROJECT_ID, 12],
639 ]);
640 }),
641 );
642
643 it.effect("reports an unreadable entry on its own and still writes the rest of the batch", () =>
644 Effect.gen(function* () {
645 const harness = yield* makeHarness();
646 const result = yield* harness.call("write_pull_request_guides", {
647 pullRequests: [
648 { url: "https://example.com/not-a-pull-request" },
649 { repository: "t3tools/t3code" },
650 { repository: "t3tools/t3code", number: 5 },
651 ],
652 });
653 expect(result.guides.map((guide) => guide.outcome)).toEqual(["failed", "failed", "started"]);
654 expect(result.guides[0]?.detail).toContain("not a recognised pull request URL");
655 expect(result.guides[1]?.detail).toContain("Pass either url");
656 expect((yield* Ref.get(harness.guideRequests)).map((ref) => ref.number)).toEqual([5]);
657 }),
658 );
659
660 it.effect("finds an Azure DevOps checkout for a pull request named by its full path", () =>
661 Effect.gen(function* () {
662 const azure = {
663 ...makeProject({
664 canonicalKey: "dev.azure.com/org/project/_git/web",
665 locator: {
666 source: "git-remote",
667 remoteName: "origin",
668 remoteUrl: "https://dev.azure.com/org/project/_git/web",
669 },
670 provider: SourceControlProviderKind.make("azure-devops"),
671 displayName: "org/project/_git/web",
672 owner: "org",
673 name: "web",
674 }),
675 id: ProjectId.make("project-azure"),
676 };
677 const harness = yield* makeHarness({ projects: [makeProject(), azure] });
678 const result = yield* harness.call("write_pull_request_guides", {
679 pullRequests: [{ host: "dev.azure.com", repository: "org/project/_git/web", number: 9 }],
680 });
681 expect(result.guides.map((guide) => guide.outcome)).toEqual(["started"]);
682 expect((yield* Ref.get(harness.guideRequests)).map((ref) => ref.projectId)).toEqual([
683 "project-azure",
684 ]);
685 }),
686 );
687});