feat: batch select and delete sessions in sidebar#835
Conversation
c872b32 to
d170f5e
Compare
roborev: Combined Review (
|
|
looking at this |
Add SoftDeleteSessions(ids []string) to batch-soft-delete multiple sessions in a single transaction. Add POST /sessions/batch-delete HTTP endpoint following the existing bulk-star pattern. Includes PG and DuckDB read-only stubs.
Add multi-select mode toggle to the session list header. When active, checkboxes appear on each session item, a toolbar shows selection count with Delete and Cancel buttons, and clicking items toggles selection instead of navigation. Calls the new POST /sessions/batch-delete endpoint to soft-delete all selected sessions at once.
The sidebar batch toolbar promised to select visible sessions, but it built that set from grouped session data. Collapsed continuation chains and collapsed group sections kept hidden child sessions in that data, so selecting all could delete rows that had no visible checkbox. Deriving the selection target from rendered display items keeps the toolbar aligned with the rows the user can actually see and interact with.
d170f5e to
5bbb58f
Compare
roborev: Combined Review (
|
Multi-select mode needs every visible row surface to toggle selection, including the session label link. Leaving the link on the normal navigation path made most of the row ignore the batch interaction model. Batch deletes are presented as one user action, so the undo state now records the deleted IDs as one batch and the toast restores that batch together instead of restoring only the last deleted session.
Batch undo entries can be partially acted on from the trash screen or partially restored from the undo toast. Dropping the whole batch after one ID changed made the remaining IDs unrecoverable from the toast, and aborting on the first restore error left already-restored IDs at the front of the retry path. Keep remaining IDs in each batch until the batch is empty, and have batch undo attempt every restore before retaining only failed IDs for retry.
A batch undo can fail after the original delete toast timer has nearly expired. Keeping that timer alive while restore attempts run can remove the retry entry before failed IDs are retained, leaving the user with no retry path. Clear the old timer when batch undo starts and create a fresh undo timer whenever failed IDs remain for retry.
roborev: Combined Review (
|
Multi-select state can outlive the rows that are currently rendered after filters, grouping changes, or sidebar reloads. Submitting the raw selected ID set could delete sessions that no longer have a visible checked row. Drive the toolbar count, disabled state, and delete payload from selected IDs that are still in the rendered sidebar list. Also remove the hard-coded white foreground on the batch delete button so the component satisfies the frontend source guard.
roborev: Combined Review (
|
The sidebar index can contain child rows while its total represents root groups, so optimistic row removal cannot safely update total or descendant visibility. Deleting a child could decrement the root-group total, and deleting a parent could leave locally promoted descendants that the backend sidebar would no longer return. Reload the sidebar index after the batch delete completes so sessions and totals follow the backend source of truth.
Batch delete is a mutation, so its refresh cannot safely join a same-signature sidebar load that started before the delete. Reusing that stale promise can republish pre-delete rows and totals after the operation resolves. Bypassing load coalescing for this post-delete refresh lets the existing abort and version guards keep the pre-delete request from publishing stale state.
roborev: Combined Review (
|
Batch undo is another mutation-triggered refresh, so it cannot safely await a sidebar load that started before the restore. If undo races the post-delete reload, reusing that promise can leave restored sessions hidden until a later refresh. Force the post-restore sidebar reload so the existing abort and version guards keep the older delete reload from publishing stale state.
roborev: Combined Review (
|
|
thank you! |
Summary
Add multi-select batch delete functionality to the session sidebar, allowing users to select and delete multiple sessions at once instead of deleting them one by one.
Ref #281
Changes
Backend:
SoftDeleteSessions(ids []string)DB method for batch soft-delete in a single transaction (batches of 500)POST /api/v1/sessions/batch-deleteendpoint accepting{ session_ids: [...] }, following the existing bulk-star patternSoftDeleteSessionsFrontend:
DeleteandCancelbuttons, plusAll/Clearfor select-allbatchDeleteSessions(ids)store method calls the new endpoint, updates local state, tracks undo toast entries, and exits select mode automaticallyTests:
TestSoftDeleteSessionscovering normal batch, pre-deleted skip, empty input, and non-existent IDs