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