Skip to content

Commit 18ed23e

Browse files
committed
fix(web): retain legacy pull request snapshot host identities
1 parent 510df58 commit 18ed23e

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ describe("cached pull request detail", () => {
14261426

14271427
// regression: #12168 cached PR details were missed across entry points on custom ports
14281428
it.each(["github", "gitlab"] as const)(
1429-
"retains portless %s snapshot identities for custom web ports",
1429+
"retains legacy portless %s snapshots without mixing explicit web ports",
14301430
(providerName) => {
14311431
const provider = SourceControlProviderKind.make(providerName);
14321432
const storage = makeStorage();
@@ -1438,6 +1438,20 @@ describe("cached pull request detail", () => {
14381438
});
14391439
writePullRequestDetailSnapshot(storage, "env-1", hosted, cached);
14401440
expect(readPullRequestDetailSnapshot(storage, "env-1", hosted)?.title).toBe(cached.title);
1441+
expect(
1442+
resolveDisplayedPullRequestDetail({
1443+
live: null,
1444+
cached,
1445+
reference: { ...reference, host: `${host}:8443` },
1446+
}),
1447+
).toBe(cached);
1448+
expect(
1449+
resolveDisplayedPullRequestDetail({
1450+
live: null,
1451+
cached,
1452+
reference: { ...reference, host: `${host}:9443` },
1453+
}),
1454+
).toBeNull();
14411455
},
14421456
);
14431457

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,11 @@ export function resolveDisplayedPullRequestDetail(input: {
13991399
}
14001400
if (input.reference.host === undefined) return input.cached;
14011401
const link = sourceControlClients.parseChangeRequestUrl(input.cached.url)?.link;
1402-
return link !== undefined && (link.authority ?? link.host) === input.reference.host.toLowerCase()
1403-
? input.cached
1404-
: null;
1402+
if (link === undefined) return null;
1403+
const host = input.reference.host.toLowerCase();
1404+
// Older GitHub/GitLab references keyed custom-port snapshots by hostname alone.
1405+
const legacyHost =
1406+
(input.cached.provider === "github" || input.cached.provider === "gitlab") &&
1407+
link.host === host;
1408+
return (link.authority ?? link.host) === host || legacyHost ? input.cached : null;
14051409
}

0 commit comments

Comments
 (0)