Open History to see the last commit
1import * as Cache from "effect/Cache";
2import * as Duration from "effect/Duration";
3import * as Effect from "effect/Effect";
4import * as Exit from "effect/Exit";
5import type {
6 PullRequestActor,
7 PullRequestCapabilities,
8 PullRequestCheck,
9 PullRequestReaction,
10 PullRequestViewerPermissions,
11} from "@t3tools/contracts";
12
13import * as GitHubPullRequestCli from "./GitHubPullRequestCli.ts";
14import { PinnedGitHubCredential } from "../sourceControl/GitHubCli.ts";
15import {
16 PullRequestProviderError,
17 type PullRequestProviderFailure,
18 type ProviderChangeRequestActivity,
19 type ProviderChangeRequestDetail,
20 type PullRequestProviderApi,
21} from "./PullRequestProvider.ts";
22import type { GitHubViewerAccess, GitHubWorkflowRunApproval } from "./gitHubPullRequestJson.ts";
23
24const CAPABILITIES: PullRequestCapabilities = {
25 diff: true,
26 comment: true,
27 actions: [
28 "merge",
29 "ready",
30 "draft",
31 "close",
32 "reopen",
33 "update-branch",
34 "enable-auto-merge",
35 "disable-auto-merge",
36 "revert",
37 "approve-workflows",
38 ],
39 mergeMethods: ["merge", "squash", "rebase"],
40 updateMethods: ["merge", "rebase"],
41 search: true,
42 reactions: true,
43 review: {
44 inlineComment: true,
45 reply: true,
46 resolve: true,
47 verdicts: ["comment", "approve", "request-changes"],
48 },
49 reviewers: { request: true, listCandidates: true },
50 edit: { changeRequest: true, comment: true },
51 stacks: true,
52 stackActions: true,
53 labels: true,
54};
55
56/**
57 * What the signed-in account may do here, from the three things GitHub says about it.
58 *
59 * Merging needs a role that can push, which is the one thing a stranger on an open-source
60 * repository never has. The other four actions go by `viewerCanUpdate`, because the author of a
61 * pull request may close it, reopen it and move it in and out of draft with no more than read
62 * access on the repository it was opened against.
63 *
64 * Commenting and reviewing are not gated at all: read access is enough to say something and
65 * enough to approve or ask for changes, which is what open-source review consists of. Resolving a
66 * conversation is the exception — GitHub allows it to whoever can write, and to the author of the
67 * pull request the conversation is on.
68 *
69 * Asking somebody else for a review needs write access, which is the one thing here an author
70 * cannot do on their own pull request: GitHub shows an outside contributor the reviewer control
71 * and refuses the request behind it.
72 */
73export function gitHubViewerPermissions(access: GitHubViewerAccess): PullRequestViewerPermissions {
74 return {
75 ...(access.canWrite ? { stackRebase: true } : {}),
76 actions: [
77 // Arming a merge and taking the arming back are the merge, deferred: whoever may not
78 // merge here may not leave an instruction to merge later either.
79 ...(access.canWrite
80 ? ([
81 "merge",
82 "enable-auto-merge",
83 "disable-auto-merge",
84 "revert",
85 "approve-workflows",
86 ] as const)
87 : []),
88 ...(access.canUpdate ? (["ready", "draft", "close", "reopen"] as const) : []),
89 // Whether this viewer may update the branch is GitHub's own answer, read with the
90 // comparison; without it the action is offered to nobody rather than to everybody.
91 ...(access.canUpdateBranch === true ? (["update-branch"] as const) : []),
92 ],
93 comment: true,
94 resolve: access.canWrite || access.didAuthor,
95 // Anyone may review a pull request they can see, except their own: GitHub refuses an author's
96 // approval and their request for changes ("Can not approve your own pull request"), and
97 // leaves them commenting, which is what an author has to say about their own change anyway.
98 verdicts: access.didAuthor ? (["comment"] as const) : CAPABILITIES.review.verdicts,
99 requestReviewers: access.canWrite,
100 ...(access.canUpdateBranch === true ? { updateMethods: CAPABILITIES.updateMethods } : {}),
101 // Triage is the one role that labels without writing, which is what triage is for.
102 labels: access.canTriage,
103 };
104}
105
106/** The CLI tags that mean the tool itself is unusable, rather than one request failing. */
107export function gitHubProviderFailure(
108 error: GitHubPullRequestCli.GitHubPullRequestCliError,
109): PullRequestProviderFailure {
110 if (error._tag === "GitHubCliUnavailableError") return { reason: "missing-tool" };
111 if (error._tag === "GitHubCliAuthenticationError") return { reason: "unauthenticated" };
112 if (error._tag === "GitHubCliRateLimitError")
113 return {
114 reason: "rate-limited",
115 ...(error.retryAt === undefined ? {} : { retryAt: error.retryAt }),
116 };
117 if (error._tag === "SourceControlRateLimitPausedError") {
118 return { reason: "rate-limited", retryAt: error.retryAt };
119 }
120 return { reason: "failed" };
121}
122
123/**
124 * `gh pr view --json` reports no avatar for anyone, so the ones the GraphQL read collected are
125 * applied here by login. An actor already carrying one keeps it.
126 *
127 * A login GitHub did not answer for falls back to the picture every GitHub install serves at
128 * `/<login>.png`. The lookup is one more request per repository and can be refused — a rate
129 * limit, a slow host — and a face that comes and goes between two loads of the same page reads
130 * as a bug in the page rather than as a request that failed quietly.
131 */
132function withAvatar(
133 actor: PullRequestActor | null,
134 avatarsByLogin: ReadonlyMap<string, string>,
135 host: string,
136 botLogins?: ReadonlySet<string>,
137): PullRequestActor | null {
138 if (actor === null) return actor;
139 if (botLogins?.has(actor.login)) actor = { ...actor, isBot: true };
140 if (actor.avatarUrl !== null) return actor;
141 const avatarUrl = avatarsByLogin.get(actor.login) ?? loginAvatarUrl(actor.login, host);
142 return avatarUrl === null ? actor : { ...actor, avatarUrl };
143}
144
145function withWorkflowApprovals(
146 checks: ReadonlyArray<PullRequestCheck>,
147 runs: ReadonlyArray<GitHubWorkflowRunApproval>,
148 unavailable: boolean,
149): ReadonlyArray<PullRequestCheck> {
150 const representedRunIds = new Set<number>();
151 for (const check of checks) {
152 if (check.status !== "action-required" || check.url === null) continue;
153 const id = check.url.match(/\/actions\/runs\/(\d+)(?:\/|$)/)?.[1];
154 if (id !== undefined) representedRunIds.add(Number(id));
155 }
156 const approvalChecks = runs
157 .filter((run) => !representedRunIds.has(run.id))
158 .map((run): PullRequestCheck => ({
159 name: run.name,
160 status: "action-required",
161 description: "A maintainer must approve this workflow before it can run.",
162 url: run.url,
163 }));
164 return [
165 ...checks,
166 ...approvalChecks,
167 ...(unavailable
168 ? [
169 {
170 name: "Workflow approval status",
171 status: "action-required" as const,
172 description: "GitHub could not determine whether workflows are awaiting approval.",
173 url: null,
174 },
175 ]
176 : []),
177 ];
178}
179
180/**
181 * Null for anything that is not a plain user login: an app posts as `dependabot[bot]`, which
182 * names no page, and a guessed URL that 404s is worse than the initials it would replace.
183 */
184export function loginAvatarUrl(login: string, host: string): string | null {
185 return /^[a-z0-9][a-z0-9-]{0,38}$/iu.test(login) ? `https://${host}/${login}.png?size=80` : null;
186}
187
188/** True where markdown would render nothing: whitespace, or only HTML comments. */
189const rendersEmpty = (body: string): boolean =>
190 body.replace(/<!--[\s\S]*?-->/g, "").trim().length === 0;
191
192export const make = Effect.gen(function* () {
193 const cli = yield* GitHubPullRequestCli.GitHubPullRequestCli;
194
195 const repositoryAccessCache = yield* Cache.makeWith(
196 (key: string) => {
197 const [cwd, repository, host] = JSON.parse(key) as [string, string, string];
198 return cli.getRepositoryAccess({ cwd, repository, host });
199 },
200 {
201 capacity: 128,
202 timeToLive: (exit) => (Exit.isSuccess(exit) ? Duration.minutes(10) : Duration.zero),
203 },
204 );
205 const getRepositoryAccess = (input: {
206 readonly cwd: string;
207 readonly repository: string;
208 readonly host: string;
209 }) =>
210 PinnedGitHubCredential.pipe(
211 Effect.flatMap((credential) =>
212 Cache.get(
213 repositoryAccessCache,
214 JSON.stringify([
215 input.cwd,
216 input.repository,
217 input.host,
218 credential?.credentialFingerprint ?? null,
219 ]),
220 ),
221 ),
222 );
223
224 const fail = (operation: string) => (error: GitHubPullRequestCli.GitHubPullRequestCliError) =>
225 new PullRequestProviderError({
226 provider: "github",
227 operation,
228 ...gitHubProviderFailure(error),
229 detail: error.detail,
230 cause: error,
231 });
232
233 const provider: PullRequestProviderApi = {
234 kind: "github",
235 capabilities: CAPABILITIES,
236 getRoutingIdentity: (input) =>
237 cli.getRoutingIdentity(input).pipe(Effect.mapError(fail("routeIdentity"))),
238 withVerifiedCredential: (input, use) =>
239 cli
240 .withVerifiedCredential(input, (identity) => use(identity).pipe(Effect.result))
241 .pipe(Effect.mapError(fail("routeIdentity")), Effect.flatMap(Effect.fromResult)),
242
243 getViewer: (input) =>
244 cli
245 .getViewerLogin({ cwd: input.cwd, host: input.host ?? "github.com" })
246 .pipe(Effect.mapError(fail("getViewer"))),
247
248 listChangeRequests: (input) =>
249 cli
250 .listPullRequests({
251 cwd: input.cwd,
252 repository: input.repository,
253 host: input.host,
254 state: input.state,
255 involvement: input.involvement,
256 viewer: input.viewer,
257 limit: input.limit,
258 query: input.query,
259 cursor: input.cursor,
260 filters: input.filters,
261 })
262 .pipe(
263 Effect.mapError(fail("listChangeRequests")),
264 Effect.flatMap((page) =>
265 cli
266 .listActorAvatars({
267 cwd: input.cwd,
268 repository: input.repository,
269 host: input.host,
270 ids: [...new Set(page.items.flatMap((item) => item.authorId ?? []))],
271 })
272 // A listing without faces is still a listing, so a failed lookup falls back to
273 // the initials rather than taking the rows down with it.
274 .pipe(
275 Effect.orElseSucceed(() => new Map<string, string>()),
276 Effect.map((avatarsByLogin) => ({
277 ...page,
278 items: page.items.map((item) => ({
279 ...item,
280 author: withAvatar(item.author, avatarsByLogin, input.host),
281 })),
282 })),
283 ),
284 ),
285 ),
286
287 /**
288 * The same listing for a whole host in one search. The avatar lookup the per-repository read
289 * needs is not here: a search reports an author's picture itself, so a face costs no request
290 * of its own — `withAvatar` still stands behind it for the login GitHub answered nothing for.
291 */
292 listChangeRequestsAcross: (input) =>
293 cli
294 .searchPullRequests({
295 cwd: input.cwd,
296 host: input.host,
297 repositories: input.repositories,
298 state: input.state,
299 involvement: input.involvement,
300 viewer: input.viewer,
301 limit: input.limit,
302 query: input.query,
303 cursor: input.cursor,
304 filters: input.filters,
305 })
306 .pipe(
307 Effect.mapError(fail("listChangeRequestsAcross")),
308 Effect.map((batch) => ({
309 truncated: batch.truncated,
310 items: batch.items.map((item) => ({
311 ...item,
312 author: withAvatar(item.author, new Map<string, string>(), input.host),
313 })),
314 })),
315 ),
316
317 listChangeRequestStats: (input) =>
318 cli
319 .listPullRequestStats({
320 cwd: input.cwd,
321 host: input.host,
322 changeRequests: input.changeRequests,
323 })
324 .pipe(Effect.mapError(fail("listChangeRequestStats"))),
325
326 getChangeRequestSummary: (input) =>
327 cli.getPullRequestSummary(input).pipe(
328 // `gh pr view` names the author without an avatar; the login-shaped URL every user
329 // has stands in, without the second request the listing spends on it.
330 Effect.map((summary) => ({
331 ...summary,
332 ...(summary.author === undefined
333 ? {}
334 : { author: withAvatar(summary.author, new Map(), input.host) }),
335 })),
336 Effect.mapError(fail("getChangeRequestSummary")),
337 ),
338
339 getChangeRequestStack: (input) =>
340 cli.getPullRequestStack(input).pipe(Effect.mapError(fail("getChangeRequestStack"))),
341
342 getChangeRequest: (input) =>
343 Effect.all(
344 [
345 cli.getPullRequestDetail(input).pipe(
346 Effect.flatMap((pullRequest) =>
347 Effect.all({
348 // Only an open pull request can be behind anything worth saying so about, and
349 // only one whose head repository is known can be compared at all.
350 comparison:
351 pullRequest.state !== "open" || pullRequest.headRepositoryOwner === null
352 ? Effect.succeed(null)
353 : cli
354 .getPullRequestBaseComparison({
355 ...input,
356 headRef: `${pullRequest.headRepositoryOwner}:${pullRequest.headBranch}`,
357 })
358 .pipe(Effect.orElseSucceed(() => null)),
359 // GitHub omits a fork workflow that has not been approved from the normal check
360 // rollup. Read the action-required runs by head revision so "all passed" cannot
361 // be shown while a whole workflow is still waiting to start.
362 workflowApprovals:
363 pullRequest.state !== "open" || pullRequest.isCrossRepository !== true
364 ? Effect.succeed({
365 runs: [] as ReadonlyArray<GitHubWorkflowRunApproval>,
366 unavailable: false,
367 })
368 : pullRequest.headSha == null || pullRequest.headRepositoryOwner == null
369 ? Effect.succeed({
370 runs: [] as ReadonlyArray<GitHubWorkflowRunApproval>,
371 unavailable: true,
372 })
373 : cli
374 .listWorkflowRunsRequiringApproval({
375 ...input,
376 headSha: pullRequest.headSha,
377 headBranch: pullRequest.headBranch,
378 headRepositoryOwner: pullRequest.headRepositoryOwner,
379 isCrossRepository: true,
380 })
381 .pipe(
382 Effect.matchEffect({
383 onFailure: (error) =>
384 error._tag === "GitHubCliRateLimitError" ||
385 error._tag === "SourceControlRateLimitPausedError"
386 ? Effect.fail(error)
387 : Effect.succeed({
388 runs: [] as ReadonlyArray<GitHubWorkflowRunApproval>,
389 unavailable: true,
390 }),
391 onSuccess: (runs) => Effect.succeed({ runs, unavailable: false }),
392 }),
393 ),
394 }).pipe(Effect.map((extra) => ({ pullRequest, ...extra }))),
395 ),
396 ),
397 getRepositoryAccess({
398 cwd: input.cwd,
399 repository: input.repository,
400 host: input.host,
401 }),
402 // A small permissions query replaces the deeply paginated review-thread walk on the
403 // core path. Writes ask again immediately before mutating, so this is presentation.
404 cli.getViewerAccess(input),
405 ],
406 { concurrency: 3 },
407 ).pipe(
408 Effect.mapError(fail("getChangeRequest")),
409 Effect.map(([detail, repository, viewerAccess]): ProviderChangeRequestDetail => ({
410 ...detail.pullRequest,
411 author: withAvatar(detail.pullRequest.author, new Map<string, string>(), input.host),
412 checks: withWorkflowApprovals(
413 detail.pullRequest.checks,
414 detail.workflowApprovals.runs,
415 detail.workflowApprovals.unavailable,
416 ),
417 ...(detail.workflowApprovals.unavailable
418 ? {}
419 : { workflowApprovalsRequired: detail.workflowApprovals.runs.length }),
420 reviewers: detail.pullRequest.reviewRequestLogins.map((login) => ({
421 login,
422 name: null,
423 avatarUrl: null,
424 })),
425 mergeCapabilities: repository.mergeCapabilities,
426 viewerPermissions: gitHubViewerPermissions({
427 ...viewerAccess,
428 canUpdateBranch: detail.comparison?.viewerCanUpdate === true,
429 }),
430 baseComparison:
431 detail.comparison === null || detail.comparison.behindBy === null
432 ? "unknown"
433 : detail.comparison.behindBy > 0
434 ? "behind"
435 : "up-to-date",
436 ...(detail.comparison?.behindBy == null ? {} : { behindBy: detail.comparison.behindBy }),
437 })),
438 ),
439
440 getChangeRequestActivity: (input) =>
441 Effect.all(
442 [
443 cli.getPullRequestActivity(input),
444 // Line comments live on review threads, which `gh pr view --json` cannot reach. A
445 // GraphQL hiccup degrades to a truncated conversation rather than blanking activity.
446 cli.listReviewThreadComments(input).pipe(
447 Effect.orElseSucceed(() => ({
448 comments: [],
449 dismissalsByReviewId: new Map<string, string>(),
450 reactions: [],
451 reactionsById: new Map<string, ReadonlyArray<PullRequestReaction>>(),
452 reviewThreads: [],
453 commentCount: 0,
454 truncated: true,
455 reviewers: [],
456 avatarsByLogin: new Map<string, string>(),
457 botLogins: new Set<string>(),
458 commitStats: new Map<
459 string,
460 { readonly additions: number; readonly deletions: number }
461 >(),
462 commits: [],
463 viewer: { canUpdate: true, didAuthor: false },
464 })),
465 ),
466 ],
467 { concurrency: 2 },
468 ).pipe(
469 Effect.mapError(fail("getChangeRequestActivity")),
470 Effect.map(([pullRequest, reviewThreads]): ProviderChangeRequestActivity => ({
471 author: withAvatar(
472 pullRequest.author,
473 reviewThreads.avatarsByLogin,
474 input.host,
475 reviewThreads.botLogins,
476 ),
477 reviewers: reviewThreads.reviewers,
478 reactions: reviewThreads.reactions,
479 commits: (reviewThreads.commits.length > 0
480 ? reviewThreads.commits
481 : pullRequest.commits
482 ).map((commit) => ({
483 ...commit,
484 ...reviewThreads.commitStats.get(commit.oid),
485 authors: commit.authors?.map(
486 (author) =>
487 withAvatar(
488 author,
489 reviewThreads.avatarsByLogin,
490 input.host,
491 reviewThreads.botLogins,
492 ) ?? author,
493 ),
494 })),
495 comments: [...pullRequest.comments, ...reviewThreads.comments]
496 .map((comment) => ({
497 ...comment,
498 // GitHub keeps the dismissal reason on the timeline event, not on the review,
499 // so a dismissed review with nothing visible of its own reads its words from
500 // there. "Visible" and not "empty": bot reviews often carry only an HTML
501 // marker comment, which markdown renders as nothing.
502 body:
503 comment.kind === "review" &&
504 comment.reviewState?.toUpperCase() === "DISMISSED" &&
505 rendersEmpty(comment.body)
506 ? (reviewThreads.dismissalsByReviewId.get(comment.id) ?? comment.body)
507 : comment.body,
508 author: withAvatar(
509 comment.author,
510 reviewThreads.avatarsByLogin,
511 input.host,
512 reviewThreads.botLogins,
513 ),
514 // A comment out of `gh pr view --json` carries none of its own: that read
515 // reports no reaction at all, so they arrive from the GraphQL page by node id.
516 reactions: comment.reactions ?? reviewThreads.reactionsById.get(comment.id) ?? [],
517 }))
518 .toSorted((left, right) => left.createdAt.localeCompare(right.createdAt)),
519 // `gh pr view --json comments,reviews` follows GitHub's cursors itself, so those two
520 // are always whole and only the thread walk can stop short of the host.
521 commentCount: pullRequest.comments.length + reviewThreads.commentCount,
522 commentsTruncated: reviewThreads.truncated,
523 reviewThreads: reviewThreads.reviewThreads.map((thread) => ({
524 ...thread,
525 comments: thread.comments.map((comment) => ({
526 ...comment,
527 author: withAvatar(
528 comment.author,
529 reviewThreads.avatarsByLogin,
530 input.host,
531 reviewThreads.botLogins,
532 ),
533 })),
534 })),
535 })),
536 ),
537
538 getReviewThreadComments: (input) =>
539 cli.getReviewThreadComments(input).pipe(Effect.mapError(fail("getReviewThreadComments"))),
540
541 getViewerPermissions: (input) =>
542 Effect.all(
543 [
544 cli.getViewerAccess({ ...input, allowReserve: true }),
545 // Whether this viewer may update the branch is only on the comparison, and the
546 // comparison only resolves through the head ref the detail carries. A failure here
547 // withholds that one action rather than the whole answer, the way the detail path
548 // leaves the banner unknown.
549 input.includeUpdateBranch === false
550 ? Effect.succeed(false)
551 : cli.getPullRequestDetail(input).pipe(
552 Effect.flatMap((pullRequest) =>
553 pullRequest.state !== "open" || pullRequest.headRepositoryOwner === null
554 ? Effect.succeed(false)
555 : cli
556 .getPullRequestBaseComparison({
557 ...input,
558 headRef: `${pullRequest.headRepositoryOwner}:${pullRequest.headBranch}`,
559 allowReserve: true,
560 })
561 .pipe(Effect.map((comparison) => comparison.viewerCanUpdate === true)),
562 ),
563 Effect.orElseSucceed(() => false),
564 ),
565 ],
566 { concurrency: 2 },
567 ).pipe(
568 Effect.mapError(fail("getViewerPermissions")),
569 Effect.map(([access, canUpdateBranch]) =>
570 gitHubViewerPermissions({ ...access, canUpdateBranch }),
571 ),
572 ),
573
574 getDiff: (input) => cli.getPullRequestDiff(input).pipe(Effect.mapError(fail("getDiff"))),
575
576 getDiffFileContents: (input) =>
577 cli.getPullRequestDiffFileContents(input).pipe(Effect.mapError(fail("getDiffFileContents"))),
578
579 listReviewerCandidates: (input) =>
580 cli.listReviewerCandidates(input).pipe(Effect.mapError(fail("listReviewerCandidates"))),
581
582 setReviewerRequest: (input) =>
583 cli
584 .setReviewerRequest({
585 cwd: input.cwd,
586 repository: input.repository,
587 host: input.host,
588 number: input.number,
589 reviewers: input.reviewers,
590 requested: input.requested,
591 })
592 .pipe(Effect.mapError(fail("setReviewerRequest"))),
593
594 listLabelCandidates: (input) =>
595 cli.listLabelCandidates(input).pipe(Effect.mapError(fail("listLabelCandidates"))),
596
597 setLabels: (input) =>
598 cli
599 .setLabels({
600 cwd: input.cwd,
601 repository: input.repository,
602 host: input.host,
603 number: input.number,
604 labels: input.labels,
605 applied: input.applied,
606 })
607 .pipe(Effect.mapError(fail("setLabels"))),
608
609 runAction: (input) =>
610 cli
611 .runPullRequestAction({
612 cwd: input.cwd,
613 repository: input.repository,
614 host: input.host,
615 number: input.number,
616 action: input.action,
617 ...(input.stackNumber === undefined ? {} : { stackNumber: input.stackNumber }),
618 ...(input.expectedStackHeads === undefined
619 ? {}
620 : { expectedStackHeads: input.expectedStackHeads }),
621 ...(input.mergeMethod === undefined ? {} : { mergeMethod: input.mergeMethod }),
622 ...(input.updateMethod === undefined ? {} : { updateMethod: input.updateMethod }),
623 })
624 .pipe(Effect.mapError(fail("runAction"))),
625
626 updateChangeRequest: (input) =>
627 cli
628 .updatePullRequest({
629 cwd: input.cwd,
630 repository: input.repository,
631 host: input.host,
632 number: input.number,
633 ...(input.title === undefined ? {} : { title: input.title }),
634 ...(input.body === undefined ? {} : { body: input.body }),
635 })
636 .pipe(Effect.mapError(fail("updateChangeRequest"))),
637
638 comment: (input) => cli.commentOnPullRequest(input).pipe(Effect.mapError(fail("comment"))),
639
640 updateComment: (input) =>
641 cli
642 .updateComment({
643 cwd: input.cwd,
644 repository: input.repository,
645 host: input.host,
646 number: input.number,
647 commentId: input.commentId,
648 kind: input.kind,
649 body: input.body,
650 })
651 .pipe(Effect.mapError(fail("updateComment"))),
652
653 submitReview: (input) => cli.submitReview(input).pipe(Effect.mapError(fail("submitReview"))),
654
655 replyToThread: (input) =>
656 cli
657 .replyToReviewThread({
658 cwd: input.cwd,
659 repository: input.repository,
660 host: input.host,
661 threadId: input.threadId,
662 body: input.body,
663 })
664 .pipe(Effect.mapError(fail("replyToThread"))),
665
666 setReaction: (input) =>
667 cli
668 .setReaction({
669 cwd: input.cwd,
670 repository: input.repository,
671 host: input.host,
672 number: input.number,
673 ...(input.subjectId === undefined ? {} : { subjectId: input.subjectId }),
674 content: input.content,
675 reacted: input.reacted,
676 })
677 .pipe(Effect.mapError(fail("setReaction"))),
678
679 setThreadResolution: (input) =>
680 cli
681 .setReviewThreadResolution({
682 cwd: input.cwd,
683 repository: input.repository,
684 host: input.host,
685 threadId: input.threadId,
686 resolved: input.resolved,
687 })
688 .pipe(Effect.mapError(fail("setThreadResolution"))),
689 };
690
691 return provider;
692});