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

GitHubPullRequestProvider.ts

672 lines25.2 KB

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