Files
buzz/desktop/scripts
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7andWill Pfleger 2bbac40fe3 fix(archive): atomic remove-kind path + split test modules
Fix A: add remove_owner_p_kind / remove_save_subscription_kind

Closes the non-atomic toggle-OFF path (Wes note 1).  The toggle handlers
in LocalArchiveSettingsCard were doing a TS-side read-modify-overwrite on
the shared owner_p row — on toggle-OFF they called deleteSaveSubscription
for the whole row, which would silently drop the *other* kind (24200 vs
44200) if subs state was stale.

- store.rs: add remove_owner_p_kind mirroring merge_owner_p_kinds — same
  BEGIN IMMEDIATE → closure → COMMIT/ROLLBACK shape; reads current kinds,
  removes the target kind, then DELETEs the row if the list becomes empty
  or UPDATEs kinds to the reduced list otherwise.
- mod.rs: add remove_save_subscription_kind Tauri command delegating to
  store::remove_owner_p_kind; registered in lib.rs alongside the merge cmd.
- tauriArchive.ts: add removeSaveSubscriptionKind wrapper calling the new
  command + notifySubscriptionChange().
- LocalArchiveSettingsCard.tsx: rewrite handleObserverToggle and
  handleMetricToggle to use atomic commands — toggle-ON calls
  mergeSaveSubscriptionKinds(KIND), toggle-OFF calls
  removeSaveSubscriptionKind(KIND).  The TS-side read-modify-overwrite and
  the whole-row deleteSaveSubscription branch are removed entirely.  subs
  dependency dropped from both useCallback dep arrays.
- store_tests (new file): 4 unit tests for remove_owner_p_kind: removes
  one kind leaving the other, deletes row on last kind, no-op when row
  absent, no-op when kind absent.

Fix B: split archive test modules (Wes note 3)

The check-file-sizes.mjs override for archive/mod.rs had ratcheted
1465→1705 across the PR series.  Split both oversized test blocks:

- archive/mod_tests.rs: extracted #[cfg(test)] mod_tests module from
  mod.rs (~1208 lines, test-only content).  Wired via #[cfg(test)]
  #[path = "mod_tests.rs"] mod mod_tests in mod.rs.
- archive/store_tests.rs: extracted #[cfg(test)] store_tests module from
  store.rs (~732 lines, fits under 1000 — no override needed).  Wired via
  #[cfg(test)] #[path = "store_tests.rs"] mod store_tests in store.rs.

mod.rs is now 532 lines, store.rs is 599 lines — both under 1000.  The
two mod.rs/store.rs overrides are replaced by a single mod_tests.rs
override (1208).  All 934 Rust tests pass unchanged.

Co-authored-by: Will Pfleger <pfleger.will@gmail.com>
Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
2026-07-06 18:33:56 -04:00
..