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
This commit is contained in:
@@ -359,19 +359,17 @@ async fn update_state_from_event(shared: &SharedState, event: PeerEvent) -> (&'s
|
||||
shared.state.write().await.remote_games = games.clone();
|
||||
("list-games", json!({ "games": games }))
|
||||
}
|
||||
PeerEvent::LocalGamesUpdated {
|
||||
games,
|
||||
active_operations,
|
||||
} => {
|
||||
PeerEvent::LocalLibraryChanged { games } => {
|
||||
let mut state = shared.state.write().await;
|
||||
state.local_games.clone_from(&games);
|
||||
("local-library-changed", json!({ "games": games }))
|
||||
}
|
||||
PeerEvent::ActiveOperationsChanged { active_operations } => {
|
||||
let mut state = shared.state.write().await;
|
||||
state.active_operations.clone_from(&active_operations);
|
||||
(
|
||||
"local-games-updated",
|
||||
json!({
|
||||
"games": games,
|
||||
"active_operations": active_operations_json(&active_operations),
|
||||
}),
|
||||
"active-operations-changed",
|
||||
json!({ "active_operations": active_operations_json(&active_operations) }),
|
||||
)
|
||||
}
|
||||
PeerEvent::GotGameFiles {
|
||||
|
||||
Reference in New Issue
Block a user