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 PullRequestActionInput,
10 type PullRequestDiffResult,
11 type PullRequestSubmitReviewInput,
12 type PullRequestActivity,
13 type PullRequestListInput,
14 type PullRequestDetail,
15 type PullRequestRef,
16 type PullRequestReviewGuideResult,
17 type ThreadPullRequestLink,
18 SourceControlProviderKind,
19} from "@t3tools/contracts";
20import { describe, expect, it } from "@effect/vitest";
21import * as SecureRandom from "effect/crypto/SecureRandom";
22import * as Effect from "effect/Effect";
23import * as Base64Url from "effect/encoding/Base64Url";
24import * as Layer from "effect/Layer";
25import * as Option from "effect/Option";
26import * as Ref from "effect/Ref";
27import * as Stream from "effect/Stream";
28import type { Tool } from "effect/ai";
29
30import * as GitManager from "../../../git/GitManager.ts";
31import * as Orchestrator from "../../../orchestration-v2/Orchestrator.ts";
32import {
33 type PullRequestTestThread,
34 v2PullRequestThread,
35} from "../../../orchestration-v2/testkit/pullRequestFixtures.ts";
36import * as ProjectService from "../../../project/ProjectService.ts";
37import * as PullRequestWatchService from "../../../pullRequest/PullRequestWatchService.ts";
38import * as PullRequestReviewGuideService from "../../../pullRequest/PullRequestReviewGuideService.ts";
39import * as PullRequestService from "../../../pullRequest/PullRequestService.ts";
40import * as McpInvocationContext from "../../McpInvocationContext.ts";
41import * as McpToolAccess from "../../McpToolAccess.ts";
42import * as McpToolAccessTestkit from "../../McpToolAccess.testkit.ts";
43import { listThreadPullRequests } from "./handlers.ts";
44import * as PullRequestsHandlers from "./handlers.ts";
45import { CHILD_PULL_REQUEST_REPORT_NEXT, PullRequestsToolkit } from "./tools.ts";
46
47const PROJECT_ID = ProjectId.make("project-1");
48const THREAD_ID = ThreadId.make("thread-1");
49
50const testCrypto = SecureRandom.make((size) => new Uint8Array(size).fill(7));
51
52const invocation = (
53 capabilities: ReadonlyArray<McpInvocationContext.McpCapability>,
54): McpInvocationContext.McpInvocationScope => ({
55 environmentId: EnvironmentId.make("environment-1"),
56 requestNamespace: "provider-session-1",
57 thread: {
58 threadId: THREAD_ID,
59 providerSessionId: "provider-session-1",
60 providerInstanceId: ProviderInstanceId.make("codex"),
61 },
62 client: undefined,
63 capabilities: new Set(capabilities),
64 issuedAt: 1,
65});
66
67function makeProject(
68 repositoryIdentity: OrchestrationProjectShell["repositoryIdentity"] = {
69 canonicalKey: "github.com/t3tools/t3code",
70 locator: {
71 source: "git-remote",
72 remoteName: "origin",
73 remoteUrl: "git@github.com:T3Tools/T3Code.git",
74 },
75 provider: SourceControlProviderKind.make("github"),
76 displayName: "T3Tools/T3Code",
77 owner: "T3Tools",
78 name: "T3Code",
79 },
80): OrchestrationProjectShell {
81 return {
82 id: PROJECT_ID,
83 title: "Project",
84 workspaceRoot: "/workspace/project",
85 defaultModelSelection: null,
86 scripts: [],
87 repositoryIdentity,
88 createdAt: "2026-08-01T00:00:00.000Z",
89 updatedAt: "2026-08-01T00:00:00.000Z",
90 };
91}
92
93function makeThread(pullRequests: ReadonlyArray<ThreadPullRequestLink>): PullRequestTestThread {
94 return {
95 id: THREAD_ID,
96 projectId: PROJECT_ID,
97 title: "Thread",
98 modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5" },
99 runtimeMode: "full-access",
100 interactionMode: "default",
101 branch: null,
102 worktreePath: null,
103 pullRequests,
104 createdAt: "2026-08-01T00:00:00.000Z",
105 updatedAt: "2026-08-20T00:00:00.000Z",
106 archivedAt: null,
107 settledOverride: null,
108 settledAt: null,
109 latestUserMessageAt: "2026-08-20T00:00:00.000Z",
110 };
111}
112
113function makeLink(
114 number: number,
115 overrides: Partial<ThreadPullRequestLink> & {
116 readonly headBranch?: string;
117 readonly baseBranch?: string;
118 } = {},
119): ThreadPullRequestLink {
120 const { headBranch, baseBranch, ...rest } = overrides;
121 return {
122 host: "github.com",
123 repository: "t3tools/t3code",
124 number,
125 url: `https://github.com/t3tools/t3code/pull/${number}`,
126 source: "manual",
127 linkedAt: "2026-08-10T00:00:00.000Z",
128 snapshot:
129 headBranch === undefined
130 ? null
131 : {
132 state: "open",
133 title: `PR ${number}`,
134 headBranch,
135 baseBranch: baseBranch ?? "main",
136 isDraft: false,
137 updatedAt: null,
138 syncedAt: "2026-08-27T00:00:00.000Z",
139 },
140 stack: null,
141 ...rest,
142 };
143}
144
145interface HarnessOptions {
146 readonly thread?: PullRequestTestThread | null;
147 readonly project?: OrchestrationProjectShell | null;
148 readonly reject?: (command: OrchestrationCommand) => string | null;
149 readonly projects?: ReadonlyArray<OrchestrationProjectShell>;
150 readonly generate?: (
151 input: PullRequestRef,
152 ) => Effect.Effect<
153 PullRequestReviewGuideResult & { started: boolean },
154 PullRequestOperationError
155 >;
156 readonly pullRequests?: Partial<PullRequestService.PullRequestService["Service"]>;
157 readonly git?: Partial<GitManager.GitManager["Service"]>;
158}
159
160const NO_GUIDE: PullRequestReviewGuideResult = { guide: null, run: null, currentHeadSha: "head-1" };
161
162const makeHarness = Effect.fn("makePullRequestsToolkitHarness")(function* (
163 options: HarnessOptions = {},
164) {
165 const commands = yield* Ref.make<ReadonlyArray<OrchestrationCommand>>([]);
166 const guideRequests = yield* Ref.make<ReadonlyArray<PullRequestRef>>([]);
167 const thread = options.thread === undefined ? makeThread([]) : options.thread;
168 const project = options.project === undefined ? makeProject() : options.project;
169 const dispatch: Orchestrator.OrchestratorV2Shape["dispatch"] = (command) =>
170 Effect.gen(function* () {
171 const rejection = options.reject?.(command) ?? null;
172 if (rejection !== null)
173 return yield* new Orchestrator.OrchestratorDispatchError({
174 commandId: command.commandId,
175 commandType: command.type,
176 cause: rejection,
177 });
178 yield* Ref.update(commands, (recorded) => [...recorded, command]);
179 return { sequence: 1, storedEvents: [] };
180 });
181 const layerDependencies = Layer.mergeAll(
182 Layer.mock(PullRequestWatchService.PullRequestWatchService)({}),
183 Layer.mock(ProjectService.ProjectService)({
184 getShell: () => Effect.succeed(Option.fromNullishOr(project)),
185 listShells: () => Effect.succeed(options.projects ?? (project ? [project] : [])),
186 }),
187 Layer.mock(PullRequestReviewGuideService.PullRequestReviewGuideService)({
188 get: () => Effect.succeed(NO_GUIDE),
189 generate: (input) =>
190 Ref.update(guideRequests, (recorded) => [...recorded, input]).pipe(
191 Effect.andThen(
192 options.generate?.(input) ??
193 Effect.succeed({
194 ...NO_GUIDE,
195 run: {
196 _tag: "Running" as const,
197 headSha: "head-1",
198 startedAt: "2026-10-11T00:00:00.000Z",
199 },
200 started: true,
201 }),
202 ),
203 ),
204 }),
205 Layer.mock(Orchestrator.OrchestratorV2)({
206 getThreadShell: (id) =>
207 Effect.succeed(id === thread?.id ? v2PullRequestThread(thread) : null),
208 dispatch,
209 }),
210 Layer.mock(PullRequestService.PullRequestService)(options.pullRequests ?? {}),
211 Layer.mock(GitManager.GitManager)(options.git ?? {}),
212 Layer.succeed(SecureRandom.SecureRandom, testCrypto),
213 McpToolAccessTestkit.liveThreadsLayer,
214 );
215 const toolkit = yield* PullRequestsToolkit.pipe(
216 Effect.provide(
217 McpToolAccess.HandlersLayer.layer(PullRequestsHandlers.layer).pipe(
218 Layer.provide(layerDependencies),
219 ),
220 ),
221 );
222 const call = <Name extends keyof typeof PullRequestsToolkit.tools>(
223 name: Name,
224 params: Parameters<typeof toolkit.handle<Name>>[1],
225 capabilities: ReadonlyArray<McpInvocationContext.McpCapability> = ["pull-requests"],
226 ) =>
227 toolkit.handle(name, params).pipe(
228 Stream.unwrap,
229 Stream.runCollect,
230 Effect.map(
231 (chunk) => chunk.at(-1)!.result as Tool.Success<(typeof PullRequestsToolkit.tools)[Name]>,
232 ),
233 Effect.provideService(McpInvocationContext.McpInvocationContext, invocation(capabilities)),
234 Effect.provide(layerDependencies),
235 );
236 return { commands, guideRequests, call };
237});
238
239describe("pull request toolkit handlers", () => {
240 it.effect("refuses a credential without the pull-requests capability", () =>
241 Effect.gen(function* () {
242 const harness = yield* makeHarness();
243 const error = yield* harness
244 .call("list_thread_pull_requests", {}, ["preview"])
245 .pipe(Effect.flip);
246 expect(error).toMatchObject({
247 _tag: "McpCapabilityUnavailableError",
248 capability: "pull-requests",
249 threadId: THREAD_ID,
250 });
251 expect(yield* Ref.get(harness.commands)).toEqual([]);
252 }),
253 );
254
255 it.effect("points a bare thread uuid at the mcp: thread it belongs to", () =>
256 Effect.gen(function* () {
257 const bareId = ThreadId.make("5d0b4a3e-8c1f-4a52-9d37-2f6c7e1b9a04");
258 const harness = yield* makeHarness({
259 thread: { ...makeThread([]), id: ThreadId.make(`mcp:${bareId}`) },
260 });
261 const error = yield* harness
262 .call("link_pull_request", { threadId: bareId, number: 123 })
263 .pipe(Effect.flip);
264 expect(error.message).toBe(
265 `Thread ${bareId} was not found. Did you mean \`mcp:${bareId}\`? Thread ids belong to one environment: for a thread on a linked one, find it with \`t3_environment_links\` and pass its \`environmentId\` to a tool that takes one.`,
266 );
267 expect(error).toMatchObject({ _tag: "OrchestratorMcpFailure", code: "thread_not_found" });
268 expect(yield* Ref.get(harness.commands)).toEqual([]);
269 }),
270 );
271
272 it.effect("links by URL with source agent on the token's thread", () =>
273 Effect.gen(function* () {
274 const harness = yield* makeHarness();
275 const result = yield* harness.call("link_pull_request", {
276 url: "https://github.com/T3Tools/T3Code/pull/123/files",
277 });
278 expect(result).toEqual({
279 host: "github.com",
280 repository: "t3tools/t3code",
281 number: 123,
282 url: "https://github.com/T3Tools/T3Code/pull/123/files",
283 alreadyLinked: false,
284 });
285 expect(yield* Ref.get(harness.commands)).toMatchObject([
286 {
287 type: "thread.pull-request.link",
288 threadId: THREAD_ID,
289 host: "github.com",
290 repository: "t3tools/t3code",
291 number: 123,
292 source: "agent",
293 },
294 ]);
295 }),
296 );
297
298 it.effect("asks a subagent thread to end with its PR report after it links", () =>
299 Effect.gen(function* () {
300 const harness = yield* makeHarness({
301 thread: {
302 ...makeThread([]),
303 lineage: {
304 rootThreadId: ThreadId.make("parent"),
305 parentThreadId: ThreadId.make("parent"),
306 relationshipToParent: "subagent",
307 },
308 },
309 });
310 const result = yield* harness.call("link_pull_request", {
311 url: "https://github.com/t3tools/t3code/pull/124",
312 });
313 expect(result).toMatchObject({ number: 124, next: CHILD_PULL_REQUEST_REPORT_NEXT });
314 }),
315 );
316
317 it.effect("canonicalizes GitCafe links independently of the thread's project host", () =>
318 Effect.gen(function* () {
319 for (const host of ["git.cafe", "staging.git.cafe"]) {
320 for (const project of [makeProject(), makeProject(null)]) {
321 for (const target of [
322 { host, repository: "PingDotGG/T3Code", number: 21353 },
323 { url: `https://${host}/PingDotGG/T3Code/pull/21353` },
324 { url: `https://${host}/PingDotGG/T3Code/pulls/21353` },
325 ]) {
326 const harness = yield* makeHarness({ project });
327 const result = yield* harness.call("link_pull_request", target);
328 const url = `https://${host}/pingdotgg/t3code/pulls/21353`;
329 expect(result).toMatchObject({
330 host,
331 repository: "pingdotgg/t3code",
332 number: 21353,
333 url,
334 });
335 expect(yield* Ref.get(harness.commands)).toMatchObject([
336 {
337 type: "thread.pull-request.link",
338 host,
339 repository: "pingdotgg/t3code",
340 number: 21353,
341 url,
342 },
343 ]);
344 }
345 }
346 }
347 }),
348 );
349
350 it.effect("builds the URL in the project host's own shape", () =>
351 Effect.gen(function* () {
352 const harness = yield* makeHarness({
353 project: makeProject({
354 canonicalKey: "gitlab.com/group/sub/project",
355 locator: {
356 source: "git-remote",
357 remoteName: "origin",
358 remoteUrl: "git@gitlab.com:group/sub/project.git",
359 },
360 provider: SourceControlProviderKind.make("gitlab"),
361 displayName: "group/sub/project",
362 }),
363 });
364 const result = yield* harness.call("link_pull_request", {
365 repository: "group/sub/project",
366 number: 42,
367 });
368 expect(result.url).toBe("https://gitlab.com/group/sub/project/-/merge_requests/42");
369 expect(result.host).toBe("gitlab.com");
370 const other = yield* harness.call("link_pull_request", {
371 host: "gitlab.example.test",
372 repository: "team/repo",
373 number: 7,
374 });
375 expect(other.url).toBe("https://gitlab.example.test/team/repo/-/merge_requests/7");
376 const onGitHub = yield* harness.call("link_pull_request", {
377 host: "github.com",
378 repository: "acme/web",
379 number: 9,
380 });
381 expect(onGitHub.url).toBe("https://github.com/acme/web/pull/9");
382 }),
383 );
384
385 it.effect("links a URL but not a bare number when the project's host is unknown", () =>
386 Effect.gen(function* () {
387 const harness = yield* makeHarness({
388 project: makeProject({
389 canonicalKey: "scm.example.test/tfs/collection/project/_git/repo",
390 locator: {
391 source: "git-remote",
392 remoteName: "origin",
393 remoteUrl: "http://dummy:secret@scm.example.test:8080/tfs/Collection/Project/_git/Repo",
394 },
395 provider: SourceControlProviderKind.make("unknown"),
396 displayName: "tfs/collection/project/_git/repo",
397 }),
398 });
399 const error = yield* harness
400 .call("link_pull_request", { repository: "tfs/Collection/Project/_git/Repo", number: 124 })
401 .pipe(Effect.flip);
402 expect(error).toMatchObject({ _tag: "PullRequestUrlUnavailableError" });
403
404 const supplied = "https://scm.example.test/tfs/Collection/Project/_git/Repo/pullrequest/123";
405 const fromUrl = yield* harness.call("link_pull_request", { url: supplied });
406 expect(fromUrl).toEqual({
407 host: "scm.example.test",
408 repository: "tfs/collection/project/_git/repo",
409 number: 123,
410 url: supplied,
411 alreadyLinked: false,
412 });
413 expect(yield* Ref.get(harness.commands)).toMatchObject([
414 { type: "thread.pull-request.link", number: 123, url: supplied },
415 ]);
416 }),
417 );
418
419 it.effect("treats a duplicate link as alreadyLinked rather than an error", () =>
420 Effect.gen(function* () {
421 const harness = yield* makeHarness({
422 thread: makeThread([makeLink(123)]),
423 reject: (command) =>
424 command.type === "thread.pull-request.link" ? "already linked" : null,
425 });
426 const result = yield* harness.call("link_pull_request", {
427 url: "https://github.com/t3tools/t3code/pull/123",
428 });
429 expect(result.alreadyLinked).toBe(true);
430 }),
431 );
432
433 it.effect("unlinks a linked pull request and reports a missing one as wasLinked=false", () =>
434 Effect.gen(function* () {
435 const harness = yield* makeHarness({
436 thread: makeThread([makeLink(5)]),
437 reject: (command) =>
438 command.type === "thread.pull-request.unlink" && command.number !== 5
439 ? "not linked"
440 : null,
441 });
442 const linked = yield* harness.call("unlink_pull_request", {
443 repository: "t3tools/t3code",
444 number: 5,
445 });
446 expect(linked).toEqual({
447 host: "github.com",
448 repository: "t3tools/t3code",
449 number: 5,
450 wasLinked: true,
451 });
452 const missing = yield* harness.call("unlink_pull_request", {
453 url: "https://github.com/t3tools/t3code/pull/9",
454 });
455 expect(missing.wasLinked).toBe(false);
456 expect(yield* Ref.get(harness.commands)).toMatchObject([
457 { type: "thread.pull-request.unlink", number: 5 },
458 ]);
459 }),
460 );
461
462 it.effect("reports a dismissed stack member as not linked and leaves it dismissed", () =>
463 Effect.gen(function* () {
464 const harness = yield* makeHarness({
465 thread: makeThread([makeLink(9, { source: "stack-dismissed" })]),
466 });
467 const result = yield* harness.call("unlink_pull_request", {
468 repository: "t3tools/t3code",
469 number: 9,
470 });
471 expect(result.wasLinked).toBe(false);
472 expect(yield* Ref.get(harness.commands)).toEqual([]);
473 }),
474 );
475
476 it.effect("links several pull requests in one call", () =>
477 Effect.gen(function* () {
478 const harness = yield* makeHarness({
479 thread: makeThread([makeLink(1), { ...makeLink(2), source: "stack-dismissed" }]),
480 });
481 const url = (number: number) => `https://github.com/t3tools/t3code/pull/${number}`;
482 const result = yield* harness.call("link_pull_requests", {
483 urls: [url(1), url(2), url(3), url(3), "https://example.com/not-a-pr"],
484 });
485 expect(result).toEqual({
486 linked: [{ host: "github.com", repository: "t3tools/t3code", numbers: [2, 3] }],
487 alreadyLinked: [{ host: "github.com", repository: "t3tools/t3code", numbers: [1] }],
488 linkedCount: 3,
489 invalidUrls: ["https://example.com/not-a-pr"],
490 });
491 expect(yield* Ref.get(harness.commands)).toMatchObject([
492 { type: "thread.pull-request.link", number: 2, source: "agent" },
493 { type: "thread.pull-request.link", number: 3, source: "agent" },
494 ]);
495 }),
496 );
497
498 it.effect("unlinks every visible pull request in the given states in one call", () =>
499 Effect.gen(function* () {
500 const withState = (number: number, state: "open" | "closed" | "merged") => {
501 const link = makeLink(number, { headBranch: `branch-${number}` });
502 return { ...link, snapshot: { ...link.snapshot!, state } };
503 };
504 const harness = yield* makeHarness({
505 thread: makeThread([
506 withState(1, "merged"),
507 withState(2, "open"),
508 withState(3, "closed"),
509 makeLink(4),
510 { ...withState(5, "merged"), source: "stack-dismissed" },
511 ]),
512 });
513 const result = yield* harness.call("unlink_pull_requests", {
514 states: ["closed", "merged"],
515 });
516 expect(result).toEqual({
517 unlinked: [
518 { host: "github.com", repository: "t3tools/t3code", state: "merged", numbers: [1] },
519 { host: "github.com", repository: "t3tools/t3code", state: "closed", numbers: [3] },
520 ],
521 unlinkedCount: 2,
522 remaining: 2,
523 });
524 expect(yield* Ref.get(harness.commands)).toMatchObject([
525 { type: "thread.pull-request.unlink", number: 1 },
526 { type: "thread.pull-request.unlink", number: 3 },
527 ]);
528 }),
529 );
530
531 it("reports an older Forgejo link's HTTP port when listing thread links", () => {
532 const result = listThreadPullRequests(
533 makeThread([
534 makeLink(42, {
535 host: "forge.example",
536 url: "http://forge.example:3000/t3tools/t3code/pulls/42",
537 }),
538 ]),
539 );
540 expect(result.pullRequests[0]?.host).toBe("forge.example:3000");
541 });
542
543 it.effect("lists visible links with host state and derived chain order", () =>
544 Effect.gen(function* () {
545 const harness = yield* makeHarness({
546 thread: makeThread([
547 makeLink(3, { headBranch: "feat-c", baseBranch: "feat-b", source: "agent" }),
548 makeLink(1, { headBranch: "feat-a", baseBranch: "main", source: "created" }),
549 makeLink(2, { headBranch: "feat-b", baseBranch: "feat-a", source: "agent" }),
550 makeLink(9, { source: "stack-dismissed" }),
551 makeLink(10),
552 ]),
553 });
554 const result = yield* harness.call("list_thread_pull_requests", {});
555 expect(result.pullRequests.map((entry) => entry.number)).toEqual([1, 2, 3, 10]);
556 expect(result.pullRequests[2]).toEqual({
557 host: "github.com",
558 repository: "t3tools/t3code",
559 number: 3,
560 url: "https://github.com/t3tools/t3code/pull/3",
561 source: "agent",
562 watching: false,
563 state: "open",
564 title: "PR 3",
565 headBranch: "feat-c",
566 baseBranch: "feat-b",
567 isDraft: false,
568 stack: { kind: "derived", position: 3, size: 3 },
569 });
570 expect(result.pullRequests[3]).toMatchObject({
571 number: 10,
572 state: null,
573 title: null,
574 headBranch: null,
575 stack: null,
576 });
577 expect(result.chains).toEqual([
578 { kind: "derived", numbers: [1, 2, 3] },
579 { kind: "derived", numbers: [10] },
580 ]);
581 }),
582 );
583});
584
585describe("listThreadPullRequests", () => {
586 it("reports a native stack position for each member", () => {
587 const stack = {
588 kind: "native" as const,
589 id: "stack-1",
590 number: 1,
591 url: "https://github.com/t3tools/t3code/stack/1",
592 base: "main",
593 layers: [
594 { number: 1, headBranch: "a", state: "open" as const },
595 { number: 2, headBranch: "b", state: "open" as const },
596 ],
597 };
598 const result = listThreadPullRequests({
599 pullRequests: [
600 makeLink(2, { stack, source: "stack" }),
601 makeLink(1, { stack, source: "created" }),
602 ],
603 });
604 expect(result.pullRequests.map((entry) => [entry.number, entry.stack])).toEqual([
605 [1, { kind: "native", position: 1, size: 2 }],
606 [2, { kind: "native", position: 2, size: 2 }],
607 ]);
608 expect(result.chains).toEqual([{ kind: "native", numbers: [1, 2] }]);
609 });
610
611 it("gives pull requests built on the same one the same position", () => {
612 const result = listThreadPullRequests({
613 pullRequests: [
614 makeLink(1, { headBranch: "feat-a", baseBranch: "main" }),
615 makeLink(2, { headBranch: "feat-b", baseBranch: "feat-a" }),
616 makeLink(3, { headBranch: "feat-c", baseBranch: "feat-a" }),
617 ],
618 });
619 expect(result.pullRequests.map((entry) => [entry.number, entry.stack])).toEqual([
620 [1, { kind: "derived", position: 1, size: 3 }],
621 [2, { kind: "derived", position: 2, size: 3 }],
622 [3, { kind: "derived", position: 2, size: 3 }],
623 ]);
624 expect(result.chains).toEqual([{ kind: "derived", numbers: [1, 2, 3] }]);
625 });
626
627 it("pages a large list once through, with each page's stacks whole", () => {
628 const thread = {
629 pullRequests: [
630 makeLink(1, { headBranch: "feat-a" }),
631 ...Array.from({ length: 118 }, (_, index) => makeLink(index + 2)),
632 makeLink(120, { headBranch: "feat-z", baseBranch: "feat-a" }),
633 ],
634 };
635 const pages = [listThreadPullRequests(thread)];
636 for (let next = pages[0]!.nextCursor; next !== null; next = pages.at(-1)!.nextCursor) {
637 pages.push(listThreadPullRequests(thread, next));
638 }
639 expect(pages.map((page) => page.pullRequests.length)).toEqual([50, 50, 20]);
640 expect(pages.flatMap((page) => page.pullRequests.map((entry) => entry.number))).toEqual(
641 Array.from({ length: 120 }, (_, index) => index + 1),
642 );
643 const stack = { kind: "derived", numbers: [1, 120] };
644 expect(pages.map((page) => page.chains.length)).toEqual([50, 50, 20]);
645 expect(pages.map((page) => page.chains.filter((chain) => chain.numbers.length > 1))).toEqual([
646 [stack],
647 [],
648 [stack],
649 ]);
650
651 // Unlinking the first page must not shift the cursor past PRs not yet seen.
652 const remaining = { pullRequests: thread.pullRequests.slice(50) };
653 expect(
654 listThreadPullRequests(remaining, pages[0]!.nextCursor!).pullRequests.map(
655 (entry) => entry.number,
656 ),
657 ).toEqual(Array.from({ length: 50 }, (_, index) => index + 51));
658 });
659
660 it("filters by state before paging, counting a PR with no known state as open", () => {
661 const merged = (number: number) => {
662 const link = makeLink(number, { headBranch: `feat-${number}` });
663 return { ...link, snapshot: { ...link.snapshot!, state: "merged" as const } };
664 };
665 const thread = {
666 pullRequests: [
667 ...Array.from({ length: 50 }, (_, index) => merged(index + 1)),
668 ...Array.from({ length: 10 }, (_, index) => makeLink(index + 51)),
669 ],
670 };
671 const open = listThreadPullRequests(thread, undefined, ["open"]);
672 expect(open.pullRequests.map((entry) => entry.number)).toEqual(
673 Array.from({ length: 10 }, (_, index) => index + 51),
674 );
675 expect(open.nextCursor).toBeNull();
676 expect(listThreadPullRequests(thread, undefined, ["merged"]).nextCursor).toBeNull();
677 });
678});
679
680describe("pull request guide tools", () => {
681 it.effect(
682 "writes guides through the project whose checkout is each pull request's repository",
683 () =>
684 Effect.gen(function* () {
685 const other = {
686 ...makeProject({
687 canonicalKey: "github.com/acme/web",
688 locator: {
689 source: "git-remote",
690 remoteName: "origin",
691 remoteUrl: "git@github.com:acme/web.git",
692 },
693 provider: SourceControlProviderKind.make("github"),
694 displayName: "acme/web",
695 owner: "acme",
696 name: "web",
697 }),
698 id: ProjectId.make("project-web"),
699 };
700 const harness = yield* makeHarness({ projects: [makeProject(), other] });
701 const result = yield* harness.call("write_pull_request_guides", {
702 pullRequests: [
703 { url: "https://github.com/acme/web/pull/7" },
704 { repository: "t3tools/t3code", number: 12 },
705 { url: "https://github.com/someone/else/pull/1" },
706 ],
707 });
708 expect(
709 result.guides.map((guide) => [guide.repository, guide.number, guide.outcome]),
710 ).toEqual([
711 ["acme/web", 7, "started"],
712 ["t3tools/t3code", 12, "started"],
713 ["someone/else", 1, "failed"],
714 ]);
715 expect(result.guides[2]?.detail).toContain("No project in this environment");
716 expect(
717 (yield* Ref.get(harness.guideRequests)).map((ref) => [ref.projectId, ref.number]),
718 ).toEqual([
719 ["project-web", 7],
720 [PROJECT_ID, 12],
721 ]);
722 }),
723 );
724
725 it.effect("reports an unreadable entry on its own and still writes the rest of the batch", () =>
726 Effect.gen(function* () {
727 const harness = yield* makeHarness();
728 const result = yield* harness.call("write_pull_request_guides", {
729 pullRequests: [
730 { url: "https://example.com/not-a-pull-request" },
731 { repository: "t3tools/t3code" },
732 { repository: "t3tools/t3code", number: 5 },
733 ],
734 });
735 expect(result.guides.map((guide) => guide.outcome)).toEqual(["failed", "failed", "started"]);
736 expect(result.guides[0]?.detail).toContain("not a recognised pull request URL");
737 expect(result.guides[1]?.detail).toContain("Pass either url");
738 expect((yield* Ref.get(harness.guideRequests)).map((ref) => ref.number)).toEqual([5]);
739 }),
740 );
741
742 it.effect(
743 "reads a guide on a host readable without a checkout through the caller's project",
744 () =>
745 Effect.gen(function* () {
746 const api = makeProject({
747 canonicalKey: "bitbucket.org/acme/api",
748 locator: {
749 source: "git-remote",
750 remoteName: "origin",
751 remoteUrl: "git@bitbucket.org:acme/api.git",
752 },
753 provider: SourceControlProviderKind.make("bitbucket"),
754 displayName: "acme/api",
755 owner: "acme",
756 name: "api",
757 });
758 const harness = yield* makeHarness({ project: api });
759 const result = yield* harness.call("read_pull_request_guide", {
760 url: "https://bitbucket.org/acme/web/pull-requests/123",
761 });
762 expect(result).toMatchObject({
763 host: "bitbucket.org",
764 repository: "acme/web",
765 number: 123,
766 guide: null,
767 currentHeadSha: "head-1",
768 });
769 }),
770 );
771
772 it.effect("finds an Azure DevOps checkout for a pull request named by its full path", () =>
773 Effect.gen(function* () {
774 const azure = {
775 ...makeProject({
776 canonicalKey: "dev.azure.com/org/project/_git/web",
777 locator: {
778 source: "git-remote",
779 remoteName: "origin",
780 remoteUrl: "https://dev.azure.com/org/project/_git/web",
781 },
782 provider: SourceControlProviderKind.make("azure-devops"),
783 displayName: "org/project/_git/web",
784 owner: "org",
785 name: "web",
786 }),
787 id: ProjectId.make("project-azure"),
788 };
789 const harness = yield* makeHarness({ projects: [makeProject(), azure] });
790 const result = yield* harness.call("write_pull_request_guides", {
791 pullRequests: [{ host: "dev.azure.com", repository: "org/project/_git/web", number: 9 }],
792 });
793 expect(result.guides.map((guide) => guide.outcome)).toEqual(["started"]);
794 expect((yield* Ref.get(harness.guideRequests)).map((ref) => ref.projectId)).toEqual([
795 "project-azure",
796 ]);
797 }),
798 );
799});
800
801describe("source control tools", () => {
802 const branchThread = {
803 ...makeThread([]),
804 worktreePath: "/workspace/worktree",
805 branchPullRequest: {
806 projectId: PROJECT_ID,
807 repository: "t3tools/t3code",
808 number: 42,
809 url: "https://github.com/t3tools/t3code/pull/42",
810 },
811 };
812 const detail = {
813 title: "Add tools",
814 body: "Adds tools.",
815 state: "open",
816 isDraft: false,
817 author: null,
818 headBranch: "tools",
819 baseBranch: "main",
820 headSha: "abc123",
821 mergeability: "mergeable",
822 additions: 1,
823 deletions: 0,
824 changedFiles: 1,
825 labels: [],
826 reviewers: [],
827 checks: [{ name: "CI", status: "success", description: null, url: null }],
828 } as unknown as PullRequestDetail;
829 const reviewThread = (id: string, isResolved: boolean) => ({
830 id,
831 path: "a.ts",
832 line: 1,
833 side: "right" as const,
834 isResolved,
835 isOutdated: false,
836 comments: [],
837 });
838 const activity: PullRequestActivity = {
839 comments: [],
840 commentCount: 0,
841 commentsTruncated: false,
842 reviewThreads: [reviewThread("open-thread", false), reviewThread("done-thread", true)],
843 commits: [],
844 };
845
846 it.effect("reads the thread's branch PR, only the sections asked, without resolved threads", () =>
847 Effect.gen(function* () {
848 const asked: Array<PullRequestRef> = [];
849 const harness = yield* makeHarness({
850 thread: branchThread,
851 pullRequests: {
852 detail: (ref) => Effect.sync(() => asked.push(ref)).pipe(Effect.as(detail)),
853 activity: () => Effect.succeed(activity),
854 },
855 });
856 const result = yield* harness.call("pull_request_read", {
857 sections: ["summary", "conversation"],
858 });
859 expect(asked).toEqual([
860 {
861 projectId: PROJECT_ID,
862 host: "github.com",
863 repository: "t3tools/t3code",
864 number: 42,
865 allowStale: false,
866 },
867 ]);
868 expect(result.summary?.headSha).toBe("abc123");
869 expect(result.checks).toBeUndefined();
870 expect(result.conversation?.reviewThreads.map((thread) => thread.id)).toEqual([
871 "open-thread",
872 ]);
873 expect(result.conversation?.hiddenResolvedThreads).toBe(1);
874 }),
875 );
876
877 it.effect("pages a long conversation and the PR list through the cursors they return", () =>
878 Effect.gen(function* () {
879 const comment = (body: string) =>
880 ({ id: body.slice(0, 8), author: null, body, createdAt: "2026-11-01T00:00:00Z" }) as never;
881 const long = (id: string) => ({
882 ...reviewThread(id, false),
883 comments: [comment("x".repeat(20_000))],
884 });
885 const listed: Array<PullRequestListInput> = [];
886 let firstResolved = false;
887 const harness = yield* makeHarness({
888 thread: branchThread,
889 pullRequests: {
890 activity: () =>
891 Effect.sync(() => ({
892 ...activity,
893 reviewThreads: [
894 {
895 ...long("first"),
896 isResolved: firstResolved,
897 nextCommentsCursor: "later",
898 },
899 long("second"),
900 reviewThread("done-thread", true),
901 ],
902 })),
903 threadComments: (input) =>
904 Effect.succeed(
905 input.cursor === "later"
906 ? { comments: [comment("reply")], nextCursor: null }
907 : { comments: [], nextCursor: null },
908 ),
909 list: (input) =>
910 Effect.sync(() => listed.push(input)).pipe(
911 Effect.as({
912 viewers: {},
913 providers: [],
914 entries: [],
915 errors: [],
916 truncated: input.cursors === undefined,
917 nextCursors: input.cursors === undefined ? { "t3tools/t3code": "page-2" } : {},
918 }),
919 ),
920 },
921 });
922 const first = yield* harness.call("pull_request_read", { sections: ["conversation"] });
923 expect(first.conversation?.reviewThreads).toMatchObject([
924 { id: "first", moreComments: false, comments: [{}, { body: "reply" }] },
925 ]);
926 const cursor = first.conversation?.nextCursor;
927 expect(cursor).toEqual(expect.any(String));
928 // The agent resolves what it read; the next page still starts at the next thread.
929 firstResolved = true;
930 const second = yield* harness.call("pull_request_read", { cursor: cursor! });
931 expect(second.summary).toBeUndefined();
932 expect(second.conversation?.reviewThreads.map((thread) => thread.id)).toEqual(["second"]);
933 expect(second.conversation?.nextCursor).toBeNull();
934 // A cursor past the current end finishes instead of repeating an empty page.
935 const stale = Base64Url.encode(
936 JSON.stringify({ threads: 99, comments: 99, includeResolved: false }),
937 );
938 const past = yield* harness.call("pull_request_read", { cursor: stale });
939 expect(past.conversation).toMatchObject({ reviewThreads: [], nextCursor: null });
940
941 const page = yield* harness.call("pull_request_list", {});
942 yield* harness.call("pull_request_list", { cursor: page.nextCursor! });
943 expect(listed.map((input) => input.cursors)).toEqual([
944 undefined,
945 { "t3tools/t3code": "page-2" },
946 ]);
947 const invalid = yield* harness
948 .call("pull_request_read", { cursor: "not-a-cursor" })
949 .pipe(Effect.flip);
950 expect(invalid._tag).toBe("PullRequestCursorInvalidError");
951 }),
952 );
953
954 it.effect("asks for a number when the thread's branch has no PR", () =>
955 Effect.gen(function* () {
956 const harness = yield* makeHarness();
957 const error = yield* harness.call("pull_request_read", {}).pipe(Effect.flip);
958 expect(error._tag).toBe("PullRequestBranchHasNoneError");
959 }),
960 );
961
962 it.effect("reads the PR this thread opened before status sync reports it", () =>
963 Effect.gen(function* () {
964 const asked: Array<PullRequestRef> = [];
965 const opened = (headBranch: string) =>
966 makeHarness({
967 thread: { ...makeThread([makeLink(43, { source: "created" })]), branch: "tools" },
968 pullRequests: {
969 summary: () => Effect.succeed({ state: "open", headBranch } as never),
970 detail: (ref) => Effect.sync(() => asked.push(ref)).pipe(Effect.as(detail)),
971 },
972 });
973 const harness = yield* opened("tools");
974 yield* harness.call("pull_request_read", { sections: ["summary"] });
975 expect(asked).toMatchObject([{ number: 43 }]);
976
977 // Before sync, the host says which branch it came from; another branch's is not this one.
978 const moved = yield* opened("old");
979 const unsynced = yield* moved.call("pull_request_read", {}).pipe(Effect.flip);
980 expect(unsynced._tag).toBe("PullRequestBranchHasNoneError");
981
982 // After a switch to another branch, the PR opened from the old one is not the branch's.
983 const switched = yield* makeHarness({
984 thread: {
985 ...makeThread([makeLink(43, { source: "created", headBranch: "old" })]),
986 branch: "new",
987 },
988 });
989 const error = yield* switched
990 .call("pull_request_update", { title: "New title" })
991 .pipe(Effect.flip);
992 expect(error._tag).toBe("PullRequestBranchHasNoneError");
993 }),
994 );
995
996 it.effect("merges pinned to the head the agent checked", () =>
997 Effect.gen(function* () {
998 const actions: Array<PullRequestActionInput> = [];
999 const harness = yield* makeHarness({
1000 thread: branchThread,
1001 pullRequests: {
1002 runAction: (input) => Effect.sync(() => void actions.push(input)),
1003 summary: () => Effect.succeed({ state: "open" } as never),
1004 },
1005 });
1006 const result = yield* harness.call("pull_request_merge", {
1007 expectedHeadSha: "abc123",
1008 method: "squash",
1009 auto: true,
1010 });
1011 expect(result).toMatchObject({ number: 42, state: "open" });
1012 expect(actions).toMatchObject([
1013 {
1014 number: 42,
1015 action: "enable-auto-merge",
1016 expectedHeadSha: "abc123",
1017 mergeMethod: "squash",
1018 },
1019 ]);
1020 }),
1021 );
1022
1023 it.effect("a stack merge pins every open layer up to the PR", () =>
1024 Effect.gen(function* () {
1025 const actions: Array<PullRequestActionInput> = [];
1026 let lowerHead: string | undefined = "bbb";
1027 const layer = (number: number, state: "open" | "merged", headSha: string | undefined) => ({
1028 number,
1029 state,
1030 ...(headSha === undefined ? {} : { headSha }),
1031 headBranch: `layer-${number}`,
1032 });
1033 const harness = yield* makeHarness({
1034 thread: branchThread,
1035 pullRequests: {
1036 stack: (_input, options) =>
1037 options?.bypassCache !== true
1038 ? Effect.die("a merge must not pin heads from the cache")
1039 : Effect.succeed({
1040 id: "stack-1",
1041 number: 7,
1042 url: "https://github.com/acme/app/stacks/7",
1043 base: "main",
1044 layers: [
1045 layer(40, "merged", "aaa"),
1046 layer(41, "open", lowerHead),
1047 layer(42, "open", "stale"),
1048 layer(43, "open", "ddd"),
1049 ],
1050 }),
1051 runAction: (input) => Effect.sync(() => void actions.push(input)),
1052 summary: () => Effect.succeed({ state: "merged" } as never),
1053 },
1054 });
1055 yield* harness.call("pull_request_merge", { expectedHeadSha: "ccc", stack: true });
1056 expect(actions).toMatchObject([
1057 {
1058 number: 42,
1059 action: "merge",
1060 stackNumber: 7,
1061 expectedStackHeads: [
1062 { number: 41, headSha: "bbb" },
1063 { number: 42, headSha: "ccc" },
1064 ],
1065 },
1066 ]);
1067 lowerHead = undefined;
1068 const unpinned = yield* harness
1069 .call("pull_request_merge", { expectedHeadSha: "ccc", stack: true })
1070 .pipe(Effect.flip);
1071 expect(unpinned._tag).toBe("PullRequestForgeError");
1072 expect(actions).toHaveLength(1);
1073 }),
1074 );
1075
1076 it.effect("re-running checks reopens a watch that saw its checks finish", () =>
1077 Effect.gen(function* () {
1078 const watch = {
1079 startedAt: "2026-08-20T00:00:00.000Z",
1080 headSha: "abc123",
1081 failedChecks: ["test"],
1082 passed: false,
1083 passedChecks: [],
1084 remarksThrough: "2026-08-20T00:00:00.000Z",
1085 remarkIds: [],
1086 conflicting: false,
1087 wakes: 0,
1088 };
1089 const rerun = (checksPending: boolean | undefined, reran: boolean) =>
1090 Effect.gen(function* () {
1091 const harness = yield* makeHarness({
1092 thread: {
1093 ...branchThread,
1094 pullRequests: [
1095 makeLink(42, {
1096 watch: checksPending === undefined ? watch : { ...watch, checksPending },
1097 }),
1098 ],
1099 },
1100 pullRequests: {
1101 rerunChecks: () => Effect.succeed([{ name: "test", rerun: reran, detail: null }]),
1102 },
1103 });
1104 yield* harness.call("ci_rerun", {});
1105 return yield* Ref.get(harness.commands);
1106 });
1107 expect(yield* rerun(false, true)).toMatchObject([
1108 { type: "thread.pull-request-watch.checks-reopen", threadId: THREAD_ID },
1109 ]);
1110 // Nothing re-ran, or the watch has no answer to clear.
1111 expect(yield* rerun(false, false)).toEqual([]);
1112 expect(yield* rerun(undefined, true)).toEqual([]);
1113 }),
1114 );
1115
1116 it.effect("opens a PR from the thread's worktree and links it even if dismissed", () =>
1117 Effect.gen(function* () {
1118 const opened: Array<{ readonly cwd: string; readonly draft: boolean | undefined }> = [];
1119 const harness = yield* makeHarness({
1120 thread: {
1121 ...makeThread([makeLink(43, { source: "stack-dismissed" })]),
1122 worktreePath: "/workspace/worktree",
1123 },
1124 git: {
1125 createPullRequest: (input) =>
1126 Effect.sync(() => opened.push({ cwd: input.cwd, draft: input.draft })).pipe(
1127 Effect.as({
1128 status: "created" as const,
1129 url: "https://github.com/t3tools/t3code/pull/43",
1130 number: 43,
1131 baseBranch: "main",
1132 headBranch: "tools",
1133 title: input.title,
1134 }),
1135 ),
1136 },
1137 });
1138 const result = yield* harness.call("pull_request_create", {
1139 title: "Add tools",
1140 body: "Adds tools.",
1141 draft: true,
1142 });
1143 expect(result).toMatchObject({ number: 43, created: true });
1144 expect(opened).toEqual([{ cwd: "/workspace/worktree", draft: true }]);
1145 expect(yield* Ref.get(harness.commands)).toMatchObject([
1146 { type: "thread.pull-request.link", number: 43, source: "created" },
1147 ]);
1148 }),
1149 );
1150
1151 it.effect("replies to and resolves a review thread, and refuses resolving without one", () =>
1152 Effect.gen(function* () {
1153 const calls: Array<string> = [];
1154 const harness = yield* makeHarness({
1155 thread: branchThread,
1156 pullRequests: {
1157 replyToThread: (input) => Effect.sync(() => calls.push(`reply ${input.threadId}`)),
1158 setThreadResolution: (input) =>
1159 input.threadId === "locked-thread"
1160 ? Effect.fail(
1161 new PullRequestOperationError({
1162 operation: "setThreadResolution",
1163 detail: "Locked.",
1164 }),
1165 )
1166 : Effect.sync(() => void calls.push(`resolve ${input.threadId} ${input.resolved}`)),
1167 },
1168 });
1169 const result = yield* harness.call("pull_request_respond", {
1170 reviewThreadId: "open-thread",
1171 body: "Fixed.",
1172 resolved: true,
1173 });
1174 expect(result).toMatchObject({ replied: true, resolved: true });
1175 expect(calls).toEqual(["reply open-thread", "resolve open-thread true"]);
1176 const partial = yield* harness
1177 .call("pull_request_respond", {
1178 reviewThreadId: "locked-thread",
1179 body: "Fixed.",
1180 resolved: true,
1181 })
1182 .pipe(Effect.flip);
1183 expect(partial.message).toContain("The reply was posted");
1184 const error = yield* harness
1185 .call("pull_request_respond", { body: "Done", resolved: true })
1186 .pipe(Effect.flip);
1187 expect(error._tag).toBe("PullRequestNothingToDoError");
1188 }),
1189 );
1190
1191 it.effect("places review comments by the diff page that shows their line", () =>
1192 Effect.gen(function* () {
1193 const reviews: Array<PullRequestSubmitReviewInput> = [];
1194 const pages: Record<string, PullRequestDiffResult> = {
1195 first: {
1196 patch:
1197 "diff --git a/a.ts b/a.ts\n--- a/a.ts\n+++ b/a.ts\n@@ -1,2 +1,2 @@\n-old\n+new\n same\n",
1198 truncated: false,
1199 nextCursor: "second",
1200 },
1201 second: {
1202 patch:
1203 "diff --git a/b.ts b/b.ts\n--- a/b.ts\n+++ b/b.ts\n@@ -9,1 +9,2 @@\n kept\n+added\n",
1204 truncated: false,
1205 nextCursor: null,
1206 },
1207 };
1208 const harness = yield* makeHarness({
1209 thread: branchThread,
1210 pullRequests: {
1211 diff: (input) => Effect.succeed(pages[input.cursor ?? "first"]!),
1212 submitReview: (input) => Effect.sync(() => void reviews.push(input)),
1213 },
1214 });
1215 yield* harness.call("pull_request_review", {
1216 verdict: "request-changes",
1217 body: "Two things.",
1218 comments: [
1219 { path: "b.ts", line: 10, startLine: 9, body: "Why?" },
1220 { path: "a.ts", line: 1, side: "old", body: "Keep this." },
1221 ],
1222 });
1223 expect(reviews).toMatchObject([
1224 {
1225 number: 42,
1226 verdict: "request-changes",
1227 body: "Two things.",
1228 comments: [
1229 {
1230 path: "b.ts",
1231 position: { kind: "added", newLine: 10 },
1232 startPosition: { kind: "context", oldLine: 9, newLine: 9, side: "right" },
1233 },
1234 { path: "a.ts", position: { kind: "deleted", oldLine: 1 } },
1235 ],
1236 },
1237 ]);
1238
1239 // A line the diff never shows fails before anything is posted.
1240 const error = yield* harness
1241 .call("pull_request_review", {
1242 verdict: "comment",
1243 comments: [{ path: "a.ts", line: 40, body: "Here?" }],
1244 })
1245 .pipe(Effect.flip);
1246 expect(error.message).toContain("a.ts line 40 (new side) is not in this PR's diff");
1247 expect(reviews).toHaveLength(1);
1248 }),
1249 );
1250
1251 it.effect("updates labels, requests reviewers by login, and closes the PR", () =>
1252 Effect.gen(function* () {
1253 const calls: Array<unknown> = [];
1254 const harness = yield* makeHarness({
1255 thread: branchThread,
1256 pullRequests: {
1257 setLabels: (input) =>
1258 Effect.sync(() => void calls.push(["labels", input.labels, input.applied])),
1259 reviewerCandidates: (input) =>
1260 Effect.succeed({
1261 candidates: [
1262 {
1263 id: "MDQ6VXNlcjE=",
1264 kind: "user",
1265 login: input.query === "Octo" ? "octo" : "x",
1266 name: null,
1267 avatarUrl: null,
1268 isRequested: false,
1269 },
1270 {
1271 id: "core",
1272 kind: "team",
1273 login: "acme/core",
1274 name: null,
1275 avatarUrl: null,
1276 isRequested: false,
1277 },
1278 ],
1279 } as never),
1280 requestReviewers: (input) =>
1281 Effect.sync(() => void calls.push(["reviewers", input.reviewers])),
1282 runAction: (input) => Effect.sync(() => void calls.push(["action", input.action])),
1283 },
1284 });
1285 yield* harness.call("pull_request_update", {
1286 addLabels: ["bug"],
1287 removeLabels: ["wip"],
1288 requestReviewers: ["Octo", "acme/core"],
1289 state: "closed",
1290 });
1291 expect(calls).toEqual([
1292 ["labels", ["bug"], true],
1293 ["labels", ["wip"], false],
1294 [
1295 "reviewers",
1296 [
1297 { id: "MDQ6VXNlcjE=", kind: "user" },
1298 { id: "core", kind: "team" },
1299 ],
1300 ],
1301 ["action", "close"],
1302 ]);
1303 const unknown = yield* harness
1304 .call("pull_request_update", { requestReviewers: ["nobody"] })
1305 .pipe(Effect.flip);
1306 expect(unknown.message).toContain("No reviewer named nobody");
1307 }),
1308 );
1309});