feat(desktop): re-land sidebar filter/sort with activity-based ordering

Closed
AV
2mo ago
+1531-24

Summary

Re-lands the dashboard sidebar filter + sort feature (#5956, reverted in #5996) with the fixes that motivated the revert:

  1. Reapply #5956 — pure revert-of-revert; the filter input, sort menu, and preference plumbing come back unchanged. Applies cleanly over #5997/#5999/#6000 (the #6000 stopPropagation guard survives).
  2. Crash fix — Electric cloud-fallback rows carry ISO-string timestamps at runtime (the shape parser doesn't handle timestamptz, despite the SelectV2Workspace type). They're normalized to real Dates where they enter mergeHostWorkspaces, and the sort coerces defensively (toTime, NaN-safe tie-breaks) so bad data can never crash the sidebar again. Fixes the workspace.updatedAt.getTime is not a function crash.
  3. Workspace-level sorting — non-manual modes now sort workspaces inside each project and inside sections, rank sections among loose workspaces by their newest member, and keep the local main workspace pinned first.
  4. "Last updated" means real activity — the revert reason: v2_workspaces.updatedAt only moves on metadata writes, so messaging an agent never reordered anything. The sidebar now polls each reachable host's terminalAgents.list (10s interval, only while the sort mode is "Last updated") and ranks everything by max(updatedAt, newest agent hook event). Sending a Claude message reorders within ~10s.
  5. Design doc — apps/desktop/docs/SIDEBAR_ACTIVITY_SORT.md records the signal semantics, the polling trade-off, and the follow-up paths (event-bus push for instant reordering; cloud-persisted activity as the long-term model; Electric timestamp-parser root fix as its own PR).

Verification

  • Full desktop suite: 2305 pass / 0 fail (new tests for string-date coercion, agent-activity ranking at workspace/section/project levels, merge normalization).
  • Live via CDP against the dev app: sort menu + filter exercised end-to-end; rendered order matches the ranking computed from real host binding data and provably diverges from updatedAt-only ordering; a synthetic UserPromptSubmit on a 3-day-idle workspace moved it to the top of its project in ~4s.
  • Typecheck and lint clean.

Notes

  • Overlaps with #6001: the reapply restores the automations bg-destructive color changes that #6001 also contains. Merge either first; the other becomes a trivial rebase/close.
  • Pinned rows intentionally keep pin order; unreachable hosts fall back to updatedAt ranking.

https://claude.ai/code/session_01SSUQYFamkYAjs5sDQC5RLS


Open in Stage

Summary by cubic

Re-lands the dashboard sidebar filter and sort, and makes “Last updated” use real agent activity so recent conversations reorder projects and workspaces. Also fixes a crash from cloud string timestamps.

  • New Features

    • Added project filter input and sort menu in the sidebar header; choice is saved in sidebarProjectSortMode.
    • “Last updated” now ranks by max(updatedAt, latest agent event), polling each reachable host’s terminalAgents.list every 10s only while this mode is active. Applies at workspace, section, and project levels; the local main workspace stays first.
    • Non-manual modes sort workspaces within projects and within sections; sections rank among loose workspaces by their newest member.
    • Drag-and-drop is disabled when sort ≠ manual or a filter is active to avoid corrupting hidden items; filter expands matched projects/sections and shows a simple “no match” state.
  • Bug Fixes

    • Prevented sidebar crash by coercing Electric cloud-fallback createdAt/updatedAt strings to Date in mergeHostWorkspaces; sorting uses NaN-safe coercion with name/id tie-breakers.
    • Standardized automation failure colors to bg-destructive.

Summary by CodeRabbit

  • New Features

    • Added sidebar project sorting by manual order, creation date, or recent activity.
    • Added project and workspace filtering with matching results automatically expanded.
    • Added persistent sorting preferences and improved controls in the sidebar header.
    • Recent agent activity now contributes to “Last updated” ordering.
  • Bug Fixes

    • Improved handling of cloud workspace timestamps.
    • Prevented drag-and-drop reordering while filtering or using non-manual sorting.
    • Standardized failed automation status styling.