From c7a4377cdaa7e47e30af280645fd5a26e7524e7f Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:00:06 +0100 Subject: [PATCH 01/13] feat(ui): cards show only the cover and quiet store logos at rest --- DESIGN.md | 10 +++++----- src/lib/Card.svelte | 28 ++++++++++++++++++---------- src/lib/i18n/en.json | 1 + src/lib/i18n/nl.json | 1 + 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 2b6b1cd..1be9023 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -270,11 +270,11 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t - Escape or a click outside closes only the top layer (a menu, popover or tooltip opened inside, or Steam log in over Settings) and returns focus to what opened it. Mouse Back and Forward never close a dialog (`keepOnBackForward`), and App ignores them while one is open. - Stacking: Settings and Add a game 20, the install popup and Notes 30, Steam log in 40, menus and the other popovers 50, tooltips 60. - **Cover card:** - - States: installed is full color. Not installed is `saturate(0.5) brightness(0.75)` with a bottom-left glass Install chip. Running gets the green badge and ring. Installing gets a 6px progress strip. Queued and Paused get glass chips. - - In the playtime and length sorts, a stat chip ("38 h played", "~25 h to beat") takes the same spot. + - States: installed is full color. Not installed is `saturate(0.5) brightness(0.75)`, with no chip at rest; its cover button's label says it isn't installed. Running gets the green badge and ring. Installing gets a 6px progress strip. Queued and Paused get glass chips. + - In the playtime and length sorts, a stat chip ("38 h played", "~25 h to beat") sits bottom-left. An installed game with an update gets an Update chip there. - Loading: while the cover loads the card shows `surface-2`, then the cover's average color, then the image fading in over 150ms. - - The store logo sits top-right in a 26px glass circle. - - On hover: lift, white ring, title, and a small Play or Install pill. The hover overlay is absent when idle, not transparent, to keep scrolling cheap. + - The store logos sit top-right, one 26px glass circle per store, at 77% scale and 60% opacity at rest and full size and opacity on hover and focus. + - On hover and focus: lift, white ring, title, and a small pill: the white Play pill when installed, a glass Install pill when not. The hover overlay is absent when idle, not transparent, to keep scrolling cheap. - **Notices:** `glass-strong`, 12px radius, with a dismiss button. Errors get a red border and `error-text` and are `role="alert"`; the others are `role="status"`. - **Fields:** 36px, `glass` fill, `glass-line` border, `text-3` placeholder. Saved secrets show only as a read-only "••••••••" field with "Saved", Replace and Remove; the real value never reaches the UI. - **Toggle:** 40×22 pill, white 18% off, `accent` on, a bits-ui `Switch`; Space and Enter flip it. @@ -318,7 +318,7 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t ## Owner decisions - The look: last-played art blurred and saturated behind everything, dark glass chrome, white pill for the primary action (2026-11-05). -- Covers carry the real store logo top-right. Not installed means faded, with an Install chip bottom-left (option C). +- Covers carry the real store logo top-right. Not installed means faded, with no chip at rest; Install shows on hover (2026-11-26). - The game page's fact tiles are Playtime, Last played and How long to beat, not size. Size lives in Details. - Settings is a frosted panel with Accounts, General and About, as grouped rows (settings v4, 2026-11-07). Its section list switches sections instead of scrolling to them, and Services moved into Accounts as Game data (2026-11-09). Don't show tool versions there, except when an update is available. - Ambient color can be turned off, which gives a neutral dark gradient. diff --git a/src/lib/Card.svelte b/src/lib/Card.svelte index ac35bf0..ab0356c 100644 --- a/src/lib/Card.svelte +++ b/src/lib/Card.svelte @@ -27,7 +27,7 @@ game: Card /** Place in the grid; covers are asked in this order. */ index: number - /** Which hours the bottom-left badge shows; it takes Install's place on a game that isn't installed. */ + /** Which hours the bottom-left badge shows. */ stat?: 'playtime' | 'ttb' | null running: boolean /** Its Play is starting. */ @@ -65,7 +65,7 @@ /** The status chip's id: the cover button is described by it. */ const statusId = $props.id() /** A badge or chip shows (the same order as the markup; the progress strip has no text). */ - const hasStatus = $derived(running || !!waiting || (!progress && ((game.installed && game.update) || !!statText || !game.installed))) + const hasStatus = $derived(running || !!waiting || (!progress && ((game.installed && game.update) || !!statText))) let el: HTMLDivElement // undefined: still asking. null: no art, so the title shows. @@ -116,7 +116,7 @@ onpointerleave={() => clearTimeout(resting)} onfocus={() => prefetch(game)} title={game.title} - aria-label={t('common.openGame', { title: game.title })} + aria-label={game.installed ? t('common.openGame', { title: game.title }) : t('card.openNotInstalled', { title: game.title })} aria-describedby={hasStatus ? statusId : undefined} > {#if art === null} @@ -170,11 +170,6 @@ {:else if statText} {statText} - {:else if !game.installed} - - - {t('common.install')} - {/if} {#if !running && (!progress || waiting)} @@ -197,7 +192,7 @@ {t('play.play')} {:else if !game.installed} - @@ -286,7 +281,7 @@ object-fit: cover; } - /* Option C: not installed fades a little, and the chip says what's next. */ + /* Not installed fades a little; Install waits for hover. */ .out .open img { filter: saturate(0.5) brightness(0.75); } @@ -333,6 +328,19 @@ flex-direction: column; gap: 4px; pointer-events: none; + /* Quiet at rest (26px × 0.77 ≈ 20px); transform and opacity keep scrolling composite-only. */ + opacity: 0.6; + transform: scale(0.77); + transform-origin: top right; + transition: + transform 160ms ease-out, + opacity 160ms ease-out; + } + + .card:hover .logos, + .card:focus-within .logos { + opacity: 1; + transform: none; } .logo { diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index e1c3e51..1d1dd58 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -283,6 +283,7 @@ "card.hoursPlayed": "{n} h played", "card.favorite": "Favorite {title}", "card.queued": "Queued", + "card.openNotInstalled": "Open {title}, not installed", "filters.title": "Filters", "filters.clear": "Clear", "filters.manage": "Manage collections…", diff --git a/src/lib/i18n/nl.json b/src/lib/i18n/nl.json index 39c328d..e7b9502 100644 --- a/src/lib/i18n/nl.json +++ b/src/lib/i18n/nl.json @@ -283,6 +283,7 @@ "card.hoursPlayed": "{n} u gespeeld", "card.favorite": "Favoriet: {title}", "card.queued": "In wachtrij", + "card.openNotInstalled": "{title} openen, niet geïnstalleerd", "filters.title": "Filters", "filters.clear": "Wissen", "filters.manage": "Collecties beheren…", From 8d888624c99dab78a7cbbb825d0eb4825830f250 Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:03:00 +0100 Subject: [PATCH 02/13] fix(ui): align the icon in the card's glass Install pill --- src/lib/Card.svelte | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/Card.svelte b/src/lib/Card.svelte index ab0356c..fbfa5a2 100644 --- a/src/lib/Card.svelte +++ b/src/lib/Card.svelte @@ -456,6 +456,9 @@ } .glass.small { + display: inline-flex; + align-items: center; + gap: 6px; padding: 6px 14px; border-radius: 999px; font-size: 12px; From a51189e270a0fafb39fbd0640a4a86df76a55984 Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:21:03 +0100 Subject: [PATCH 03/13] feat(library): sidebar counts, collection covers and one lock for list writes --- src-tauri/src/commands/library.rs | 51 +++++++++++++++ src-tauri/src/commands/lists.rs | 63 +++++++++++++++---- src-tauri/src/commands/mod.rs | 3 + ...rary__tests__library_payload_snapshot.snap | 7 ++- src/App.svelte | 1 + src/lib/bindings.ts | 12 ++++ 6 files changed, 124 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/commands/library.rs b/src-tauri/src/commands/library.rs index be5f06e..a6091fb 100644 --- a/src-tauri/src/commands/library.rs +++ b/src-tauri/src/commands/library.rs @@ -103,6 +103,34 @@ pub struct Library { amazon_attention: bool, /// The stores the whole library has a game from, in toolbar order; games the owner added don't count. stores: Vec, + /// For the sidebar's rows. + counts: Counts, +} + +#[derive(Serialize, specta::Type)] +pub struct Counts { + /// Cards that are not hidden. + library: usize, + /// Favorites that are not hidden. + favorites: usize, + hidden: usize, +} + +fn sidebar_counts(entries: &[Entry], games: &[Game], lists: &Lists) -> Counts { + let mut c = Counts { + library: 0, + favorites: 0, + hidden: 0, + }; + for e in entries { + if lists.hidden(e, games) { + c.hidden += 1; + } else { + c.library += 1; + c.favorites += usize::from(lists.favorite(e, games)); + } + } + c } /// `lists` are the Lists filters that are on ("favorites", "hidden", "collection-"); the UI applies @@ -171,6 +199,7 @@ pub fn library( amazon: s.amazon_login, amazon_attention, stores: stores_in_use(&s.games), + counts: sidebar_counts(&s.entries, &s.games, &s.lists), } } @@ -250,6 +279,8 @@ pub struct ViewPrefs { pub async fn load_cache(app: AppHandle) -> Res { blocking(move || { let state = app.state::(); + // Held until the lists are published, so a list change can't be overwritten by an older read. + let turn = state.lists_write.lock().expect("lists lock poisoned"); let conn = cache::db::open(&state.dirs.db)?; let mut games = cache::db::load(&conn)?; view::merge_last_played(&mut games, &cache::db::launches(&conn)?); @@ -261,6 +292,7 @@ pub async fn load_cache(app: AppHandle) -> Res { let mut s = state.lock(); s.ttb = ttb; s.lists = lists; + drop(turn); // A scan that already finished wins over the cache. if s.games.is_empty() { s.games = games; @@ -1863,6 +1895,24 @@ mod tests { (games, entries, lists) } + #[test] + fn sidebar_counts_count_cards_and_leave_hidden_out() { + use crate::view::tests::game; + let games = vec![ + game("a", true, None, None), + game("b", true, None, None), + game("c", true, None, None), + ]; + let entries = entries::group(&games, &HashMap::new()); + let lists = Lists { + favorite: HashSet::from([games[0].key(), games[1].key()]), + hidden: HashSet::from([games[1].key(), games[2].key()]), + ..Lists::default() + }; + let c = sidebar_counts(&entries, &games, &lists); + assert_eq!((c.library, c.favorites, c.hidden), (1, 1, 2)); + } + #[test] fn library_payload_snapshot() { let (games, entries, lists) = payload_games(); @@ -1893,6 +1943,7 @@ mod tests { amazon: None, amazon_attention: false, stores: stores_in_use(&games), + counts: sidebar_counts(&entries, &games, &lists), }; insta::assert_json_snapshot!(library); } diff --git a/src-tauri/src/commands/lists.rs b/src-tauri/src/commands/lists.rs index ee99a08..b2e403e 100644 --- a/src-tauri/src/commands/lists.rs +++ b/src-tauri/src/commands/lists.rs @@ -1,7 +1,5 @@ //! Favorites, hidden games and collections. Stored per copy key, so setting one on a game sets every copy. -use std::collections::HashMap; - use serde::Serialize; use tauri::{AppHandle, Manager}; @@ -16,6 +14,8 @@ pub struct Collection { name: String, /// Games in it. count: usize, + /// Up to three entry keys of its games, most recently played first. + covers: Vec, } /// Every copy key of the game with this key. @@ -28,6 +28,8 @@ fn copy_keys(state: &AppState, key: &str) -> Res> { /// Runs a change on the database, then reads the lists again for the library. fn change(app: &AppHandle, f: impl FnOnce(&mut rusqlite::Connection) -> Res) -> Res { let state = app.state::(); + // Held to the publish below, so two changes can't publish their reads out of order. + let _turn = state.lists_write.lock().expect("lists lock poisoned"); let mut conn = open_db(&state).ok_or(msg!(noDb))?; let out = f(&mut conn)?; let lists = cache::db::lists(&conn)?; @@ -67,24 +69,39 @@ pub async fn collections(app: AppHandle) -> Res> { let state = app.state::(); let list = collections_in(&open_db(&state).ok_or(msg!(noDb))?)?; let s = state.lock(); - let mut counts: HashMap = HashMap::new(); - for e in &s.entries { - for id in s.lists.collections(e, &s.games) { - *counts.entry(id).or_default() += 1; - } - } Ok(list .into_iter() - .map(|(id, name)| Collection { - id, - count: counts.get(&id).copied().unwrap_or(0), - name, + .map(|(id, name)| { + let (count, covers) = collection_summary(id, &s.entries, &s.games, &s.lists); + Collection { + id, + name, + count, + covers, + } }) .collect()) }) .await } +/// How many games a collection holds, hidden ones left out, and up to three of their keys, most recently +/// played first. `entries` are in title order, so the stable sort puts never-played ones after, by title. +fn collection_summary( + id: i64, + entries: &[entries::Entry], + games: &[crate::library::Game], + lists: &crate::view::Lists, +) -> (usize, Vec) { + let mut members: Vec<&entries::Entry> = entries + .iter() + .filter(|e| !lists.hidden(e, games) && lists.collections(e, games).contains(&id)) + .collect(); + members.sort_by_key(|e| std::cmp::Reverse(entries::last_played(e, games).map(|p| p.0))); + let covers = members.iter().take(3).map(|e| e.key.clone()).collect(); + (members.len(), covers) +} + /// The name to store: trimmed, not empty, and not another collection's in any case. fn check_name(name: &str, taken: &[(i64, String)], except: Option) -> Res { let name = name.trim(); @@ -174,4 +191,26 @@ mod tests { assert_eq!(check_name("BACKLOG", &taken, Some(1)).unwrap(), "BACKLOG"); assert!(check_name("co-op ", &taken, Some(1)).is_err()); } + + #[test] + fn collection_summary_skips_hidden_and_takes_three_latest_covers() { + use crate::view::tests::game; + use std::collections::{HashMap, HashSet}; + // Titles sort a..e; played 1..4 for a..d, e never, and "b" hidden. + let games: Vec<_> = [("a", 1), ("b", 2), ("c", 3), ("d", 4), ("e", 0)] + .into_iter() + .map(|(t, n)| game(t, true, None, (n > 0).then_some(n))) + .collect(); + let entries = entries::group(&games, &HashMap::new()); + let keys: Vec = games.iter().map(|g| g.key()).collect(); + let lists = crate::view::Lists { + hidden: HashSet::from([keys[1].clone()]), + collections: keys.iter().map(|k| (k.clone(), vec![7])).collect(), + ..Default::default() + }; + let (count, covers) = collection_summary(7, &entries, &games, &lists); + assert_eq!(count, 4); + assert_eq!(covers, [keys[3].clone(), keys[2].clone(), keys[0].clone()]); + assert_eq!(collection_summary(8, &entries, &games, &lists), (0, vec![])); + } } diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 0812411..69d040a 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -34,6 +34,8 @@ pub struct AppState { dirs: Dirs, http: reqwest::Client, shared: Mutex, + /// Held from reading the lists in SQLite to publishing them in `shared`. Taken before `shared`, never after. + lists_write: Mutex<()>, cover_jobs: tokio::sync::Semaphore, /// Held across every Steam logon (download size, DLC, owned games), so they never stack. steam_size: tokio::sync::Mutex<()>, @@ -157,6 +159,7 @@ impl AppState { status: vec![msg!(loadingLibrary)], ..Shared::default() }), + lists_write: Mutex::new(()), cover_jobs: tokio::sync::Semaphore::new(COVER_JOBS), steam_size: tokio::sync::Mutex::new(()), scans: library::ScanTurns::default(), diff --git a/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap b/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap index 1055b86..2963dc8 100644 --- a/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap +++ b/src-tauri/src/commands/snapshots/launcher__commands__library__tests__library_payload_snapshot.snap @@ -80,5 +80,10 @@ expression: library "steam", "epic", "gog" - ] + ], + "counts": { + "library": 2, + "favorites": 1, + "hidden": 0 + } } diff --git a/src/App.svelte b/src/App.svelte index da70efe..679dc83 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -76,6 +76,7 @@ amazon: null, amazonAttention: false, stores: [], + counts: { library: 0, favorites: 0, hidden: 0 }, }) let featured = $state(null) let version = $state(0) diff --git a/src/lib/bindings.ts b/src/lib/bindings.ts index 9f10ef0..482805b 100644 --- a/src/lib/bindings.ts +++ b/src/lib/bindings.ts @@ -318,6 +318,8 @@ export type Collection = { name: string, /** Games in it. */ count: number, + /** Up to three entry keys of its games, most recently played first. */ + covers: string[], }; /** Why an Epic or GOG Play didn't launch yet: the question to ask first. */ @@ -342,6 +344,14 @@ export type CopyView = { cloudSaves: boolean, }; +export type Counts = { + /** Cards that are not hidden. */ + library: number, + /** Favorites that are not hidden. */ + favorites: number, + hidden: number, +}; + export type Cover = { src: string, /** Average colour, `#rrggbb`, painted until the image has loaded. */ @@ -537,6 +547,8 @@ export type Library = { amazonAttention: boolean, /** The stores the whole library has a game from, in toolbar order; games the owner added don't count. */ stores: Store[], + /** For the sidebar's rows. */ + counts: Counts, }; export type LinkKind = "steamStore" | "epicStore" | "pcGamingWiki" | "steamDb" | "protonDb"; From 6959c13634329c1c5ced4e92a437e5247ff55277 Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:23:30 +0100 Subject: [PATCH 04/13] refactor(filters): lists leave the Filters popover for the sidebar --- package.json | 2 +- scripts/filters.test.ts | 45 ++----- scripts/sidebar.test.ts | 46 +++++++ src/App.svelte | 2 - src/lib/FilterPopover.svelte | 224 +---------------------------------- src/lib/Toolbar.svelte | 16 +-- src/lib/filters.ts | 15 ++- src/lib/sidebar.ts | 39 ++++++ 8 files changed, 108 insertions(+), 281 deletions(-) create mode 100644 scripts/sidebar.test.ts create mode 100644 src/lib/sidebar.ts diff --git a/package.json b/package.json index de1f63e..9812e70 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build": "vite build", "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json", "tauri": "tauri", - "test": "node --test scripts/filters.test.ts scripts/format.test.ts scripts/changelog.test.ts scripts/messages.test.ts scripts/i18n.test.ts scripts/outside.test.ts", + "test": "node --test scripts/filters.test.ts scripts/sidebar.test.ts scripts/format.test.ts scripts/changelog.test.ts scripts/messages.test.ts scripts/i18n.test.ts scripts/outside.test.ts", "bump": "node scripts/bump.ts", "format": "prettier --write .", "format:check": "prettier --check ." diff --git a/scripts/filters.test.ts b/scripts/filters.test.ts index 51a8fa9..c4aa763 100644 --- a/scripts/filters.test.ts +++ b/scripts/filters.test.ts @@ -1,18 +1,7 @@ // node --test scripts/ import { test } from 'node:test' import assert from 'node:assert/strict' -import { - collectionFilter, - filterChips, - filterGroups, - isList, - matches, - removeChip, - storeSegments, - titleMatches, - toggleFilter, - type Filter, -} from '../src/lib/filters.ts' +import { collectionFilter, filterChips, filterGroups, matches, removeChip, storeSegments, titleMatches, toggleFilter, type Filter } from '../src/lib/filters.ts' test('chips follow the popover order, one per filter that is on', () => { assert.deepEqual(filterChips([]), []) @@ -107,37 +96,19 @@ test('the new groups widen inside and narrow across', () => { ) }) -const collections = [ - { id: 3, name: 'Backlog', count: 2 }, - { id: 7, name: 'Co-op', count: 1 }, -] - -test('Lists come after Status: Favorites, each collection, then Hidden', () => { - const lists = filterGroups(collections)[1] - assert.deepEqual(lists, { label: 'Lists', filters: ['favorites', 'collection-3', 'collection-7', 'hidden'] }) - assert.deepEqual(filterGroups([])[1].filters, ['favorites', 'hidden']) - assert.deepEqual( - filterGroups([]).map((g) => g.label), - ['Status', 'Lists', 'Your playtime', 'How long to beat', 'Has'], - ) -}) - -test('list chips are named after the list and come after Status', () => { - const on: Filter[] = ['bothStores', 'hidden', collectionFilter(7), 'notInstalled', 'favorites'] +test('the popover has no Lists group', () => { assert.deepEqual( - filterChips(on, collections).map((c) => c.label), - ['Not installed', 'Favorites', 'Co-op', 'Hidden', 'On more than one store'], + filterGroups().map((g) => g.label), + ['Status', 'Your playtime', 'How long to beat', 'Has'], ) - const left = removeChip(on, filterChips(on, collections)[2]) - assert.deepEqual(left, ['bothStores', 'hidden', 'notInstalled', 'favorites']) - assert.ok(isList('collection-7') && isList('hidden') && !isList('update')) }) -test('lists widen each other and narrow the other groups', () => { +test('the view relies on lists widening each other and narrowing the other groups', () => { const fav = { ...game, favorite: true } const inCoop = { ...game, collections: [7] } const hidden = { ...game, hidden: true, installed: false } assert.ok(matches(fav, ['favorites'], {})) + assert.ok(!matches(game, ['favorites'], {})) assert.ok(!matches(inCoop, ['favorites'], {})) assert.ok(matches(inCoop, ['favorites', collectionFilter(7)], {})) assert.ok(!matches(inCoop, [collectionFilter(3)], {})) @@ -154,10 +125,10 @@ test('more than one store means two or more, of any stores', () => { }) test('the Has group shows only with more than one store in use', () => { - const ids = (multi: boolean) => filterGroups([], multi).flatMap((g) => g.filters) + const ids = (multi: boolean) => filterGroups(multi).flatMap((g) => g.filters) assert.ok(ids(true).includes('bothStores')) assert.ok(!ids(false).includes('bothStores')) - assert.equal(filterGroups([], false).length, filterGroups([]).length - 1) + assert.equal(filterGroups(false).length, filterGroups().length - 1) }) test('store segments: All plus the stores in use, none for a single store', () => { diff --git a/scripts/sidebar.test.ts b/scripts/sidebar.test.ts new file mode 100644 index 0000000..94babfe --- /dev/null +++ b/scripts/sidebar.test.ts @@ -0,0 +1,46 @@ +// node --test scripts/ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { downloadFraction, fallbackView, viewCount, viewLists, withView } from '../src/lib/sidebar.ts' +import type { Filter } from '../src/lib/filters.ts' +import type { Progress, QueueView } from '../src/lib/bindings.ts' + +const counts = { library: 9, favorites: 2, hidden: 1 } +const collections = [{ id: 3, name: 'Backlog', count: 4, covers: [] }] + +test('the view joins the filters matches() gets', () => { + assert.deepEqual(withView(['notInstalled'], 'collection-3'), ['notInstalled', 'collection-3']) + const f: Filter[] = ['update'] + assert.deepEqual(withView(f, null), f) +}) + +test('the library is asked for the view as its only list', () => { + assert.deepEqual(viewLists(null), []) + assert.deepEqual(viewLists('hidden'), ['hidden']) +}) + +test('a view counts its own games', () => { + assert.equal(viewCount(null, counts, collections), 9) + assert.equal(viewCount('favorites', counts, []), 2) + assert.equal(viewCount('hidden', counts, []), 1) + assert.equal(viewCount('collection-3', counts, collections), 4) +}) + +test('a view whose row is gone falls back to the library', () => { + assert.equal(fallbackView('favorites', { ...counts, favorites: 0 }, []), null) + assert.equal(fallbackView('favorites', counts, []), 'favorites') + assert.equal(fallbackView('hidden', { ...counts, hidden: 0 }, []), null) + assert.equal(fallbackView('collection-3', counts, []), null) + assert.equal(fallbackView('collection-3', counts, collections), 'collection-3') + assert.equal(fallbackView(null, counts, []), null) +}) + +const job = (fraction: number) => ({ fraction }) as Progress + +test('the download fraction is the active job, else the average, else 0', () => { + const queue = (active: string | null) => ({ jobs: [], paused: false, active }) as QueueView + assert.equal(downloadFraction({ a: job(0.2), b: job(0.9) }, queue('b')), 0.9) + assert.ok(Math.abs(downloadFraction({ a: job(0.2), b: job(0.6) }, queue(null)) - 0.4) < 1e-9) + assert.equal(downloadFraction({}, queue(null)), 0) + assert.equal(downloadFraction({ a: job(0.5) }, queue('gone')), 0.5) +}) diff --git a/src/App.svelte b/src/App.svelte index 679dc83..80de7a2 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -509,8 +509,6 @@ bind:store bind:installedOnly bind:filters - {collections} - oncollections={reload} bind:sort bind:popoverOpen {attention} diff --git a/src/lib/FilterPopover.svelte b/src/lib/FilterPopover.svelte index a6d804d..42b3576 100644 --- a/src/lib/FilterPopover.svelte +++ b/src/lib/FilterPopover.svelte @@ -1,109 +1,25 @@ @@ -121,54 +37,13 @@

{group.label}

{#each group.filters as f (f)} - + {/each}
{/each}
-
- {#if managing} -
- {#each collections as c (c.id)} -
- {#if deleting === c.id} - {t('filters.askDelete', { name: c.name })} - - - {:else if renaming === c.id} - renameKeydown(e, c)} - onblur={() => saveRename(c)} - /> - {:else} - - {#snippet children({ props })} - - {/snippet} - - - {/if} -
- {:else} -

{t('filters.noCollections')}

- {/each} - {#if problem} - {#snippet children({ props })}{/snippet} - {/if} -
- {/if} {/snippet} @@ -256,95 +131,4 @@ background: transparent; color: var(--text); } - - .manage { - display: grid; - gap: 2px; - margin-top: 8px; - } - - .row { - display: flex; - align-items: center; - gap: 6px; - min-height: 32px; - font-size: 13px; - } - - .name { - flex: 1; - min-width: 0; - padding: 6px 8px; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - text-align: left; - background: transparent; - } - - .name:hover:not(:disabled), - .x:hover:not(:disabled) { - background: var(--glass-hover); - } - - .x { - width: 28px; - height: 28px; - padding: 0; - flex: none; - border-radius: 999px; - background: transparent; - color: var(--text-3); - font-size: 11px; - } - - .x:hover:not(:disabled) { - color: var(--text); - } - - input { - flex: 1; - height: 28px; - padding: 0 10px; - border-radius: 10px; - background: var(--glass); - border: 1px solid var(--glass-line); - font-size: 13px; - } - - .ask { - flex: 1; - min-width: 0; - color: var(--text); - } - - .small { - flex: none; - height: 28px; - padding: 0 10px; - border-radius: 999px; - background: var(--glass-hover); - border: 1px solid var(--glass-line); - font-size: 13px; - } - - .small:hover:not(:disabled) { - background: var(--glass-on); - } - - .danger { - color: var(--danger-text); - } - - .note { - margin: 4px 8px; - font-size: 13px; - color: var(--text-2); - } - - .problem { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } diff --git a/src/lib/Toolbar.svelte b/src/lib/Toolbar.svelte index 9e2697f..2261f3f 100644 --- a/src/lib/Toolbar.svelte +++ b/src/lib/Toolbar.svelte @@ -4,7 +4,7 @@ import DownloadsPopover from './DownloadsPopover.svelte' import UpdatePopover from './UpdatePopover.svelte' import ChoiceMenu from './ChoiceMenu.svelte' - import { filterChips, removeChip, storeSegments, type Collection, type Filter } from './filters' + import { filterChips, removeChip, storeSegments, type Filter } from './filters' import { t } from './i18n' import Tip from './Tip.svelte' import { mergeProps, RadioGroup } from 'bits-ui' @@ -17,7 +17,6 @@ store = $bindable(), installedOnly = $bindable(), filters = $bindable(), - collections, sort = $bindable(), popoverOpen = $bindable(), attention, @@ -32,7 +31,6 @@ onmove, onsettings, onadd, - oncollections, update, appVersion, running, @@ -46,7 +44,6 @@ /** The Filters popover's extra filters. */ filters: Filter[] /** For the Lists filters' names. */ - collections: Collection[] sort: Sort /** A popover is open; App ignores mouse Back/Forward meanwhile, as for Settings. */ popoverOpen: boolean @@ -69,7 +66,6 @@ /** Opens the Add a game dialog. */ onadd: () => void /** A collection was renamed or deleted in the Filters popover. */ - oncollections: () => void /** A newer release: the Update chip shows while it's set. */ update: UpdateInfo | null appVersion: string @@ -83,7 +79,7 @@ /** The store segments, in order; null is All. Empty (no control) with fewer than two stores. */ const stores = $derived(storeSegments(storesInUse)) const storeIndex = $derived(stores.indexOf(store)) - const chips = $derived(filterChips(filters, collections)) + const chips = $derived(filterChips(filters)) const sorts = $derived( (['lastPlayed', 'mostPlayed', 'longestToBeat', 'shortestToBeat', 'title'] as const).map((value) => ({ value, label: t(`sort.${value}`) })), @@ -184,13 +180,7 @@ {chip.label} {/each} - 1} - bind:open={() => open === 'filters', (v) => show('filters', v)} - onchanged={oncollections} - > + 1} bind:open={() => open === 'filters', (v) => show('filters', v)}> {#snippet trigger({ props })} - - {/if} - - - {/if} - {#if lib.epicNotice} -
- {t('app.epicLoggedOut')} - - -
- {/if} - {#if error} - - {/if} - - {#if confirming} - - {#key confirming.game.key} - (confirming = null)} - onconfirm={(choice) => { - const { key } = confirming!.game - confirming = null - act('install', key, { choice }) - }} - /> - {/key} - {/if} - -
- -
- {#if shown.length > 0} - + openAddGame()} + {update} + appVersion={settings?.appVersion ?? ''} + running={running !== null} + {installing} + {installError} + oninstall={installUpdate} + /> + + {#if updatedTo} + {@const notes = installedNotes(updatedTo)} + {@const [before, after] = around('app.updatedTo', 'version')} +
+ {before}{updatedTo}{after} + {#if notes} + + + {/if} + +
+ {/if} + {#if lib.epicNotice} +
+ {t('app.epicLoggedOut')} + + +
+ {/if} + {#if error} + + {/if} + + {#if confirming} + + {#key confirming.game.key} + (confirming = null)} + onconfirm={(choice) => { + const { key } = confirming!.game + confirming = null + act('install', key, { choice }) + }} + /> + {/key} + {/if} + +
+ +
+ {#if shown.length > 0} + act('play', key)} + oninstall={install} + oncancel={cancelDownload} + onresume={resumeDownloads} + onfavorite={setFavorite} + onmenu={openCardMenu} + benchSpeed={ready ? benchSpeed : null} + {headerHeight} + > + {#snippet header()} + {#if showContinue && featured} +
+ act('play', key)} + onopen={openGame} + /> +
+ {/if} + {#if !grid.sections} +

+ {query || filtered ? t('app.results') : libView ? filterName(libView, collections) : t('app.library')} + {shown.length} +

+ {/if} + {/snippet} +
+ {:else if epicEmpty && lib.epic === 'noTool'} +
+

{t('app.noLegendary')}

+ {t('app.noLegendaryHint')} +
+ +
+
+ {:else if epicEmpty && lib.epic === 'loggedOut'} +
+

{t('app.epicLoggedOutEmpty')}

+ +
+ {:else if epicEmpty && lib.epic === 'unreachable'} +
+

{t('app.epicUnreachable')}

+ {t('app.epicUnreachableHint')} +
+ {:else if started && lib.counts.library + lib.counts.hidden > 0 && !query && !filtered && viewTotal === 0} +
+

+ {libView === null + ? t('sidebar.allHidden') + : libView === 'favorites' + ? t('sidebar.emptyFavorites') + : libView === 'hidden' + ? t('sidebar.emptyHidden') + : t('sidebar.emptyCollection', { name: filterName(libView, collections) })} +

+
+ {:else if started && viewTotal > 0} +
+

{t('app.noMatch')}

+ {query && filtered ? t('app.noMatchQueryFilters', { query }) : query ? t('app.noMatchQuery', { query }) : t('app.noMatchFilters')} +
+ +
+
+ {:else if started && noGames} +
+

{t('app.noGames')}

+ {t('app.noGamesHint')} +
+ + +
+
+ {:else if started} +
+

{lib.status.map(api.message).join('\n')}

+
+ {/if} +
+ {#if open} + act('play', key)} - oninstall={install} oncancel={cancelDownload} onresume={resumeDownloads} - onfavorite={setFavorite} - onmenu={openCardMenu} - benchSpeed={ready ? benchSpeed : null} - {headerHeight} - > - {#snippet header()} - {#if showContinue && featured} -
- act('play', key)} - onopen={openGame} - /> -
- {/if} - {#if !view.sections} -

- {query || store || installedOnly || filters.length ? t('app.results') : t('app.library')} - {shown.length} -

- {/if} - {/snippet} - - {:else if epicEmpty && lib.epic === 'noTool'} -
-

{t('app.noLegendary')}

- {t('app.noLegendaryHint')} -
- -
-
- {:else if epicEmpty && lib.epic === 'loggedOut'} -
-

{t('app.epicLoggedOutEmpty')}

- -
- {:else if epicEmpty && lib.epic === 'unreachable'} -
-

{t('app.epicUnreachable')}

- {t('app.epicUnreachableHint')} -
- {:else if started && lib.total > 0} -
-

{t('app.noMatch')}

- {query && filtered ? t('app.noMatchQueryFilters', { query }) : query ? t('app.noMatchQuery', { query }) : t('app.noMatchFilters')} -
- -
-
- {:else if started && noGames} -
-

{t('app.noGames')}

- {t('app.noGamesHint')} -
- - -
-
- {:else if started} -
-

{lib.status.map(api.message).join('\n')}

-
+ {version} + onback={() => closeGame()} + onerror={(m) => (error = m)} + onchanged={reload} + ontint={(url) => (tint = url)} + onedit={openAddGame} + conflict={saveConflict} + /> {/if}
- {#if open} - (error = m)} - onchanged={reload} - ontint={(url) => (tint = url)} - onedit={openAddGame} - conflict={saveConflict} - /> - {/if}
@@ -745,6 +790,12 @@ z-index: 1; height: 100%; display: flex; + } + + .pane { + flex: 1; + min-width: 0; + display: flex; flex-direction: column; } diff --git a/src/lib/ActionMenu.svelte b/src/lib/ActionMenu.svelte index 4d94b7b..af7d12b 100644 --- a/src/lib/ActionMenu.svelte +++ b/src/lib/ActionMenu.svelte @@ -20,15 +20,18 @@ let { actions, label, + at = null, open = $bindable(), trigger, }: { actions: Action[] /** The menu's accessible name. */ label: string + /** Opens at the pointer (a right-click); otherwise it hangs below `trigger`, right-aligned. */ + at?: { x: number; y: number } | null open: boolean /** The caller's ⋯ button: spread `props` on it. */ - trigger: Snippet<[{ props: Record }]> + trigger?: Snippet<[{ props: Record }]> } = $props() let content = $state(null) @@ -53,16 +56,19 @@ - - {#snippet child({ props })} - {@render trigger({ props })} - {/snippet} - + {#if trigger} + + {#snippet child({ props })} + {@render trigger({ props })} + {/snippet} + + {/if} new DOMRect(at.x, at.y, 0, 0) } : null} + align={at ? 'start' : 'end'} + sideOffset={at ? 0 : 8} collisionPadding={8} preventScroll={false} aria-label={label} diff --git a/src/lib/DownloadsPopover.svelte b/src/lib/DownloadsPopover.svelte index a4fe703..31fe223 100644 --- a/src/lib/DownloadsPopover.svelte +++ b/src/lib/DownloadsPopover.svelte @@ -26,7 +26,7 @@ /** The library as loaded, for titles; a game hidden by the search is asked for once. */ games: Card[] open: boolean - /** The Downloads chip: spread `props` on it. */ + /** The sidebar's Downloads row: spread `props` on it. */ trigger: Snippet<[{ props: Record }]> oncancel: (key: string) => void onpause: () => void @@ -99,7 +99,7 @@ {/snippet} - + {#snippet child({ props, wrapperProps })}
+ {#if rail}{@render plus()}{/if} {#if counts.hidden > 0} {@render row( @@ -376,30 +406,39 @@ {#if downloading} pop === 'downloads', showDownloads} {oncancel} {onpause} {onresume} {onmove}> {#snippet trigger({ props })} - + + {#snippet children({ props: tip })} + + {/snippet} + {/snippet} {/if} - + + {#snippet children({ props })} + + {/snippet} +
@@ -698,4 +737,93 @@ border-radius: 50%; background: var(--warn); } + + /* Instant, no width transition: the virtualised grid's column count follows its width. */ + .rail { + width: 64px; + padding: 14px 10px; + align-items: center; + } + + .rail .item { + width: 44px; + height: 44px; + padding: 0; + justify-content: center; + } + + .rail .item .line { + width: 20px; + height: 20px; + } + + .rail .name, + .rail em, + .rail .text, + .rail .more { + display: none; + } + + .rail .sec { + width: 28px; + height: 1px; + margin: 8px 0; + padding: 0; + background: var(--glass-line); + } + + .rail .list { + scrollbar-width: none; + } + + .rail .list::-webkit-scrollbar { + display: none; + } + + .rail .stack { + width: 30px; + height: 36px; + } + + .rail .stack img, + .rail .tile { + width: 23px; + height: 34px; + } + + .rail .plus { + margin-top: 6px; + } + + .rail .bottom { + align-items: center; + } + + .rail .dot { + position: absolute; + top: 8px; + right: 8px; + } + + /* Progress as a ring inside the button's edge; it changes with each poll, never per frame. */ + .ring { + position: absolute; + inset: 3px; + padding: 2px; + border-radius: 8px; + background: conic-gradient(var(--accent-2) 0 var(--done), transparent var(--done)); + mask: + linear-gradient(#000 0 0) content-box exclude, + linear-gradient(#000 0 0); + pointer-events: none; + } + + /* Over the content, out of the layout: the grid keeps the rail's width while a field, question or failure shows. */ + .over { + position: relative; + z-index: 25; + margin-right: -160px; + background: var(--surface-2); + box-shadow: var(--shadow-modal); + } diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 7a02215..9d86318 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -290,6 +290,7 @@ "filters.renameNamed": "Rename {name}", "filters.deleteNamed": "Delete {name}", "sidebar.label": "Library navigation", + "sidebar.rowName": "{name}, {count}", "sidebar.collections": "Collections", "sidebar.newCollection": "New collection", "sidebar.collectionName": "Collection name", diff --git a/src/lib/i18n/nl.json b/src/lib/i18n/nl.json index 8cc50e3..3b4416b 100644 --- a/src/lib/i18n/nl.json +++ b/src/lib/i18n/nl.json @@ -290,6 +290,7 @@ "filters.renameNamed": "{name} hernoemen", "filters.deleteNamed": "{name} verwijderen", "sidebar.label": "Bibliotheeknavigatie", + "sidebar.rowName": "{name}, {count}", "sidebar.collections": "Collecties", "sidebar.newCollection": "Nieuwe collectie", "sidebar.collectionName": "Naam van de collectie", From 421f1e89d14ae0e5acfe61034ea8e242c6f2f5da Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:45:57 +0100 Subject: [PATCH 08/13] fix(ui): a sidebar failure note closes on Escape or when focus leaves --- DESIGN.md | 2 +- src/lib/Sidebar.svelte | 22 ++++++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 2edf50a..cbb7924 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -226,7 +226,7 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t - Hidden with its count, only while it holds a game. - Pushed to the bottom: Downloads only while something downloads, with its job count and a 3px `accent-2` bar under the label, updated per poll; it opens the Downloads popover to its right. When the last download ends with focus on it or in its popover, focus moves to Settings. Then Settings, which opens the dialog and carries the 8px amber dot only for a real problem: a saved login that stopped working, or a store that was set up and broke. A store never set up raises nothing. - Library through Hidden, collections included, are one Tab stop on the chosen row (`tabindex` 0 there, -1 on the rest); Up, Down, Home and End move between them. +, Downloads and Settings are their own Tab stops; ⋯ is not, its menu opens from the row with Menu or Shift+F10. Every row's accessible name is its name and count ("Favorites, 14"; "Backlog, 61 games"). When the chosen row goes away (its last favorite or hidden game, or a deleted collection), the view returns to Library and focus that was in the sidebar goes to Library. - - Below 1100px wide (`RAIL_BELOW` in `sidebar.ts`, also used by the grid's first-covers estimate) it is a 64px rail, switched instantly with no width transition because the virtualised grid's columns follow its width: 44px icon-only buttons with 20px icons, collections as their cover stack only (23×34 covers), a 28px `glass-line` rule in place of the Collections heading, + as the 24px round button under the collections, and no ⋯ (right click and Menu or Shift+F10 still open the menu). Each button has a `Tip` with its name and count, on hover and keyboard focus. Downloads shows its progress as an `accent-2` ring inside the button's edge instead of the bar; the Settings dot sits in the button's top right. The collections list scrolls without a visible scrollbar. While a name field, a delete question or a failure note is open, the full 224px sidebar lies over the content on `surface-2` with `shadow-modal`, so the grid keeps its width; it returns to the rail when that closes (a failure note closes when a row is chosen). + - Below 1100px wide (`RAIL_BELOW` in `sidebar.ts`, also used by the grid's first-covers estimate) it is a 64px rail, switched instantly with no width transition because the virtualised grid's columns follow its width: 44px icon-only buttons with 20px icons, collections as their cover stack only (23×34 covers), a 28px `glass-line` rule in place of the Collections heading, + as the 24px round button under the collections, and no ⋯ (right click and Menu or Shift+F10 still open the menu). Each button has a `Tip` with its name and count, on hover and keyboard focus. Downloads shows its progress as an `accent-2` ring inside the button's edge instead of the bar; the Settings dot sits in the button's top right. The collections list scrolls without a visible scrollbar. While a name field, a delete question or a failure note is open, the full 224px sidebar lies over the content on `surface-2` with `shadow-modal`, so the grid keeps its width; it returns to the rail when that closes (a failure note closes on Escape, when focus leaves the sidebar or when a row is chosen, in either width). - **Views:** a sidebar row picks a view (Library, Favorites, a collection, Hidden), never a filter: no chip, not "Results". The toolbar's search, filters and sort narrow and order it, and clearing them keeps the view. The label above an ungrouped grid names the view with its count, or Results while search or filters are on. The Continue banner shows only in Library. An empty view with no search or filters on says so in its own words without a Clear button ("No favorites yet…", Library with every game hidden too); a library with no games at all keeps the empty-library state. Choosing a row on the game page closes the page with focus on the row. - **Settings:** a modal panel, max 760px wide, with a 190px section list on the left (stacked under 640px) that works as vertical tabs: only the chosen section shows, from its top. Sections: Accounts (Stores, then Game data with IGDB and SteamGridDB), General, About. Each section is a title, then Label headings over one rounded `glass` group per heading, its rows split by `glass-line` rules. Never a box per row. About opens with the 64px app logo beside Guild and its version, the acronym in small italic `text-3`, one line on what Guild is for, and Source code · GPL-3.0 · Credits (the README's Thanks); its Updates row then says only what the last check found. On Linux a Wine section sits between General and About (Windows never shows it), direction A (2026-11-09): - The top group: an umu-launcher row with Install only while umu is missing, then Proton for Windows games, one menu (Newest, naming the build that is now, then each build) with the subtitle that a game's own choice in Launch options comes first. diff --git a/src/lib/Sidebar.svelte b/src/lib/Sidebar.svelte index 872f50b..1e58e25 100644 --- a/src/lib/Sidebar.svelte +++ b/src/lib/Sidebar.svelte @@ -209,6 +209,8 @@ problem = null } catch (e) { problem = api.message(e) + // Saved by leaving the field: focus already left, so bring it back where Escape closes the note. + if (!nav?.contains(document.activeElement)) rowOf(c.id)?.focus() } onchanged() } @@ -300,7 +302,17 @@ {/snippet} -