The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { useClientSettings } from "../../hooks/useSettings"; |
| 2 | import { buildSidebarProjectSnapshots } from "../../sidebarProjectGrouping"; |
| 3 | import { useEnvironments, usePrimaryEnvironmentId } from "../../state/environments"; |
| 4 | import { useProjects } from "../../state/entities"; |
| 5 | |
| 6 | export function useSettingsProjectGroups() { |
| 7 | const projects = useProjects(); |
| 8 | // Avoid object selector identities that rebuild groups and every settings row on each write. |
| 9 | const sidebarProjectGroupingMode = useClientSettings( |
| 10 | (settings) => settings.sidebarProjectGroupingMode, |
| 11 | ); |
| 12 | const sidebarProjectGroupingOverrides = useClientSettings( |
| 13 | (settings) => settings.sidebarProjectGroupingOverrides, |
| 14 | ); |
| 15 | const primaryEnvironmentId = usePrimaryEnvironmentId(); |
| 16 | const { environments } = useEnvironments(); |
| 17 | const labels = new Map(environments.map((entry) => [entry.environmentId, entry.label])); |
| 18 | return buildSidebarProjectSnapshots({ |
| 19 | projects, |
| 20 | settings: { sidebarProjectGroupingMode, sidebarProjectGroupingOverrides }, |
| 21 | primaryEnvironmentId, |
| 22 | resolveEnvironmentLabel: (id) => labels.get(id) ?? null, |
| 23 | }).sort((a, b) => a.displayName.localeCompare(b.displayName)); |
| 24 | } |