@devries-cameron20 / t3code Mirror · read-only / commits / 6e3c5e67f6
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 19:30 UTC

feat(gitcafe): request reviewers and apply labels on GitCafe pull requests (#23034)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 21, 2026 at 21:23 UTC 6e3c5e67f636f29efaa5abf6add908abc4505bcb
4 files changed +354 -24
docs/user/source-control.md
+1 -1
@@ -116,7 +116,7 @@ kept in the server's secret store, applies right away, and is used before `CAFE_
116 sent to `git.cafe`; `CAFE_TOKEN` follows `CAFE_HOST` if you set it. Repositories on
117 `staging.git.cafe` need their own login with `--host https://staging.git.cafe/api`.
118
119 -Line comments, reviewer requests, and labels are not available for GitCafe pull requests yet.
119 +Line comments are not available for GitCafe pull requests yet.
120 Merging a stack lands it through GitCafe, and updating a branch restacks the layers above it.
121
122 ## Start, clone, or publish a project
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.test.ts
+157 -7
@@ -52,9 +52,11 @@ function fakeGitCafe(
52 const response =
53 route === undefined
54 ? new Response(encodeJson({ type: "https://cafe.sh/errors/not-found" }), { status: 404 })
55 - : new Response(encodeJson(typeof route === "function" ? route(entry) : route), {
56 - status: options.status ?? 200,
57 - });
55 + : route instanceof Response
56 + ? route
57 + : new Response(encodeJson(typeof route === "function" ? route(entry) : route), {
58 + status: options.status ?? 200,
59 + });
60 return Effect.succeed(HttpClientResponse.fromWeb(request, response));
61 },
62 );
@@ -104,6 +106,10 @@ const pull = {
106 sourceRepo: null,
107 capabilities: { comment: true, review: true, merge: true, edit: true, moderate: true },
108 };
109 +const labels = [
110 + { id: "label_bug", name: "bug", color: "#d73a4a", description: null },
111 + { id: "label_docs", name: "docs", color: "#0075ca", description: "Documentation" },
112 +];
113 const root = {
114 id: "root",
115 threadId: "root",
@@ -439,16 +445,18 @@ describe("GitCafePullRequestProvider", () => {
445 },
446 );
447
442 - it.effect("reads line counts, open merge strategies and requested reviewers", () => {
448 + it.effect("reads line counts, open merge strategies, reviewers and labels", () => {
449 const snapshot = { version: 4, headOid, comparisonBaseOid: baseOid };
450 const files = (from: number, count: number) =>
451 Array.from({ length: count }, (_, index) => ({ path: `f${from + index}.ts` }));
452 let changePage = 0;
453 const server = fakeGitCafe({
448 - "GET /repos/owner/repo/pulls/7": { ...pull, reviewers: [{ actor }] },
454 + "GET /repos/owner/repo/pulls/7": pull,
455 + "GET /repos/owner/repo/pulls/7/reviewers": { items: [{ id: "act_one", actor }], next: null },
456 + "GET /repos/owner/repo/pulls/7/labels": { items: [labels[0]], next: null },
457 "GET /repos/owner/repo/pulls/7/status": {
458 merge: {
451 - conflicts: "unknown",
459 + conflicts: "none",
460 fastForward: true,
461 strategies: ["merge", "squash", "rebase"],
462 blockers: [{ blockedStrategies: ["squash"] }, {}],
@@ -483,7 +491,12 @@ describe("GitCafePullRequestProvider", () => {
491 return Effect.gen(function* () {
492 const provider = yield* GitCafePullRequestProvider.make;
493 const detail = yield* provider.getChangeRequest(target);
486 - assert.deepInclude(detail, { additions: 6, deletions: 3, changedFiles: 3 });
494 + assert.deepInclude(detail, {
495 + additions: 6,
496 + deletions: 3,
497 + changedFiles: 3,
498 + mergeability: "mergeable",
499 + });
500 assert.strictEqual(
501 server.sent.filter((request) => request.path.endsWith("/changes"))[1]?.query.get("after"),
502 "cursor-1",
@@ -501,6 +514,143 @@ describe("GitCafePullRequestProvider", () => {
514 detail.reviewers.map((reviewer) => reviewer.login),
515 ["alice"],
516 );
517 + assert.deepStrictEqual(detail.reviewRequestLogins, ["alice"]);
518 + assert.deepStrictEqual(detail.labels, [{ name: "bug", color: "#d73a4a" }]);
519 + }).pipe(Effect.provide(server.layer));
520 + });
521 +
522 + it.effect("still reads a pull request whose reviewers the token may not see", () => {
523 + const server = fakeGitCafe({
524 + "GET /repos/owner/repo/pulls/7": { ...pull, headOid: null },
525 + "GET /repos/owner/repo/pulls/7/reviewers": new Response(
526 + encodeJson({ type: "https://cafe.sh/errors/forbidden" }),
527 + { status: 403 },
528 + ),
529 + "GET /repos/owner/repo/pulls/7/labels": { items: [labels[0]], next: null },
530 + "GET /repos/owner/repo/pulls/7/status": {
531 + merge: { conflicts: "unknown", fastForward: null, strategies: [] },
532 + checks: { pending: 0, failing: 0, total: 0 },
533 + },
534 + });
535 + return Effect.gen(function* () {
536 + const provider = yield* GitCafePullRequestProvider.make;
537 + const detail = yield* provider.getChangeRequest(target);
538 + assert.deepStrictEqual(detail.reviewers, []);
539 + assert.deepStrictEqual(detail.labels, [{ name: "bug", color: "#d73a4a" }]);
540 + }).pipe(Effect.provide(server.layer));
541 + });
542 +
543 + it.effect("fails the detail rather than hide reviewers GitCafe could not serve", () => {
544 + const server = fakeGitCafe({
545 + "GET /repos/owner/repo/pulls/7": { ...pull, headOid: null },
546 + "GET /repos/owner/repo/pulls/7/reviewers": new Response("", { status: 503 }),
547 + "GET /repos/owner/repo/pulls/7/labels": { items: [], next: null },
548 + "GET /repos/owner/repo/pulls/7/status": {
549 + merge: { conflicts: "unknown", fastForward: null, strategies: [] },
550 + checks: { pending: 0, failing: 0, total: 0 },
551 + },
552 + });
553 + return Effect.gen(function* () {
554 + const provider = yield* GitCafePullRequestProvider.make;
555 + const result = yield* provider.getChangeRequest(target).pipe(Effect.result);
556 + assert.strictEqual(result._tag, "Failure");
557 + }).pipe(Effect.provide(server.layer));
558 + });
559 +
560 + it.effect("requests and withdraws reviewers by rewriting the whole list", () => {
561 + const bob = { ...actor, actorId: "act_two", handle: "bob" };
562 + let requested = [{ id: "act_two", actor: bob }];
563 + const server = fakeGitCafe({
564 + "GET /repos/owner/repo/pulls/7": pull,
565 + "GET /repos/owner/repo/pulls/7/reviewer-candidates": {
566 + items: [
567 + { id: "act_one", actor },
568 + { id: "act_two", actor: bob },
569 + { id: "act_bot", actor: { ...actor, actorId: "act_bot", handle: "lint", bot: true } },
570 + ],
571 + next: null,
572 + },
573 + "GET /repos/owner/repo/pulls/7/reviewers": () => ({ items: requested, next: null }),
574 + "PUT /repos/owner/repo/pulls/7/reviewers": { version: 5, items: [] },
575 + });
576 + return Effect.gen(function* () {
577 + const provider = yield* GitCafePullRequestProvider.make;
578 + const list = yield* provider.listReviewerCandidates(target);
579 + // The author, alice, cannot review her own pull request.
580 + assert.deepStrictEqual(
581 + list.candidates.map((c) => [c.id, c.login, c.isRequested, c.isBot ?? false]),
582 + [
583 + ["act_two", "bob", true, false],
584 + ["act_bot", "lint", false, true],
585 + ],
586 + );
587 +
588 + const set = (id: string, on: boolean) =>
589 + provider.setReviewerRequest({
590 + ...target,
591 + reviewers: [{ id, kind: "user" }],
592 + requested: on,
593 + });
594 + yield* set("act_bot", true);
595 + assert.deepStrictEqual(server.sent.at(-1)?.body, {
596 + expectedVersion: 4,
597 + actorIds: ["act_two", "act_bot"],
598 + });
599 + yield* set("act_two", false);
600 + assert.deepStrictEqual(server.sent.at(-1)?.body, { expectedVersion: 4, actorIds: [] });
601 +
602 + requested = [];
603 + yield* set("act_two", false);
604 + assert.strictEqual(server.writes().length, 2);
605 + }).pipe(Effect.provide(server.layer));
606 + });
607 +
608 + it.effect("names the missing scopes when the token may not request reviewers", () => {
609 + const server = fakeGitCafe({
610 + "GET /repos/owner/repo/pulls/7": pull,
611 + "GET /repos/owner/repo/pulls/7/reviewer-candidates": new Response("", { status: 403 }),
612 + "GET /repos/owner/repo/pulls/7/reviewers": { items: [], next: null },
613 + });
614 + return Effect.gen(function* () {
615 + const provider = yield* GitCafePullRequestProvider.make;
616 + const error = yield* Effect.flip(provider.listReviewerCandidates(target));
617 + assert.match(error.detail, /pr:reviewers:write/u);
618 + }).pipe(Effect.provide(server.layer));
619 + });
620 +
621 + it.effect("applies and removes labels by name through their ids", () => {
622 + const server = fakeGitCafe({
623 + "GET /repos/owner/repo/pulls/7": pull,
624 + "GET /repos/owner/repo/labels": { items: labels, next: null },
625 + "GET /repos/owner/repo/pulls/7/labels": { items: [labels[0]], next: null },
626 + "PUT /repos/owner/repo/pulls/7/labels": { version: 5, items: [] },
627 + });
628 + return Effect.gen(function* () {
629 + const provider = yield* GitCafePullRequestProvider.make;
630 + const list = yield* provider.listLabelCandidates!(target);
631 + assert.deepStrictEqual(
632 + list.candidates.map((label) => [label.name, label.isApplied]),
633 + [
634 + ["bug", true],
635 + ["docs", false],
636 + ],
637 + );
638 +
639 + yield* provider.setLabels!({ ...target, labels: ["docs"], applied: true });
640 + assert.deepStrictEqual(server.sent.at(-1)?.body, {
641 + expectedVersion: 4,
642 + labelIds: ["label_bug", "label_docs"],
643 + });
644 + yield* provider.setLabels!({ ...target, labels: ["bug"], applied: false });
645 + assert.deepStrictEqual(server.sent.at(-1)?.body, { expectedVersion: 4, labelIds: [] });
646 +
647 + const missing = yield* provider.setLabels!({
648 + ...target,
649 + labels: ["nope"],
650 + applied: true,
651 + }).pipe(Effect.result);
652 + assert.strictEqual(missing._tag, "Failure");
653 + assert.strictEqual(server.writes().length, 2);
654 }).pipe(Effect.provide(server.layer));
655 });
656
packages/source-control-gitcafe/src/server/GitCafePullRequestProvider.ts
+156 -14
@@ -31,7 +31,7 @@ const CAPABILITIES: PullRequestCapabilities = {
31 stacks: true,
32 stackActions: true,
33 reactions: true,
34 - labels: false,
34 + labels: true,
35 // Line comments go through GitCafe's review drafts, which arrive with revision fencing.
36 review: {
37 inlineComment: false,
@@ -39,7 +39,7 @@ const CAPABILITIES: PullRequestCapabilities = {
39 resolve: true,
40 verdicts: ["approve", "request-changes", "comment"],
41 },
42 - reviewers: { request: false, listCandidates: false },
42 + reviewers: { request: true, listCandidates: true },
43 edit: { changeRequest: true, comment: true },
44 };
45
@@ -72,13 +72,16 @@ const mergeStrategyOpen = (status: typeof Status.Type, strategy: string) =>
72
73 const Id = TrimmedNonEmptyString.check(Schema.isPattern(/^[A-Za-z0-9_-]+$/u));
74 const isId = Schema.is(Id);
75 +const isApiError = Schema.is(GitCafeApi.GitCafeApiError);
76 const Principal = Schema.Struct({ handle: TrimmedNonEmptyString });
77 const Written = Schema.Struct({ id: Id });
78 const Versioned = Schema.Struct({ version: NonNegativeInt });
79 const CommentDetail = Schema.Struct({ id: Id, version: NonNegativeInt });
80 const Status = Schema.Struct({
81 merge: Schema.Struct({
81 - conflicts: Schema.Literals(["unknown", "conflicting"]),
82 + // The API reference lists "unknown" and "conflicting", but git.cafe also sends "none" and
83 + // "pending", so any state is read and only the known ones are mapped.
84 + conflicts: Schema.String,
85 fastForward: Schema.NullOr(Schema.Boolean),
86 strategies: Schema.Array(Schema.String),
87 permitted: Schema.optional(Schema.Boolean),
@@ -94,6 +97,10 @@ const Status = Schema.Struct({
97 total: NonNegativeInt,
98 }),
99 });
100 +const Listed = Schema.Struct({
101 + items: Schema.Array(Schema.Struct({ id: TrimmedNonEmptyString })),
102 + next: Schema.NullOr(Schema.String),
103 +});
104 const FilterOptions = Schema.Struct({
105 actors: Schema.Array(
106 Schema.Struct({ actorId: TrimmedNonEmptyString, handle: TrimmedNonEmptyString }),
@@ -255,6 +262,62 @@ export const make = Effect.gen(function* () {
262 ),
263 );
264
265 + const isForbidden = (error: PullRequestProviderError) =>
266 + isApiError(error.cause) && error.cause.status === 403;
267 +
268 + /**
269 + * GitCafe offers no way to read a token's scopes, so reviewer controls show
270 + * for anyone who may edit the pull request; a token without the reviewer
271 + * scopes learns which ones it lacks when it uses them.
272 + */
273 + const explainReviewerScopes =
274 + (operation: string) =>
275 + <A, R>(effect: Effect.Effect<A, PullRequestProviderError, R>) =>
276 + effect.pipe(
277 + Effect.catchIf(isForbidden, (error) =>
278 + Effect.fail(
279 + failure(
280 + operation,
281 + "This GitCafe token cannot request reviewers. It needs the pr:review:read and pr:reviewers:write scopes.",
282 + error,
283 + ),
284 + ),
285 + ),
286 + );
287 +
288 + /**
289 + * GitCafe replaces a pull request's whole reviewer or label list, so one toggle reads the
290 + * list, changes it, and writes it back fenced on the pull request's version. The version is
291 + * read first: a change landing between the two reads then fails the fence instead of being
292 + * overwritten.
293 + */
294 + const toggleListed = Effect.fn("GitCafePullRequestProvider.toggleListed")(function* (
295 + operation: string,
296 + input: PullRef,
297 + list: { readonly name: "reviewers" | "labels"; readonly key: "actorIds" | "labelIds" },
298 + ids: ReadonlyArray<string>,
299 + on: boolean,
300 + ) {
301 + const path = yield* pullPath(operation, input);
302 + const pull = yield* readPull(operation, input);
303 + const listed = yield* readPages(operation, input, `${path}/${list.name}`, Listed);
304 + const current = listed.items.map((item) => item.id);
305 + const next = on
306 + ? [...new Set([...current, ...ids])]
307 + : current.filter((id) => !ids.includes(id));
308 + if (next.length === current.length) return;
309 + yield* read(
310 + operation,
311 + input,
312 + {
313 + method: "PUT",
314 + path: `${path}/${list.name}`,
315 + body: { expectedVersion: pull.version, [list.key]: next },
316 + },
317 + Versioned,
318 + );
319 + });
320 +
321 /**
322 * GitCafe's stack lists no heads, and they are what a land or restack is fenced on, so each
323 * open layer's pull is read.
@@ -568,7 +631,8 @@ export const make = Effect.gen(function* () {
631 const pull = yield* readPull("getChangeRequest", input);
632 const path = yield* pullPath("getChangeRequest", input);
633 const base = yield* repositoryPath("getChangeRequest", input);
571 - const [status, checks, changes] = yield* Effect.all(
634 + // A single pull request read carries neither its reviewers nor its labels.
635 + const [status, checks, changes, reviewers, labels] = yield* Effect.all(
636 [
637 read("getChangeRequest", input, { path: `${path}/status` }, Status),
638 pull.headOid === null
@@ -582,12 +646,20 @@ export const make = Effect.gen(function* () {
646 pull.headOid === null
647 ? Effect.succeed(null)
648 : readLineStats(input, pull.version).pipe(Effect.orElseSucceed(() => null)),
649 + // Reviewers need `pr:review:read`, which a contents-only token lacks.
650 + readPages("getChangeRequest", input, `${path}/reviewers`, Json.GitCafeActorEntries).pipe(
651 + Effect.catch((error) =>
652 + isForbidden(error) ? Effect.succeed({ items: [], next: null }) : Effect.fail(error),
653 + ),
654 + ),
655 + readPages("getChangeRequest", input, `${path}/labels`, Json.GitCafeLabels),
656 ],
586 - { concurrency: 3 },
657 + { concurrency: 5 },
658 );
659 + const listed = { ...pull, reviewers: reviewers.items, labels: labels.items };
660 const permissions = Json.toViewerPermissions(pull);
661 return {
590 - ...Json.toChangeRequest(pull, input),
662 + ...Json.toChangeRequest(listed, input),
663 headSha: pull.headOid,
664 body: pull.description ?? "",
665 ...(pull.sourceRepo === null
@@ -598,7 +670,7 @@ export const make = Effect.gen(function* () {
670 changedFiles: changes?.changedFiles ?? 0,
671 closedAt: pull.closedAt,
672 mergedAt: pull.mergedAt,
601 - reviewers: Json.toReviewers(pull, input.host),
673 + reviewers: Json.toReviewers(listed, input.host),
674 checks: checks === null ? [] : Json.toChecks(checks),
675 ...(status.checks.total === 0
676 ? {}
@@ -613,7 +685,9 @@ export const make = Effect.gen(function* () {
685 mergeability:
686 status.merge.conflicts === "conflicting"
687 ? ("conflicting" as const)
616 - : ("unknown" as const),
688 + : status.merge.conflicts === "none"
689 + ? ("mergeable" as const)
690 + : ("unknown" as const),
691 baseComparison:
692 status.merge.fastForward === null
693 ? ("unknown" as const)
@@ -789,12 +863,80 @@ export const make = Effect.gen(function* () {
863 Written,
864 );
865 }),
792 - listReviewerCandidates: () =>
793 - Effect.fail(
794 - failure("listReviewerCandidates", "GitCafe reviewer requests are not supported."),
795 - ),
796 - setReviewerRequest: () =>
797 - Effect.fail(failure("setReviewerRequest", "GitCafe reviewer requests are not supported.")),
866 + listReviewerCandidates: Effect.fn("GitCafePullRequestProvider.listReviewerCandidates")(
867 + function* (input) {
868 + const operation = "listReviewerCandidates";
869 + const path = yield* pullPath(operation, input);
870 + const [pull, candidates, reviewers] = yield* Effect.all(
871 + [
872 + readPull(operation, input),
873 + readPages(
874 + operation,
875 + input,
876 + `${path}/reviewer-candidates`,
877 + Json.GitCafeActorEntries,
878 + ).pipe(explainReviewerScopes(operation)),
879 + readPages(operation, input, `${path}/reviewers`, Listed).pipe(
880 + explainReviewerScopes(operation),
881 + ),
882 + ],
883 + { concurrency: 3 },
884 + );
885 + return {
886 + candidates: Json.toReviewerCandidates(candidates, {
887 + requested: new Set(reviewers.items.map((reviewer) => reviewer.id)),
888 + authorActorId: pull.author.actorId,
889 + host: input.host,
890 + }),
891 + truncated: candidates.next !== null,
892 + };
893 + },
894 + ),
895 + setReviewerRequest: (input) =>
896 + toggleListed(
897 + "setReviewerRequest",
898 + input,
899 + { name: "reviewers", key: "actorIds" },
900 + input.reviewers.map((reviewer) => reviewer.id),
901 + input.requested,
902 + ).pipe(explainReviewerScopes("setReviewerRequest")),
903 + listLabelCandidates: Effect.fn("GitCafePullRequestProvider.listLabelCandidates")(
904 + function* (input) {
905 + const operation = "listLabelCandidates";
906 + const base = yield* repositoryPath(operation, input);
907 + const [labels, applied] = yield* Effect.all(
908 + [
909 + readPages(operation, input, `${base}/labels`, Json.GitCafeLabels),
910 + readPages(operation, input, `${base}/pulls/${input.number}/labels`, Listed),
911 + ],
912 + { concurrency: 2 },
913 + );
914 + const appliedIds = new Set(applied.items.map((label) => label.id));
915 + return {
916 + candidates: labels.items.map((label) => ({
917 + name: label.name,
918 + color: label.color,
919 + description: label.description ?? null,
920 + isApplied: appliedIds.has(label.id),
921 + })),
922 + truncated: labels.next !== null,
923 + };
924 + },
925 + ),
926 + setLabels: Effect.fn("GitCafePullRequestProvider.setLabels")(function* (input) {
927 + const base = yield* repositoryPath("setLabels", input);
928 + const labels = yield* readPages("setLabels", input, `${base}/labels`, Json.GitCafeLabels);
929 + const selected = labels.items.filter((label) => input.labels.includes(label.name));
930 + if (selected.length !== input.labels.length)
931 + return yield* failure("setLabels", "One or more requested labels could not be found.");
932 + yield* toggleListed(
933 + "setLabels",
934 + input,
935 + { name: "labels", key: "labelIds" },
936 + selected.map((label) => label.id),
937 + input.applied,
938 + );
939 + }),
940 replyToThread: Effect.fn("GitCafePullRequestProvider.replyToThread")(function* (input) {
941 if (!isId(input.threadId))
942 return yield* failure("replyToThread", "GitCafe thread ids are opaque slugs.");
packages/source-control-gitcafe/src/server/gitCafePullRequestJson.ts
+40 -2
@@ -12,6 +12,7 @@ import {
12 type PullRequestComment,
13 type PullRequestReaction,
14 type PullRequestReactionContent,
15 + type PullRequestReviewerCandidate,
16 type PullRequestReviewThread,
17 type PullRequestViewerPermissions,
18 } from "@t3tools/contracts";
@@ -29,6 +30,7 @@ const Actor = Schema.Union([
30 handle: TrimmedNonEmptyString,
31 displayName: Schema.NullOr(Schema.String),
32 avatarUrl: Schema.NullOr(Schema.String),
33 + bot: Schema.optional(Schema.Boolean),
34 }),
35 Schema.Struct({
36 kind: Schema.Literal("github"),
@@ -143,6 +145,24 @@ export const GitCafeCommits = Schema.Struct({
145 headOid: Schema.String,
146 });
147
148 +export const GitCafeLabels = Schema.Struct({
149 + items: Schema.Array(
150 + Schema.Struct({
151 + id: TrimmedNonEmptyString,
152 + name: TrimmedNonEmptyString,
153 + color: Schema.NullOr(Schema.String),
154 + description: Schema.optional(Schema.NullOr(Schema.String)),
155 + }),
156 + ),
157 + next: Schema.NullOr(Schema.String),
158 +});
159 +
160 +/** A pull request's reviewers and its reviewer candidates, each actor under its id. */
161 +export const GitCafeActorEntries = Schema.Struct({
162 + items: Schema.Array(Schema.Struct({ id: TrimmedNonEmptyString, actor: Actor })),
163 + next: Schema.NullOr(Schema.String),
164 +});
165 +
166 export const GitCafeReactions = Schema.Struct({
167 items: Schema.Array(
168 Schema.Struct({
@@ -249,6 +269,7 @@ function toActor(actor: Actor, host: string): PullRequestActor | null {
269 return {
270 login: actor.kind === "local" ? actor.handle : actor.login,
271 name: actor.kind === "local" ? actor.displayName : null,
272 + ...(actor.kind === "local" && actor.bot === true ? { isBot: true } : {}),
273 // GitCafe serves its own avatars by path, so a relative one is read against the host.
274 avatarUrl: actor.avatarUrl === null ? null : new URL(actor.avatarUrl, `https://${host}`).href,
275 };
@@ -264,6 +285,22 @@ export function toReviewers(
285 });
286 }
287
288 +export function toReviewerCandidates(
289 + candidates: typeof GitCafeActorEntries.Type,
290 + input: {
291 + readonly requested: ReadonlySet<string>;
292 + readonly authorActorId: string;
293 + readonly host: string;
294 + },
295 +): ReadonlyArray<PullRequestReviewerCandidate> {
296 + return candidates.items.flatMap(({ id, actor }) => {
297 + const reviewer = id === input.authorActorId ? null : toActor(actor, input.host);
298 + return reviewer === null
299 + ? []
300 + : [{ ...reviewer, id, kind: "user" as const, isRequested: input.requested.has(id) }];
301 + });
302 +}
303 +
304 function reviewerLogins(actor: Actor, host: string): ReadonlyArray<string> {
305 const reviewer = toActor(actor, host);
306 if (reviewer === null) return [];
@@ -293,7 +330,7 @@ export function toChangeRequest(
330 reviewRequestLogins: (pull.reviewers ?? []).flatMap(({ actor }) =>
331 reviewerLogins(actor, target.host),
332 ),
296 - labels: pull.labels ?? [],
333 + labels: (pull.labels ?? []).map(({ name, color }) => ({ name, color })),
334 };
335 }
336
@@ -313,7 +350,8 @@ export function toViewerPermissions(detail: GitCafePullDetail): PullRequestViewe
350 comment: open,
351 resolve: open,
352 verdicts: review ? ["approve", "request-changes", "comment"] : [],
316 - requestReviewers: false,
353 + requestReviewers: edit && detail.state === "open",
354 + labels: edit && detail.state === "open",
355 editChangeRequest: edit,
356 // GitCafe's only branch update moves a whole stack.
357 updateMethods: [],