From 44516a774a2e459ee3fc8c12f08e212cd2c090da Mon Sep 17 00:00:00 2001 From: zurdi Date: Fri, 11 Sep 2026 14:13:21 +0200 Subject: [PATCH] review(pr-ready step 2): harden select-all against races and bad contexts Code-review pass fixes: a re-triggered select-all re-arms the pending epoch instead of no-opping; the loaded-only fallback waits for the metadata bootstrap; deselections made during the fetch survive the merge; fetches are refused off the gallery view and on empty results; the Missing tab clears the selection on unmount; Esc cancels an in-flight select-all even before anything is selected; hot-path scans short-circuit on count and read through toRaw; the sidecar-skip flags and page size get one home; failures reach the console. Six new tests pin the races. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01Ldi4YaXJWDDmFdbKfQay8L --- .../v2/components/Gallery/GalleryShell.vue | 9 +- .../v2/components/Gallery/GameListHeader.vue | 7 +- .../v2/components/Gallery/SelectionBar.vue | 8 +- .../Settings/MissingGamesSection.vue | 4 + .../useGallerySelectAll/index.test.ts | 125 ++++++++++++++++-- .../composables/useGallerySelectAll/index.ts | 82 ++++++++---- frontend/src/v2/stores/galleryRoms.test.ts | 50 +++---- frontend/src/v2/stores/galleryRoms.ts | 55 ++++---- frontend/src/v2/stores/gallerySelection.ts | 31 +++-- 9 files changed, 254 insertions(+), 117 deletions(-) diff --git a/frontend/src/v2/components/Gallery/GalleryShell.vue b/frontend/src/v2/components/Gallery/GalleryShell.vue index 29ccb3461..d2eee4865 100644 --- a/frontend/src/v2/components/Gallery/GalleryShell.vue +++ b/frontend/src/v2/components/Gallery/GalleryShell.vue @@ -783,7 +783,7 @@ onBeforeRouteLeave((_to, from) => { // Whole-result select-all, shared with the SelectionBar button and // the list header checkbox. -const { selectAll } = useGallerySelectAll(); +const { selectAll, selectingAll } = useGallerySelectAll(); // Global hotkeys scoped to the gallery shell — Esc clears the // selection, Ctrl/Cmd+A selects the whole filtered result. Both are @@ -800,14 +800,17 @@ function onShellKey(e: KeyboardEvent) { ) { return; } - if (e.key === "Escape" && gallerySelection.enabled) { + // `selectingAll` keeps Esc working while a whole-result fetch is + // still in flight with nothing selected yet (clear() abandons it). + if (e.key === "Escape" && (gallerySelection.enabled || selectingAll.value)) { e.preventDefault(); gallerySelection.clear(); return; } if ((e.ctrlKey || e.metaKey) && (e.key === "a" || e.key === "A")) { e.preventDefault(); - void selectAll(); + // A held chord repeats keydown at the OS rate; one trigger is enough. + if (!e.repeat) void selectAll(); } } diff --git a/frontend/src/v2/components/Gallery/GameListHeader.vue b/frontend/src/v2/components/Gallery/GameListHeader.vue index 4b8fbf484..2500de954 100644 --- a/frontend/src/v2/components/Gallery/GameListHeader.vue +++ b/frontend/src/v2/components/Gallery/GameListHeader.vue @@ -90,11 +90,8 @@ function handleClick(col: ListColumn) {