Skip to content

Commit f52b391

Browse files
fix(web): a comment link on a pull request with no loaded comments still rereads the host
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 9de3953 commit f52b391

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,7 @@ describe("review thread conversations", () => {
588588
const pull = "https://github.com/o/r/pull/1";
589589
expect(pullRequestCommentLinkMayLoad(issueItems, `${pull}#issuecomment-999`)).toBe(true);
590590
expect(pullRequestCommentLinkMayLoad(githubItems, `${pull}/files#r999`)).toBe(true);
591+
expect(pullRequestCommentLinkMayLoad([], `${pull}#issuecomment-1`)).toBe(true);
591592
for (const fragment of ["#diff-abc", "#issue-1", "#event-1", "#partial-pull-merging", ""]) {
592593
expect(pullRequestCommentLinkMayLoad(issueItems, `${pull}/files${fragment}`), fragment).toBe(
593594
false,

‎apps/web/src/components/pullRequest/pullRequestDetail.logic.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,16 @@ export function pullRequestCommentLinkMayLoad(
668668
): boolean {
669669
const anchor = commentAnchor(url);
670670
if (!anchor) return false;
671-
const kind = anchorKind(anchor);
672-
return items.some((item) =>
673-
pullRequestConversationItemComments(item).some(
674-
(comment) => comment.url !== null && anchorKind(commentAnchor(comment.url) ?? "") === kind,
671+
const kinds = new Set(
672+
items.flatMap((item) =>
673+
pullRequestConversationItemComments(item).flatMap((comment) => {
674+
const loaded = comment.url === null ? null : commentAnchor(comment.url);
675+
return loaded ? [anchorKind(loaded)] : [];
676+
}),
675677
),
676678
);
679+
// With no loaded anchor to compare, the link may name the first comment.
680+
return kinds.size === 0 || kinds.has(anchorKind(anchor));
677681
}
678682

679683
export function filterPullRequestConversationItems(

0 commit comments

Comments
 (0)