feat(web): quick-filter on Library tabs (Tier B5)
test-web / test (push) Successful in 33s

Add a debounced QuickFilter input at the top of each Library section
to narrow the loaded list without leaving the tab. Server-side
/search remains the route for full-library searches.

- QuickFilter.svelte: 120ms debounced two-way bound input with a
  clear button and Escape-to-clear.
- Artists: filter by name; empty-match copy includes a "Search the
  full library" link to /search/artists.
- Albums: filter by title + artist_name; same fallback link.
- Liked: filters all three sub-sections (artists/albums/tracks);
  sub-section header hides when its filtered length is zero.
- History: filters flatEvents before groupByDay, so day-grouping
  reflects the filter.
- Playlists: filters owned + public by name; owners CTA stays.

Covered by QuickFilter unit tests (debounce + clear + Escape).
This commit is contained in:
2026-06-01 13:48:05 -04:00
parent fd12a145c8
commit be7be6f617
7 changed files with 299 additions and 33 deletions
+22 -2
View File
@@ -6,18 +6,33 @@
import InfiniteScrollSentinel from '$lib/components/InfiniteScrollSentinel.svelte';
import LibrarySkeleton from '$lib/components/LibrarySkeleton.svelte';
import ApiErrorBanner from '$lib/components/ApiErrorBanner.svelte';
import QuickFilter from '$lib/components/QuickFilter.svelte';
const queryStore = createHistoryQuery();
const query = $derived($queryStore);
const flatEvents = $derived(query.data?.pages?.flatMap((p) => p.events) ?? []);
const grouped = $derived(groupByDay(flatEvents, new Date()));
let filter = $state('');
const filteredEvents = $derived.by(() => {
const q = filter.trim().toLowerCase();
if (!q) return flatEvents;
return flatEvents.filter((e) =>
e.track.title.toLowerCase().includes(q) ||
e.track.artist_name.toLowerCase().includes(q) ||
(e.track.album_title ?? '').toLowerCase().includes(q)
);
});
const grouped = $derived(groupByDay(filteredEvents, new Date()));
</script>
<svelte:head><title>{pageTitle('Library · History')}</title></svelte:head>
<div class="space-y-4">
<header>
<header class="flex flex-wrap items-end justify-between gap-3">
<h1 class="font-display text-2xl font-medium text-text-primary">History</h1>
{#if flatEvents.length > 0}
<QuickFilter bind:value={filter} placeholder="Filter history" />
{/if}
</header>
{#if query.isPending}
@@ -26,6 +41,11 @@
<ApiErrorBanner error={query.error} onRetry={query.refetch} />
{:else if flatEvents.length === 0}
<p class="p-8 text-center text-text-secondary">No listening history yet.</p>
{:else if filter.trim() && filteredEvents.length === 0}
<p class="text-text-secondary">
No history in your loaded events matches
<span class="font-medium">'{filter.trim()}'</span>.
</p>
{:else}
{#each grouped as group (group.label)}
<section>