Open History to see the last commit
1import { removeAgentCredits } from "@t3tools/source-control-core/server/mergeMessage";
2import * as Effect from "effect/Effect";
3import type {
4 PullRequestActor,
5 PullRequestCapabilities,
6 PullRequestCheck,
7 PullRequestReaction,
8 PullRequestViewerPermissions,
9} from "@t3tools/contracts";
10
11import * as SourceControlRateLimit from "@t3tools/source-control-core/server/SourceControlRateLimit";
12import * as GitHubPullRequestApi from "./GitHubPullRequestApi.ts";
13import {
14 PullRequestProviderError,
15 type PullRequestProviderFailure,
16 type ProviderChangeRequestActivity,
17 type ProviderChangeRequestDetail,
18 type PullRequestProviderApi,
19 type ProviderRepositoryRef,
20} from "@t3tools/source-control-core/server/PullRequestProvider";
21import type { GitHubViewerAccess, GitHubWorkflowRunApproval } from "./gitHubPullRequestJson.ts";
22
23const CAPABILITIES: PullRequestCapabilities = {
24 diff: true,
25 comment: true,
26 actions: [
27 "merge",
28 "ready",
29 "draft",
30 "close",
31 "reopen",
32 "update-branch",
33 "enable-auto-merge",
34 "disable-auto-merge",
35 "revert",
36 "approve-workflows",
37 ],
38 mergeMethods: ["merge", "squash", "rebase"],
39 updateMethods: ["merge", "rebase"],
40 search: true,
41 reactions: true,
42 viewedFiles: "host",
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 };
104}
105
106/** The tags that mean GitHub is out of reach for this account, rather than one request failing. */
107export function gitHubProviderFailure(
108 error: GitHubPullRequestApi.GitHubPullRequestApiError,
109): PullRequestProviderFailure {
110 switch (error._tag) {
111 case "GitHubCliMissingError":
112 return { reason: "missing-tool" };
113 case "GitHubNotSignedInError":
114 case "GitHubHostDisabledError":
115 case "GitHubApiAuthenticationError":
116 return { reason: "unauthenticated" };
117 case "GitHubApiRateLimitError":
118 return {
119 reason: "rate-limited",
120 ...(error.retryAt === undefined ? {} : { retryAt: error.retryAt }),
121 };
122 case "SourceControlRateLimitPausedError":
123 return { reason: "rate-limited", retryAt: error.retryAt };
124 case "GitHubApiNotFoundError":
125 return { reason: "not-found" };
126 default:
127 return { reason: "failed" };
128 }
129}
130
131/**
132 * `gh pr view --json` reports no avatar for anyone, so the ones the GraphQL read collected are
133 * applied here by login. An actor already carrying one keeps it.
134 *
135 * A login GitHub did not answer for falls back to the picture every GitHub install serves at
136 * `/<login>.png`. The lookup is one more request per repository and can be refused — a rate
137 * limit, a slow host — and a face that comes and goes between two loads of the same page reads
138 * as a bug in the page rather than as a request that failed quietly.
139 */
140function withAvatar(
141 actor: PullRequestActor | null,
142 avatarsByLogin: ReadonlyMap<string, string>,
143 host: string,
144 botLogins?: ReadonlySet<string>,
145): PullRequestActor | null {
146 if (actor === null) return actor;
147 if (botLogins?.has(actor.login)) actor = { ...actor, isBot: true };
148 if (actor.avatarUrl !== null) return actor;
149 const avatarUrl = avatarsByLogin.get(actor.login) ?? loginAvatarUrl(actor.login, host);
150 return avatarUrl === null ? actor : { ...actor, avatarUrl };
151}
152
153function withWorkflowApprovals(
154 checks: ReadonlyArray<PullRequestCheck>,
155 runs: ReadonlyArray<GitHubWorkflowRunApproval>,
156 unavailable: boolean,
157): ReadonlyArray<PullRequestCheck> {
158 const representedRunIds = new Set<number>();
159 for (const check of checks) {
160 if (check.status !== "action-required" || check.url === null) continue;
161 const id = check.url.match(/\/actions\/runs\/(\d+)(?:\/|$)/)?.[1];
162 if (id !== undefined) representedRunIds.add(Number(id));
163 }
164 const approvalChecks = runs
165 .filter((run) => !representedRunIds.has(run.id))
166 .map((run): PullRequestCheck => ({
167 name: run.name,
168 status: "action-required",
169 description: "A maintainer must approve this workflow before it can run.",
170 url: run.url,
171 }));
172 return [
173 ...checks,
174 ...approvalChecks,
175 ...(unavailable
176 ? [
177 {
178 name: "Workflow approval status",
179 status: "action-required" as const,
180 description: "GitHub could not determine whether workflows are awaiting approval.",
181 url: null,
182 },
183 ]
184 : []),
185 ];
186}
187
188/**
189 * Null for anything that is not a plain user login: an app posts as `dependabot[bot]`, which
190 * names no page, and a guessed URL that 404s is worse than the initials it would replace.
191 */
192export function loginAvatarUrl(login: string, host: string): string | null {
193 return /^[a-z0-9][a-z0-9-]{0,38}$/iu.test(login) ? `https://${host}/${login}.png?size=80` : null;
194}
195
196/** True where markdown would render nothing: whitespace, or only HTML comments. */
197const rendersEmpty = (body: string): boolean =>
198 body.replace(/<!--[\s\S]*?-->/g, "").trim().length === 0;
199
200export const make = Effect.gen(function* () {
201 const cli = yield* GitHubPullRequestApi.GitHubPullRequestApi;
202
203 const fail = (operation: string) => (error: GitHubPullRequestApi.GitHubPullRequestApiError) =>
204 new PullRequestProviderError({
205 provider: "github",
206 operation,
207 ...gitHubProviderFailure(error),
208 detail: error.message,
209 cause: error,
210 });
211
212 const readChecks = (input: ProviderRepositoryRef & { readonly number: number }) =>
213 cli.getPullRequestDetail(input).pipe(
214 Effect.flatMap((pullRequest) =>
215 (pullRequest.state !== "open" || pullRequest.isCrossRepository !== true
216 ? Effect.succeed({
217 runs: [] as ReadonlyArray<GitHubWorkflowRunApproval>,
218 unavailable: false,
219 })
220 : pullRequest.headSha == null || pullRequest.headRepositoryOwner == null
221 ? Effect.succeed({
222 runs: [] as ReadonlyArray<GitHubWorkflowRunApproval>,
223 unavailable: true,
224 })
225 : cli
226 .listWorkflowRunsRequiringApproval({
227 ...input,
228 headSha: pullRequest.headSha,
229 headBranch: pullRequest.headBranch,
230 headRepositoryOwner: pullRequest.headRepositoryOwner,
231 isCrossRepository: true,
232 })
233 .pipe(
234 Effect.matchEffect({
235 onFailure: (error) =>
236 error._tag === "GitHubApiRateLimitError" ||
237 error._tag === "SourceControlRateLimitPausedError"
238 ? Effect.fail(error)
239 : Effect.succeed({
240 runs: [] as ReadonlyArray<GitHubWorkflowRunApproval>,
241 unavailable: true,
242 }),
243 onSuccess: (runs) => Effect.succeed({ runs, unavailable: false }),
244 }),
245 )
246 ).pipe(
247 Effect.map((workflowApprovals) => ({
248 ...pullRequest,
249 author: withAvatar(pullRequest.author, new Map(), input.host),
250 checks: withWorkflowApprovals(
251 pullRequest.checks,
252 workflowApprovals.runs,
253 workflowApprovals.unavailable,
254 ),
255 ...(workflowApprovals.unavailable
256 ? {}
257 : { workflowApprovalsRequired: workflowApprovals.runs.length }),
258 })),
259 ),
260 ),
261 );
262
263 const provider: PullRequestProviderApi = {
264 kind: "github",
265 capabilities: CAPABILITIES,
266 mergeMessageRewrite: removeAgentCredits,
267 getRoutingIdentity: (input) =>
268 cli.getRoutingIdentity(input).pipe(Effect.mapError(fail("routeIdentity"))),
269 withVerifiedCredential: (input, use) =>
270 cli
271 .withVerifiedCredential(input, (identity) => use(identity).pipe(Effect.result))
272 .pipe(Effect.mapError(fail("routeIdentity")), Effect.flatMap(Effect.fromResult)),
273
274 getViewer: (input) =>
275 cli
276 .getViewerLogin({ cwd: input.cwd, host: input.host ?? "github.com" })
277 .pipe(Effect.mapError(fail("getViewer"))),
278
279 listChangeRequests: (input) =>
280 cli
281 .listPullRequests({
282 cwd: input.cwd,
283 repository: input.repository,
284 host: input.host,
285 state: input.state,
286 involvement: input.involvement,
287 viewer: input.viewer,
288 limit: input.limit,
289 query: input.query,
290 cursor: input.cursor,
291 filters: input.filters,
292 })
293 .pipe(
294 Effect.mapError(fail("listChangeRequests")),
295 Effect.flatMap((page) =>
296 cli
297 .listActorAvatars({
298 cwd: input.cwd,
299 repository: input.repository,
300 host: input.host,
301 ids: [...new Set(page.items.flatMap((item) => item.authorId ?? []))],
302 })
303 // A listing without faces is still a listing, so a failed lookup falls back to
304 // the initials rather than taking the rows down with it.
305 .pipe(
306 Effect.orElseSucceed(() => new Map<string, string>()),
307 Effect.map((avatarsByLogin) => ({
308 ...page,
309 items: page.items.map((item) => ({
310 ...item,
311 author: withAvatar(item.author, avatarsByLogin, input.host),
312 })),
313 })),
314 ),
315 ),
316 ),
317
318 /**
319 * The same listing for a whole host in one search. The avatar lookup the per-repository read
320 * needs is not here: a search reports an author's picture itself, so a face costs no request
321 * of its own — `withAvatar` still stands behind it for the login GitHub answered nothing for.
322 */
323 listChangeRequestsAcross: (input) =>
324 cli
325 .searchPullRequests({
326 cwd: input.cwd,
327 host: input.host,
328 repositories: input.repositories,
329 state: input.state,
330 involvement: input.involvement,
331 viewer: input.viewer,
332 limit: input.limit,
333 query: input.query,
334 cursor: input.cursor,
335 filters: input.filters,
336 })
337 .pipe(
338 Effect.mapError(fail("listChangeRequestsAcross")),
339 Effect.map((batch) => ({
340 truncated: batch.truncated,
341 items: batch.items.map((item) => ({
342 ...item,
343 author: withAvatar(item.author, new Map<string, string>(), input.host),
344 })),
345 })),
346 ),
347
348 listChangeRequestStats: (input) =>
349 cli
350 .listPullRequestStats({
351 cwd: input.cwd,
352 host: input.host,
353 changeRequests: input.changeRequests,
354 })
355 .pipe(Effect.mapError(fail("listChangeRequestStats"))),
356
357 getChangeRequestSummary: (input) =>
358 cli.getPullRequestSummary(input).pipe(
359 // `gh pr view` names the author without an avatar; the login-shaped URL every user
360 // has stands in, without the second request the listing spends on it.
361 Effect.map((summary) => ({
362 ...summary,
363 ...(summary.author === undefined
364 ? {}
365 : { author: withAvatar(summary.author, new Map(), input.host) }),
366 })),
367 Effect.mapError(fail("getChangeRequestSummary")),
368 ),
369
370 getChangeRequestStack: (input) =>
371 cli.getPullRequestStack(input).pipe(Effect.mapError(fail("getChangeRequestStack"))),
372
373 getChangeRequestWatchFingerprint: (input) =>
374 cli
375 .getPullRequestWatchFingerprint(input)
376 .pipe(Effect.mapError(fail("getChangeRequestWatchFingerprint"))),
377
378 getChangeRequestPreview: (input) =>
379 cli.getPullRequestPreview(input).pipe(Effect.mapError(fail("getChangeRequestPreview"))),
380
381 getChangeRequestChecks: (input) =>
382 cli.revalidateChecks(input, readChecks(input)).pipe(
383 Effect.map(({ state, checks }) => ({ state, checks })),
384 Effect.mapError(fail("getChangeRequestChecks")),
385 ),
386
387 getChangeRequest: (input) =>
388 readChecks(input).pipe(
389 Effect.map((pullRequest): ProviderChangeRequestDetail => ({
390 ...pullRequest,
391 author: withAvatar(pullRequest.author, new Map<string, string>(), input.host),
392 reviewers: pullRequest.reviewRequestLogins.map((login) => ({
393 login,
394 name: null,
395 avatarUrl: null,
396 })),
397 mergeCapabilities: pullRequest.viewerAccess.mergeCapabilities,
398 viewerPermissions: gitHubViewerPermissions({
399 ...pullRequest.viewerAccess,
400 canUpdateBranch: pullRequest.comparison?.viewerCanUpdate === true,
401 }),
402 baseComparison:
403 pullRequest.comparison === null || pullRequest.comparison.behindBy === null
404 ? "unknown"
405 : pullRequest.comparison.behindBy > 0
406 ? "behind"
407 : "up-to-date",
408 ...(pullRequest.comparison?.behindBy == null
409 ? {}
410 : { behindBy: pullRequest.comparison.behindBy }),
411 })),
412 Effect.mapError(fail("getChangeRequest")),
413 ),
414
415 getChangeRequestActivity: (input) =>
416 Effect.all(
417 [
418 cli.getPullRequestActivity(input),
419 // Line comments live on review threads, which `gh pr view --json` cannot reach. A
420 // GraphQL hiccup degrades to a truncated conversation rather than blanking activity.
421 cli.listReviewThreadComments(input).pipe(
422 Effect.orElseSucceed(() => ({
423 comments: [],
424 dismissalsByReviewId: new Map<string, string>(),
425 reactions: [],
426 reactionsById: new Map<string, ReadonlyArray<PullRequestReaction>>(),
427 editedAtById: new Map<string, string>(),
428 reviewThreads: [],
429 commentCount: 0,
430 truncated: true,
431 reviewThreadsTruncated: true,
432 reviewers: [],
433 avatarsByLogin: new Map<string, string>(),
434 botLogins: new Set<string>(),
435 commitStats: new Map<
436 string,
437 { readonly additions: number; readonly deletions: number }
438 >(),
439 commits: [],
440 viewer: { canUpdate: true, didAuthor: false },
441 })),
442 ),
443 ],
444 { concurrency: 2 },
445 ).pipe(
446 Effect.mapError(fail("getChangeRequestActivity")),
447 Effect.map(([pullRequest, reviewThreads]): ProviderChangeRequestActivity => ({
448 author: withAvatar(
449 pullRequest.author,
450 reviewThreads.avatarsByLogin,
451 input.host,
452 reviewThreads.botLogins,
453 ),
454 reviewers: reviewThreads.reviewers,
455 reactions: reviewThreads.reactions,
456 commits: (reviewThreads.commits.length > 0
457 ? reviewThreads.commits
458 : pullRequest.commits
459 ).map((commit) => ({
460 ...commit,
461 ...reviewThreads.commitStats.get(commit.oid),
462 authors: commit.authors?.map(
463 (author) =>
464 withAvatar(
465 author,
466 reviewThreads.avatarsByLogin,
467 input.host,
468 reviewThreads.botLogins,
469 ) ?? author,
470 ),
471 })),
472 comments: [...pullRequest.comments, ...reviewThreads.comments]
473 .map((comment) => ({
474 ...comment,
475 // GitHub keeps the dismissal reason on the timeline event, not on the review,
476 // so a dismissed review with nothing visible of its own reads its words from
477 // there. "Visible" and not "empty": bot reviews often carry only an HTML
478 // marker comment, which markdown renders as nothing.
479 body:
480 comment.kind === "review" &&
481 comment.reviewState?.toUpperCase() === "DISMISSED" &&
482 rendersEmpty(comment.body)
483 ? (reviewThreads.dismissalsByReviewId.get(comment.id) ?? comment.body)
484 : comment.body,
485 author: withAvatar(
486 comment.author,
487 reviewThreads.avatarsByLogin,
488 input.host,
489 reviewThreads.botLogins,
490 ),
491 // A comment out of `gh pr view --json` carries none of its own: that read
492 // reports no reaction at all, so they arrive from the GraphQL page by node id.
493 reactions: comment.reactions ?? reviewThreads.reactionsById.get(comment.id) ?? [],
494 editedAt: reviewThreads.editedAtById.get(comment.id) ?? comment.editedAt ?? null,
495 }))
496 .toSorted((left, right) => left.createdAt.localeCompare(right.createdAt)),
497 // `gh pr view --json comments,reviews` follows GitHub's cursors itself, so those two
498 // are always whole and only the thread walk can stop short of the host.
499 commentCount: pullRequest.comments.length + reviewThreads.commentCount,
500 commentsTruncated: reviewThreads.truncated,
501 reviewThreadsTruncated: reviewThreads.reviewThreadsTruncated,
502 reviewThreads: reviewThreads.reviewThreads.map((thread) => ({
503 ...thread,
504 comments: thread.comments.map((comment) => ({
505 ...comment,
506 author: withAvatar(
507 comment.author,
508 reviewThreads.avatarsByLogin,
509 input.host,
510 reviewThreads.botLogins,
511 ),
512 })),
513 })),
514 })),
515 ),
516
517 getReviewThreadComments: (input) =>
518 cli.getReviewThreadComments(input).pipe(Effect.mapError(fail("getReviewThreadComments"))),
519
520 getViewerPermissions: (input) => {
521 const lightAccess = cli
522 .getViewerAccess({ ...input, allowReserve: true })
523 .pipe(Effect.map((access) => gitHubViewerPermissions(access)));
524 if (input.includeUpdateBranch === false) {
525 return lightAccess.pipe(Effect.mapError(fail("getViewerPermissions")));
526 }
527 // The core detail already carries the viewer's access, the merge settings, and the base
528 // comparison, so one read usually answers what used to take three. When that heavier read
529 // fails, the light access read still answers, withholding only update-branch.
530 return cli.getPullRequestDetail(input).pipe(
531 Effect.provideService(SourceControlRateLimit.Interactive, true),
532 Effect.map((pullRequest) =>
533 gitHubViewerPermissions({
534 ...pullRequest.viewerAccess,
535 canUpdateBranch:
536 pullRequest.state === "open" && pullRequest.comparison?.viewerCanUpdate === true,
537 }),
538 ),
539 Effect.catchIf(
540 (error) =>
541 error._tag !== "GitHubApiRateLimitError" &&
542 error._tag !== "SourceControlRateLimitPausedError",
543 () => lightAccess,
544 ),
545 Effect.mapError(fail("getViewerPermissions")),
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});