Files
lanspread/IMPL_DECISIONS.md
T
ddidderr 41e9a0efc1 refactor(peer): split local library and operation UI events
Replace the `a9f9845` local-update dedup cache with explicit peer event
semantics. Local scans now emit `LocalLibraryChanged` when the library changes,
while operation mutations emit `ActiveOperationsChanged` from the mutation
path. Tauri keeps joining those facts into the existing `games-list-updated`
payload, so the frontend contract stays stable.

This removes the cache/invalidation coupling between scan emission and
operation state. The remaining forced local snapshot is explicit: accepted game
directory changes can refresh the UI for an equivalent new path without sending
a peer library delta.

Operation guard cleanup and liveness cancellation now publish the same active
operation snapshot as normal command-handler transitions. The peer CLI JSONL
events follow the same split with `local-library-changed` and
`active-operations-changed`.

Test Plan:
- `just fmt`
- `CARGO_BUILD_RUSTC_WRAPPER= just test`
- `CARGO_BUILD_RUSTC_WRAPPER= just clippy`
- `git diff --check`

Refs: CLEAN_CODE_PLAN_1.md
2026-05-18 21:25:20 +02:00

2.3 KiB

Implementation Decisions

  • Added a just test recipe so unit tests can be run through the repository's required just ... command surface instead of invoking cargo test directly.
  • Renamed the frontend success event to game-install-finished; the old unpack name no longer matched the transactional install/update lifecycle.
  • Implemented watcher rescans by reusing the existing .lanspread/library_index.json cache and updating a single game entry in that index. This satisfies the per-ID optimized rescan requirement without adding a second cache format.
  • Split full startup recovery from ordinary settled refreshes. Startup and real SetGameDir changes run recovery plus a scan; install/update/uninstall completion only rescans the affected game after operation tracking has been cleared.
  • Rejected path-changing SetGameDir while operations are active. Same-path refreshes are allowed and deliberately skip full recovery so they cannot sweep download transients for in-flight work.
  • Kept a separate active_downloads cancellation-token map next to the single active_operations table. The operation table is the authoritative state for gates; the token map is only cancellation plumbing for in-flight downloads.
  • Treated a downloaded-but-not-installed game as immediately installable from Tauri by sending PeerCommand::InstallGame directly. A not-downloaded game still uses GetGame, and the peer auto-installs after the sentinel commit.
  • Removed the dead internal PeerCommand::UpdateGame path. The UI update button now sends FetchLatestFromPeers, which skips local manifest serving and asks latest-version peers for fresh file metadata before the normal download and update transaction runs.
  • Removed the unreachable Availability::Downloading protocol value. Active operations are reported separately, and local summaries emit only settled availability.
  • Threaded availability through the UI-facing Game payload so LocalOnly rendering follows backend state instead of reverse-engineering it from installed && !downloaded.
  • Removed Tauri's parallel whole-library filesystem scan. The UI database keeps bundled catalog metadata, while peer LocalLibraryChanged snapshots now own downloaded, installed, local_version, and availability.