Skip to content

Feat/host drag drop reorder#70

Merged
macnev2013 merged 5 commits into
macnev2013:mainfrom
BungeeDEV:feat/host-drag-drop-reorder
Jun 15, 2026
Merged

Feat/host drag drop reorder#70
macnev2013 merged 5 commits into
macnev2013:mainfrom
BungeeDEV:feat/host-drag-drop-reorder

Conversation

@BungeeDEV

Copy link
Copy Markdown
Contributor

This pull request adds support for manual drag-and-drop reordering of hosts and groups on the dashboard. It introduces new backend commands and database schema changes to persist the custom order, and updates the frontend to provide visual feedback for draggable cards. Additionally, it adds the necessary drag-and-drop dependencies to the project.

Manual ordering support:

  • Added new backend commands reorder_hosts and reorder_groups in src-tauri/src/db/commands.rs to persist manual ordering of hosts and groups, respectively. These commands update a new sort_order column and ensure atomicity and consistency. [1] [2] [3]
  • Updated the database schema in src-tauri/src/db/mod.rs to add a sort_order column to saved_hosts and to use this column (falling back to label/name) when listing hosts and groups. Added migration logic to ensure backward compatibility. [1] [2] [3] [4] [5]

Frontend drag-and-drop readiness:

  • Updated HostCard and GroupCard components to use cursor-grab and cursor-grabbing styles, providing users with visual feedback that cards are draggable. [1] [2]

Dependency management:

  • Added @dnd-kit/core, @dnd-kit/sortable, and @dnd-kit/utilities to package.json and pnpm-lock.yaml to enable frontend drag-and-drop functionality. Also added tslib as a dependency for these libraries. [1] [2] [3] [4] [5] [6]

Other package updates:

  • Updated platform-specific package configurations in pnpm-lock.yaml to specify the correct libc for various native dependencies, improving cross-platform compatibility. [1] [2] [3] [4]

BungeeDEV and others added 3 commits June 9, 2026 02:22
Let users manually reorder host cards on the dashboard via drag and drop;
the custom order is persisted in SQLite and survives app restarts.

- DB: add saved_hosts.sort_order (migration 13→14) and a reorder_hosts
  command that bulk-updates sort_order in a transaction; list_hosts now
  orders by sort_order ASC, label ASC.
- Frontend: wrap the host grid in @dnd-kit DndContext/SortableContext. The
  whole card is the drag surface (MouseSensor 5px / TouchSensor 250ms), so a
  plain click still connects.
- Store: reorderHosts applies the new order optimistically and reverts on
  persist failure, with a Vitest unit test covering the action.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Let users reorder the group cards via drag and drop, alongside the existing
within-grid host reordering. The custom order is persisted in SQLite and
survives app restarts.

- DB: add a reorder_groups command that bulk-updates host_groups.sort_order in
  a transaction. The sort_order column and the ordered list_groups query
  already existed, so no migration is needed.
- Frontend: the Groups grid gets its own DndContext/SortableContext, separate
  from the per-host DnD layer so the two never interfere. The whole group card
  is the drag surface (shared MouseSensor 5px / TouchSensor 250ms sensors), so
  a plain click still filters by group.
- Store: reorderGroups applies the new order optimistically and reverts on
  persist failure, with a Vitest unit test covering the action.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add E2E coverage for drag-and-drop reordering and polish the interaction.

- E2E: 63-host-reorder.spec.ts drags a host card and a group card to a new
  position via a real pointer gesture, confirms the order persisted to the
  backend, then relaunches the app and verifies the new order reloads from
  SQLite. New reorder.ts helper drives the gesture (W3C performActions) and
  reads DOM + persisted order; __e2eHostOrder / __e2eGroupOrder store hooks
  let the spec await the async DB write before relaunch.
- UX: grab/grabbing cursors on host and group cards so the drag affordance is
  clear; a plain click still selects/connects (drag needs a 5px move first).
- Add TODO markers above both DndContext blocks for future keyboard reordering.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BungeeDEV BungeeDEV marked this pull request as ready for review June 9, 2026 00:41
@BungeeDEV

Copy link
Copy Markdown
Contributor Author

Should cover #41 in general

@macnev2013 macnev2013 self-requested a review June 10, 2026 09:07
@macnev2013 macnev2013 added the enhancement New feature or request label Jun 10, 2026
@macnev2013 macnev2013 added this to the v0.10.4 milestone Jun 10, 2026
@macnev2013 macnev2013 linked an issue Jun 10, 2026 that may be closed by this pull request
Extends the host/group reordering to the Cloud Storage section so every
connection type on the hosts page can be manually ordered.

Backend: migration 14→15 adds s3_connections.sort_order (idempotent),
list_s3_connections orders by sort_order then label, and a transactional
reorder_s3_connections DB method + Tauri command (rolls back on unknown
id), mirroring reorder_hosts. Adds Rust tests for the persist and
rollback paths.

Frontend: SortableS3Card wraps S3Card, the Cloud Storage grid gets its
own DndContext, and handleS3DragEnd applies an optimistic reorder (with
rollback on failure) over the local connection state — reordering the
visible subset and splicing it back into the full list so filtered-out
connections keep their positions. Adds an __e2eS3Order hook and a
64-s3-reorder e2e spec verifying persistence across restart.
…ableCard, keyboard a11y, reorder tests

- Move the S3 connection list into s3-store with a reorderConnections action
  (optimistic update + rollback), mirroring hosts-store/groups-store; drop the
  inline invoke/rollback from HostsDashboard
- Replace SortableHostCard/GroupCard/S3Card with one generic SortableCard
- Add KeyboardSensor + sortableKeyboardCoordinates for accessible reordering
- Add reorder_hosts/reorder_groups DB tests and s3-store reorder tests
@macnev2013

Copy link
Copy Markdown
Owner

Pushed c1dea0f addressing the review feedback. Summary of changes:

1. S3 reorder now goes through the store (symmetry with hosts/groups)

The S3 connection list moved out of HostsDashboard local state into s3-store, which now owns connections, loadConnections, and a reorderConnections action (optimistic update + rollback) — mirroring hosts-store/groups-store. The inline invoke/rollback in handleS3DragEnd is gone, handleS3Delete reloads via the store, and the __e2eReloadS3Connections hook moved alongside the other S3 e2e hooks so the test contract is unchanged.

2. Backend test coverage for host/group reordering

Added DB-layer unit tests mirroring the existing S3 ones:

  • reorder_hosts_persists_order / reorder_hosts_rolls_back_on_unknown_id
  • reorder_groups_persists_order / reorder_groups_rolls_back_on_unknown_id

3. One generic SortableCard

SortableHostCard / SortableGroupCard / SortableS3Card were near-identical and have been replaced by a single generic SortableCard wrapper (the dead group/drag class was dropped).

4. Keyboard reordering (accessibility)

Added KeyboardSensor + sortableKeyboardCoordinates; SortableCard spreads attributes so a card can be focused and reordered with the arrow keys (Space/Enter to pick up and drop). The three TODO: keyboard reordering comments are removed. Also added s3-store.test.ts to complete store-test coverage.

Verification

  • cargo test --lib → 159 passed (incl. the 4 new reorder tests)
  • tsc --noEmit → clean
  • vitest run → 34 passed (incl. the new s3-store test)

@macnev2013 macnev2013 merged commit c104dbd into macnev2013:main Jun 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to sort the hosts yourself

2 participants