GeezerVison is showing github.com — fix(gitlab): unresolved overview threads count as review findings (#3… · pingdotgg/t3code@bd7da7f
File treeExpand file treeCollapse file tree Open diff view settings packages/source-control-gitlab/src/server
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts +115-81Lines changed: 115 additions & 81 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1236,93 +1236,127 @@ layer("GitLabPullRequestCli.layer", (it) => { | 1236 | 1236 | }), | 1237 | 1237 | ); | 1238 | 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 | + }, | 1261 | 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", | 1285 | 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, | 1302 | 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 | + ), | 1307 | 1341 | ), | 1308 | | - ), | 1309 | | - ); | 1310 | | - const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli; | | 1342 | + ); | | 1343 | + const cli = yield* GitLabPullRequestCli.GitLabPullRequestCli; | 1311 | 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 | + }); | 1317 | 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 | + }), | 1326 | 1360 | ); | 1327 | 1361 |
| 1328 | 1362 | it.effect("sends a review as its comments, then its summary, then the verdict", () => | |
Collapse file Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/GitLabPullRequestCli.ts +25-8Lines changed: 25 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -524,7 +524,11 @@ export class GitLabPullRequestCli extends Context.Service< | 524 | 524 | readonly repository: string; | 525 | 525 | readonly number: number; | 526 | 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 | + }, | 528 | 532 | GitLabPullRequestCliError | 529 | 533 | >; | 530 | 534 |
| @@ -1069,8 +1073,13 @@ export const make = Effect.gen(function* () { | 1069 | 1073 | readonly number: number; | 1070 | 1074 | readonly page: number; | 1071 | 1075 | readonly collected: ReadonlyArray<PullRequestReviewThread>; | | 1076 | + readonly collectedFindingIds: ReadonlyArray<string>; | 1072 | 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 | + }, | 1074 | 1083 | GitLabPullRequestCliError | 1075 | 1084 | > => | 1076 | 1085 | api({ | @@ -1096,13 +1105,21 @@ export const make = Effect.gen(function* () { | 1096 | 1105 | ); | 1097 | 1106 | } | 1098 | 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 | + }); | 1099 | 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); | 1103 | 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 }); | 1106 | 1123 | }), | 1107 | 1124 | ); | 1108 | 1125 |
| @@ -2278,7 +2295,7 @@ export const make = Effect.gen(function* () { | 2278 | 2295 | }), | 2279 | 2296 |
| 2280 | 2297 | listDiscussions: Effect.fn("GitLabPullRequestCli.listDiscussions")(function (input) { | 2281 | | - return discussionsPage({ ...input, page: 1, collected: [] }); | | 2298 | + return discussionsPage({ ...input, page: 1, collected: [], collectedFindingIds: [] }); | 2282 | 2299 | }), | 2283 | 2300 |
| 2284 | 2301 | submitReview: Effect.fn("GitLabPullRequestCli.submitReview")(function* (input) { | |
Collapse file Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts +31-1Lines changed: 31 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -532,7 +532,8 @@ describe("optional activity reads", () => { | 532 | 532 | }), | 533 | 533 | listNotes: () => Effect.succeed({ comments: [comment], truncated: false }), | 534 | 534 | listCommits: () => Effect.succeed([commit]), | 535 | | - listDiscussions: () => Effect.succeed({ threads: [], truncated: false }), | | 535 | + listDiscussions: () => | | 536 | + Effect.succeed({ threads: [], overviewFindingIds: [], truncated: false }), | 536 | 537 | listReactions: () => | 537 | 538 | Effect.succeed({ | 538 | 539 | reactions: [], | @@ -586,6 +587,32 @@ describe("optional activity reads", () => { | 586 | 587 | }), | 587 | 588 | ); | 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 | + | 589 | 616 | it.effect("dates edited comments in the conversation and in threads", () => | 590 | 617 | Effect.gen(function* () { | 591 | 618 | const editedAt = "2026-07-02T00:00:00Z"; | @@ -606,6 +633,7 @@ describe("optional activity reads", () => { | 606 | 633 | comments: [comment], | 607 | 634 | }, | 608 | 635 | ], | | 636 | + overviewFindingIds: [], | 609 | 637 | truncated: false, | 610 | 638 | }), | 611 | 639 | listReactions: () => | @@ -645,6 +673,7 @@ describe("optional activity reads", () => { | 645 | 673 | comments: [comment], | 646 | 674 | }, | 647 | 675 | ], | | 676 | + overviewFindingIds: [], | 648 | 677 | truncated: false, | 649 | 678 | }), | 650 | 679 | }), | @@ -721,6 +750,7 @@ describe("optional activity reads", () => { | 721 | 750 | ], | 722 | 751 | }, | 723 | 752 | ], | | 753 | + overviewFindingIds: [], | 724 | 754 | truncated: false, | 725 | 755 | }), | 726 | 756 | listReactions: () => | |
Collapse file Copy file name to clipboardExpand all lines: packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts +7-1Lines changed: 7 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -362,7 +362,11 @@ export const make = Effect.gen(function* () { | 362 | 362 | [ | 363 | 363 | recoverRead(cli.listNotes(input), { comments: [], truncated: true }), | 364 | 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 | + }), | 366 | 370 | recoverRead(cli.listReactions(input), { | 367 | 371 | reactions: [] as ReadonlyArray<PullRequestReaction>, | 368 | 372 | reactionsByNoteId: new Map<string, ReadonlyArray<PullRequestReaction>>(), | @@ -381,6 +385,7 @@ export const make = Effect.gen(function* () { | 381 | 385 | Effect.map( | 382 | 386 | ([notes, commits, discussions, awards, webUrl]): ProviderChangeRequestActivity => { | 383 | 387 | const noteUrl = (id: string) => (webUrl === null ? null : `${webUrl}#note_${id}`); | | 388 | + const findingIds = new Set(discussions.overviewFindingIds); | 384 | 389 | const edited = (id: string) => { | 385 | 390 | const editedAt = awards.editedAtByNoteId.get(id); | 386 | 391 | return editedAt === undefined ? {} : { editedAt }; | @@ -394,6 +399,7 @@ export const make = Effect.gen(function* () { | 394 | 399 | reactions: awards.reactions, | 395 | 400 | comments: notes.comments.map((comment) => ({ | 396 | 401 | ...comment, | | 402 | + ...(findingIds.has(comment.id) ? { kind: "review-comment" as const } : {}), | 397 | 403 | ...edited(comment.id), | 398 | 404 | author: withBotFlag(comment.author), | 399 | 405 | url: noteUrl(comment.id), | |
|