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

GitHubPullRequestProvider.ts

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