diff --git a/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx b/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx index cba33df1..0768a099 100644 --- a/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx +++ b/packages/ui/src/components/session/sidebar/SessionGroupSection.tsx @@ -350,6 +350,7 @@ function SessionGroupSectionBase(props: Props): React.ReactNode { setRenameFolderDraft, setRenamingFolderId, pinnedSessionIds, + expandedParents, sessionOrderIndex, currentSessionId, editingId, @@ -569,6 +570,16 @@ function SessionGroupSectionBase(props: Props): React.ReactNode { && visibleSessions.length >= ACTIVE_VIRTUALIZE_THRESHOLD; const shouldVirtualize = shouldVirtualizeArchived || shouldVirtualizeActive; + // Check if any parent node is expanded - expanded parents render their + // children inline, making them much taller than the fixed estimate. + // When expanded parents exist, increase bufferSize to cover the extra height. + const bucketTag = group.isArchivedBucket ? 'archived' : 'active'; + const hasExpandedParent = shouldVirtualize && visibleSessions.some((node) => { + if (node.children.length === 0) return false; + const expansionKey = `project:${bucketTag}:${node.session.id}`; + return expandedParents.has(expansionKey); + }); + const archivedVirtualContainerRef = React.useRef(null); const archivedScrollRef = React.useRef(null); const [archivedScrollEl, setArchivedScrollEl] = React.useState(null); @@ -904,7 +915,7 @@ function SessionGroupSectionBase(props: Props): React.ReactNode {