@devries-cameron20 / t3code Mirror · read-only / commits / bd7da7fa48
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, 03:15 UTC

fix(gitlab): unresolved overview threads count as review findings (#30397)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>

Antony committed Nov 6, 2026 at 01:54 UTC bd7da7fa485d20d361e9c7146bfe29c0bcf82d5a
5 files changed +185 -92
packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts
+115 -81
@@ -1236,93 +1236,127 @@ layer("GitLabPullRequestCli.layer", (it) => {
1236 }),
1237 );
1238
1239 - it.effect("reads a positioned discussion as a thread anchored to its line", () =>
1240 - Effect.gen(function* () {
1241 - mockedExecute.mockReturnValueOnce(
1242 - Effect.succeed(
1243 - output(
1244 - JSON.stringify([
1245 - {
1246 - id: "abc123",
1247 - notes: [
1248 - {
1249 - id: 1,
1250 - body: "rename this",
1251 - author: { username: "bilal", avatar_url: "https://avatars/b.png" },
1252 - created_at: "2026-07-01T00:00:00Z",
1253 - resolvable: true,
1254 - resolved: true,
1255 - position: {
1256 - position_type: "text",
1257 - new_path: "src/a.ts",
1258 - old_path: "src/a.ts",
1259 - new_line: 12,
1260 - old_line: null,
1239 + it.effect(
1240 + "reads a positioned discussion as a thread and an open overview discussion as a finding",
1241 + () =>
1242 + Effect.gen(function* () {
1243 + mockedExecute.mockReturnValueOnce(
1244 + Effect.succeed(
1245 + output(
1246 + JSON.stringify([
1247 + {
1248 + id: "abc123",
1249 + notes: [
1250 + {
1251 + id: 1,
1252 + body: "rename this",
1253 + author: { username: "bilal", avatar_url: "https://avatars/b.png" },
1254 + created_at: "2026-07-01T00:00:00Z",
1255 + resolvable: true,
1256 + resolved: true,
1257 + position: {
1258 + position_type: "text",
1259 + new_path: "src/a.ts",
1260 + old_path: "src/a.ts",
1261 + new_line: 12,
1262 + old_line: null,
1263 + },
1264 },
1262 - },
1263 - {
1264 - id: 2,
1265 - body: "done",
1266 - author: { username: "julius" },
1267 - created_at: "2026-07-01T01:00:00Z",
1268 - },
1269 - ],
1270 - },
1271 - { id: "def456", notes: [{ id: 3, body: "ship it", created_at: "2026-07-01Z" }] },
1272 - {
1273 - id: "file789",
1274 - notes: [
1275 - {
1276 - id: 4,
1277 - body: "split this file",
1278 - created_at: "2026-07-01Z",
1279 - position: {
1280 - position_type: "file",
1281 - new_path: "src/b.ts",
1282 - old_path: "src/b.ts",
1283 - new_line: null,
1284 - old_line: null,
1265 + {
1266 + id: 2,
1267 + body: "done",
1268 + author: { username: "julius" },
1269 + created_at: "2026-07-01T01:00:00Z",
1270 },
1286 - },
1287 - ],
1288 - },
1289 - {
1290 - id: "img012",
1291 - notes: [
1292 - {
1293 - id: 5,
1294 - body: "logo is blurry",
1295 - created_at: "2026-07-01Z",
1296 - position: {
1297 - position_type: "image",
1298 - new_path: "logo.png",
1299 - old_path: "logo.png",
1300 - new_line: null,
1301 - old_line: null,
1271 + ],
1272 + },
1273 + { id: "def456", notes: [{ id: 3, body: "ship it", created_at: "2026-07-01Z" }] },
1274 + {
1275 + id: "ghi789",
1276 + notes: [
1277 + {
1278 + id: 4,
1279 + body: "mention the new flag in the README",
1280 + created_at: "2026-07-01T02:00:00Z",
1281 + resolvable: true,
1282 + resolved: false,
1283 },
1303 - },
1304 - ],
1305 - },
1306 - ]),
1284 + {
1285 + id: 5,
1286 + body: "will do",
1287 + created_at: "2026-07-01T03:00:00Z",
1288 + resolvable: true,
1289 + resolved: false,
1290 + },
1291 + ],
1292 + },
1293 + {
1294 + id: "jkl012",
1295 + notes: [
1296 + {
1297 + id: 6,
1298 + body: "already addressed",
1299 + created_at: "2026-07-01T04:00:00Z",
1300 + resolvable: true,
1301 + resolved: true,
1302 + },
1303 + ],
1304 + },
1305 + {
1306 + id: "file789",
1307 + notes: [
1308 + {
1309 + id: 7,
1310 + body: "split this file",
1311 + created_at: "2026-07-01Z",
1312 + position: {
1313 + position_type: "file",
1314 + new_path: "src/b.ts",
1315 + old_path: "src/b.ts",
1316 + new_line: null,
1317 + old_line: null,
1318 + },
1319 + },
1320 + ],
1321 + },
1322 + {
1323 + id: "img012",
1324 + notes: [
1325 + {
1326 + id: 8,
1327 + body: "logo is blurry",
1328 + created_at: "2026-07-01Z",
1329 + position: {
1330 + position_type: "image",
1331 + new_path: "logo.png",
1332 + old_path: "logo.png",
1333 + new_line: null,
1334 + old_line: null,
1335 + },
1336 + },
1337 + ],
1338 + },
1339 + ]),
1340 + ),
1341 ),
1308 - ),
1309 - );
1310 - const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
1342 + );
1343 + const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli;
1344
1312 - const { threads } = yield* cli.listDiscussions({
1313 - cwd: "/w",
1314 - repository: "acme/web",
1315 - number: 7,
1316 - });
1345 + const { threads, overviewFindingIds } = yield* cli.listDiscussions({
1346 + cwd: "/w",
1347 + repository: "acme/web",
1348 + number: 7,
1349 + });
1350
1318 - expect(threads.map(({ id, path, line, side }) => ({ id, path, line, side }))).toEqual([
1319 - { id: "abc123", path: "src/a.ts", line: 12, side: "right" },
1320 - { id: "file789", path: "src/b.ts", line: null, side: "right" },
1321 - { id: "img012", path: "logo.png", line: null, side: "right" },
1322 - ]);
1323 - expect(threads[0]).toMatchObject({ isResolved: true });
1324 - assert.strictEqual(threads[0]?.comments.length, 2);
1325 - }),
1351 + expect(overviewFindingIds).toEqual(["4"]);
1352 + expect(threads.map(({ id, path, line, side }) => ({ id, path, line, side }))).toEqual([
1353 + { id: "abc123", path: "src/a.ts", line: 12, side: "right" },
1354 + { id: "file789", path: "src/b.ts", line: null, side: "right" },
1355 + { id: "img012", path: "logo.png", line: null, side: "right" },
1356 + ]);
1357 + expect(threads[0]).toMatchObject({ isResolved: true });
1358 + assert.strictEqual(threads[0]?.comments.length, 2);
1359 + }),
1360 );
1361
1362 it.effect("sends a review as its comments, then its summary, then the verdict", () =>
packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts
+25 -8
@@ -524,7 +524,11 @@ export class GitLabPullRequestCli extends Context.Service<
524 readonly repository: string;
525 readonly number: number;
526 }) => Effect.Effect<
527 - { readonly threads: ReadonlyArray<PullRequestReviewThread>; readonly truncated: boolean },
527 + {
528 + readonly threads: ReadonlyArray<PullRequestReviewThread>;
529 + readonly overviewFindingIds: ReadonlyArray<string>;
530 + readonly truncated: boolean;
531 + },
532 GitLabPullRequestCliError
533 >;
534
@@ -1069,8 +1073,13 @@ export const make = Effect.gen(function* () {
1073 readonly number: number;
1074 readonly page: number;
1075 readonly collected: ReadonlyArray<PullRequestReviewThread>;
1076 + readonly collectedFindingIds: ReadonlyArray<string>;
1077 }): Effect.Effect<
1073 - { readonly threads: ReadonlyArray<PullRequestReviewThread>; readonly truncated: boolean },
1078 + {
1079 + readonly threads: ReadonlyArray<PullRequestReviewThread>;
1080 + readonly overviewFindingIds: ReadonlyArray<string>;
1081 + readonly truncated: boolean;
1082 + },
1083 GitLabPullRequestCliError
1084 > =>
1085 api({
@@ -1096,13 +1105,21 @@ export const make = Effect.gen(function* () {
1105 );
1106 }
1107 const collected = [...input.collected, ...decoded.success.threads];
1108 + const collectedFindingIds = [
1109 + ...input.collectedFindingIds,
1110 + ...decoded.success.overviewFindingIds,
1111 + ];
1112 + const done = (truncated: boolean) =>
1113 + Effect.succeed({
1114 + threads: collected,
1115 + overviewFindingIds: collectedFindingIds,
1116 + truncated,
1117 + });
1118 // Plain notes count toward the page size even when no positioned threads survive decoding.
1100 - if (decoded.success.rawCount < MAX_PAGE_SIZE) {
1101 - return Effect.succeed({ threads: collected, truncated: false });
1102 - }
1119 + if (decoded.success.rawCount < MAX_PAGE_SIZE) return done(false);
1120 return input.page >= CONVERSATION_PAGES
1104 - ? Effect.succeed({ threads: collected, truncated: true })
1105 - : discussionsPage({ ...input, page: input.page + 1, collected });
1121 + ? done(true)
1122 + : discussionsPage({ ...input, page: input.page + 1, collected, collectedFindingIds });
1123 }),
1124 );
1125
@@ -2278,7 +2295,7 @@ export const make = Effect.gen(function* () {
2295 }),
2296
2297 listDiscussions: Effect.fn("GitLabPullRequestCli.listDiscussions")(function (input) {
2281 - return discussionsPage({ ...input, page: 1, collected: [] });
2298 + return discussionsPage({ ...input, page: 1, collected: [], collectedFindingIds: [] });
2299 }),
2300
2301 submitReview: Effect.fn("GitLabPullRequestCli.submitReview")(function* (input) {
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts
+31 -1
@@ -532,7 +532,8 @@ describe("optional activity reads", () => {
532 }),
533 listNotes: () => Effect.succeed({ comments: [comment], truncated: false }),
534 listCommits: () => Effect.succeed([commit]),
535 - listDiscussions: () => Effect.succeed({ threads: [], truncated: false }),
535 + listDiscussions: () =>
536 + Effect.succeed({ threads: [], overviewFindingIds: [], truncated: false }),
537 listReactions: () =>
538 Effect.succeed({
539 reactions: [],
@@ -586,6 +587,32 @@ describe("optional activity reads", () => {
587 }),
588 );
589
590 + it.effect("turns the first note of an open overview discussion into a review finding", () =>
591 + Effect.gen(function* () {
592 + const finding = { ...comment, id: "10", body: "Mention the flag in the README" };
593 + const reply = { ...comment, id: "11", body: "Will do" };
594 + const provider = yield* make.pipe(
595 + Effect.provide(
596 + Layer.mock(GitLabPullRequestCli.GitLabPullRequestCli)({
597 + ...reads,
598 + listNotes: () =>
599 + Effect.succeed({ comments: [comment, finding, reply], truncated: false }),
600 + listDiscussions: () =>
601 + Effect.succeed({ threads: [], overviewFindingIds: ["10"], truncated: false }),
602 + }),
603 + ),
604 + );
605 +
606 + const { comments } = yield* provider.getChangeRequestActivity(reference);
607 +
608 + expect(comments.map((item) => [item.id, item.kind])).toEqual([
609 + ["42", "issue-comment"],
610 + ["10", "review-comment"],
611 + ["11", "issue-comment"],
612 + ]);
613 + }),
614 + );
615 +
616 it.effect("dates edited comments in the conversation and in threads", () =>
617 Effect.gen(function* () {
618 const editedAt = "2026-07-02T00:00:00Z";
@@ -606,6 +633,7 @@ describe("optional activity reads", () => {
633 comments: [comment],
634 },
635 ],
636 + overviewFindingIds: [],
637 truncated: false,
638 }),
639 listReactions: () =>
@@ -645,6 +673,7 @@ describe("optional activity reads", () => {
673 comments: [comment],
674 },
675 ],
676 + overviewFindingIds: [],
677 truncated: false,
678 }),
679 }),
@@ -721,6 +750,7 @@ describe("optional activity reads", () => {
750 ],
751 },
752 ],
753 + overviewFindingIds: [],
754 truncated: false,
755 }),
756 listReactions: () =>
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts
+7 -1
@@ -362,7 +362,11 @@ export const make = Effect.gen(function* () {
362 [
363 recoverRead(cli.listNotes(input), { comments: [], truncated: true }),
364 recoverRead(cli.listCommits(input), []),
365 - recoverRead(cli.listDiscussions(input), { threads: [], truncated: true }),
365 + recoverRead(cli.listDiscussions(input), {
366 + threads: [],
367 + overviewFindingIds: [],
368 + truncated: true,
369 + }),
370 recoverRead(cli.listReactions(input), {
371 reactions: [] as ReadonlyArray<PullRequestReaction>,
372 reactionsByNoteId: new Map<string, ReadonlyArray<PullRequestReaction>>(),
@@ -381,6 +385,7 @@ export const make = Effect.gen(function* () {
385 Effect.map(
386 ([notes, commits, discussions, awards, webUrl]): ProviderChangeRequestActivity => {
387 const noteUrl = (id: string) => (webUrl === null ? null : `${webUrl}#note_${id}`);
388 + const findingIds = new Set(discussions.overviewFindingIds);
389 const edited = (id: string) => {
390 const editedAt = awards.editedAtByNoteId.get(id);
391 return editedAt === undefined ? {} : { editedAt };
@@ -394,6 +399,7 @@ export const make = Effect.gen(function* () {
399 reactions: awards.reactions,
400 comments: notes.comments.map((comment) => ({
401 ...comment,
402 + ...(findingIds.has(comment.id) ? { kind: "review-comment" as const } : {}),
403 ...edited(comment.id),
404 author: withBotFlag(comment.author),
405 url: noteUrl(comment.id),
packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts
+7 -1
@@ -556,6 +556,8 @@ export interface GitLabDiffRefs {
556
557 export interface GitLabDiscussions {
558 readonly threads: ReadonlyArray<PullRequestReviewThread>;
559 + /** First notes of unresolved discussions on the MR itself rather than a diff line. */
560 + readonly overviewFindingIds: ReadonlyArray<string>;
561 readonly rawCount: number;
562 }
563
@@ -567,12 +569,16 @@ export function decodeDiscussionsJson(
569 return Result.fail(decoded.failure);
570 }
571 const threads: PullRequestReviewThread[] = [];
572 + const overviewFindingIds: string[] = [];
573 for (const entry of decoded.success) {
574 const discussion = decodeDiscussionEntry(entry);
575 if (!Exit.isSuccess(discussion)) continue;
576 const notes = (discussion.value.notes ?? []).filter((note) => note.system !== true);
577 const root = notes[0];
578 const position = root?.position;
579 + if (root !== undefined && !position && root.resolvable === true && root.resolved !== true) {
580 + overviewFindingIds.push(String(root.id));
581 + }
582 if (root === undefined || !position) continue;
583 let side: "left" | "right";
584 let path: string | null;
@@ -605,7 +611,7 @@ export function decodeDiscussionsJson(
611 })),
612 });
613 }
608 - return Result.succeed({ threads, rawCount: decoded.success.length });
614 + return Result.succeed({ threads, overviewFindingIds, rawCount: decoded.success.length });
615 }
616
617 export function decodeDiffRefsJson(