feat(desktop): nestable sidebar workspace groups (stacked on #6274)

Closed
KI
1mo ago
+1075-160

Summary

Stacked on #6274 (sessions) — extracted from it so the two features get independent review and revert levers under squash-merge. The single commit here is a byte-exact reconstruction of the grouping-tree code as it stood after all review rounds on #6274 (produced via git revert of the extraction commit — no re-implementation).

Generalizes flat sidebar sections into a nestable grouping tree:

  • v2SidebarSections schema extended in place (parentSectionId, nullable projectId for the Sessions scope) — widening-with-default, zero migration; existing rows parse untouched
  • Groups nest to depth 4, folders-first rendering (DashboardSidebarNestedSection, recursive); read-side cycle/dangling/depth violations splice to the scope root (never dropped); write-side canMoveSectionToParent (shared by the mutation and the menus) refuses self/descendant/cross-scope/over-depth targets
  • Context-menu re-parenting: group "Move to group" / "Move to top level"; workspace "Move to group" lists nested groups; "New group from workspace" enabled for sessions (session-scope groups)
  • ⌘1–9 / arrow nav recurse the tree and expand the full collapsed-ancestor chain on reveal (both scopes); bulk-select covers workspaces inside nested groups
  • Root-level DnD unchanged (positional membership model); drag-into-nested-group is a follow-up

Testing

Carried over from the #6274 review cycle where this code was written and hardened: tree-safety unit tests (cycle/dangling/depth splices, session-scope nesting), plus CDP end-to-end verification of nested create/move/reveal/delete-reparent and reload persistence in both scopes. After #6274 merges this branch rebases onto main and CI re-runs the full suite.

Merge order

Merge #6274 first, then rebase this onto main (squash-merge invalidates the stacked base) and merge.


Summary by cubic

Adds nestable workspace groups to the sidebar for both Projects and Sessions. Improves organization and navigation with safe re-parenting, folders-first trees, and shortcuts that reveal nested items.

  • New Features

    • Groups can nest up to 4 levels with folders-first rendering; cycles, missing parents, and over-depth nodes are spliced to the root (never dropped).
    • Sessions area supports groups alongside loose sessions; nested groups render recursively.
    • Context menus: group “Move to group” and “Move to top level”; workspace “Move to group” lists nested targets. Moves refuse self/descendant, cross-scope, and over-depth targets.
    • ⌘1–9 and arrow navigation traverse nested groups and auto-expand all collapsed ancestors; bulk-select matches the visual order, including nested groups.
    • Root-level DnD unchanged; drag-into-nested-group will come later.
  • Migration

    • v2SidebarSections widened in place: parentSectionId added; projectId is now nullable. No migration required; existing rows continue to parse.