Skip to content

Commit 1c2d4e1

Browse files
committed
fix(web): both sides of a stacked context row share one resolved marker
1 parent 410b033 commit 1c2d4e1

2 files changed

Lines changed: 48 additions & 12 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx‎

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,13 @@ it("folds a resolved conversation into avatars on its line until it is opened",
366366
};
367367
const container = document.createElement("div");
368368
container.className = "flex h-[700px] w-[900px]";
369-
const withThread = (isResolved: boolean) => (
369+
const comment = {
370+
author: { login: "reviewer", name: null, avatarUrl: null },
371+
body: "Rename this.",
372+
createdAt: "2026-09-01T00:00:00Z",
373+
url: null,
374+
};
375+
const withThread = (isResolved: boolean, oldSideToo = false) => (
370376
<PullRequestCodeTab
371377
scrollerRef={() => {}}
372378
environmentId={EnvironmentId.make("environment")}
@@ -386,16 +392,21 @@ it("folds a resolved conversation into avatars on its line until it is opened",
386392
side: "right",
387393
isResolved,
388394
isOutdated: false,
389-
comments: [
390-
{
391-
id: "comment",
392-
author: { login: "reviewer", name: null, avatarUrl: null },
393-
body: "Rename this.",
394-
createdAt: "2026-09-01T00:00:00Z",
395-
url: null,
396-
},
397-
],
395+
comments: [{ id: "comment", ...comment }],
398396
},
397+
...(oldSideToo
398+
? [
399+
{
400+
id: "old-side",
401+
path: "a.ts",
402+
line: 3,
403+
side: "left" as const,
404+
isResolved: true,
405+
isOutdated: false,
406+
comments: [{ id: "old-side-comment", ...comment }],
407+
},
408+
]
409+
: []),
399410
],
400411
}}
401412
selectedCommitOid={null}
@@ -438,4 +449,11 @@ it("folds a resolved conversation into avatars on its line until it is opened",
438449
await screen.rerender(withThread(true));
439450
await expect.element(marker()).toBeVisible();
440451
await expect.element(card("Resolved")).not.toBeInTheDocument();
452+
453+
// Stacked view draws a context row once, so both sides' conversations share its marker.
454+
await screen.rerender(withThread(true, true));
455+
await expect
456+
.element(screen.getByRole("button", { name: "Show 2 resolved conversations" }))
457+
.toBeVisible();
458+
await expect.element(marker()).not.toBeInTheDocument();
441459
});

‎apps/web/src/components/pullRequest/PullRequestCodeTab.tsx‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import {
6262
canEditPullRequestComment,
6363
canResolvePullRequestThread,
6464
} from "@t3tools/client-runtime/pull-request-editing";
65+
import { fileDiffRows } from "@t3tools/client-runtime/review-guide-tour";
6566
import { isTestChangedFile } from "@t3tools/shared/changedFileKind";
6667
import { orderDiffFiles } from "./pullRequestFileOrder.logic";
6768
import {
@@ -655,9 +656,26 @@ function PullRequestCodeTab({
655656
return created;
656657
};
657658

658-
for (const thread of threadsByPath.get(path) ?? []) {
659+
const fileThreads = threadsByPath.get(path) ?? [];
660+
// Stacked view draws a context row once, so its old side's conversations join the new side's.
661+
const contextNewLines =
662+
diffLayout !== "split" && fileThreads.some((thread) => thread.side === "left")
663+
? new Map(
664+
fileDiffRows(fileDiff).flatMap((row) =>
665+
row.oldLine !== null && row.newLine !== null
666+
? [[row.oldLine, row.newLine] as const]
667+
: [],
668+
),
669+
)
670+
: null;
671+
for (const thread of fileThreads) {
659672
if (thread.line === null || !placedThreadIds.has(thread.id)) continue;
660-
groupAt(thread.side, thread.line).threads.push(thread);
673+
const contextLine = thread.side === "left" ? contextNewLines?.get(thread.line) : undefined;
674+
const group =
675+
contextLine === undefined
676+
? groupAt(thread.side, thread.line)
677+
: groupAt("right", contextLine);
678+
group.threads.push(thread);
661679
}
662680
if (commit === null) {
663681
for (const comment of pendingComments) {

0 commit comments

Comments
 (0)