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