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): panel presence keeps its retained value in state (#20459)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 18:46 UTC
a17781f638226b2f1c5f46954175e2be969ad112
2 files changed
+11
-17
apps/web/reactCompiledFiles.ts
+1
@@ -34,4 +34,5 @@ export const REACT_COMPILED_FILES = [
34
"apps/web/src/state/sourceControlActions.ts",
35
"apps/web/src/components/settings/ProjectFaviconPickerDialog.tsx",
36
"apps/web/src/components/settings/ThemeEditorPanel.tsx",
37
+ "apps/web/src/panelAnimations.ts",
38
] as const;
apps/web/src/panelAnimations.ts
+10
-17
@@ -1,4 +1,4 @@
1
-import { createContext, useContext, useEffect, useRef, useState } from "react";
1
+import { createContext, useContext, useEffect, useState } from "react";
2
import { type PanelAnimationDurationMs } from "@t3tools/contracts/settings";
3
4
import { useMediaQuery } from "./hooks/useMediaQuery";
@@ -45,30 +45,23 @@ export function usePanelPresence<T>(
45
durationMs: PanelAnimationDurationMs,
46
): { present: boolean; value: T | null } {
47
const [present, setPresent] = useState(open);
48
- const retainedRef = useRef<{ scopeKey: string | null; value: T | null } | null>(
48
+ const [retained, setRetained] = useState<{ scopeKey: string | null; value: T | null } | null>(
49
open ? { scopeKey, value } : null,
50
);
51
+ if (open && (retained?.scopeKey !== scopeKey || retained.value !== value)) {
52
+ setRetained({ scopeKey, value });
53
+ }
54
52
- useEffect(() => {
53
- if (open) retainedRef.current = { scopeKey, value };
54
- }, [open, scopeKey, value]);
55
+ if (open && !present) setPresent(true);
56
+ if (!open && !animated && present) setPresent(false);
57
58
useEffect(() => {
57
- if (open) {
58
- setPresent(true);
59
- return;
60
- }
61
- if (!animated) {
62
- setPresent(false);
63
- return;
64
- }
65
-
59
+ if (open || !animated) return;
60
const timeout = window.setTimeout(() => setPresent(false), durationMs);
61
return () => window.clearTimeout(timeout);
62
}, [animated, durationMs, open]);
63
70
- const retainedValue =
71
- retainedRef.current?.scopeKey === scopeKey ? retainedRef.current.value : null;
72
- const visible = open || (animated && present && retainedRef.current?.scopeKey === scopeKey);
64
+ const retainedValue = retained?.scopeKey === scopeKey ? retained.value : null;
65
+ const visible = open || (animated && present && retained?.scopeKey === scopeKey);
66
return { present: visible, value: open ? value : visible ? retainedValue : null };
67
}