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

GitHubPullRequestProvider.ts

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