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 22, 12:00 UTC
perf(web): skip favicon loading for custom project icons (#23569)
Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Oct 30, 2026 at 15:53 UTC
37022730bacb03f26c1cba9b31ec1d8da3c6e730
2 files changed
+69
-7
apps/web/src/components/ProjectFavicon.browser.test.tsx
new
+57
@@ -0,0 +1,57 @@
1
+import { RegistryContext } from "@effect/atom-react";
2
+import { EnvironmentId } from "@t3tools/contracts";
3
+import { Atom, AtomRegistry } from "effect/reactivity";
4
+import { expect, it, vi } from "vite-plus/test";
5
+
6
+import { render } from "../../test/render";
7
+import { ProjectFavicon, type ProjectFaviconProject } from "./ProjectFavicon";
8
+
9
+const state = vi.hoisted(() => ({ favicon: undefined as Atom.Atom<string | null> | undefined }));
10
+vi.mock(import("../state/assets"), () => ({
11
+ projectFaviconUrlAtom: () => {
12
+ if (!state.favicon) throw new Error("Favicon resource not configured");
13
+ return state.favicon;
14
+ },
15
+}));
16
+
17
+function setup() {
18
+ const activeResources = new Set<string>();
19
+ state.favicon = Atom.make((get) => {
20
+ activeResources.add("favicon");
21
+ get.addFinalizer(() => activeResources.delete("favicon"));
22
+ return null;
23
+ });
24
+ return { activeResources };
25
+}
26
+
27
+it("only activates the favicon resource after removing a custom icon", async () => {
28
+ const { activeResources } = setup();
29
+ const registry = AtomRegistry.make();
30
+ const project: ProjectFaviconProject = {
31
+ environmentId: EnvironmentId.make("test"),
32
+ workspaceRoot: "/project",
33
+ title: "Project",
34
+ faviconPath: "icon.png",
35
+ projectIcon: { kind: "monogram", text: "PR", color: "blue" },
36
+ };
37
+ const view = (projectIcon: ProjectFaviconProject["projectIcon"]) => (
38
+ <RegistryContext value={registry}>
39
+ <ProjectFavicon project={{ ...project, projectIcon }} />
40
+ </RegistryContext>
41
+ );
42
+ try {
43
+ await using screen = await render(view(project.projectIcon));
44
+ expect(activeResources.size).toBe(0);
45
+ await screen.rerender(view({ kind: "emoji", emoji: "🌱" }));
46
+ expect(activeResources.size).toBe(0);
47
+ await screen.rerender(view({ kind: "lucide", name: "leaf", color: "green" }));
48
+ expect(activeResources.size).toBe(0);
49
+ await screen.rerender(view(null));
50
+ expect(activeResources.size).toBe(1);
51
+ await screen.rerender(view(project.projectIcon));
52
+ await screen.rerender(view(null));
53
+ expect(activeResources.size).toBe(1);
54
+ } finally {
55
+ registry.dispose();
56
+ }
57
+});
apps/web/src/components/ProjectFavicon.tsx
+12
-7
@@ -38,13 +38,6 @@ export function ProjectFavicon(input: {
38
fallbackIcon?: ComponentType<{ className?: string }>;
39
}) {
40
const { project } = input;
41
- const src = useAtomValue(
42
- projectFaviconUrlAtom({
43
- environmentId: project.environmentId,
44
- cwd: project.workspaceRoot,
45
- faviconPath: project.faviconPath,
46
- }),
47
- );
41
if (project.projectIcon?.kind === "monogram") {
42
return (
43
<ProjectMonogram
@@ -81,6 +74,18 @@ export function ProjectFavicon(input: {
74
</span>
75
);
76
}
77
+ return <AutomaticProjectFavicon {...input} />;
78
+}
79
+
80
+function AutomaticProjectFavicon(input: Parameters<typeof ProjectFavicon>[0]) {
81
+ const { project } = input;
82
+ const src = useAtomValue(
83
+ projectFaviconUrlAtom({
84
+ environmentId: project.environmentId,
85
+ cwd: project.workspaceRoot,
86
+ faviconPath: project.faviconPath,
87
+ }),
88
+ );
89
const FallbackIcon = input.fallbackIcon ?? FolderCodeIcon;
90
91
if (!src || isProjectFaviconFallbackUrl(src)) {