fix(v2): clear gallery selection after deleting ROMs#3828
Merged
Conversation
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>
Contributor
Greptile SummaryThis PR synchronizes ROM deletion with the v2 gallery selection. The main changes are:
Confidence Score: 4/5The selection reconciliation needs to preserve failed deletions and use the original request IDs.
frontend/src/v2/components/Dialogs/DeleteRomDialog.vue Important Files Changed
Reviews (1): Last reviewed commit: "fix(v2): clear gallery selection after d..." | Re-trigger Greptile |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sdeleteRoms()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 > 0keeps the bar open).Changes:
gallerySelection.removeIds)./roms/deleteand/firmware/delete, both viaBulkOperationResponse) now returnfailed_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.showDeleteRomDialogevent arriving mid-request can't make the completed request prune the wrong IDs.test_delete_roms_reports_failed_idsasserting 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.
Screenshots (if applicable)
🤖 Generated with Claude Code