feat(desktop): group sessions into tag folders in the sidebar

Merged
KI
2mo ago
+718-183

Summary

  • Sessions in the sidebar now group into collapsible tag folders, matching how projects already group, instead of rendering as one flat list.
  • Session groups support create / rename / delete and move-to-group from the context menu, plus bulk selection and bulk move.
  • Extracts a shared DashboardSidebarGroupHeader and promotes DashboardSidebarSectionHeader to the sidebar's components/ now that both lanes use it.

Why / Context

Projects already had tag folders, but the Sessions lane was a flat list and the new-group action bailed out early behind a // Sessions get groups in the stacked nesting PR. comment. This is that follow-up. Rather than inventing a second grouping model, sessions reuse the existing tag-folder model.

How It Works

Sessions have no project to hang folder settings off, so groups are derived from host-owned workspace tags rather than stored placement rows:

  • buildDashboardSidebarSessions partitions sessions into ungroupedWorkspaces + tagGroups, sorted alphabetically by normalized tag.
  • A session carrying several tags lands in its alphabetically first normalized tag. This mirrors how project folders pick one winning tag, so every session has exactly one deterministic home.
  • Untagged sessions stay at the top.
  • Group mutations are tag rewrites via applyFolderTagChange / mintFolderTag, so renaming a group retags its members and deleting one untags them.

The DnD model is deliberately untouched: Sessions remains a single persisted reorder/pin container, so the builder also returns a flat orderedWorkspaces that the existing SortableContext consumes. Collapsed groups are excluded from the selection range so shift-click can't select rows you can't see.

Manual QA Checklist

Grouping

  • Untagged sessions render at the top, above all groups
  • Tagged sessions appear under their tag, groups sorted alphabetically
  • A session with multiple tags appears in exactly one group (alphabetically first)
  • Collapse/expand a group persists while the sidebar is open

Group actions

  • "New group" mints a group and opens the rename input focused
  • Rename retags every member; renaming to an existing tag merges the groups
  • Delete untags members and they return to the ungrouped area
  • Move-to-group from a session's context menu moves it between groups

Selection / DnD

  • Shift-click range select does not span a collapsed group
  • Bulk move applies to every selected session
  • Reordering and pinning within Sessions still persists across restart
  • Project tag folders are unchanged

Testing

  • `bun run typecheck` — 38/38 tasks pass
  • `bun run lint` — clean, no fixes applied
  • `bun test` on `DashboardSidebar/` — 106 pass / 0 fail across 15 files, including new cases in `buildDashboardSidebarProjects.test.ts` and `workspaceSelection.test.ts`

Not yet exercised in a running app: the QA checklist above is unverified, so the interaction paths (rename focus, bulk move, collapsed-range select) still need a manual pass.

Design Decisions

  • Derived tag groups instead of stored placements: sessions have no project row to store folder settings against, and tags are already host-owned and synced. This avoids a sessions-only placement table.
  • Alphabetically first tag wins: a session must have one home. Matching the project-folder rule keeps one mental model rather than two.
  • Flat `orderedWorkspaces` retained: keeps Sessions as one DnD/persistence container, so grouping stays presentation-only and no reorder semantics change.

Known Limitations

  • Group collapse state is component-local, so it resets on remount rather than persisting like project section collapse.
  • A session with multiple tags is only visible under one of them; the other tags are not shown as additional homes.

Summary by cubic

Groups sessions into collapsible tag folders in the sidebar, matching how projects already group, instead of a flat list. Groups are derived from existing workspace tags, so untagged sessions stay at the top and multi-tag sessions land in their alphabetically first tag.

Behavior

  • Session groups support create, rename, delete, and move-to-group from the context menu, plus bulk selection and move.
  • Renaming a group retags its members; deleting untags them. Collapse state is local and resets on remount.
  • Group actions are gated on workspace type so project-less cloud workspaces no longer receive them.
  • DnD and persistence are unchanged; sessions remain a single reorder/pin container.

Refactors

  • Extracts a shared DashboardSidebarGroupHeader used by both project and session groups.
  • Makes section color actions optional since session groups have no project color.

Summary by CodeRabbit

  • New Features

    • Sessions in the sidebar are now grouped by tags, with collapsible groups and ungrouped sessions shown separately.
    • Session groups can be renamed, created, moved, and ungrouped.
    • Workspace selection better preserves the active workspace during multi-selection and range selection.
    • Sidebar indentation is refined for top-level and grouped workspaces.
  • Bug Fixes

    • Group actions now work for session workspaces without a project.
    • Sidebar group headers offer improved keyboard and interaction behavior.