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

GitHubPullRequestProvider.ts

699 lines26.8 KB

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