preserve expanded workspaces on session switch

This commit is contained in:
Benjamin Shafii
2026-04-24 14:56:22 -07:00
parent e64eb9366f
commit 7c306c7f88

View File

@@ -210,14 +210,10 @@ export function WorkspaceSessionList(props: Props) {
useEffect(() => { useEffect(() => {
const id = props.selectedWorkspaceId.trim(); const id = props.selectedWorkspaceId.trim();
if (!id) return; if (!id) return;
// Keep the selected workspace expanded and collapse the rest by default. // Keep the selected workspace visible without collapsing other workspaces.
// Without this, repeated switching leaves multiple large session trees open // Collapsing the previous workspace on every cross-workspace session click
// at once, which makes the sidebar increasingly expensive to render as // makes the sidebar feel jumpy and hides the context the user just left.
// histories grow. expandWorkspace(id);
setExpandedWorkspaceIds((previous) => {
if (previous.size === 1 && previous.has(id)) return previous;
return new Set([id]);
});
}, [props.selectedWorkspaceId]); }, [props.selectedWorkspaceId]);
const previewCount = (workspaceId: string) => const previewCount = (workspaceId: string) =>