From 57cef1b278a61fce43344069e29b273ee4adff47 Mon Sep 17 00:00:00 2001 From: bashrusakh <127580858+bashrusakh@users.noreply.github.com> Date: Wed, 24 Jun 2026 06:24:11 +1100 Subject: [PATCH] fix(sidebar): correct expansion-key format for virtualizer buffer (#1711) * fix(sidebar): increase virtualizer buffer for expanded parents Fix #1530: archive sub-session layout broken because the virtualizer used a fixed 28px height estimate per row. Expanded parents with inline children are much taller. Now dynamically increases bufferSize when expanded parents are present. * fix(sidebar): correct expansion-key format for virtualizer buffer The expansion key was using raw sessionId instead of the scoped format 'project:{archived|active}:{sessionId}'. This made hasExpandedParent always false, so bufferSize never increased. Also removed dead hasSessionSearchQuery branch. --------- Co-authored-by: Leonid Skorobogatyy --- .../session/sidebar/SessionGroupSection.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 {