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, 06:45 UTC
perf(web): the branch picker compiles without manual memoization (#20557)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 22:07 UTC
78c0d7df69e193ca5e8ecde0cbea6be6050a3366
1 file changed
+11
-15
apps/web/src/components/BranchPicker.tsx
+11
-15
@@ -1,7 +1,6 @@
1
import type { VcsRef } from "@t3tools/contracts";
2
import { LegendList, type LegendListRef } from "@legendapp/list/react";
3
import {
4
- useCallback,
4
useEffect,
5
useId,
6
useLayoutEffect,
@@ -71,24 +70,21 @@ export function BranchPicker({
70
const startFromOriginSwitchId = useId();
71
const branchListScrollElementRef = useRef<HTMLElement | null>(null);
72
const previousBranchListScrollTopRef = useRef<number | null>(null);
74
- const handleOpenChange = useCallback(
75
- (nextOpen: boolean) => {
76
- previousBranchListScrollTopRef.current = null;
77
- if (!nextOpen) highlightedValueRef.current = null;
78
- onOpenChange(nextOpen);
79
- },
80
- [onOpenChange],
81
- );
73
+ const handleOpenChange = (nextOpen: boolean) => {
74
+ previousBranchListScrollTopRef.current = null;
75
+ if (!nextOpen) highlightedValueRef.current = null;
76
+ onOpenChange(nextOpen);
77
+ };
78
const [showTopBranchScrollFade, setShowTopBranchScrollFade] = useState(false);
79
const [showBottomBranchScrollFade, setShowBottomBranchScrollFade] = useState(false);
84
- const fetchNextBranchPage = useCallback(() => {
80
+ const fetchNextBranchPage = () => {
81
if (!hasNextPage || isFetchingNextPage) {
82
return;
83
}
84
85
onLoadNext();
90
- }, [onLoadNext, hasNextPage, isFetchingNextPage]);
91
- const maybeFetchNextBranchPage = useCallback(() => {
86
+ };
87
+ const maybeFetchNextBranchPage = () => {
88
const scrollElement = branchListScrollElementRef.current;
89
if (!scrollElement) {
90
return;
@@ -111,10 +107,10 @@ export function BranchPicker({
107
}
108
109
fetchNextBranchPage();
114
- }, [fetchNextBranchPage, hasNextPage, open, isFetchingNextPage]);
110
+ };
111
112
const branchListRef = useRef<LegendListRef | null>(null);
117
- const updateBranchListScrollFades = useCallback(() => {
113
+ const updateBranchListScrollFades = () => {
114
const scrollElement = branchListRef.current?.getScrollableNode?.();
115
if (!(scrollElement instanceof HTMLElement)) {
116
return;
@@ -123,7 +119,7 @@ export function BranchPicker({
119
const maxScrollOffset = Math.max(0, scrollElement.scrollHeight - scrollElement.clientHeight);
120
setShowTopBranchScrollFade(scrollElement.scrollTop > 1);
121
setShowBottomBranchScrollFade(maxScrollOffset - scrollElement.scrollTop > 1);
126
- }, []);
122
+ };
123
124
useLayoutEffect(() => {
125
if (!open) {