vibe-kanban icon indicating copy to clipboard operation
vibe-kanban copied to clipboard

feat: Sort projects by most recent activity (workspace interactions, task runs, new tasks)

Open isomoes opened this issue 3 months ago • 0 comments

Problem

Projects were sorted by creation date, meaning recently created projects always appeared at the top regardless of usage. This made it difficult to find actively-used projects among many older ones.

Solution

Projects are now sorted by their most recent activity. A project's "last active" timestamp is determined by the most recent of:

Activity Type Timestamp Description
Workspace opened/interacted workspace.updated_at When a workspace is opened (calls Workspace::touch())
Task run started workspace.created_at When a new workspace is created for a task run
New task created task.created_at When a task is created in the project
Fallback project.created_at For projects with no activity

Implementation

Backend (crates/db/src/models/project.rs)

Modified Project::find_all() to use a computed ordering:

ORDER BY COALESCE(
  (SELECT MAX(w.updated_at) FROM workspaces w
   INNER JOIN tasks t ON t.id = w.task_id
   WHERE t.project_id = p.id),  -- Workspace interactions
  (SELECT MAX(w.created_at) FROM workspaces w
   INNER JOIN tasks t ON t.id = w.task_id
   WHERE t.project_id = p.id),  -- Task runs started
  (SELECT MAX(created_at) FROM tasks
   WHERE project_id = p.id),     -- New tasks created
  p.created_at                    -- Fallback
) DESC
  • Uses COALESCE to find the maximum timestamp across all activity types
  • No database migration required (computed on-the-fly)
  • Single subquery per activity type, indexed by existing foreign keys

Frontend

  • useProjects.ts: Removed frontend .sort() that was overriding backend order
  • useCreateModeState.ts: Removed redundant project sorting

Projects now respect the ordering sent by the backend WebSocket stream.

Test Plan

  • [x] Create multiple projects
  • [x] Create and run a task in Project B → Project B should appear first
  • [x] Run task in Project A → Project A should bubble to the top
  • [x] Create a new task in Project C → Project C should bubble to the top

Related

Fixes the project list ordering to match user expectations of "recently used" rather than "recently created."

  • https://github.com/BloopAI/vibe-kanban/issues/1417
  • https://github.com/BloopAI/vibe-kanban/issues/575

isomoes avatar Jan 13 '26 08:01 isomoes