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
refactor(web): the open panel pull request URL keeps its caching without "use memo" (#20768)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 23:22 UTC
64b16d83a2a91eb07570cb2556861f5ccda01c0a
1 file changed
+21
-21
apps/web/src/hooks/useOpenPanelPullRequestUrl.ts
+21
-21
@@ -3,7 +3,6 @@ import { EnvironmentId, ProjectId, type ScopedThreadRef } from "@t3tools/contrac
3
4
import {
5
readPullRequestDetailSnapshot,
6
- resolveDisplayedPullRequestDetail,
6
resolvePullRequestReferenceHost,
7
} from "../components/pullRequest/pullRequestDetail.logic";
8
import { gitHubPullRequestBrowserUrl } from "../lib/openPullRequestLink";
@@ -18,13 +17,11 @@ type PanelPullRequestSurface = Extract<
17
{ kind: "pull-request" }
18
>;
19
21
-// The reference keys the detail query atom, so it must keep its identity across renders.
22
-function usePanelPullRequestReference(
20
+function panelPullRequestReference(
21
requestedReference: PanelPullRequestSurface | null,
22
supportsMultiplePullRequests: boolean,
23
repositoryIdentity: Parameters<typeof resolvePullRequestReferenceHost>[1],
24
) {
27
- "use memo";
25
if (requestedReference === null) return null;
26
const input = {
27
projectId: ProjectId.make(requestedReference.projectId),
@@ -56,19 +53,14 @@ export function useOpenPanelPullRequestUrl(threadRef: ScopedThreadRef | null) {
53
? scopeProjectRef(environmentId, ProjectId.make(requestedReference.projectId))
54
: null,
55
);
59
- const reference = usePanelPullRequestReference(
56
+ const reference = panelPullRequestReference(
57
requestedReference,
58
supportsMultiplePullRequests,
59
project?.repositoryIdentity,
60
);
64
- const detail = useEnvironmentQuery(
65
- reference && environmentId
66
- ? pullRequestEnvironment.detail({
67
- environmentId,
68
- input: reference,
69
- })
70
- : null,
71
- ).data;
61
+ // Everything that reads reference or the project runs before the query hook; a plain
62
+ // call on either after it would leave reference, and the detail atom it keys, uncached.
63
+ // The snapshot is already checked against reference, so live detail just wins below.
64
const cachedDetail =
65
reference && environmentId
66
? readPullRequestDetailSnapshot(
@@ -77,13 +69,21 @@ export function useOpenPanelPullRequestUrl(threadRef: ScopedThreadRef | null) {
69
reference,
70
)
71
: null;
80
- return reference
81
- ? (resolveDisplayedPullRequestDetail({ live: detail, cached: cachedDetail, reference })?.url ??
82
- requestedReference?.url ??
83
- gitHubPullRequestBrowserUrl(
84
- project?.repositoryIdentity,
85
- reference.repository,
86
- reference.number,
87
- ))
72
+ const fallbackUrl = reference
73
+ ? (requestedReference?.url ??
74
+ gitHubPullRequestBrowserUrl(
75
+ project?.repositoryIdentity,
76
+ reference.repository,
77
+ reference.number,
78
+ ))
79
: undefined;
80
+ const detail = useEnvironmentQuery(
81
+ reference && environmentId
82
+ ? pullRequestEnvironment.detail({
83
+ environmentId,
84
+ input: reference,
85
+ })
86
+ : null,
87
+ ).data;
88
+ return reference ? ((detail ?? cachedDetail)?.url ?? fallbackUrl) : undefined;
89
}