@devries-cameron20 / t3code Mirror · read-only / commits / 546c67f443
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, 08:00 UTC

perf(web): sidebar retained git status lives in state (#20462)

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

Julius Marminge committed Oct 16, 2026 at 18:46 UTC 546c67f443765cebcecbc5db96999ac36aafbadc
2 files changed +16 -17
apps/web/reactCompiledFiles.ts
+1
@@ -37,4 +37,5 @@ export const REACT_COMPILED_FILES = [
37 "apps/web/src/panelAnimations.ts",
38 "apps/web/src/hooks/useCopyToClipboard.ts",
39 "apps/web/src/components/auth/PairingRouteSurface.tsx",
40 + "apps/web/src/components/Sidebar.logic.ts",
41 ] as const;
apps/web/src/components/Sidebar.logic.ts
+15 -17
@@ -71,17 +71,12 @@ export function useSidebarRowSubscriptionLease(isActive: boolean): {
71 } {
72 const [row, setRow] = React.useState<HTMLElement | null>(null);
73 const [isNearViewport, setIsNearViewport] = React.useState(isActive);
74 + // The active row stays leased after it deactivates until the observer reports.
75 + if (isActive && !isNearViewport) setIsNearViewport(true);
76 + const canObserve = typeof IntersectionObserver !== "undefined";
77
78 React.useEffect(() => {
76 - if (isActive) {
77 - setIsNearViewport(true);
78 - return;
79 - }
80 - if (row === null) return;
81 - if (typeof IntersectionObserver === "undefined") {
82 - setIsNearViewport(true);
83 - return;
84 - }
79 + if (isActive || row === null || !canObserve) return;
80
81 const scrollRoot = row.closest<HTMLElement>('[data-slot="scroll-area-viewport"]');
82 const observer = new IntersectionObserver(
@@ -93,21 +88,24 @@ export function useSidebarRowSubscriptionLease(isActive: boolean): {
88 );
89 observer.observe(row);
90 return () => observer.disconnect();
96 - }, [isActive, row]);
91 + }, [canObserve, isActive, row]);
92
93 return {
99 - leaseLiveStatus: isActive || isNearViewport,
94 + leaseLiveStatus: isActive || isNearViewport || !canObserve,
95 rowRef: setRow,
96 };
97 }
98
99 export function useRetainedValue<T>(key: string | null, value: T | null): T | null {
105 - const retained = React.useRef<{ readonly key: string; readonly value: T } | null>(null);
106 - if (key !== null && value !== null) {
107 - retained.current = { key, value };
100 + const [retained, setRetained] = React.useState<{
101 + readonly key: string;
102 + readonly value: T;
103 + } | null>(null);
104 + if (key !== null && value !== null && (retained?.key !== key || retained.value !== value)) {
105 + setRetained({ key, value });
106 }
107 if (value !== null) return value;
110 - return key !== null && retained.current?.key === key ? retained.current.value : null;
108 + return key !== null && retained?.key === key ? retained.value : null;
109 }
110
111 // Sidebar.motion handles ordinary section changes. Sortable transforms own
@@ -688,9 +686,9 @@ export function useThreadJumpHintVisibility(): {
686 };
687 }, []);
688
691 - const updateThreadJumpHintsVisibility = React.useCallback((shouldShow: boolean) => {
689 + const updateThreadJumpHintsVisibility = (shouldShow: boolean) => {
690 controllerRef.current?.sync(shouldShow);
693 - }, []);
691 + };
692
693 return {
694 showThreadJumpHints,