From 549f6c3df3df9784d2d30ef8da45957833a05af9 Mon Sep 17 00:00:00 2001 From: Satya Patel Date: Fri, 17 Apr 2026 18:43:16 -0700 Subject: [PATCH] fix(desktop): v2 sidebar section count reflects visually grouped workspaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ungrouped workspaces that render after a section header are already visually grouped with that section (shared accent color, collapse together) and get committed into it on next drag. The count, however, was reading section.workspaces which only included workspaces whose DB sectionId already matched — so a freshly created section showed "(0)" while the user sees N workspaces beneath it. Reparent those workspaces into section.workspaces in the data layer so the count matches the visual grouping and DnD commit behavior. --- .../useDashboardSidebarData.ts | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/useDashboardSidebarData.ts b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/useDashboardSidebarData.ts index 9c60cb14333..b9a8b6b5c3a 100644 --- a/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/useDashboardSidebarData.ts +++ b/apps/desktop/src/renderer/routes/_authenticated/_dashboard/components/DashboardSidebar/hooks/useDashboardSidebarData/useDashboardSidebarData.ts @@ -324,9 +324,31 @@ export function useDashboardSidebarData() { sectionMap: _sectionMap, ...sidebarProject } = resolvedProject; - sidebarProject.children = childEntries + + const sortedChildren = childEntries .sort((left, right) => left.tabOrder - right.tabOrder) .map(({ child }) => child); + + // Ungrouped workspaces rendered after a section header are visually + // grouped with that section (shared accent, collapse-together) and will + // be committed into it on next DnD. Reparent them here so section counts + // match what the user sees. + const children: DashboardSidebarProjectChild[] = []; + let currentSection: DashboardSidebarSection | null = null; + for (const child of sortedChildren) { + if (child.type === "section") { + currentSection = child.section; + children.push(child); + } else if (currentSection) { + currentSection.workspaces.push({ + ...child.workspace, + accentColor: currentSection.color, + }); + } else { + children.push(child); + } + } + sidebarProject.children = children; return [sidebarProject]; }); }, [