feat(desktop,cli): host-owned sidebar sections (workspace groups)
Links
- Issue: Fixes #5757
Summary
- Sidebar sections ("workspace groups") move from desktop-local state to a host-owned
sidebar_sectionstable on host-service, synced via a newsectionstRPC router — so groups are visible to both the desktop app and the CLI, not just the machine that created them. - Existing local sidebar sections migrate automatically to host-owned storage on first launch (
SidebarSectionsMigration,useMigrateSidebarSectionsToHost). - New CLI commands:
workspaces groups create/add/remove/rename/delete/list/moveandworkspaces move. - CLI docs (
apps/docs/content/docs/cli/cli-reference.mdx) updated with the new commands.
Why / Context
Sidebar groups previously lived only in the desktop app's local IndexedDB-backed state, so there was no way to see or manage them outside the desktop UI. Moving them to host-service (the same place workspace/PTY state already lives) makes them a first-class, host-owned concept the CLI can read and mutate directly — enabling scripted/automated workspace organization instead of drag-and-drop only.
How It Works
packages/host-service/src/db/schema.ts: newsidebar_sectionsSQLite table (id,project_id,name,color,tab_order), plussection_id/tab_ordercolumns onworkspaces.packages/host-service/src/trpc/router/sections/: CRUD +moveWorkspace+reorderLanemutations, backed bysidebar-sections-store.ts.packages/shared/src/sidebar-order.ts: shared tab-order comparison/insertion helpers used by host-service, CLI, and desktop so ordering logic isn't duplicated three times.packages/cli/src/lib/host-sections/: resolves a group or workspace by name or id (scoped to a project when ambiguous) against a single host's client. Host selection itself is the caller's job — see the rebase note below.- Desktop:
useDashboardSidebarState,useSidebarDnd, and the workspace/project context menus now read/write sections through the host instead of local Collections state;SidebarSectionsMigrationruns once per host to backfill any pre-existing local sections.
Rebased onto the single-host CLI model
This branch was opened before #5885 ("single-host reads with explicit host targeting") and #5731 ("local-first projects") landed. Merging main in required reworking the CLI surface, so re-review the CLI commits rather than assuming the earlier review still applies:
listHostWorkspacesis gone. The org-wide fan-out this branch was built on was deleted upstream and replaced with the single-hostworkspacesOnHost.ts.listWorkspacesOnHostnow also returns the host'ssections(tolerating aNOT_FOUNDsectionsrouter on an older host as "no groups").- Group commands take
--host/--local, defaulting to this machine. They previously searched the org for the workspace's host.groups add/removeandworkspaces moveno longer derive the host — they follow the same convention asworkspaces delete/update. workspaces listdrops theHOSTcolumn (the listing is single-host now) and keepsGROUP.resolveProjectIdreads the host'sproject.listinstead of the retired cloudv2Project.list, so--project <name>resolves against host-owned projects.- Migration renumbered
0010→0012, sincemaintook0010/0011. Content is unchanged. relinkLocalWorkspaceIdand the workspace cloud-sync helpers were deleted upstream, so this branch'ssectionId/tabOrderadditions to them went away with them.
A follow-up commit also removed two duplicate code paths this branch had accumulated: an inline copy of the compareTopLevelItems tie-break in getFlattenedV2WorkspaceIds, and moveWorkspaceToSectionAtIndex, which lost its last caller when the DnD commit path moved to the batched reorderSectionMembers (one plan instead of N).
Manual QA
⚠️ Needs re-running. The checklist below passed against the pre-rebase fan-out CLI, which no longer exists — the commands still parse, but host resolution changed underneath them. Treating these as verified would be misleading, so they're unchecked pending a re-run against a local dev stack (./.superset/setup.local.sh + bun run dev):
-
workspaces groups create <name> --project <p>creates a group on this machine (and--host <id>targets another) -
workspaces groups add <workspaceId> <group>moves a workspace in, setssectionId+ sequentialtabOrder -
workspaces groups listreports correctworkspaceCount;workspaces listreports correctgroupNameper workspace -
workspaces groups remove <workspaceId>moves a workspace back out (sectionId: null); no-op case returns a message instead of erroring -
workspaces groups rename <group> <newName>renames without touching membership -
workspaces groups delete <group>deletes the group and ungroups its members — members are not deleted -
--project <name>resolves against the host's project list (not the retired cloud table) -
sidebar_sectionsrows in host-service's local SQLite (host.db) match CLI output - Desktop UI: drag-and-drop create/reorder/collapse persistence and context-menu actions, against the post-merge sidebar (main restyled it and added project filter/sort in the meantime)
Testing
bun run lint— clean (5488 files)bun run typecheck— 35/35 packages passbun run test— 14/14 task packages pass, 0 failures (measured directly: desktop 2297, host-service 910, shared 704, CLI 48)
Summary by cubic
Make sidebar groups host-owned and synced across desktop and CLI. Adds a sections API with transactional reordering, shared ordering helpers, and CLI commands, plus a one-time migration from legacy local state.
-
New Features
- Host service:
sidebar_sectionstable;section_id/tab_orderonworkspaces;sectionstRPC router (CRUD,reorderLane,moveWorkspace) with strict validation;section:changedevent sends the full list; workspacelistincludessectionId/tabOrder. - Desktop: sidebar reads/writes groups via host; DnD batches a single reorder plan (optimistic rollback offline); cross-host grouping blocked; old hosts fall back to persisted local
tabOrder; create-then-move awaits create; delete preflights owner and sequences cross-host ungroup; sidebar ordering now uses@superset/shared/sidebar-order. - CLI:
workspaces groups create/add/remove/rename/delete/list,workspaces groups move, andworkspaces move;workspaces listshowsGROUP;workspaces createsupports--groupand--after; UUID/name resolution is case-insensitive; old-hostNOT_FOUNDdistinguished from transient failures. - Shared:
@superset/sharedsidebar-orderhelpers unify ordering and handle all-negative lanes; all surfaces usegetNextTabOrder.
- Host service:
-
Migration
- First launch per org runs
SidebarSectionsMigration(useMigrateSidebarSectionsToHost) to move legacy local sections to host storage; marks complete only after every placement succeeds and skips already-adopted orgs. - Collapse state stays per-client via
v2SectionUiState(not synced).
- First launch per org runs
Summary by CodeRabbit
- New Features
- Added workspace groups in the desktop sidebar, including creation, renaming, color updates, deletion, collapsing, grouping, and reordering.
- Added host-synced group data with offline snapshot support and live updates.
- Added CLI commands to list, create, rename, delete, move, and manage workspace groups.
- Workspace creation and listing now support group placement and group details.
- Bug Fixes
- Improved drag-and-drop ordering, cross-host validation, optimistic updates, rollback behavior, and workspace navigation.
- Added migration of existing sidebar groups and preserved group membership during workspace removal.