( workspaces: FrontendWorkspaceMetadata[], sections: WorkspaceGroupConfig[] )
| 827 | * @returns Partitioned workspaces |
| 828 | */ |
| 829 | export function partitionWorkspacesBySection( |
| 830 | workspaces: FrontendWorkspaceMetadata[], |
| 831 | sections: WorkspaceGroupConfig[] |
| 832 | ): SectionPartitionResult { |
| 833 | const sectionIds = new Set(sections.map((s) => s.id)); |
| 834 | const unsectioned: FrontendWorkspaceMetadata[] = []; |
| 835 | const bySectionId = new Map<string, FrontendWorkspaceMetadata[]>(); |
| 836 | |
| 837 | // Initialize all sections with empty arrays to ensure consistent ordering |
| 838 | for (const section of sections) { |
| 839 | bySectionId.set(section.id, []); |
| 840 | } |
| 841 | |
| 842 | // Build workspace lookup for parent resolution |
| 843 | const byId = new Map<string, FrontendWorkspaceMetadata>(); |
| 844 | for (const workspace of workspaces) { |
| 845 | byId.set(workspace.id, workspace); |
| 846 | } |
| 847 | |
| 848 | for (const workspace of workspaces) { |
| 849 | const effectiveSectionId = resolveEffectiveSectionId(workspace, byId, sectionIds); |
| 850 | if (effectiveSectionId) { |
| 851 | const list = bySectionId.get(effectiveSectionId)!; |
| 852 | list.push(workspace); |
| 853 | } else { |
| 854 | unsectioned.push(workspace); |
| 855 | } |
| 856 | } |
| 857 | |
| 858 | return { unsectioned, bySectionId }; |
| 859 | } |
| 860 | |
| 861 | /** |
| 862 | * Resolve the effective sub-project section ID for a workspace, matching how |
no test coverage detected