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, 08:00 UTC
perf(web): pull request markdown compiles without manual memoization (#20722)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 21:46 UTC
311319e92fa6710bd666cc4731c419eb108b8353
1 file changed
+12
-9
apps/web/src/components/pullRequest/PullRequestMarkdown.tsx
+12
-9
@@ -2,7 +2,7 @@ import { ExternalLinkIcon, PaperclipIcon } from "lucide-react";
2
import { markdownImageSourceFragment } from "@t3tools/client-runtime/markdown-images";
3
import { githubMediaFetchUrl } from "@t3tools/shared/githubMedia";
4
import type { AssetResource, EnvironmentId, ScopedThreadRef } from "@t3tools/contracts";
5
-import { createContext, useContext, useMemo } from "react";
5
+import { createContext, useContext } from "react";
6
import type { Options as ReactMarkdownOptions } from "react-markdown";
7
8
import { useAssetUrlRefresh, useAssetUrlState } from "~/assets/assetUrls";
@@ -18,6 +18,13 @@ export const PullRequestMarkdownContext = createContext<{
18
threadRef: ScopedThreadRef | null;
19
} | null>(null);
20
21
+// Both asset hooks key on the resource's identity; the compiler cannot cache a value
22
+// across successive hook calls in the component itself.
23
+function useGitHubMediaResource(cwd: string, fetchUrl: string): AssetResource {
24
+ "use memo";
25
+ return { _tag: "github-media", cwd, url: fetchUrl };
26
+}
27
+
28
function PullRequestGitHubVideo({
29
environmentId,
30
cwd,
@@ -29,10 +36,7 @@ function PullRequestGitHubVideo({
36
url: string;
37
fetchUrl: string;
38
}) {
32
- const resource = useMemo<AssetResource>(
33
- () => ({ _tag: "github-media", cwd, url: fetchUrl }),
34
- [cwd, fetchUrl],
35
- );
39
+ const resource = useGitHubMediaResource(cwd, fetchUrl);
40
const assetUrl = useAssetUrlState(environmentId, resource);
41
const refreshAssetUrl = useAssetUrlRefresh(environmentId, resource);
42
const src =
@@ -66,10 +70,9 @@ export function PullRequestMarkdown({
70
const context = useContext(PullRequestMarkdownContext);
71
const repositoryUrl = context?.repositoryUrl;
72
const resolvedThreadRef = threadRef ?? context?.threadRef ?? undefined;
69
- const extraRemarkPlugins = useMemo<NonNullable<ReactMarkdownOptions["remarkPlugins"]>>(
70
- () => (repositoryUrl ? [[remarkPullRequestAutolinks, { repositoryUrl }]] : []),
71
- [repositoryUrl],
72
- );
73
+ const extraRemarkPlugins: NonNullable<ReactMarkdownOptions["remarkPlugins"]> = repositoryUrl
74
+ ? [[remarkPullRequestAutolinks, { repositoryUrl }]]
75
+ : [];
76
return (
77
<div
78
className={cn(