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
@@ -15,6 +15,7 @@ interface Props {
thumbnailUrl: string | null;
onOpen: (game: Game) => void;
onPrimary: (game: Game) => void;
onCancelDownload: (game: Game) => void;
}
const metaSeparator = (...parts: Array<string | null | undefined>): JSX.Element[] => {
@@ -27,7 +28,14 @@ const metaSeparator = (...parts: Array<string | null | undefined>): JSX.Element[
return out;
};
export const GameCard = ({ game, aspect, thumbnailUrl, onOpen, onPrimary }: Props) => {
export const GameCard = ({
game,
aspect,
thumbnailUrl,
onOpen,
onPrimary,
onCancelDownload,
}: Props) => {
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
@@ -61,7 +69,12 @@ export const GameCard = ({ game, aspect, thumbnailUrl, onOpen, onPrimary }: Prop
<div className={`card-status${game.status_level === 'error' ? ' is-error' : ''}`}>
{game.status_message ?? ''}
</div>
<ActionButton game={game} full onClick={() => onPrimary(game)} />
<ActionButton
game={game}
full
onClick={() => onPrimary(game)}
onCancelDownload={onCancelDownload}
/>
</div>
</button>
);
@@ -9,9 +9,17 @@ interface Props {
getThumbnail: (id: string) => string | null;
onOpen: (game: Game) => void;
onPrimary: (game: Game) => void;
onCancelDownload: (game: Game) => void;
}
export const GameGrid = ({ games, aspect, getThumbnail, onOpen, onPrimary }: Props) => (
export const GameGrid = ({
games,
aspect,
getThumbnail,
onOpen,
onPrimary,
onCancelDownload,
}: Props) => (
<div className="grid">
{games.map(g => (
<GameCard
@@ -21,6 +29,7 @@ export const GameGrid = ({ games, aspect, getThumbnail, onOpen, onPrimary }: Pro
thumbnailUrl={getThumbnail(g.id)}
onOpen={onOpen}
onPrimary={onPrimary}
onCancelDownload={onCancelDownload}
/>
))}
</div>