@devries-cameron20 / t3code-1 / commits / e945fcc50f
Fork 0

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

fix(gitlab): bot authors are flagged as bots (#30383)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>

Antony committed Nov 6, 2026 at 01:23 UTC e945fcc50fb28b4f5bde72fa44d764db7f5a9b42
5 files changed +100 -17
packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts
+5
@@ -466,6 +466,7 @@ export class GitLabPullRequestCli extends Context.Service<
466 {
467 readonly reactions: ReadonlyArray<PullRequestReaction>;
468 readonly reactionsByNoteId: ReadonlyMap<string, ReadonlyArray<PullRequestReaction>>;
469 + readonly botLogins: ReadonlySet<string>;
470 },
471 GitLabPullRequestCliError
472 >;
@@ -1091,11 +1092,13 @@ export const make = Effect.gen(function* () {
1092 readonly collected: {
1093 readonly reactions: ReadonlyArray<PullRequestReaction>;
1094 readonly reactionsByNoteId: Map<string, ReadonlyArray<PullRequestReaction>>;
1095 + readonly botLogins: Set<string>;
1096 } | null;
1097 }): Effect.Effect<
1098 {
1099 readonly reactions: ReadonlyArray<PullRequestReaction>;
1100 readonly reactionsByNoteId: ReadonlyMap<string, ReadonlyArray<PullRequestReaction>>;
1101 + readonly botLogins: ReadonlySet<string>;
1102 },
1103 GitLabPullRequestCliError
1104 > =>
@@ -1128,9 +1131,11 @@ export const make = Effect.gen(function* () {
1131 const collected = input.collected ?? {
1132 reactions: decoded.success.reactions,
1133 reactionsByNoteId: new Map<string, ReadonlyArray<PullRequestReaction>>(),
1134 + botLogins: new Set<string>(),
1135 };
1136 for (const [id, reactions] of decoded.success.reactionsByNoteId)
1137 collected.reactionsByNoteId.set(id, reactions);
1138 + for (const login of decoded.success.botLogins) collected.botLogins.add(login);
1139 return decoded.success.nextCursor === null || input.page >= CONVERSATION_PAGES
1140 ? Effect.succeed(collected)
1141 : awardsPage({
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts
+51 -1
@@ -484,7 +484,8 @@ describe("optional activity reads", () => {
484 listNotes: () => Effect.succeed({ comments: [comment], truncated: false }),
485 listCommits: () => Effect.succeed([commit]),
486 listDiscussions: () => Effect.succeed({ threads: [], truncated: false }),
487 - listReactions: () => Effect.succeed({ reactions: [], reactionsByNoteId: new Map() }),
487 + listReactions: () =>
488 + Effect.succeed({ reactions: [], reactionsByNoteId: new Map(), botLogins: new Set<string>() }),
489 };
490 const context = {
491 operation: "execute" as const,
@@ -561,6 +562,55 @@ describe("optional activity reads", () => {
562 });
563 }),
564 );
565 +
566 + it.effect("flags comments by bot authors as bots, in the conversation and in threads", () =>
567 + Effect.gen(function* () {
568 + const bot = { login: "project_1_bot_abc", name: "Review bot", avatarUrl: null };
569 + const human = { login: "julius", name: null, avatarUrl: null };
570 + const provider = yield* make.pipe(
571 + Effect.provide(
572 + Layer.mock(GitLabPullRequestCli.GitLabPullRequestCli)({
573 + ...reads,
574 + listNotes: () =>
575 + Effect.succeed({
576 + comments: [
577 + { ...comment, author: bot },
578 + { ...comment, id: "43", author: human },
579 + ],
580 + truncated: false,
581 + }),
582 + listDiscussions: () =>
583 + Effect.succeed({
584 + threads: [
585 + {
586 + id: "d1",
587 + path: "a.ts",
588 + line: 1,
589 + side: "right" as const,
590 + isResolved: false,
591 + isOutdated: false,
592 + comments: [
593 + { id: "44", author: bot, body: "x", createdAt: comment.createdAt, url: null },
594 + ],
595 + },
596 + ],
597 + truncated: false,
598 + }),
599 + listReactions: () =>
600 + Effect.succeed({
601 + reactions: [],
602 + reactionsByNoteId: new Map(),
603 + botLogins: new Set([bot.login.toUpperCase()]),
604 + }),
605 + }),
606 + ),
607 + );
608 +
609 + const activity = yield* provider.getChangeRequestActivity(reference);
610 + expect(activity.comments.map((entry) => entry.author?.isBot)).toEqual([true, undefined]);
611 + expect(activity.reviewThreads[0]?.comments[0]?.author?.isBot).toBe(true);
612 + }),
613 + );
614 });
615
616 describe("review decisions", () => {
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts
+25 -14
@@ -5,6 +5,7 @@ import * as Duration from "effect/Duration";
5 import * as Effect from "effect/Effect";
6 import * as Exit from "effect/Exit";
7 import type {
8 + PullRequestActor,
9 PullRequestCapabilities,
10 PullRequestReaction,
11 PullRequestReviewDecision,
@@ -330,28 +331,38 @@ export const make = Effect.gen(function* () {
331 recoverRead(cli.listReactions(input), {
332 reactions: [] as ReadonlyArray<PullRequestReaction>,
333 reactionsByNoteId: new Map<string, ReadonlyArray<PullRequestReaction>>(),
334 + botLogins: new Set<string>(),
335 }),
336 ],
337 { concurrency: 4 },
338 ).pipe(
339 Effect.mapError(fail("getChangeRequestActivity")),
338 - Effect.map(([notes, commits, discussions, awards]): ProviderChangeRequestActivity => ({
339 - reactions: awards.reactions,
340 - comments: notes.comments.map((comment) => ({
341 - ...comment,
342 - reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
343 - })),
344 - commentCount: notes.comments.length,
345 - commentsTruncated: notes.truncated || discussions.truncated,
346 - reviewThreads: discussions.threads.map((thread) => ({
347 - ...thread,
348 - comments: thread.comments.map((comment) => ({
340 + Effect.map(([notes, commits, discussions, awards]): ProviderChangeRequestActivity => {
341 + const botLogins = new Set([...awards.botLogins].map((login) => login.toLowerCase()));
342 + const withBotFlag = (author: PullRequestActor | null) =>
343 + author !== null && botLogins.has(author.login.toLowerCase())
344 + ? { ...author, isBot: true }
345 + : author;
346 + return {
347 + reactions: awards.reactions,
348 + comments: notes.comments.map((comment) => ({
349 ...comment,
350 + author: withBotFlag(comment.author),
351 reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
352 })),
352 - })),
353 - commits,
354 - })),
353 + commentCount: notes.comments.length,
354 + commentsTruncated: notes.truncated || discussions.truncated,
355 + reviewThreads: discussions.threads.map((thread) => ({
356 + ...thread,
357 + comments: thread.comments.map((comment) => ({
358 + ...comment,
359 + author: withBotFlag(comment.author),
360 + reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
361 + })),
362 + })),
363 + commits,
364 + };
365 + }),
366 ),
367
368 // Straight from the host, never the shared read: this is what a write is refused or let
packages/source-control-gitlab/src/server/gitLabMergeRequestJson.test.ts
+4 -1
@@ -496,7 +496,7 @@ describe("merge request viewer fields", () => {
496 });
497
498 describe("decodeAwardEmojiJson", () => {
499 - it("reads MR-level awards, keys per-note awards by the REST id inside their gid, and ignores an award outside the eight", () => {
499 + it("reads MR-level awards, keys per-note awards by the REST id inside their gid, ignores an award outside the eight, and collects bot note authors", () => {
500 const result = expectSuccess(
501 decodeAwardEmojiJson(
502 JSON.stringify({
@@ -515,10 +515,12 @@ describe("decodeAwardEmojiJson", () => {
515 nodes: [
516 {
517 id: "gid://gitlab/DiffNote/42",
518 + author: { username: "julius", bot: false },
519 awardEmoji: { nodes: [{ name: "heart", user: { username: "julius" } }] },
520 },
521 {
522 id: "gid://gitlab/Note/7",
523 + author: { username: "project_278964_bot_89f97e2c", bot: true },
524 awardEmoji: {
525 nodes: [{ name: "partyparrot", user: { username: "bilal" } }],
526 },
@@ -538,6 +540,7 @@ describe("decodeAwardEmojiJson", () => {
540 expect([...result.reactionsByNoteId]).toEqual([
541 ["42", [{ content: "heart", count: 1, actors: ["julius"], viewerHasReacted: false }]],
542 ]);
543 + expect([...result.botLogins]).toEqual(["project_278964_bot_89f97e2c"]);
544 expect(result.nextCursor).toBeNull();
545 });
546
packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts
+15 -1
@@ -780,7 +780,7 @@ export const AWARD_EMOJI_GRAPHQL_QUERY = `query($fullPath: ID!, $iid: String!, $
780 awardEmoji { nodes { name user { username } } }
781 notes(first: 100, after: $cursor) {
782 pageInfo { hasNextPage endCursor }
783 - nodes { id awardEmoji { nodes { name user { username } } } }
783 + nodes { id author { username bot } awardEmoji { nodes { name user { username } } } }
784 }
785 }
786 }
@@ -832,6 +832,15 @@ const RawAwardEmojiPageSchema = Schema.Struct({
832 Schema.NullOr(
833 Schema.Struct({
834 id: Schema.optional(Schema.NullOr(Schema.String)),
835 + // REST note authors carry no bot flag; GraphQL's does.
836 + author: Schema.optional(
837 + Schema.NullOr(
838 + Schema.Struct({
839 + username: Schema.optional(Schema.NullOr(Schema.String)),
840 + bot: Schema.optional(Schema.NullOr(Schema.Boolean)),
841 + }),
842 + ),
843 + ),
844 awardEmoji: RawAwardEmojiNodesSchema,
845 }),
846 ),
@@ -886,6 +895,7 @@ function noteIdOf(gid: string | null | undefined): string | null {
895 export interface GitLabAwardEmojiPage {
896 readonly reactions: ReadonlyArray<PullRequestReaction>;
897 readonly reactionsByNoteId: ReadonlyMap<string, ReadonlyArray<PullRequestReaction>>;
898 + readonly botLogins: ReadonlySet<string>;
899 readonly nextCursor: string | null;
900 }
901
@@ -900,7 +910,10 @@ export function decodeAwardEmojiJson(
910 const viewer = trimmed(data.currentUser?.username);
911 const mergeRequest = data.project?.mergeRequest;
912 const reactionsByNoteId = new Map<string, ReadonlyArray<PullRequestReaction>>();
913 + const botLogins = new Set<string>();
914 for (const node of mergeRequest?.notes?.nodes ?? []) {
915 + const author = trimmed(node?.author?.username);
916 + if (author !== null && node?.author?.bot === true) botLogins.add(author);
917 const id = noteIdOf(node?.id);
918 if (id === null) continue;
919 const reactions = toReactions(node?.awardEmoji, viewer);
@@ -910,6 +923,7 @@ export function decodeAwardEmojiJson(
923 return Result.succeed({
924 reactions: toReactions(mergeRequest?.awardEmoji, viewer),
925 reactionsByNoteId,
926 + botLogins,
927 nextCursor: pageInfo?.hasNextPage === true ? (trimmed(pageInfo.endCursor) ?? null) : null,
928 });
929 }