Skip to content

Commit f1c95c7

Browse files
TonybynMp4claude
andcommitted
fix(gitlab): file and image comments appear as review threads
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent b183048 commit f1c95c7

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
@@ -864,6 +864,40 @@ layer("GitLabPullRequestCli.layer", (it) => {
864864
],
865865
},
866866
{ id: "def456", notes: [{ id: 3, body: "ship it", created_at: "2026-07-01Z" }] },
867+
{
868+
id: "file789",
869+
notes: [
870+
{
871+
id: 4,
872+
body: "split this file",
873+
created_at: "2026-07-01Z",
874+
position: {
875+
position_type: "file",
876+
new_path: "src/b.ts",
877+
old_path: "src/b.ts",
878+
new_line: null,
879+
old_line: null,
880+
},
881+
},
882+
],
883+
},
884+
{
885+
id: "img012",
886+
notes: [
887+
{
888+
id: 5,
889+
body: "logo is blurry",
890+
created_at: "2026-07-01Z",
891+
position: {
892+
position_type: "image",
893+
new_path: "logo.png",
894+
old_path: "logo.png",
895+
new_line: null,
896+
old_line: null,
897+
},
898+
},
899+
],
900+
},
867901
]),
868902
),
869903
),
@@ -876,14 +910,12 @@ layer("GitLabPullRequestCli.layer", (it) => {
876910
number: 7,
877911
});
878912

879-
assert.strictEqual(threads.length, 1);
880-
expect(threads[0]).toMatchObject({
881-
id: "abc123",
882-
path: "src/a.ts",
883-
line: 12,
884-
side: "right",
885-
isResolved: true,
886-
});
913+
expect(threads.map(({ id, path, line, side }) => ({ id, path, line, side }))).toEqual([
914+
{ id: "abc123", path: "src/a.ts", line: 12, side: "right" },
915+
{ id: "file789", path: "src/b.ts", line: null, side: "right" },
916+
{ id: "img012", path: "logo.png", line: null, side: "right" },
917+
]);
918+
expect(threads[0]).toMatchObject({ isResolved: true });
887919
assert.strictEqual(threads[0]?.comments.length, 2);
888920
}),
889921
);

‎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)