Compare commits

...
Author SHA1 Message Date
72cd4a39d2 Avoid mutating memoized sidebar registries
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: codex <[email protected]>
2026-06-18 23:20:30 -07:00
02ea090cb4 Format sidebar allocation fix
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: codex <[email protected]>
2026-06-18 23:20:29 -07:00
a504c7bf88 Avoid eager sidebar collection allocation
Co-authored-by: Julius Marminge <[email protected]>
Co-authored-by: codex <[email protected]>
2026-06-18 23:20:28 -07:00
+16 -12
View File
@@ -323,7 +323,7 @@ interface SidebarThreadRowProps {
renamingCommittedRef: React.RefObject<boolean>;
confirmingArchiveThreadKey: string | null;
setConfirmingArchiveThreadKey: React.Dispatch<React.SetStateAction<string | null>>;
confirmArchiveButtonRefs: React.RefObject<Map<string, HTMLButtonElement>>;
confirmArchiveButtonRefs: Map<string, HTMLButtonElement>;
handleThreadClick: (
event: React.MouseEvent,
threadRef: ScopedThreadRef,
@@ -608,9 +608,9 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
const handleConfirmArchiveRef = useCallback(
(element: HTMLButtonElement | null) => {
if (element) {
confirmArchiveButtonRefs.current.set(threadKey, element);
confirmArchiveButtonRefs.set(threadKey, element);
} else {
confirmArchiveButtonRefs.current.delete(threadKey);
confirmArchiveButtonRefs.delete(threadKey);
}
},
[confirmArchiveButtonRefs, threadKey],
@@ -636,7 +636,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
event.stopPropagation();
setConfirmingArchiveThreadKey(threadKey);
requestAnimationFrame(() => {
confirmArchiveButtonRefs.current.get(threadKey)?.focus();
confirmArchiveButtonRefs.get(threadKey)?.focus();
});
},
[confirmArchiveButtonRefs, setConfirmingArchiveThreadKey, threadKey],
@@ -888,7 +888,7 @@ interface SidebarProjectThreadListProps {
renamingCommittedRef: React.RefObject<boolean>;
confirmingArchiveThreadKey: string | null;
setConfirmingArchiveThreadKey: React.Dispatch<React.SetStateAction<string | null>>;
confirmArchiveButtonRefs: React.RefObject<Map<string, HTMLButtonElement>>;
confirmArchiveButtonRefs: Map<string, HTMLButtonElement>;
attachThreadListAutoAnimateRef: (node: HTMLElement | null) => void;
handleThreadClick: (
event: React.MouseEvent,
@@ -1223,7 +1223,7 @@ const SidebarProjectItem = memo(function SidebarProjectItem(props: SidebarProjec
>("inherit");
const renamingCommittedRef = useRef(false);
const renamingInputRef = useRef<HTMLInputElement | null>(null);
const confirmArchiveButtonRefs = useRef(new Map<string, HTMLButtonElement>());
const confirmArchiveButtonRefs = useMemo(() => new Map<string, HTMLButtonElement>(), []);
const memberProjectByScopedKey = useMemo(
() =>
new Map(
@@ -3246,22 +3246,26 @@ export default function Sidebar() {
dragInProgressRef.current = false;
}, []);
const animatedProjectListsRef = useRef(new WeakSet<HTMLElement>());
const animatedProjectListsRef = useRef<WeakSet<HTMLElement> | null>(null);
const attachProjectListAutoAnimateRef = useCallback((node: HTMLElement | null) => {
if (!node || animatedProjectListsRef.current.has(node)) {
const animatedProjectLists =
animatedProjectListsRef.current ?? (animatedProjectListsRef.current = new WeakSet());
if (!node || animatedProjectLists.has(node)) {
return;
}
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
animatedProjectListsRef.current.add(node);
animatedProjectLists.add(node);
}, []);
const animatedThreadListsRef = useRef(new WeakSet<HTMLElement>());
const animatedThreadListsRef = useRef<WeakSet<HTMLElement> | null>(null);
const attachThreadListAutoAnimateRef = useCallback((node: HTMLElement | null) => {
if (!node || animatedThreadListsRef.current.has(node)) {
const animatedThreadLists =
animatedThreadListsRef.current ?? (animatedThreadListsRef.current = new WeakSet());
if (!node || animatedThreadLists.has(node)) {
return;
}
autoAnimate(node, SIDEBAR_LIST_ANIMATION_OPTIONS);
animatedThreadListsRef.current.add(node);
animatedThreadLists.add(node);
}, []);
const visibleThreads = useMemo(