Add drag-to-reorder for sidebar Workspaces #39

Merged
parkerhdavis merged 1 commit from workspaces-drag-reorder into main 2026-06-01 13:50:43 -06:00
parkerhdavis commented 2026-06-01 13:50:37 -06:00 (Migrated from github.com)

What

The sidebar's Workspaces can now be dragged up and down to reorder them, and the order persists.

How

The workspaces table already carried an indexed sort_order column and list_workspaces already ordered by it — this just wires the UI up to set it.

  • Backend — new reorder_workspaces command rewrites each row's sort_order to its position in the supplied id list, atomically (write_order helper + unit test).
  • Frontend — the Workspaces section renders through motion's Reorder.Group / Reorder.Item (no new dependency; motion was already in use). onReorder updates the store live during the drag; onDragEnd persists the final order. The store applies the new order optimistically and falls back to a server refresh if the write fails. The "New workspace" action sits inside the group but isn't a Reorder.Item, so it stays pinned at the bottom and isn't draggable.

Testing

tsc, Biome, cargo check, and the workspace unit tests (incl. the new reorder_rewrites_sort_order) all pass. Verified visually via make dev: drag reorders, order survives a restart, plain clicks still navigate, and the right-click context menu still works.

## What The sidebar's Workspaces can now be dragged up and down to reorder them, and the order persists. ## How The `workspaces` table already carried an indexed `sort_order` column and `list_workspaces` already ordered by it — this just wires the UI up to set it. - **Backend** — new `reorder_workspaces` command rewrites each row's `sort_order` to its position in the supplied id list, atomically (`write_order` helper + unit test). - **Frontend** — the Workspaces section renders through motion's `Reorder.Group` / `Reorder.Item` (no new dependency; `motion` was already in use). `onReorder` updates the store live during the drag; `onDragEnd` persists the final order. The store applies the new order optimistically and falls back to a server refresh if the write fails. The "New workspace" action sits inside the group but isn't a `Reorder.Item`, so it stays pinned at the bottom and isn't draggable. ## Testing `tsc`, Biome, `cargo check`, and the workspace unit tests (incl. the new `reorder_rewrites_sort_order`) all pass. Verified visually via `make dev`: drag reorders, order survives a restart, plain clicks still navigate, and the right-click context menu still works.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
parker/garnet!39
No description provided.