Skip to content

Commit 25b5329

Browse files
TonybynMp4claude
andauthored
fix(gitlab): file and image comments appear as review threads (#30425)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 938b4d4 commit 25b5329

2 files changed

Lines changed: 55 additions & 12 deletions

File tree

‎packages/source-control-gitlab/src/server/GitLabPullRequestCli.test.ts‎

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,40 @@ layer("GitLabPullRequestCli.layer", (it) => {
10221022
],
10231023
},
10241024
{ id: "def456", notes: [{ id: 3, body: "ship it", created_at: "2026-07-01Z" }] },
1025+
{
1026+
id: "file789",
1027+
notes: [
1028+
{
1029+
id: 4,
1030+
body: "split this file",
1031+
created_at: "2026-07-01Z",
1032+
position: {
1033+
position_type: "file",
1034+
new_path: "src/b.ts",
1035+
old_path: "src/b.ts",
1036+
new_line: null,
1037+
old_line: null,
1038+
},
1039+
},
1040+
],
1041+
},
1042+
{
1043+
id: "img012",
1044+
notes: [
1045+
{
1046+
id: 5,
1047+
body: "logo is blurry",
1048+
created_at: "2026-07-01Z",
1049+
position: {
1050+
position_type: "image",
1051+
new_path: "logo.png",
1052+
old_path: "logo.png",
1053+
new_line: null,
1054+
old_line: null,
1055+
},
1056+
},
1057+
],
1058+
},
10251059
]),
10261060
),
10271061
),
@@ -1034,14 +1068,12 @@ layer("GitLabPullRequestCli.layer", (it) => {
10341068
number: 7,
10351069
});
10361070

1037-
assert.strictEqual(threads.length, 1);
1038-
expect(threads[0]).toMatchObject({
1039-
id: "abc123",
1040-
path: "src/a.ts",
1041-
line: 12,
1042-
side: "right",
1043-
isResolved: true,
1044-
});
1071+
expect(threads.map(({ id, path, line, side }) => ({ id, path, line, side }))).toEqual([
1072+
{ id: "abc123", path: "src/a.ts", line: 12, side: "right" },
1073+
{ id: "file789", path: "src/b.ts", line: null, side: "right" },
1074+
{ id: "img012", path: "logo.png", line: null, side: "right" },
1075+
]);
1076+
expect(threads[0]).toMatchObject({ isResolved: true });
10451077
assert.strictEqual(threads[0]?.comments.length, 2);
10461078
}),
10471079
);

‎packages/source-control-gitlab/src/server/gitLabMergeRequestJson.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,21 @@ export function decodeDiscussionsJson(
547547
const notes = (discussion.value.notes ?? []).filter((note) => note.system !== true);
548548
const root = notes[0];
549549
const position = root?.position;
550-
if (root === undefined || !position || position.position_type !== "text") continue;
551-
const side = position.new_line === null || position.new_line === undefined ? "left" : "right";
552-
const path = trimmed(side === "left" ? position.old_path : position.new_path);
553-
const line = side === "left" ? position.old_line : position.new_line;
550+
if (root === undefined || !position) continue;
551+
let side: "left" | "right";
552+
let path: string | null;
553+
let line: number | null | undefined;
554+
if (position.position_type === "text") {
555+
side = position.new_line === null || position.new_line === undefined ? "left" : "right";
556+
path = trimmed(side === "left" ? position.old_path : position.new_path);
557+
line = side === "left" ? position.old_line : position.new_line;
558+
} else if (position.position_type === "file" || position.position_type === "image") {
559+
side = "right";
560+
path = trimmed(position.new_path) ?? trimmed(position.old_path);
561+
line = null;
562+
} else {
563+
continue;
564+
}
554565
if (path === null) continue;
555566
threads.push({
556567
id: discussion.value.id,

0 commit comments

Comments
 (0)