feat(events): backend reconciliation replacing frontend optimistic updates#41
Merged
pythoninthegrass merged 1 commit intomainfrom Apr 13, 2026
Merged
Conversation
…mistic updates Add LibraryReconcileEvent with authoritative stats (total_tracks, total_duration, revision) emitted after every library mutation. Replace LibraryUpdatedEvent::deleted calls in delete, purge, dedup, scan, favorite, and watcher flows. Frontend applies backend-provided totals instead of computing them locally, eliminating count divergence and phantom tracks. - Add LibraryReconcileEvent struct with delete/scan_complete/dedup/favorite factory methods and emit_library_reconcile on EventEmitter trait - Modify library_delete_track(s), library_delete_all, library_purge_missing, run_backfill_and_dedup to emit reconcile events with DB stats + revision - Modify scan_paths_to_library and watcher to emit reconcile on completion - Modify favorites_add/remove to emit reconcile with affected_sections - Add _removeFromView to library store (filters view without recomputing totals) - Add handleLibraryReconcile handler in events.js with queue cleanup - Remove deleted-action branch from createLibraryUpdatedHandler - Remove fetchTracks from handleScanComplete (reconcile handles it) - Update context-menu-actions to use _removeFromView for optimistic UI - Add 7 Rust unit tests and 13 Vitest tests for reconcile event handling Co-Authored-By: Claude Opus 4.6 <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.
Summary
LibraryReconcileEventwith authoritative stats (total_tracks, total_duration, revision) emitted after every library mutation (delete, scan, dedup, favorite toggle, watcher)LibraryUpdatedEvent::deleted(...)emissions with reconcile events that query DB stats post-transactionhandleLibraryReconcilehandler applies backend-provided totals instead of computing them locally, eliminating count divergence and phantom tracks_removeFromViewto library store for optimistic visual removal without recomputing totals (reconcile event provides authoritative numbers)Test plan
cargo buildcompiles with no warningscargo test— 737 tests passnpx vitest run— 112 relevant tests pass (13 reconcile + 49 library + 50 queue)🤖 Generated with Claude Code