feat(ui): add download progress controls

Replace the downloading action button with a dedicated progress component in
both card and detail views. The card now shows percent plus current speed, while
the detail modal shows bytes, speed, ETA, percent, and an inline cancel affordance
using the same backend progress payload.

Expose download cancellation as a peer command that cancels the tracked transfer
token and lets the running operation clear the authoritative active-operation
snapshot. Add a View Files action that resolves the game root safely and opens it
with the platform file viewer through Tauri's shell plugin.

Test Plan:
- just fmt
- just frontend-test
- just test
- just build
- just clippy
- git diff --cached --check

Refs: design reference e308009a08
This commit is contained in:
2026-05-20 23:20:53 +02:00
parent e308009a08
commit 47e2bbd454
16 changed files with 776 additions and 48 deletions
@@ -9,13 +9,15 @@ export interface GameActions {
update: (id: string) => Promise<void>;
uninstall: (id: string) => Promise<void>;
removeDownload: (id: string) => Promise<void>;
cancelDownload: (id: string) => Promise<void>;
viewFiles: (id: string) => Promise<void>;
}
/**
* Thin wrappers over the backend `run_game` / `install_game` / `update_game`
* / `uninstall_game` / `remove_downloaded_game` commands. Peer-backed downloads
* are marked as "checking peers" until the backend emits an authoritative
* operation snapshot.
* operation snapshot; cancellation waits for the backend to clear that snapshot.
*/
export const useGameActions = (games: UseGamesResult): GameActions => {
const play = useCallback(async (id: string) => {
@@ -65,5 +67,21 @@ export const useGameActions = (games: UseGamesResult): GameActions => {
}
}, []);
return { play, install, update, uninstall, removeDownload };
const cancelDownload = useCallback(async (id: string) => {
try {
await invoke('cancel_download', { id });
} catch (err) {
console.error('cancel_download failed:', err);
}
}, []);
const viewFiles = useCallback(async (id: string) => {
try {
await invoke('open_game_files', { id });
} catch (err) {
console.error('open_game_files failed:', err);
}
}, []);
return { play, install, update, uninstall, removeDownload, cancelDownload, viewFiles };
};