@devries-cameron20 / t3code Mirror · read-only / commits / 9c161462c9
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 05:30 UTC

perf(web): pull request chains parse each link's URL once (#21147)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 18, 2026 at 02:13 UTC 9c161462c94f7d9d6d9169da5c841457cbadf213
1 file changed +16 -3
packages/shared/src/threadPullRequests.ts
+16 -3
@@ -69,8 +69,21 @@ export function threadPullRequestKeysEqual(
69 return threadPullRequestKeyOf(left) === threadPullRequestKeyOf(right);
70 }
71
72 +// Clients re-derive chains for every link on each render, and normalizing parses the
73 +// link's URL. Links are immutable and keep their identity until they change.
74 +const normalizedKeys = new WeakMap<ThreadPullRequestKeySource, ThreadPullRequestKey>();
75 +
76 +function normalizedKeyOf(key: ThreadPullRequestKeySource): ThreadPullRequestKey {
77 + let normalized = normalizedKeys.get(key);
78 + if (normalized === undefined) {
79 + normalized = normalizeThreadPullRequestKey(key);
80 + normalizedKeys.set(key, normalized);
81 + }
82 + return normalized;
83 +}
84 +
85 export function threadPullRequestKeyOf(key: ThreadPullRequestKeySource): string {
73 - const normalized = normalizeThreadPullRequestKey(key);
86 + const normalized = normalizedKeyOf(key);
87 return `${normalized.host}/${normalized.repository}#${normalized.number}`;
88 }
89
@@ -210,7 +223,7 @@ export function resolveThreadPullRequestChains(
223 const nativeStacks = new Map<string, Array<ThreadPullRequestLink>>();
224 for (const link of visible) {
225 if (link.stack === null) continue;
213 - const key = normalizeThreadPullRequestKey(link);
226 + const key = normalizedKeyOf(link);
227 const stackKey = `${key.host}/${key.repository}#stack:${link.stack.id}`;
228 const members = nativeStacks.get(stackKey) ?? [];
229 members.push(link);
@@ -225,7 +238,7 @@ export function resolveThreadPullRequestChains(
238
239 const remaining = visible.filter((link) => !placed.has(threadPullRequestKeyOf(link)));
240 const branchKey = (link: ThreadPullRequestLink, branch: string) => {
228 - const key = normalizeThreadPullRequestKey(link);
241 + const key = normalizedKeyOf(link);
242 return `${key.host}/${key.repository}:${branch}`;
243 };
244 const byHead = new Map<string, ThreadPullRequestLink | null>();