fix(ui): reconcile active operations from local scans
Local operation spinners were driven by begin, finish, and failure event history. If one of those lifecycle events was missed, the Tauri bridge could keep a stale active operation and the React state would keep showing an in-progress spinner until restart. Peer local scan updates now carry an authoritative active-operation snapshot. The peer still suppresses active game roots from peer-facing library deltas, but it emits LocalGamesUpdated to the UI even when no library delta changed so the snapshot can clear stale state after rollback or completion. The Tauri bridge replaces its active-operation map from that snapshot, emits it with the games-list payload, and the React merge uses it to restore download, install, update, and uninstall spinners from current peer state rather than event history alone. This also enables the Tauri lib unit-test target so the reconciliation helper can stay covered by the workspace test recipe. Test Plan: - git diff --check - just fmt - just clippy - just test Follow-up-Plan: FOLLOW_UP_2.md
This commit is contained in:
@@ -111,8 +111,11 @@ pub enum PeerEvent {
|
||||
PeerLost(SocketAddr),
|
||||
/// The total peer count has changed.
|
||||
PeerCountUpdated(usize),
|
||||
/// Local games have been updated.
|
||||
LocalGamesUpdated(Vec<Game>),
|
||||
/// Local games have been scanned, with authoritative in-progress work.
|
||||
LocalGamesUpdated {
|
||||
games: Vec<Game>,
|
||||
active_operations: Vec<ActiveOperation>,
|
||||
},
|
||||
/// A required peer runtime component failed.
|
||||
RuntimeFailed {
|
||||
component: PeerRuntimeComponent,
|
||||
@@ -144,6 +147,26 @@ pub enum InstallOperation {
|
||||
Updating,
|
||||
}
|
||||
|
||||
/// In-progress operation snapshot attached to local library updates.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ActiveOperation {
|
||||
pub id: String,
|
||||
pub operation: ActiveOperationKind,
|
||||
}
|
||||
|
||||
/// Operation kinds visible to UI reconciliation.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, strum::IntoStaticStr)]
|
||||
pub enum ActiveOperationKind {
|
||||
/// Downloading or replacing archive files.
|
||||
Downloading,
|
||||
/// Extracting into a previously uninstalled game root.
|
||||
Installing,
|
||||
/// Replacing an existing `local/` install.
|
||||
Updating,
|
||||
/// Removing an existing `local/` install.
|
||||
Uninstalling,
|
||||
}
|
||||
|
||||
/// Commands sent to the peer system from the UI.
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum PeerCommand {
|
||||
|
||||
Reference in New Issue
Block a user