From 545a3d749b4ab330c21deebdfafb630c0bb43d38 Mon Sep 17 00:00:00 2001 From: Towsty Date: Sat, 24 Oct 2026 12:01:25 -0500 Subject: [PATCH] Stop a folder wipe from restoring the pre-wipe library catalog. The in-memory catalog could outlive the write, so delete-all came back as thousands of empty tiles and a stale badge. Co-authored-by: Cursor --- ARCHITECTURE.md | 4 +- PROGRESS.md | 2 + TASKS.md | 2 + components/studio2/Bench.vue | 82 +++++++++++-- components/studio2/LibraryModal.vue | 87 +++++++------- components/studio2/Mobile.vue | 3 +- pages/library.vue | 72 +++++------- server/api/library/folders/[id]/wipe.post.ts | 9 +- server/utils/library.ts | 114 +++++++++++++++---- shared/studio2/viewer.mjs | 48 +++++++- tests/library-delete-harden.test.mjs | 62 +++++++++- tests/library-wipe-state.test.mjs | 39 +++++++ 12 files changed, 393 insertions(+), 131 deletions(-) create mode 100644 tests/library-wipe-state.test.mjs diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 6a4cd46..c90c5a8 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -6,9 +6,9 @@ Nuxt 3 app, Nitro `node-server`, Vue 3. Production image is `node:22.23.4-alpine `server/utils/library.ts` stores one catalog per owner under `users//`. The owner key is a hash of the session identity, or a single private-instance id when password auth is on. Catalog writes are serialized per owner and written to a temp file, then renamed. -`deleteStill`, `deleteStillFamily`, and `wipeFolderContents` update the catalog even if `rmSync` fails. After those writes, `pruneMissingStillMasters` drops any remaining still whose master file is gone. `publicLibrary` and `publicLibraryPage` run that prune before they return rows or folder counts. +`deleteStill`, `deleteStillFamily`, and `wipeFolderContents` update the catalog even if `rmSync` fails. A folder wipe removes every still, clip, and track for that folder, checks the folder is empty, and drops that owner's in-memory catalog cache. The next read loads the file that was just written. It does not treat an unchanged mtime as proof the cache is current. `pruneMissingStillMasters` only drops stills whose master file is missing. `publicLibrary` and `publicLibraryPage` run that prune before they return rows or folder counts. The wipe route returns that read after the cache drop. -Studio 2 reads a paged `/api/library` list. After a delete it refetches that list and clears form slots that pointed at the deleted id. +Studio 2 reads a paged `/api/library` list. After a delete or wipe it replaces local library state from the server response, refetches that list, and clears the stage still and form slots that pointed at a removed id. A folder `imageCount` of 0 is an empty folder. ## Auth diff --git a/PROGRESS.md b/PROGRESS.md index 0dcbc74..0d2d25f 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -2,6 +2,8 @@ ## 2026-10-24 +Delete-all was still serving a pre-wipe catalog. The folder wipe now strips that folder's stills, clips, and tracks, filters again if any rows remain, and deletes the owner's in-memory catalog cache after the write. The wipe route reads the library only after that drop. Prune still only removes stills. Studio 2 and the library page replace local rows from the wipe response instead of merging, keep wiped ids out of later pages, and treat a folder image count of 0 as empty. The stage drops a selected still that is no longer in the library. + Library deletes now commit the catalog when file removal fails, then prune stills whose masters are missing. Studio 2 and the library page drop the deleted id from the selected still, photo slots, and the in-memory list, and they refetch `/api/library` instead of trusting that list. Select-all uses the rows already loaded. It does not start a second full-catalog fetch that can merge a suppressed id back in from a later page. LoRA engine matching prefers the folder under `xaigen/` or `aigen/`. The task text said an `aigen` path segment marks a LoRA xAIGen-only. That conflicts with the check that `aigen/flux/bar.safetensors` is visible on AIGen. The checks win: `xaigen/` and the `xiagen` typo are xAIGen-only; `aigen/` is visible on AIGen. Old `krea-something.safetensors` names still match Krea. diff --git a/TASKS.md b/TASKS.md index c74ed10..b42353f 100644 --- a/TASKS.md +++ b/TASKS.md @@ -6,6 +6,8 @@ 2. LoRA folders. Engine matching prefers `xaigen//` and `aigen//`. `xaigen` and the `xiagen` typo stay xAIGen-only. `aigen/` stays visible on AIGen. Filename prefixes remain the fallback. Refresh with `fresh=1` still live-scans Comfy, and the stack stores the Comfy-relative path. +3. Library delete-all. A folder wipe leaves that folder empty in the catalog that is written, drops the owner's in-memory catalog cache, and the wipe route returns a library read taken after that drop. The client replaces its lists from that response, trusts a server image count of 0, and clears the stage still and photo slots that pointed at wiped ids. + ## Not in this pass Klein, Krea, MOSS, MiniMax, and LTX graph changes. Coolify app targets. The `studio-2` branch. diff --git a/components/studio2/Bench.vue b/components/studio2/Bench.vue index 45f961f..6f8d529 100644 --- a/components/studio2/Bench.vue +++ b/components/studio2/Bench.vue @@ -237,7 +237,7 @@ @click="libraryOpen=true" >Library{{ familyStillCount }}
@@ -282,7 +282,7 @@