feat(desktop): make Pinned and Sessions sidebar sections collapsible like Projects

Merged
KI
3mo ago
+170-97

Summary

The Pinned and Sessions sidebar sections now collapse exactly like the Projects header: click the header strip to toggle, with the chevron cue that stays visible while collapsed (per the GH #6009 convention) so hidden rows read as hidden rather than missing. Collapse state persists per section.

Refactor

  • New shared DashboardSidebarSectionHeader renders the top-level section header strip (label, chevron, right-aligned action slot); DashboardSidebarWorkspacesHeader (Projects), DashboardSidebarPinnedSection, and DashboardSidebarSessionsSection all use it now.
  • sidebar-workspaces-collapse store generalized to sidebar-sections-collapse holding collapsed: { pinned, sessions, workspaces }. The legacy localStorage key is kept with a v0→v1 persist migration, so an already-collapsed projects list carries over; persisted-key registry updated.

Behavior notes

  • Collapsed sections hide their rows (and unregister their sortables), matching collapsed project groups — drops don't target a collapsed section.
  • The empty-Pinned drop zone still renders mid-drag regardless of collapse, so the first drag-to-pin always has a landing target.
  • Sessions rows stay hidden when either its own collapse or the global Projects-list collapse is active; the Sessions "+" now stops propagation so it doesn't toggle the header.

Verification

Typecheck, lint, and persisted-key registry tests pass. Verified end-to-end over CDP against this worktree's dev app with trusted input: hover→chevron, collapse/expand each section, both-collapsed → location.reload() → still collapsed (store: {"collapsed":{"pinned":true,"sessions":true,"workspaces":false},"version":1}), console.error hooked throughout — zero entries. 27s screen recording captured.


Summary by cubic

Makes Pinned and Sessions sidebar sections collapsible with the same UX as Projects. Previously only Projects collapsed; now each section toggles via its header, shows the chevron while collapsed, and remembers its own state.

  • Review notes

    • Introduces DashboardSidebarSectionHeader and uses it for Projects, Pinned, and Sessions.
    • Replaces useSidebarWorkspacesCollapseStore with useSidebarSectionsCollapseStore consumers.
    • Collapsing unmounts rows and unregisters sortables; drops cannot target a collapsed section. The empty Pinned drop zone still renders mid-drag so the first pin always has a target. The Sessions “+” stops event propagation to avoid toggling; Sessions rows also hide when Projects is collapsed.
  • Persistence/migration

    • Generalizes persisted state to { collapsed: { pinned, sessions, workspaces } } under the legacy sidebar-workspaces-collapse key with a v0→v1 migration that maps isCollapsed to collapsed.workspaces.
    • Persisted-key registry updated; no migration action required.

Summary by CodeRabbit

  • New Features
    • Added collapsible sidebar sections for pinned items, sessions, and workspaces.
    • Added consistent section headers with chevrons, optional actions, and keyboard accessibility.
    • Sidebar collapse preferences are now saved between sessions.
    • Preserved drop zones and section actions when content is collapsed or hidden.