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

GitHubPullRequestProvider.ts

668 lines25.5 KB

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