feat(pull-requests): link multiple pull requests to threads (#10839)

This commit is contained in:
Julius Marminge authored and GitHub committed 2026-09-09 15:50:58 -07:00
1 parent 383cc40f4d
commit afb84898be
172 files changed
+12063 -914

No files matched your search

@@ -1,4 +1,5 @@
import * as Schema from "effect/Schema";
import { parseChangeRequestUrl } from "@t3tools/shared/changeRequestUrl";
import {
PullRequestDetail,
@@ -1028,6 +1029,7 @@ export function pullRequestActionNeedsHostRefresh(action: PullRequestAction): bo
type SnapshotStorage = Pick<Storage, "getItem" | "setItem">;
export interface PullRequestDetailSnapshotRef {
readonly host?: string | undefined;
readonly projectId: string;
readonly repository: string;
readonly number: number;
@@ -1037,7 +1039,9 @@ const pullRequestDetailSnapshotKey = (
environmentId: string,
reference: PullRequestDetailSnapshotRef,
) =>
`t3.pullRequests.detail:${environmentId}:${reference.projectId}:${reference.repository}#${reference.number}`;
reference.host
? `t3.pullRequests.detail:${JSON.stringify([environmentId, reference.projectId, reference.host.toLowerCase(), reference.repository.toLowerCase(), reference.number])}`
: `t3.pullRequests.detail:${environmentId}:${reference.projectId}:${reference.repository}#${reference.number}`;
const decodeDetailSnapshot = Schema.decodeUnknownOption(PullRequestDetail);
@@ -1056,7 +1060,9 @@ export function readPullRequestDetailSnapshot(
const raw = storage?.getItem(pullRequestDetailSnapshotKey(environmentId, reference));
if (!raw) return null;
const decoded = decodeDetailSnapshot(JSON.parse(raw));
return decoded._tag === "Some" ? decoded.value : null;
return decoded._tag === "Some"
? resolveDisplayedPullRequestDetail({ live: null, cached: decoded.value, reference })
: null;
} catch {
return null;
}
@@ -1090,7 +1096,9 @@ export function resolveDisplayedPullRequestDetail(input: {
input.cached !== null &&
input.cached.projectId === input.reference.projectId &&
input.cached.repository.toLowerCase() === input.reference.repository.toLowerCase() &&
input.cached.number === input.reference.number
input.cached.number === input.reference.number &&
(input.reference.host === undefined ||
parseChangeRequestUrl(input.cached.url)?.host === input.reference.host.toLowerCase())
) {
return input.cached;
}