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): comments link to their note on GitLab (#30411)
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:44 UTC
05bd5a1ca383db63a4f1ed1664e34bff6e8da23f
2 files changed
+99
-29
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.test.ts
+61
-1
@@ -502,7 +502,34 @@ describe("optional activity reads", () => {
502
messageHeadline: "Keep this commit",
503
committedDate: "2026-07-01T00:00:00Z",
504
};
505
+ const webUrl = "https://git.acme.dev/acme/web/-/merge_requests/7";
506
const reads = {
507
+ getMergeRequestDetail: () =>
508
+ Effect.succeed({
509
+ number: 7,
510
+ title: "Merge request 7",
511
+ url: webUrl,
512
+ author: null,
513
+ headBranch: "feat/page",
514
+ baseBranch: "main",
515
+ state: "open" as const,
516
+ isDraft: false,
517
+ mergeability: "mergeable" as const,
518
+ additions: 0,
519
+ deletions: 0,
520
+ createdAt: "2026-07-01T00:00:00Z",
521
+ updatedAt: "2026-07-02T00:00:00Z",
522
+ reviewRequestLogins: [],
523
+ labels: [],
524
+ body: "",
525
+ changedFiles: 1,
526
+ mergedAt: null,
527
+ closedAt: null,
528
+ reviewers: [],
529
+ checks: [],
530
+ viewerCanMerge: true,
531
+ reviewerIds: [],
532
+ }),
533
listNotes: () => Effect.succeed({ comments: [comment], truncated: false }),
534
listCommits: () => Effect.succeed([commit]),
535
listDiscussions: () => Effect.succeed({ threads: [], truncated: false }),
@@ -599,7 +626,39 @@ describe("optional activity reads", () => {
626
}),
627
);
628
602
- it.effect("keeps comments and commits when optional discussions and reactions fail", () =>
629
+ it.effect("links comments and thread comments to their note on the merge request page", () =>
630
+ Effect.gen(function* () {
631
+ const provider = yield* make.pipe(
632
+ Effect.provide(
633
+ Layer.mock(GitLabPullRequestCli.GitLabPullRequestCli)({
634
+ ...reads,
635
+ listDiscussions: () =>
636
+ Effect.succeed({
637
+ threads: [
638
+ {
639
+ id: "d1",
640
+ path: "src/a.ts",
641
+ line: 1,
642
+ side: "right" as const,
643
+ isResolved: false,
644
+ isOutdated: false,
645
+ comments: [comment],
646
+ },
647
+ ],
648
+ truncated: false,
649
+ }),
650
+ }),
651
+ ),
652
+ );
653
+
654
+ const activity = yield* provider.getChangeRequestActivity(reference);
655
+
656
+ expect(activity.comments[0]?.url).toBe(`${webUrl}#note_42`);
657
+ expect(activity.reviewThreads[0]?.comments[0]?.url).toBe(`${webUrl}#note_42`);
658
+ }),
659
+ );
660
+
661
+ it.effect("keeps comments and commits when optional discussions, reactions and links fail", () =>
662
Effect.gen(function* () {
663
const provider = yield* make.pipe(
664
Effect.provide(
@@ -615,6 +674,7 @@ describe("optional activity reads", () => {
674
}),
675
),
676
listReactions: () => Effect.fail(new GitLabCli.GitLabCliCommandError(context)),
677
+ getMergeRequestDetail: () => Effect.fail(new GitLabCli.GitLabCliCommandError(context)),
678
}),
679
),
680
);
packages/source-control-gitlab/src/server/GitLabPullRequestProvider.ts
+38
-28
@@ -341,42 +341,52 @@ export const make = Effect.gen(function* () {
341
editedAtByNoteId: new Map<string, string>(),
342
botLogins: new Set<string>(),
343
}),
344
+ // Usually cached by the detail read beside this one; web_url holds the real web origin.
345
+ recoverRead(
346
+ mergeRequestDetail(input).pipe(Effect.map((mergeRequest) => mergeRequest.url)),
347
+ null,
348
+ ),
349
],
345
- { concurrency: 4 },
350
+ { concurrency: 5 },
351
).pipe(
352
Effect.mapError(fail("getChangeRequestActivity")),
348
- Effect.map(([notes, commits, discussions, awards]): ProviderChangeRequestActivity => {
349
- const edited = (id: string) => {
350
- const editedAt = awards.editedAtByNoteId.get(id);
351
- return editedAt === undefined ? {} : { editedAt };
352
- };
353
- const botLogins = new Set([...awards.botLogins].map((login) => login.toLowerCase()));
354
- const withBotFlag = (author: PullRequestActor | null) =>
355
- author !== null && botLogins.has(author.login.toLowerCase())
356
- ? { ...author, isBot: true }
357
- : author;
358
- return {
359
- reactions: awards.reactions,
360
- comments: notes.comments.map((comment) => ({
361
- ...comment,
362
- ...edited(comment.id),
363
- author: withBotFlag(comment.author),
364
- reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
365
- })),
366
- commentCount: notes.comments.length,
367
- commentsTruncated: notes.truncated || discussions.truncated,
368
- reviewThreads: discussions.threads.map((thread) => ({
369
- ...thread,
370
- comments: thread.comments.map((comment) => ({
353
+ Effect.map(
354
+ ([notes, commits, discussions, awards, webUrl]): ProviderChangeRequestActivity => {
355
+ const noteUrl = (id: string) => (webUrl === null ? null : `${webUrl}#note_${id}`);
356
+ const edited = (id: string) => {
357
+ const editedAt = awards.editedAtByNoteId.get(id);
358
+ return editedAt === undefined ? {} : { editedAt };
359
+ };
360
+ const botLogins = new Set([...awards.botLogins].map((login) => login.toLowerCase()));
361
+ const withBotFlag = (author: PullRequestActor | null) =>
362
+ author !== null && botLogins.has(author.login.toLowerCase())
363
+ ? { ...author, isBot: true }
364
+ : author;
365
+ return {
366
+ reactions: awards.reactions,
367
+ comments: notes.comments.map((comment) => ({
368
...comment,
369
...edited(comment.id),
370
author: withBotFlag(comment.author),
371
+ url: noteUrl(comment.id),
372
reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
373
})),
376
- })),
377
- commits,
378
- };
379
- }),
374
+ commentCount: notes.comments.length,
375
+ commentsTruncated: notes.truncated || discussions.truncated,
376
+ reviewThreads: discussions.threads.map((thread) => ({
377
+ ...thread,
378
+ comments: thread.comments.map((comment) => ({
379
+ ...comment,
380
+ ...edited(comment.id),
381
+ author: withBotFlag(comment.author),
382
+ url: noteUrl(comment.id),
383
+ reactions: awards.reactionsByNoteId.get(comment.id) ?? [],
384
+ })),
385
+ })),
386
+ commits,
387
+ };
388
+ },
389
+ ),
390
),
391
392
// Straight from the host, never the shared read: this is what a write is refused or let