Skip to content

fix(v2): clear gallery selection after deleting ROMs#3828

Merged
gantoine merged 6 commits into
masterfrom
fix/v2-clear-selection-after-delete
Jul 19, 2026
Merged

fix(v2): clear gallery selection after deleting ROMs#3828
gantoine merged 6 commits into
masterfrom
fix/v2-clear-selection-after-delete

Conversation

@gantoine

@gantoine gantoine commented Jul 19, 2026

Copy link
Copy Markdown
Member

Description
Explain the changes or enhancements you are proposing with this pull request.

Fixes #3822.

In the v2 UI, deleting selected games left them "selected": multiselect mode stayed active, the SelectionBar stayed open pointing at rows that no longer exist, and re-running a bulk action (delete again, download, ...) returned a "not found" error.

Root cause: DeleteRomDialog.vue's deleteRoms() cleared only the legacy v1 selection store (romsStore.resetSelection()). v2 multiselect and the SelectionBar read from a separate store, v2GallerySelection (frontend/src/v2/stores/gallerySelection.ts), which was never touched, so the deleted ROMs stayed in the selection set (enabled = size > 0 keeps the bar open).

Changes:

  • Frontend: after a delete, prune the deleted ROMs from the v2 gallery selection (gallerySelection.removeIds).
  • Partial-failure correctness: the bulk delete endpoint deletes per-ROM and can partially fail. The endpoints (/roms/delete and /firmware/delete, both via BulkOperationResponse) now return failed_ids, and the client only prunes the ROMs that were actually removed, so a failed subset stays visible and selected for retry. Only the succeeded IDs are removed from the gallery / recent / continue-playing lists, and the single-ROM route only navigates away when its ROM was deleted.
  • Concurrency safety: the handler snapshots the dialog state at entry and acts on that snapshot, so a showDeleteRomDialog event arriving mid-request can't make the completed request prune the wrong IDs.
  • Tests: added test_delete_roms_reports_failed_ids asserting the failed id is reported while the valid one is deleted.

AI assistance disclosure: This change was written with AI assistance (Claude Code), reviewed by the author.

Checklist
Please check all that apply.

  • I've tested the changes locally
  • I've updated relevant comments
  • I've assigned reviewers for this PR
  • I've added unit tests that cover the changes

Screenshots (if applicable)

🤖 Generated with Claude Code

The v2 delete flow cleared only the legacy v1 selection store
(romsStore.resetSelection()), leaving the v2 gallerySelection store
untouched. Since v2 multiselect and the SelectionBar read from
gallerySelection, the deleted ROMs stayed selected: the bar remained
open with stale rows and re-running a bulk action 404'd.

Drop the deleted IDs from gallerySelection via removeIds so a full
delete closes the bar while a partial delete keeps the rest selected.

Fixes #3822

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 19, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR synchronizes ROM deletion with the v2 gallery selection. The main changes are:

  • Adds the v2 gallery-selection store to the delete dialog.
  • Removes requested ROM IDs from v2 selection after deletion.

Confidence Score: 4/5

The selection reconciliation needs to preserve failed deletions and use the original request IDs.

  • Partial bulk failures remove ROMs from selection even though they remain in the gallery.
  • Reading mutable dialog state after the request can clear IDs from a later dialog invocation.

frontend/src/v2/components/Dialogs/DeleteRomDialog.vue

Important Files Changed

Filename Overview
frontend/src/v2/components/Dialogs/DeleteRomDialog.vue Reconciles v2 gallery selection after deletion, but can clear failed or unrelated ROM IDs.

Fix All in Claude Code

Reviews (1): Last reviewed commit: "fix(v2): clear gallery selection after d..." | Re-trigger Greptile

Comment thread frontend/src/v2/components/Dialogs/DeleteRomDialog.vue Outdated
Comment thread frontend/src/v2/components/Dialogs/DeleteRomDialog.vue Outdated
gantoine and others added 5 commits July 19, 2026 12:13
The bulk delete endpoint deletes per-ROM and can partially fail, but the
v2 dialog pruned every requested ROM from the selection and gallery. A
ROM that failed to delete stayed in the library yet lost its selected
state, so the user couldn't retry the failed subset.

Return the failed IDs from the delete endpoints (roms + firmware, both
via BulkOperationResponse) and, on the client, only prune the ROMs that
were actually removed. Failed ROMs stay selected and visible for retry;
the single-ROM route only navigates away when its ROM was deleted.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The delete handler re-read the dialog refs (roms, platform, exclude flag)
after the request resolved. Because the dialog is a singleton, a fresh
showDeleteRomDialog event arriving mid-request could swap those refs, so
the completed request would prune the new dialog's IDs instead of the
ones it processed. Snapshot the state at entry and act on the snapshot.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
failed_items was just the length of failed_ids. Remove the redundant
counter from the delete endpoints (roms + firmware) and the response
type; callers that need the count derive it from failed_ids.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gantoine
gantoine merged commit 791ebd9 into master Jul 19, 2026
13 checks passed
@gantoine
gantoine deleted the fix/v2-clear-selection-after-delete branch July 19, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Selection status isn't cleared after deletion

2 participants