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

@@ -6,7 +6,7 @@
* hosts that have no pending review of their own. That also means a draft lives only as long
* as the tab does, which is why this is deliberately not persisted.
*/
import type { ProjectId, PullRequestRef, PullRequestReviewCommentDraft } from "@t3tools/contracts";
import type { PullRequestRef, PullRequestReviewCommentDraft } from "@t3tools/contracts";
import { create } from "zustand";
export type PendingReviewComment = PullRequestReviewCommentDraft & { readonly id: string };
@@ -24,9 +24,14 @@ export function nextPendingReviewCommentId(): string {
return `pending-review-comment-${pendingCommentSequence}`;
}
/** One pull request's draft, scoped by project as well as repository: a repository can be checked out twice. */
/** A project's thread can review the same repository path and number on different hosts. */
export function pullRequestReviewKey(reference: PullRequestRef): string {
return `${reference.projectId}/${reference.repository}#${reference.number}`;
return JSON.stringify([
reference.projectId,
reference.host?.toLowerCase() ?? null,
reference.repository.toLowerCase(),
reference.number,
]);
}
interface PullRequestReviewStoreState {
@@ -81,11 +86,9 @@ export const usePullRequestReviewStore = create<PullRequestReviewStoreState>()((
}));
/** The comments a pull request's draft holds, stable across renders while it is empty. */
export function usePendingReviewComments(reference: {
readonly projectId: ProjectId;
readonly repository: string;
readonly number: number;
}): ReadonlyArray<PendingReviewComment> {
export function usePendingReviewComments(
reference: PullRequestRef,
): ReadonlyArray<PendingReviewComment> {
return usePullRequestReviewStore(
(store) => store.drafts[pullRequestReviewKey(reference)] ?? EMPTY,
);