chore: complete v1.0 Consolidation milestone

Archive milestone artifacts:
- milestones/v1.0-ROADMAP.md (full roadmap archive)
- milestones/v1.0-REQUIREMENTS.md (26/26 requirements complete)
- milestones/v1.0-phases/ (8 phase directories with plans, summaries, verifications)

Updated:
- PROJECT.md: full evolution review, all consolidation requirements validated
- ROADMAP.md: collapsed to milestone summary with archive link
- STATE.md: reset for next milestone
- MILESTONES.md: created with stats and accomplishments
- RETROSPECTIVE.md: created with lessons learned

Deleted:
- REQUIREMENTS.md (archived, fresh for next milestone)

8 phases, 17 plans, 34 tasks, 84 tests added, 6 days
This commit is contained in:
2026-03-05 09:34:43 -05:00
parent 5ef45f91ed
commit 6ce0661fca
58 changed files with 348 additions and 294 deletions
@@ -0,0 +1,232 @@
---
phase: 08-frontend-performance-ux
plan: 01
type: execute
wave: 1
depends_on: []
files_modified:
- frontend/src/store/library-store.ts
- frontend/src/components/search-bar/search-bar.ts
- frontend/src/styles/tokens.css.ts
autonomous: true
requirements:
- PERF-05
- UX-01
must_haves:
truths:
- "Library store notifications during rapid updates (scan, invalidation) are coalesced into a single subscriber notification per microtask tick"
- "CSS custom properties for icon sizing (--yj-icon-sm, --yj-icon-md, --yj-icon-lg) and type scale (--yj-text-xs through --yj-text-lg) are defined and available to all components"
- "Search input is debounced ~150ms before triggering filter/rank computation"
artifacts:
- path: "frontend/src/store/library-store.ts"
provides: "queueMicrotask-based notification coalescing"
contains: "queueMicrotask"
- path: "frontend/src/styles/tokens.css.ts"
provides: "Design token definitions for icon sizes and type scale"
contains: "--yj-icon-sm"
- path: "frontend/src/components/search-bar/search-bar.ts"
provides: "Debounced search input"
contains: "debounce"
key_links:
- from: "frontend/src/store/library-store.ts"
to: "subscribers"
via: "queueMicrotask coalescing in notify()"
pattern: "queueMicrotask"
- from: "frontend/src/styles/tokens.css.ts"
to: "all components"
via: "CSS custom property inheritance from :host or adopted stylesheets"
pattern: "--yj-icon-sm|--yj-text-xs"
---
<objective>
Add performance plumbing (store debouncing, search debounce) and define the design token foundation (icon sizes, type scale) that all subsequent plans depend on.
Purpose: Library store fires 8+ notifications during scan invalidation (4 parallel fetches × 2 notifications each). Coalescing via queueMicrotask prevents layout thrashing. Design tokens establish the visual vocabulary that Plan 04 will systematically apply.
Output: Debounced store, debounced search, design token CSS file.
</objective>
<execution_context>
@/home/caleb/.config/opencode/get-shit-done/workflows/execute-plan.md
@/home/caleb/.config/opencode/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/08-frontend-performance-ux/08-CONTEXT.md
@frontend/src/store/library-store.ts
@frontend/src/components/search-bar/search-bar.ts
<interfaces>
<!-- Key types and contracts the executor needs. -->
From frontend/src/store/library-store.ts:
```typescript
type Subscriber = () => void;
class LibraryStore {
private subscribers = new Set<Subscriber>();
// Current notify — called ~12 times during invalidate→eagerFetch cycle:
private notify(): void {
this.subscribers.forEach((callback) => callback());
}
// Called from: getTracks/getAlbums/getArtists/getGenres (loading start + end),
// invalidate(), setCoverSize()
subscribe(callback: Subscriber): () => void {
this.subscribers.add(callback);
return () => this.subscribers.delete(callback);
}
}
export const libraryStore = new LibraryStore();
```
From frontend/src/store/search-store.ts:
```typescript
class SearchStore {
private term = '';
setTerm(term: string): void {
if (term === this.term) return;
this.term = term;
this.notify();
}
}
export const searchStore = new SearchStore();
```
From frontend/src/components/search-bar/search-bar.ts:
```typescript
// Current: directly sets search term on every input event
// searchCtrl is a SearchController with a `term` setter
this.searchCtrl.term = input.value;
```
Existing CSS custom properties (already defined, DO NOT redefine):
- --yj-text-primary, --yj-text-secondary, --yj-text-tertiary
- --yj-bg-surface, --yj-bg-elevated, --yj-bg-overlay, --yj-bg-base
- --yj-border, --yj-border-subtle
- --yj-accent, --yj-accent-bg
- --yj-hover-overlay, --yj-selection-bg, --yj-error
</interfaces>
</context>
<tasks>
<task type="auto">
<name>Task 1: Add queueMicrotask debouncing to library store and search input debounce</name>
<files>frontend/src/store/library-store.ts, frontend/src/components/search-bar/search-bar.ts</files>
<action>
**Library store debouncing (library-store.ts):**
Replace the current `notify()` method with a queueMicrotask-based coalescing pattern:
1. Add a private boolean field `private notifyScheduled = false;`
2. Replace `notify()` implementation:
```typescript
private notify(): void {
if (this.notifyScheduled) return;
this.notifyScheduled = true;
queueMicrotask(() => {
this.notifyScheduled = false;
this.subscribers.forEach((callback) => callback());
});
}
```
This coalesces ALL notify() calls within the same microtask tick into a single subscriber notification round. During invalidate() → eagerFetch() → 4 parallel fetches × 2 notifications each = 8+ calls → 1 actual notification.
The subscribe() API is unchanged — this is transparent to subscribers.
**Search input debounce (search-bar.ts):**
Add a ~150ms debounce to the search input handler so that rapid typing doesn't trigger expensive filter/rank computation on every keystroke.
1. Add a private timer field: `private searchDebounceTimer: ReturnType<typeof setTimeout> | null = null;`
2. In the input handler, instead of immediately setting `this.searchCtrl.term = input.value`:
- Clear any existing timer
- If the input is empty, set term immediately (instant clear feedback)
- Otherwise, set a 150ms timeout that sets `this.searchCtrl.term`
Do NOT debounce the visual update of the input field itself — only debounce the propagation to the search store. The input should still show characters as typed.
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>Library store notify() uses queueMicrotask to coalesce multiple calls per tick. Search input debounces store propagation by 150ms while maintaining instant visual feedback on the input element.</done>
</task>
<task type="auto">
<name>Task 2: Define design token CSS custom properties for icon sizes and type scale</name>
<files>frontend/src/styles/tokens.css.ts</files>
<action>
Create a new file `frontend/src/styles/tokens.css.ts` that exports a Lit `css` tagged template with design token definitions.
Use the same pattern as other style files in the project — export a `css` tagged template literal from `lit`.
```typescript
import { css } from 'lit';
/**
* Design tokens for consistent sizing across all components.
* Import and include in a component's static styles array:
*
* import { designTokens } from '../../styles/tokens.css';
* static styles = [designTokens, css`...`];
*/
export const designTokens = css`
:host {
/* ── Icon sizes ── */
--yj-icon-sm: 14px;
--yj-icon-md: 18px;
--yj-icon-lg: 24px;
/* ── Type scale ── */
--yj-text-xs: 11px;
--yj-text-sm: 12px;
--yj-text-md: 13px;
--yj-text-lg: 15px;
--yj-text-xl: 18px;
}
`;
```
**Design rationale:**
- Icon sizes: sm=14px covers small inline icons (favorites, sort indicators), md=18px covers standard toolbar/sidebar icons, lg=24px covers feature icons (now-playing placeholder, large action icons)
- Type scale: xs=11px for smallest text (cover-grid small cards), sm=12px for secondary info and labels, md=13px for body text and inputs, lg=15px for headings and emphasis, xl=18px for large titles
- These values are derived from the actual pixel values already scattered across the codebase — this consolidates them rather than inventing new sizes
- :host scope means tokens are available within each component that imports the stylesheet
Verify the file path exists: check for a `frontend/src/styles/` directory. If it doesn't exist, create it.
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>Design token file exists at frontend/src/styles/tokens.css.ts, exports `designTokens` css template with --yj-icon-sm/md/lg and --yj-text-xs/sm/md/lg/xl custom properties on :host.</done>
</task>
</tasks>
<verification>
1. `cd frontend && npx tsc --noEmit` compiles without errors
2. library-store.ts contains `queueMicrotask` in the notify method
3. search-bar.ts has debounce logic with ~150ms delay
4. frontend/src/styles/tokens.css.ts exists and exports designTokens
5. No behavioral regressions — subscribe() API is unchanged, search still works
</verification>
<success_criteria>
- Library store notify() coalesces multiple calls within a microtask tick into one notification round
- Search input propagation to store is debounced by ~150ms (empty input clears immediately)
- Design token file defines --yj-icon-sm/md/lg and --yj-text-xs/sm/md/lg/xl
- TypeScript compiles without errors
</success_criteria>
<output>
After completion, create `.planning/phases/08-frontend-performance-ux/08-01-SUMMARY.md`
</output>
@@ -0,0 +1,94 @@
---
phase: 08-frontend-performance-ux
plan: 01
subsystem: frontend
tags: [lit, queueMicrotask, debounce, css-custom-properties, design-tokens]
# Dependency graph
requires: []
provides:
- queueMicrotask-based notification coalescing in library store
- debounced search input (150ms) with instant clear
- design token CSS custom properties for icon sizes and type scale
affects: [08-02, 08-03, 08-04]
# Tech tracking
tech-stack:
added: []
patterns: [queueMicrotask coalescing, debounced input propagation, design tokens via Lit css tagged templates]
key-files:
created:
- frontend/src/styles/tokens.css.ts
modified:
- frontend/src/store/library-store.ts
- frontend/src/components/search-bar/search-bar.ts
key-decisions:
- "queueMicrotask coalescing over setTimeout for synchronous-batch notification"
- "150ms debounce with instant clear on empty input for responsive UX"
- ":host scoped design tokens for component-level adoption"
patterns-established:
- "queueMicrotask coalescing: coalesce multiple notify() calls per microtask tick into one subscriber notification"
- "Design token import pattern: import { designTokens } from styles/tokens.css and include in static styles array"
requirements-completed: [PERF-05, UX-01]
# Metrics
duration: 1min
completed: 2026-03-05
---
# Phase 08 Plan 01: Performance Plumbing & Design Tokens Summary
**queueMicrotask notification coalescing in library store, 150ms debounced search input, and design token CSS custom properties for icon/type sizing**
## Performance
- **Duration:** 1 min
- **Started:** 2026-03-05T04:13:30Z
- **Completed:** 2026-03-05T04:15:16Z
- **Tasks:** 2
- **Files modified:** 3
## Accomplishments
- Library store notify() coalesces 8+ notifications during scan invalidation into a single subscriber notification per microtask tick
- Search input debounces store propagation by 150ms while maintaining instant visual feedback and instant clear
- Design token file defines --yj-icon-sm/md/lg and --yj-text-xs/sm/md/lg/xl CSS custom properties for consistent sizing
## Task Commits
Each task was committed atomically:
1. **Task 1: Add queueMicrotask debouncing to library store and search input debounce** - `3bf66ed` (perf)
2. **Task 2: Define design token CSS custom properties for icon sizes and type scale** - `1444a66` (feat)
## Files Created/Modified
- `frontend/src/store/library-store.ts` - Added notifyScheduled flag and queueMicrotask coalescing in notify()
- `frontend/src/components/search-bar/search-bar.ts` - Added 150ms debounce timer for search store propagation
- `frontend/src/styles/tokens.css.ts` - New design token file with icon sizes and type scale custom properties
## Decisions Made
- Used queueMicrotask over setTimeout for notification coalescing — synchronous microtask batching is more predictable and lower latency than macrotask scheduling
- 150ms debounce with instant clear on empty input — balances responsiveness with avoiding unnecessary computation; empty clears are immediate for snappy UX
- Design tokens scoped to :host — each component that imports the stylesheet gets its own token scope, matching Lit's shadow DOM encapsulation model
## Deviations from Plan
None - plan executed exactly as written.
## Issues Encountered
None
## User Setup Required
None - no external service configuration required.
## Next Phase Readiness
- Performance plumbing and design tokens in place
- Ready for Plan 02 (subsequent frontend work can import designTokens)
- Library store subscribers will automatically benefit from coalesced notifications
---
*Phase: 08-frontend-performance-ux*
*Completed: 2026-03-05*
@@ -0,0 +1,311 @@
---
phase: 08-frontend-performance-ux
plan: 02
type: execute
wave: 1
depends_on: []
files_modified:
- frontend/src/components/track-list/track-list.ts
- frontend/src/components/queue-panel/queue-panel.ts
- frontend/src/components/cover-grid/cover-grid.ts
- frontend/src/components/artists-view/artists-view.ts
- frontend/src/components/genres-view/genres-view.ts
autonomous: true
requirements:
- PERF-05
- UX-02
must_haves:
truths:
- "All virtualizer components use repeat() directive with stable keys instead of .items/.renderItem"
- "Track list uses FilePath as key, cover grid uses album.ID, queue panel uses QueueTrack.id"
- "Artists and genres views use their entity ID as repeat() key"
- "Scrolling through 10k+ tracks reuses DOM nodes efficiently via keyed repeat()"
artifacts:
- path: "frontend/src/components/track-list/track-list.ts"
provides: "repeat() with FilePath key for track virtualizer"
contains: "repeat("
- path: "frontend/src/components/queue-panel/queue-panel.ts"
provides: "repeat() with QueueTrack.id key for queue virtualizer"
contains: "repeat("
- path: "frontend/src/components/cover-grid/cover-grid.ts"
provides: "repeat() with album.ID key for all 3 cover grid virtualizers"
contains: "repeat("
- path: "frontend/src/components/artists-view/artists-view.ts"
provides: "repeat() with artist entry key"
contains: "repeat("
- path: "frontend/src/components/genres-view/genres-view.ts"
provides: "repeat() with genre entry key"
contains: "repeat("
key_links:
- from: "track-list.ts"
to: "lit-virtualizer"
via: "repeat() directive as child of lit-virtualizer"
pattern: "repeat\\(.*FilePath"
- from: "cover-grid.ts"
to: "lit-virtualizer"
via: "repeat() directive replacing .items/.renderItem/.keyFunction"
pattern: "repeat\\(.*album\\.ID"
---
<objective>
Migrate all virtualizer components from the `.items/.renderItem` property pattern to Lit's `repeat()` directive with stable keys for efficient DOM reuse during scrolling and filtering.
Purpose: The repeat() directive with stable keys enables Lit's DOM recycling — when items are reordered, added, or removed, Lit moves existing DOM nodes instead of destroying and recreating them. This eliminates jank during scrolling and filtering in large libraries.
Output: All 5 virtualizer components use repeat() with appropriate stable keys.
</objective>
<execution_context>
@/home/caleb/.config/opencode/get-shit-done/workflows/execute-plan.md
@/home/caleb/.config/opencode/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/08-frontend-performance-ux/08-CONTEXT.md
@frontend/src/components/track-list/track-list.ts
@frontend/src/components/queue-panel/queue-panel.ts
@frontend/src/components/cover-grid/cover-grid.ts
@frontend/src/components/artists-view/artists-view.ts
@frontend/src/components/genres-view/genres-view.ts
<interfaces>
<!-- Current virtualizer patterns to replace -->
track-list.ts (1 virtualizer):
```html
<lit-virtualizer
.items=${visibleTracks}
.renderItem=${this.renderTrackRow}
></lit-virtualizer>
```
Key: track.FilePath (unique per track, string)
renderTrackRow signature: (track: library.Track, index: number) => TemplateResult
cover-grid.ts (3 virtualizers — main grid, before-split, after-split):
```html
<lit-virtualizer
.items=${this.buildGridEntries()}
.renderItem=${this.renderGridEntry}
.keyFunction=${this.gridKeyFunction}
></lit-virtualizer>
```
Current gridKeyFunction: `(entry: GridEntry) => \`a-${entry.album.ID}\``
Key: entry.album.ID (number, use as string in repeat key)
renderGridEntry signature: (entry: GridEntry, index: number) => TemplateResult
queue-panel.ts (1 virtualizer):
```html
<lit-virtualizer
.items=${tracks}
.renderItem=${this.renderTrackItem}
></lit-virtualizer>
```
Key: QueueTrack.id (string field, unique per queue entry even for duplicate tracks)
renderTrackItem signature: (track: QueueTrack, index: number) => TemplateResult
artists-view.ts (1 virtualizer):
```html
<lit-virtualizer
.items=${entries}
.renderItem=${(entry: ArtistEntry) => this.renderArtistCard(entry)}
></lit-virtualizer>
```
Key: entry.artist.ID (number)
genres-view.ts (1 virtualizer):
```html
<lit-virtualizer
.items=${entries}
.renderItem=${(entry: GenreEntry) => this.renderGenreCard(entry)}
></lit-virtualizer>
```
Key: entry.genre.Name (string, genres identified by name)
Import needed:
```typescript
import { repeat } from 'lit/directives/repeat.js';
```
</interfaces>
</context>
<tasks>
<task type="auto">
<name>Task 1: Migrate track-list and queue-panel virtualizers to repeat() directive</name>
<files>frontend/src/components/track-list/track-list.ts, frontend/src/components/queue-panel/queue-panel.ts</files>
<action>
Both components use flow layout virtualizers with `.items` + `.renderItem`. Convert to repeat() directive.
**track-list.ts:**
1. Add import: `import { repeat } from 'lit/directives/repeat.js';`
2. Find the `<lit-virtualizer>` element (around line 1736-1741). Replace:
```html
<lit-virtualizer
.items=${visibleTracks}
.renderItem=${this.renderTrackRow}
></lit-virtualizer>
```
With:
```html
<lit-virtualizer
.items=${visibleTracks}
>
${repeat(
visibleTracks,
(track) => track.FilePath,
(track, index) => this.renderTrackRow(track, index),
)}
</lit-virtualizer>
```
3. Remove the `.renderItem` property but keep `.items` — lit-virtualizer still needs `.items` for scroll sizing/virtualization calculations even when using repeat() for rendering.
4. Keep all other virtualizer properties unchanged (`.layout`, event handlers, etc.).
**queue-panel.ts:**
1. Add import: `import { repeat } from 'lit/directives/repeat.js';`
2. Find the `<lit-virtualizer>` element (around line 1282-1288). Replace the same pattern:
```html
<lit-virtualizer
.items=${tracks}
.renderItem=${this.renderTrackItem}
></lit-virtualizer>
```
With:
```html
<lit-virtualizer
.items=${tracks}
>
${repeat(
tracks,
(track) => track.id,
(track, index) => this.renderTrackItem(track, index),
)}
</lit-virtualizer>
```
3. Remove `.renderItem` property, keep `.items`.
**Important:** The `renderTrackRow` and `renderTrackItem` methods stay as-is. The repeat() directive wraps them — it provides the key function, while the existing render methods provide the template. Do NOT change render method signatures.
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>track-list.ts uses repeat() with FilePath key. queue-panel.ts uses repeat() with QueueTrack.id key. Both keep .items for virtualization sizing. TypeScript compiles.</done>
</task>
<task type="auto">
<name>Task 2: Migrate cover-grid, artists-view, and genres-view virtualizers to repeat() directive</name>
<files>frontend/src/components/cover-grid/cover-grid.ts, frontend/src/components/artists-view/artists-view.ts, frontend/src/components/genres-view/genres-view.ts</files>
<action>
**cover-grid.ts (3 virtualizers):**
1. Add import: `import { repeat } from 'lit/directives/repeat.js';`
2. Cover-grid has THREE `<lit-virtualizer>` instances (main grid ~line 1853, before-split ~line 1880, after-split ~line 1909). ALL three currently use `.items`, `.renderItem`, and `.keyFunction`. Convert ALL three.
For each virtualizer, replace:
```html
<lit-virtualizer
.items=${items}
.renderItem=${this.renderGridEntry}
.keyFunction=${this.gridKeyFunction}
></lit-virtualizer>
```
With:
```html
<lit-virtualizer
.items=${items}
>
${repeat(
items,
(entry) => entry.album.ID,
(entry, index) => this.renderGridEntry(entry, index),
)}
</lit-virtualizer>
```
3. Remove both `.renderItem` and `.keyFunction` properties from all three virtualizers.
4. The `gridKeyFunction` method can be removed since its logic is now inline in the repeat() calls. Alternatively, keep it as a private method and reference it: `(entry) => this.gridKeyFunction(entry)` — either approach is fine, but inline is cleaner.
5. Keep `.items` on all three for virtualization sizing.
6. Preserve all other properties (`.layout`, CSS classes, event handlers).
**artists-view.ts (1 virtualizer):**
1. Add import: `import { repeat } from 'lit/directives/repeat.js';`
2. Find the virtualizer (~line 1217-1227). Replace:
```html
<lit-virtualizer
.items=${entries}
.renderItem=${(entry: ArtistEntry) => this.renderArtistCard(entry)}
></lit-virtualizer>
```
With:
```html
<lit-virtualizer
.items=${entries}
>
${repeat(
entries,
(entry) => entry.artist.ID,
(entry) => this.renderArtistCard(entry),
)}
</lit-virtualizer>
```
3. Determine the correct key — look at the ArtistEntry type to find the artist ID field. Use the artist's unique identifier.
**genres-view.ts (1 virtualizer):**
1. Add import: `import { repeat } from 'lit/directives/repeat.js';`
2. Find the virtualizer (~line 1169-1177). Same pattern:
```html
<lit-virtualizer
.items=${entries}
.renderItem=${(entry: GenreEntry) => this.renderGenreCard(entry)}
></lit-virtualizer>
```
With:
```html
<lit-virtualizer
.items=${entries}
>
${repeat(
entries,
(entry) => entry.genre.Name,
(entry) => this.renderGenreCard(entry),
)}
</lit-virtualizer>
```
3. Determine the correct key — genres are identified by name (string). Use the genre name as key.
**Important for all:** Keep `.items` property on virtualizers. The virtualizer needs the items array for scroll height calculation and viewport management. The repeat() directive handles the rendering and keying.
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>All three cover-grid virtualizers use repeat() with album.ID key. artists-view uses repeat() with artist ID key. genres-view uses repeat() with genre name key. .keyFunction and .renderItem properties removed. TypeScript compiles.</done>
</task>
</tasks>
<verification>
1. `cd frontend && npx tsc --noEmit` compiles without errors
2. All 7 virtualizer instances across 5 files use repeat() directive
3. No .renderItem properties remain on any lit-virtualizer element
4. No .keyFunction properties remain on any lit-virtualizer element
5. All virtualizers retain .items property for scroll sizing
6. Stable keys: FilePath (tracks), album.ID (covers), QueueTrack.id (queue), artist.ID (artists), genre.Name (genres)
</verification>
<success_criteria>
- Every lit-virtualizer in the codebase uses repeat() directive with stable keys
- .items is preserved on all virtualizers for virtualization sizing
- .renderItem and .keyFunction properties are removed
- TypeScript compiles without errors
</success_criteria>
<output>
After completion, create `.planning/phases/08-frontend-performance-ux/08-02-SUMMARY.md`
</output>
@@ -0,0 +1,117 @@
---
phase: 08-frontend-performance-ux
plan: 02
subsystem: ui
tags: [lit, virtualizer, repeat-directive, dom-recycling, performance]
# Dependency graph
requires:
- phase: 08-frontend-performance-ux
provides: "Phase context with virtualizer component analysis"
provides:
- "All 7 lit-virtualizer instances use repeat() with stable keys for efficient DOM reuse"
- "Keyed rendering: FilePath (tracks), album.ID (covers), QueueTrack.id (queue), artist.ID (artists), genre.name (genres)"
affects: [08-frontend-performance-ux]
# Tech tracking
tech-stack:
added: []
patterns: ["repeat() directive with stable keys on all lit-virtualizer instances"]
key-files:
created: []
modified:
- frontend/src/components/track-list/track-list.ts
- frontend/src/components/queue-panel/queue-panel.ts
- frontend/src/components/cover-grid/cover-grid.ts
- frontend/src/components/artists-view/artists-view.ts
- frontend/src/components/genres-view/genres-view.ts
key-decisions:
- "Inline album.ID key in repeat() calls instead of keeping gridKeyFunction method"
- "Use genre.name (lowercase) as key matching Genre interface, not genre.Name from plan"
patterns-established:
- "Virtualizer pattern: always use repeat() with stable entity key as child of lit-virtualizer, keep .items for sizing"
requirements-completed: [PERF-05, UX-02]
# Metrics
duration: 3min
completed: 2026-03-05
---
# Phase 8 Plan 02: Virtualizer repeat() Directive Migration Summary
**Migrated all 7 lit-virtualizer instances across 5 components to repeat() directive with stable entity keys for efficient DOM recycling during scrolling and filtering**
## Performance
- **Duration:** 3 min
- **Started:** 2026-03-05T04:13:34Z
- **Completed:** 2026-03-05T04:17:06Z
- **Tasks:** 2
- **Files modified:** 5
## Accomplishments
- All 7 virtualizer instances now use repeat() with stable keys for DOM node reuse
- Removed .renderItem and .keyFunction properties from all lit-virtualizer elements
- Removed dead gridKeyFunction method from cover-grid component
- Stable keys: FilePath (tracks), QueueTrack.id (queue), album.ID (covers), artist.ID (artists), genre.name (genres)
## Task Commits
Each task was committed atomically:
1. **Task 1: Migrate track-list and queue-panel virtualizers** - `d2d7d8c` (perf)
2. **Task 2: Migrate cover-grid, artists-view, and genres-view virtualizers** - `1c3514d` (perf)
## Files Created/Modified
- `frontend/src/components/track-list/track-list.ts` - repeat() with FilePath key for track virtualizer
- `frontend/src/components/queue-panel/queue-panel.ts` - repeat() with QueueTrack.id key for queue virtualizer
- `frontend/src/components/cover-grid/cover-grid.ts` - repeat() with album.ID key for all 3 cover grid virtualizers, removed gridKeyFunction
- `frontend/src/components/artists-view/artists-view.ts` - repeat() with artist.ID key
- `frontend/src/components/genres-view/genres-view.ts` - repeat() with genre.name key
## Decisions Made
- **Inlined album.ID key instead of keeping gridKeyFunction:** The gridKeyFunction method was only used for .keyFunction property bindings. Since repeat() takes an inline key function, the method became dead code and was removed for cleanliness.
- **Used genre.name (lowercase) not genre.Name:** The Genre interface in genres-view uses lowercase `name` field, not the Go-model-style `Name`. Plan referenced `genre.Name` but actual code uses `genre.name`.
## Deviations from Plan
### Auto-fixed Issues
**1. [Rule 1 - Bug] Fixed renderGridEntry call signature in cover-grid repeat()**
- **Found during:** Task 2 (cover-grid migration)
- **Issue:** Plan template used `(entry, index) => this.renderGridEntry(entry, index)` but renderGridEntry only accepts 1 argument (GridEntry), not 2
- **Fix:** Changed to `(entry) => this.renderGridEntry(entry)` for all 3 cover-grid virtualizers
- **Files modified:** frontend/src/components/cover-grid/cover-grid.ts
- **Verification:** TypeScript compiles without errors
- **Committed in:** 1c3514d (Task 2 commit)
**2. [Rule 1 - Bug] Corrected genre key from genre.Name to genre.name**
- **Found during:** Task 2 (genres-view migration)
- **Issue:** Plan specified `entry.genre.Name` but Genre interface uses lowercase `name` field
- **Fix:** Used `entry.genre.name` as the repeat() key
- **Files modified:** frontend/src/components/genres-view/genres-view.ts
- **Verification:** TypeScript compiles without errors
- **Committed in:** 1c3514d (Task 2 commit)
---
**Total deviations:** 2 auto-fixed (2 bugs)
**Impact on plan:** Both fixes necessary for TypeScript correctness. No scope creep.
## Issues Encountered
None
## User Setup Required
None - no external service configuration required.
## Next Phase Readiness
- All virtualizer components now use repeat() with stable keys
- Ready for remaining Phase 8 plans (08-03, 08-04)
---
*Phase: 08-frontend-performance-ux*
*Completed: 2026-03-05*
@@ -0,0 +1,168 @@
---
phase: 08-frontend-performance-ux
plan: 03
type: execute
wave: 2
depends_on:
- "08-01"
- "08-02"
files_modified:
- frontend/src/components/track-list/track-list.ts
autonomous: true
requirements:
- PERF-05
- UX-02
must_haves:
truths:
- "renderTrackRow does not allocate arrays or join strings for CSS classes on every render call"
- "Column values used in rendering are pre-computed or cached, not recomputed per-cell on every render"
- "Scrolling through a 10k+ track list is smooth with no visible jank"
artifacts:
- path: "frontend/src/components/track-list/track-list.ts"
provides: "Optimized renderTrackRow with cached class strings and pre-computed column values"
contains: "classMap\\|ifDefined\\|cached"
key_links:
- from: "frontend/src/components/track-list/track-list.ts renderTrackRow"
to: "repeat() directive"
via: "Called per-item by repeat() — must be fast"
pattern: "renderTrackRow"
---
<objective>
Optimize the track-list renderTrackRow method to minimize per-row allocations and template computation during scrolling and filtering.
Purpose: renderTrackRow is the hot path for the largest list component. It's called for every visible row on every scroll event. Current implementation builds CSS class strings via array filter/join and computes column values per-cell on every call. With 10k+ tracks, reducing per-row work directly impacts scroll smoothness.
Output: Optimized renderTrackRow with cached class strings and efficient column rendering.
</objective>
<execution_context>
@/home/caleb/.config/opencode/get-shit-done/workflows/execute-plan.md
@/home/caleb/.config/opencode/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/08-frontend-performance-ux/08-CONTEXT.md
@.planning/phases/08-frontend-performance-ux/08-01-SUMMARY.md
@.planning/phases/08-frontend-performance-ux/08-02-SUMMARY.md
@frontend/src/components/track-list/track-list.ts
<interfaces>
<!-- The executor must read track-list.ts to understand the full renderTrackRow method.
Key patterns to optimize: -->
Current renderTrackRow pattern (approximate):
```typescript
private renderTrackRow = (track: library.Track, index: number) => {
// 1. Class string built via array filter/join on EVERY render:
const classes = [
'track-row',
this.isSelected(track) ? 'selected' : '',
this.isCurrentTrack(track) ? 'playing' : '',
// ... more conditions
].filter(Boolean).join(' ');
// 2. Column values computed per-cell via accessor:
// col.accessor(track) called for each column on each row
// 3. Search highlighting applied per-cell
};
```
Optimization targets:
1. Replace array filter/join class construction with Lit's classMap directive
2. Pre-compute or cache column accessor results where possible
3. Avoid object/array allocations in the render hot path
</interfaces>
</context>
<tasks>
<task type="auto">
<name>Task 1: Replace class string construction with classMap directive in renderTrackRow</name>
<files>frontend/src/components/track-list/track-list.ts</files>
<action>
The current renderTrackRow builds CSS class strings by creating an array of conditional class names, filtering out falsy values, and joining with spaces — this allocates a new array and string on every render call for every visible row.
Replace with Lit's `classMap` directive which is purpose-built for conditional classes and avoids these allocations:
1. Add import: `import { classMap } from 'lit/directives/class-map.js';` (if not already imported)
2. In renderTrackRow, find every pattern like:
```typescript
const classes = ['base-class', condition ? 'class-a' : '', ...].filter(Boolean).join(' ');
// Used as: class="${classes}"
```
3. Replace with:
```typescript
// Used as: class=${classMap({ 'base-class': true, 'class-a': condition, ... })}
```
Read the full renderTrackRow method carefully — there may be multiple class string constructions (row-level and cell-level). Convert ALL of them.
The classMap object literal is still allocated per-call, but classMap internally compares with previous values and only updates changed classes — it's significantly faster than string concatenation for Lit's update cycle.
Also check `renderTrackItem` in queue-panel.ts for the same pattern — if it uses array filter/join for classes, apply the same classMap conversion there too. (Queue panel was listed in CONTEXT.md as having this pattern.)
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>All class string construction in renderTrackRow uses classMap directive instead of array filter/join. No .filter(Boolean).join(' ') patterns remain in track-list render methods. TypeScript compiles.</done>
</task>
<task type="auto">
<name>Task 2: Optimize column value computation and apply classMap to queue-panel renderTrackItem</name>
<files>frontend/src/components/track-list/track-list.ts, frontend/src/components/queue-panel/queue-panel.ts</files>
<action>
**Track-list column optimization (track-list.ts):**
Read the full renderTrackRow method to understand how column values are computed. The current pattern calls `col.accessor(track)` for each visible column on each row during render.
Optimization approach — evaluate what's actually expensive:
1. If `col.accessor` is a simple property lookup (e.g., `track.Title`, `track.Artist`), it's already fast — no caching needed
2. If any accessor does computation (string formatting, duration conversion, etc.), consider whether it can be memoized or moved outside the per-cell loop
3. If search highlighting is applied per-cell, check if the highlight computation can be short-circuited when there's no active search term (skip the regex/string manipulation entirely when term is empty)
Focus on the highest-impact optimizations:
- **Search highlight short-circuit**: When searchTerm is empty, skip all highlight logic entirely — just render the raw column value. This eliminates regex creation and string splitting for every cell in the common case.
- **Duration formatting**: If a time/duration column reformats on every render, cache the formatted string on the track object or in a WeakMap.
Do NOT over-optimize — if accessor is just `track.Title`, a cache would be slower than the direct access. Only optimize where measurement or code inspection shows actual waste.
**Queue-panel classMap (queue-panel.ts):**
Apply the same classMap directive conversion to renderTrackItem in queue-panel.ts:
1. Add import: `import { classMap } from 'lit/directives/class-map.js';`
2. Find the class string construction pattern (array filter/join) in renderTrackItem
3. Convert to classMap directive (same pattern as Task 1)
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>Track-list search highlighting is short-circuited when search term is empty. Queue-panel renderTrackItem uses classMap. No unnecessary per-row allocations in render hot paths. TypeScript compiles.</done>
</task>
</tasks>
<verification>
1. `cd frontend && npx tsc --noEmit` compiles without errors
2. No `.filter(Boolean).join(' ')` patterns in track-list.ts or queue-panel.ts render methods
3. classMap directive is used for all conditional CSS classes in render hot paths
4. Search highlighting short-circuits when search term is empty
5. No regressions — row selection, playing indicator, and search highlighting still work
</verification>
<success_criteria>
- renderTrackRow uses classMap for all conditional CSS classes
- renderTrackItem (queue) uses classMap for all conditional CSS classes
- Search highlighting skips computation when search term is empty
- No array allocations (filter/join) in render hot paths
- TypeScript compiles without errors
</success_criteria>
<output>
After completion, create `.planning/phases/08-frontend-performance-ux/08-03-SUMMARY.md`
</output>
@@ -0,0 +1,95 @@
---
phase: 08-frontend-performance-ux
plan: 03
subsystem: frontend
tags: [lit, classMap, performance, render-optimization, directives]
# Dependency graph
requires:
- phase: 08-frontend-performance-ux
provides: "repeat() directive migration on all virtualizer instances"
provides:
- "classMap directive for conditional CSS classes in track-list renderTrackRow and queue-panel renderTrackItem"
- "Search highlight short-circuit when search term is empty"
- "Hoisted search term lookup outside per-column iteration loop"
affects: [08-frontend-performance-ux]
# Tech tracking
tech-stack:
added: []
patterns: ["classMap directive for conditional CSS classes in render hot paths"]
key-files:
created: []
modified:
- frontend/src/components/track-list/track-list.ts
- frontend/src/components/queue-panel/queue-panel.ts
key-decisions:
- "classMap object literal per-call is acceptable — classMap internally diffs and only updates changed classes"
- "Hoisted searchCtrl.term outside cols.map to avoid repeated property access per column"
patterns-established:
- "Render hot path pattern: use classMap directive instead of array filter/join for conditional CSS classes"
requirements-completed: [PERF-05, UX-02]
# Metrics
duration: 2min
completed: 2026-03-05
---
# Phase 8 Plan 03: renderTrackRow Optimization Summary
**Replaced array filter/join class construction with classMap directive in track-list and queue-panel render hot paths, eliminating per-row array allocations during scrolling**
## Performance
- **Duration:** 2 min
- **Started:** 2026-03-05T04:19:55Z
- **Completed:** 2026-03-05T04:22:19Z
- **Tasks:** 2
- **Files modified:** 2
## Accomplishments
- All conditional CSS class construction in renderTrackRow (track-row, fav-icon, cell) converted from array filter/join to classMap directive
- Queue-panel renderTrackItem class construction (track-item, active, selected, drop-before, drop-after) converted to classMap
- Search term property lookup hoisted outside per-column loop to avoid repeated access
- Search highlighting already short-circuits when term is empty — no additional optimization needed
## Task Commits
Each task was committed atomically:
1. **Task 1: Replace class string construction with classMap directive in renderTrackRow** - `ad21027` (perf)
2. **Task 2: Optimize column value computation and apply classMap to queue-panel renderTrackItem** - `62f41c2` (perf)
## Files Created/Modified
- `frontend/src/components/track-list/track-list.ts` - classMap for track-row, fav-icon, and cell classes; hoisted search term lookup
- `frontend/src/components/queue-panel/queue-panel.ts` - classMap for track-item with active, selected, drop-before, drop-after states
## Decisions Made
- classMap object literal allocation per-call is acceptable since classMap internally diffs previous values and only applies DOM changes for actually changed classes — net benefit over string concatenation in Lit's update cycle
- Hoisted searchCtrl.term outside the cols.map loop — avoids redundant property access per column per row
## Deviations from Plan
None - plan executed exactly as written.
## Issues Encountered
None
## User Setup Required
None - no external service configuration required.
## Next Phase Readiness
- All render hot path optimizations complete for track-list and queue-panel
- Ready for Plan 04 (final phase 8 plan)
## Self-Check: PASSED
All key files exist on disk. All task commits verified in git history.
---
*Phase: 08-frontend-performance-ux*
*Completed: 2026-03-05*
@@ -0,0 +1,267 @@
---
phase: 08-frontend-performance-ux
plan: 04
type: execute
wave: 2
depends_on:
- "08-01"
files_modified:
- frontend/src/components/sidebar/app-sidebar.ts
- frontend/src/components/now-playing/now-playing.ts
- frontend/src/components/search-bar/search-bar.ts
- frontend/src/components/audio-player/controls/player-controls.ts
- frontend/src/components/audio-player/seekbar/seek-bar.ts
- frontend/src/components/audio-player/volume-control/volume-control.ts
- frontend/src/components/audio-player/audio-player.ts
- frontend/src/components/cover-grid/cover-grid.ts
- frontend/src/components/cover-grid/cover-grid-styles.ts
- frontend/src/components/track-list/track-list.ts
- frontend/src/components/queue-panel/queue-panel.ts
- frontend/src/components/track-details/track-details.ts
- frontend/src/components/track-info/track-info.ts
- frontend/src/components/artist-details/artist-details.ts
- frontend/src/components/genre-details/genre-details.ts
autonomous: false
requirements:
- UX-01
must_haves:
truths:
- "All components use px-based spacing (no em-based padding/gap/margin in sidebar or anywhere)"
- "Icon sizes reference --yj-icon-sm/md/lg tokens instead of ad-hoc pixel or em values"
- "Typography references --yj-text-xs/sm/md/lg/xl tokens instead of ad-hoc font-size values"
- "Cover-grid dynamic text sizing tiers map to the type scale tokens"
- "Visual consistency is verified by human inspection across all views"
artifacts:
- path: "frontend/src/components/sidebar/app-sidebar.ts"
provides: "px-based spacing, icon tokens"
contains: "--yj-icon-"
- path: "frontend/src/components/now-playing/now-playing.ts"
provides: "Icon tokens for cover placeholder"
contains: "--yj-icon-lg"
- path: "frontend/src/components/search-bar/search-bar.ts"
provides: "Icon and type scale tokens"
contains: "--yj-icon-sm"
- path: "frontend/src/components/cover-grid/cover-grid.ts"
provides: "Dynamic text sizing mapped to type scale tokens"
contains: "--yj-text-"
key_links:
- from: "all components"
to: "frontend/src/styles/tokens.css.ts"
via: "import { designTokens } and include in static styles"
pattern: "designTokens"
---
<objective>
Systematically audit and fix visual inconsistencies across all components — convert em-based spacing to px, apply icon size tokens, apply type scale tokens, and ensure coherent visual language.
Purpose: The codebase has evolved with ad-hoc values (0.9em icons in sidebar, 24px in now-playing, 14px in search-bar, 11-16px dynamic text in cover-grid). This pass replaces them with the design tokens defined in Plan 01, creating a single source of truth for sizing.
Output: All components use consistent design tokens. Human-verified visual quality.
</objective>
<execution_context>
@/home/caleb/.config/opencode/get-shit-done/workflows/execute-plan.md
@/home/caleb/.config/opencode/get-shit-done/templates/summary.md
</execution_context>
<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/08-frontend-performance-ux/08-CONTEXT.md
@.planning/phases/08-frontend-performance-ux/08-01-SUMMARY.md
@frontend/src/styles/tokens.css.ts
@frontend/src/components/sidebar/app-sidebar.ts
@frontend/src/components/now-playing/now-playing.ts
@frontend/src/components/search-bar/search-bar.ts
@frontend/src/components/cover-grid/cover-grid.ts
@frontend/src/components/cover-grid/cover-grid-styles.ts
<interfaces>
<!-- Design tokens from Plan 01 -->
From frontend/src/styles/tokens.css.ts:
```typescript
export const designTokens = css`
:host {
--yj-icon-sm: 14px;
--yj-icon-md: 18px;
--yj-icon-lg: 24px;
--yj-text-xs: 11px;
--yj-text-sm: 12px;
--yj-text-md: 13px;
--yj-text-lg: 15px;
--yj-text-xl: 18px;
}
`;
```
How to use in a component:
```typescript
import { designTokens } from '../../styles/tokens.css';
@customElement('my-component')
export class MyComponent extends LitElement {
static styles = [designTokens, css`
.icon { font-size: var(--yj-icon-md); }
.label { font-size: var(--yj-text-sm); }
`];
}
```
Known inconsistencies to fix:
- app-sidebar.ts: em-based spacing (padding: 1em, gap: 0.6em, padding: 0.5em), icon 0.9em/1.1em, border-radius: 5px
- now-playing.ts: cover placeholder icon font-size: 24px → --yj-icon-lg
- search-bar.ts: search icon font-size: 14px → --yj-icon-sm, input font-size: 13px → --yj-text-md
- cover-grid.ts: dynamic text sizing tiers (11px/10px, 14px/12px, 16px/13px) in updateSizeProperties()
- Various components: ad-hoc font-size values that should map to type scale
</interfaces>
</context>
<tasks>
<task type="auto">
<name>Task 1: Convert sidebar em-based spacing to px and apply icon/type tokens to sidebar, now-playing, search-bar, and audio-player components</name>
<files>frontend/src/components/sidebar/app-sidebar.ts, frontend/src/components/now-playing/now-playing.ts, frontend/src/components/search-bar/search-bar.ts, frontend/src/components/audio-player/controls/player-controls.ts, frontend/src/components/audio-player/seekbar/seek-bar.ts, frontend/src/components/audio-player/volume-control/volume-control.ts, frontend/src/components/audio-player/audio-player.ts</files>
<action>
For EACH component listed, read the file first, then:
1. Import designTokens: `import { designTokens } from '../../styles/tokens.css';` (adjust relative path based on file location)
2. Add designTokens to the component's `static styles` array (prepend it so tokens are available to component styles)
3. Apply the following conversions:
**app-sidebar.ts:**
- Convert ALL em-based values to px equivalents:
- `padding: 1em` → `padding: 16px`
- `gap: 0.6em` → `gap: 10px`
- `padding: 0.5em` → `padding: 8px`
- Any other em values → compute px (base is ~16px for desktop)
- Icon font-size `0.9em` → `var(--yj-icon-md)` (was ~14px, md=18px is closer to sidebar intent)
- Icon font-size `1.1em` (collapsed mode) → `var(--yj-icon-md)` (same token, consistent)
- Audit ALL font-size values and replace with appropriate --yj-text-* tokens
- `border-radius: 5px` → keep as-is (border-radius doesn't need tokenizing)
**now-playing.ts:**
- Cover placeholder icon `font-size: 24px` → `font-size: var(--yj-icon-lg)`
- Audit all font-size values → replace with --yj-text-* tokens
**search-bar.ts:**
- Search icon `font-size: 14px` → `font-size: var(--yj-icon-sm)`
- Input `font-size: 13px` → `font-size: var(--yj-text-md)`
- Audit all other font-size values
**audio-player components (player-controls.ts, seek-bar.ts, volume-control.ts, audio-player.ts):**
- Read each file, audit for ad-hoc font-size and icon-size values
- Replace with appropriate --yj-text-* and --yj-icon-* tokens
- Convert any em-based spacing to px if found
**General rules:**
- When mapping existing px values to tokens, pick the NEAREST token value. If 12px → --yj-text-sm (12px). If 13px → --yj-text-md (13px). If 14px and it's text → --yj-text-sm or --yj-text-md based on context. If 14px and it's an icon → --yj-icon-sm (14px).
- Do NOT change values that are layout-specific (width, height, margins for positioning). Only convert font-size, icon font-size, and em-based spacing.
- Do NOT change color values — those already use --yj- tokens.
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>Sidebar uses px-based spacing throughout. All icon sizes in sidebar, now-playing, search-bar, and audio-player use --yj-icon-* tokens. All text sizes in these components use --yj-text-* tokens. No em-based spacing remains. TypeScript compiles.</done>
</task>
<task type="auto">
<name>Task 2: Apply design tokens to cover-grid dynamic text sizing, track-list, queue-panel, and remaining detail/info components</name>
<files>frontend/src/components/cover-grid/cover-grid.ts, frontend/src/components/cover-grid/cover-grid-styles.ts, frontend/src/components/track-list/track-list.ts, frontend/src/components/queue-panel/queue-panel.ts, frontend/src/components/track-details/track-details.ts, frontend/src/components/track-info/track-info.ts, frontend/src/components/artist-details/artist-details.ts, frontend/src/components/genre-details/genre-details.ts</files>
<action>
For EACH component, read the file, import designTokens, add to static styles, then audit and fix:
**cover-grid.ts — Dynamic text sizing:**
The updateSizeProperties() method has hardcoded px values for text sizing tiers based on card size:
- Small cards: 11px/10px → map to `--yj-text-xs` (11px) / computed smaller
- Medium cards: 14px/12px → map to `--yj-text-lg` (15px) / `--yj-text-sm` (12px) — or adjust
- Large cards: 16px/13px → map to values near `--yj-text-lg`/`--yj-text-md`
For the dynamic sizing tiers, the approach depends on how they're applied:
- If set as inline styles or CSS custom properties on the element, replace hardcoded values with references to the tokens: `var(--yj-text-xs)`, `var(--yj-text-sm)`, etc.
- If set programmatically in JS (this.style.setProperty), use the token values directly or set CSS custom properties that reference the tokens
- The goal is that card text sizes use the SAME scale as everything else, not independent magic numbers
Read the updateSizeProperties() method carefully to understand the tier logic before modifying.
**cover-grid-styles.ts:**
- Audit for ad-hoc font-size values, replace with --yj-text-* tokens
**track-list.ts:**
- Import designTokens (if not already from Plan 03)
- Audit ALL font-size values in styles — header, cells, sort labels, etc.
- Replace with --yj-text-* tokens
- Audit icon sizes (favorites icon was noted as 12px) → --yj-icon-sm
**queue-panel.ts:**
- Import designTokens (if not already from Plan 03)
- Audit font-size values → --yj-text-* tokens
- Audit icon sizes → --yj-icon-* tokens
**track-details.ts, track-info.ts, artist-details.ts, genre-details.ts:**
- Read each file, audit for font-size and icon-size values
- Import designTokens, add to static styles
- Replace ad-hoc values with tokens
**Same rules as Task 1:** Only convert font-size, icon sizes, em-based spacing. Don't change layout dimensions or colors.
</action>
<verify>
<automated>cd frontend && npx tsc --noEmit 2>&1 | head -30</automated>
</verify>
<done>Cover-grid dynamic text tiers use type scale tokens. Track-list, queue-panel, and detail components use design tokens for all font-size and icon-size values. No meaningful ad-hoc font-size values remain across audited components. TypeScript compiles.</done>
</task>
<task type="checkpoint:human-verify" gate="blocking">
<name>Task 3: Visual consistency verification</name>
<files>n/a</files>
<action>
Human verifies visual consistency after Tasks 1-2.
What was built:
- Sidebar: px-based spacing, icon tokens, type tokens
- Now-playing: icon tokens, type tokens
- Search bar: icon and type tokens
- Audio player: icon and type tokens
- Cover grid: dynamic text sizing mapped to type scale
- Track list: type and icon tokens
- Queue panel: type and icon tokens
- Detail/info views: type and icon tokens
How to verify — run the app and check each view:
1. Sidebar — Icons are consistent size, text is readable, spacing looks balanced (no too-tight or too-loose areas from em→px conversion)
2. Track list — Column headers, cell text, and sort indicators look consistent. Favorites icon is appropriately sized.
3. Cover grid — Album names scale with card size using the type scale tiers. Small, medium, and large cards all have readable text.
4. Queue panel — Track names, durations, and icons are consistently sized
5. Now playing — Cover placeholder icon is appropriately sized, track info text is consistent
6. Search bar — Search icon and input text are balanced
7. Audio player — Play/pause/skip icons, seek bar labels, volume icon are consistent
8. Detail views — Artist details, genre details, track details/info all use consistent typography
9. Overall — No view has text that looks noticeably different in size from the same-purpose text in another view
</action>
<verify>Human visual inspection — type "approved" or describe specific visual issues to fix</verify>
<done>All views pass visual consistency check — no em-based spacing, icon sizes are consistent, typography follows the type scale, and no jarring size mismatches between views.</done>
</task>
</tasks>
<verification>
1. `cd frontend && npx tsc --noEmit` compiles without errors
2. `grep -r "0\.\d*em" frontend/src/components/sidebar/` returns no em-based spacing
3. `grep -rn "font-size:" frontend/src/components/ | grep -v "var(--yj-"` shows minimal remaining ad-hoc values (only layout-specific sizes)
4. All components that have styles import designTokens
5. Human verification confirms visual consistency
</verification>
<success_criteria>
- Zero em-based spacing values in sidebar
- All icon sizes use --yj-icon-sm/md/lg tokens
- All text sizes use --yj-text-xs/sm/md/lg/xl tokens (with minimal justified exceptions)
- Cover-grid dynamic text tiers map to the type scale
- Human approves visual consistency across all views
- TypeScript compiles without errors
</success_criteria>
<output>
After completion, create `.planning/phases/08-frontend-performance-ux/08-04-SUMMARY.md`
</output>
@@ -0,0 +1,146 @@
---
phase: 08-frontend-performance-ux
plan: 04
subsystem: frontend
tags: [lit, design-tokens, css-custom-properties, px-spacing, icon-tokens, type-scale, visual-consistency]
# Dependency graph
requires:
- phase: 08-frontend-performance-ux
provides: "Design token CSS custom properties (tokens.css.ts) from Plan 01"
provides:
- "All 15 components use design token CSS custom properties for icon sizing and type scale"
- "Sidebar fully converted from em-based to px-based spacing"
- "Cover-grid dynamic text sizing tiers mapped to type scale tokens"
- "Consistent visual language across all views"
affects: []
# Tech tracking
tech-stack:
added: []
patterns: ["designTokens import + static styles array pattern applied across all components"]
key-files:
created: []
modified:
- frontend/src/components/sidebar/app-sidebar.ts
- frontend/src/components/now-playing/now-playing.ts
- frontend/src/components/search-bar/search-bar.ts
- frontend/src/components/audio-player/controls/player-controls.ts
- frontend/src/components/audio-player/seekbar/seek-bar.ts
- frontend/src/components/audio-player/volume-control/volume-control.ts
- frontend/src/components/audio-player/audio-player.ts
- frontend/src/components/cover-grid/cover-grid.ts
- frontend/src/components/cover-grid/cover-grid-styles.ts
- frontend/src/components/track-list/track-list.ts
- frontend/src/components/queue-panel/queue-panel.ts
- frontend/src/components/track-details/track-details.ts
- frontend/src/components/track-info/track-info.ts
- frontend/src/components/artist-details/artist-details.ts
- frontend/src/components/genre-details/genre-details.ts
key-decisions:
- "em→px conversion uses 16px base (standard browser default) for sidebar spacing"
- "Icon tokens: --yj-icon-sm (14px) for small indicators, --yj-icon-md (18px) for sidebar/player controls, --yj-icon-lg (24px) for cover placeholders"
- "Cover-grid dynamic text tiers mapped to --yj-text-xs/sm/md/lg tokens via updateSizeProperties()"
patterns-established:
- "Design token adoption pattern: import designTokens, prepend to static styles array, replace ad-hoc px/em values with var(--yj-*) references"
- "All font-size and icon font-size values use --yj-text-* and --yj-icon-* tokens respectively"
requirements-completed: [UX-01]
# Metrics
duration: 8min
completed: 2026-03-05
---
# Phase 8 Plan 04: Visual Consistency Audit & Token Application Summary
**Systematic em→px conversion and design token application across 15 components — sidebar spacing, icon sizing via --yj-icon-* tokens, and typography via --yj-text-* tokens for coherent visual language**
## Performance
- **Duration:** ~8 min (across sessions with checkpoint)
- **Started:** 2026-03-05T04:30:00Z
- **Completed:** 2026-03-05T14:13:19Z
- **Tasks:** 3 (2 auto + 1 human-verify checkpoint)
- **Files modified:** 15
## Accomplishments
- Sidebar fully converted from em-based spacing (padding: 1em, gap: 0.6em) to px-based values — eliminates compound inheritance issues
- All icon sizes across 15 components now use --yj-icon-sm/md/lg tokens instead of ad-hoc pixel or em values
- All text sizes use --yj-text-xs/sm/md/lg/xl tokens instead of hardcoded font-size values
- Cover-grid dynamic text sizing tiers in updateSizeProperties() mapped to type scale tokens
- Human-verified visual consistency across all views — sidebar, track list, cover grid, queue panel, now playing, search bar, audio player, and detail views
## Task Commits
Each task was committed atomically:
1. **Task 1: Convert sidebar em→px and apply icon/type tokens to sidebar, now-playing, search-bar, audio-player** - `aed90d7` (feat)
2. **Task 2: Apply design tokens to cover-grid, track-list, queue-panel, and detail components** - `1303422` (feat)
3. **Task 3: Visual consistency verification** - checkpoint:human-verify (approved, no commit)
**Hotfix during phase:** `72ef719` (fix) — revert repeat() inside lit-virtualizer, restore .renderItem + .keyFunction
## Files Created/Modified
- `frontend/src/components/sidebar/app-sidebar.ts` - em→px spacing conversion, --yj-icon-md for nav icons, --yj-text-* for labels
- `frontend/src/components/now-playing/now-playing.ts` - --yj-icon-lg for cover placeholder, --yj-text-* for track info
- `frontend/src/components/search-bar/search-bar.ts` - --yj-icon-sm for search icon, --yj-text-md for input
- `frontend/src/components/audio-player/audio-player.ts` - designTokens import, type tokens
- `frontend/src/components/audio-player/controls/player-controls.ts` - --yj-icon-* for transport controls
- `frontend/src/components/audio-player/seekbar/seek-bar.ts` - --yj-text-* for time labels
- `frontend/src/components/audio-player/volume-control/volume-control.ts` - --yj-icon-* for volume icon
- `frontend/src/components/cover-grid/cover-grid.ts` - Dynamic text tiers mapped to --yj-text-xs/sm/md/lg
- `frontend/src/components/cover-grid/cover-grid-styles.ts` - Type token adoption in base styles
- `frontend/src/components/track-list/track-list.ts` - --yj-text-* for headers/cells, --yj-icon-sm for favorites
- `frontend/src/components/queue-panel/queue-panel.ts` - --yj-text-* and --yj-icon-* tokens
- `frontend/src/components/track-details/track-details.ts` - Type and icon tokens for detail layout
- `frontend/src/components/track-info/track-info.ts` - Type tokens for track metadata display
- `frontend/src/components/artist-details/artist-details.ts` - Type and icon tokens
- `frontend/src/components/genre-details/genre-details.ts` - Type and icon tokens
## Decisions Made
- **em→px conversion uses 16px base:** Standard browser default font size — 1em ≈ 16px, 0.5em ≈ 8px, 0.6em ≈ 10px. This eliminates compound inheritance issues where nested em values compound unexpectedly.
- **Icon token mapping:** --yj-icon-sm (14px) for small indicators like favorites star and search icon, --yj-icon-md (18px) for sidebar navigation and player controls, --yj-icon-lg (24px) for cover art placeholders.
- **Cover-grid dynamic tiers use tokens:** updateSizeProperties() maps card-size tiers to token values (small → --yj-text-xs, medium → --yj-text-sm, large → --yj-text-md/lg) instead of hardcoded pixel values.
## Deviations from Plan
None for the plan's own tasks — plan 04 executed exactly as written.
### Critical Hotfix (Plan 08-02 regression)
**[Rule 1 - Bug] repeat() directive inside lit-virtualizer defeated virtualization**
- **Found during:** Phase 8 execution (between plans 03 and 04)
- **Issue:** Plan 08-02 migrated all 7 lit-virtualizer instances to use repeat() as child content. However, repeat() renders ALL items as DOM children, bypassing lit-virtualizer's viewport-based rendering. This caused 2+ minute loading times and UI freezing with large libraries.
- **Root cause:** lit-virtualizer's .renderItem and .keyFunction properties integrate with its scroll-based viewport management. When content is provided as children (via repeat()), the virtualizer loses control of which items are rendered.
- **Fix:** Reverted all 7 virtualizer instances to use .renderItem + .keyFunction properties (the proper lit-virtualizer API). Removed repeat() from all virtualizer elements.
- **Files modified:** frontend/src/components/track-list/track-list.ts, frontend/src/components/queue-panel/queue-panel.ts, frontend/src/components/cover-grid/cover-grid.ts, frontend/src/components/artists-view/artists-view.ts, frontend/src/components/genres-view/genres-view.ts
- **Verification:** App loads instantly with large library, virtualization confirmed working (only visible items rendered)
- **Committed in:** `72ef719`
---
**Total deviations:** 1 hotfix (critical bug from prior plan)
**Impact on plan:** Hotfix was prerequisite for meaningful visual testing — without it, the app was unusable with real data.
## Issues Encountered
- The repeat() virtualizer regression from Plan 08-02 caused 2-minute load times with large libraries. This was a fundamental API misuse — lit-virtualizer requires .renderItem/.keyFunction for virtualization, not repeat() child content. Fixed before Plan 04 visual verification could proceed.
## User Setup Required
None - no external service configuration required.
## Next Phase Readiness
- Phase 8 complete — all 4 plans executed
- All 26 consolidation milestone requirements delivered
- Ready for milestone completion
## Self-Check: PASSED
All 15 key files verified on disk. All 3 task/hotfix commits (aed90d7, 1303422, 72ef719) verified in git history.
---
*Phase: 08-frontend-performance-ux*
*Completed: 2026-03-05*
@@ -0,0 +1,89 @@
# Phase 8: Frontend Performance & UX - Context
**Gathered:** 2026-03-04
**Status:** Ready for planning
<domain>
## Phase Boundary
Make the app feel smooth and visually consistent — large libraries (10k+ tracks) render without jank during scrolling, view switching, and search filtering, and the UI follows a coherent visual language across all components. This is the final phase of the consolidation milestone.
Performance work targets: Lit `repeat()` directive with stable keys for DOM reuse, `queueMicrotask()` debouncing for store notifications during rapid updates. Visual work targets: audit and fix spacing, colors, typography, and icon sizing inconsistencies.
</domain>
<decisions>
## Implementation Decisions
### Visual consistency scope
- Full audit of every component — check for hardcoded colors, inconsistent spacing, mismatched typography, and icon sizing
- Systematic pass, not just known issues
### Spacing units
- Converge all components to px-based spacing (not em/rem)
- The sidebar currently uses em-based spacing (padding: 0.5em, gap: 0.6em) — convert to px
- Track-list and cover-grid already use px — these are the reference pattern
### Icon sizing
- Define a CSS custom properties scale: --yj-icon-sm, --yj-icon-md, --yj-icon-lg (and apply consistently)
- Replace ad-hoc values (0.9em in sidebar, 12px in track-list favorites, 24px in now-playing) with scale tokens
### Typography
- Define a type scale via CSS custom properties (--yj-text-xs through --yj-text-lg)
- Apply everywhere — eliminate meaningless variations (e.g., 12px vs 13px in sort labels should pick one)
- Album name scaling with card size (11-16px tiers in cover-grid) should map to the type scale tokens
### Store notification debouncing
- Apply queueMicrotask() debouncing to library store only — it's the only store with rapid-fire updates (scan events)
- Queue, player, playlist stores stay with immediate synchronous notifications (user-driven, not rapid)
- Coalesce ALL library store notifications (data fetches, cover size changes, scroll position) through one debounced notify()
- Transparent to subscribers — same subscribe() API, debouncing is an internal optimization
- No partial progress during scan — one coalesced update after all data loads is acceptable
### Large library rendering
- Reference identity check is sufficient for detecting data changes (lastTracksRef !== cached pattern already exists)
- No deep equality checking
- Debounce search input ~150ms before triggering filter/rank computation on large datasets
- Aim for instant view switches — no loading skeletons needed (virtualizer only renders visible items, data is pre-cached via eagerFetch)
- Full optimization pass on per-row rendering: repeat() keys + reduce per-row allocations (cache class strings, pre-compute column values, minimize template computation in renderTrackRow)
### Rendering strategy
- Switch from .items/.renderItem pattern to repeat(items, keyFn, renderFn) directive in all virtualizer-based components
- Stable key strategy:
- track-list: FilePath (unique per track)
- cover-grid: album.ID (already has gridKeyFunction — convert to repeat())
- queue-panel: QueueTrack.id (unique per queue entry, handles duplicate tracks)
- playlist-view: uses track-list component (inherits FilePath key)
- Apply to ALL lit-virtualizer components, not just library views
### Claude's Discretion
- Exact px values for the icon scale (--yj-icon-sm: 14px? 16px? Claude decides)
- Exact px values for the type scale (--yj-text-xs through --yj-text-lg ranges)
- Which specific visual inconsistencies to fix during the audit — Claude identifies them
- Whether to extract CSS custom property definitions into a shared file or keep them in :root
- Search debounce exact timing (guideline: ~150ms, but Claude can adjust based on feel)
- How to handle cover-grid's dynamic text sizing tiers (size-small class, cardTextHeight) within the type scale
</decisions>
<specifics>
## Specific Ideas
- The cover-grid already has a gridKeyFunction using `a-${entry.album.ID}` — this should be migrated to the repeat() directive pattern rather than the .keyFunction property
- QueueTrack has an `id` field that uniquely identifies each queue entry even when the same track appears multiple times — use this as the queue repeat() key
- The library store's notify() currently does `this.subscribers.forEach((callback) => callback())` — the queueMicrotask wrapper should coalesce multiple notify() calls within the same microtask tick into a single subscriber notification round
- Track-list's renderTrackRow does class string concatenation and column mapping on every render call — the full optimization pass should address this
</specifics>
<deferred>
## Deferred Ideas
None — discussion stayed within phase scope
</deferred>
---
*Phase: 08-frontend-performance-ux*
*Context gathered: 2026-03-04*
@@ -0,0 +1,157 @@
---
phase: 08-frontend-performance-ux
verified: 2026-03-05T15:30:00Z
status: passed
score: 8/8 must-haves verified
human_verification:
- test: "Scroll through a 10k+ track library — verify smooth scrolling with no jank or dropped frames"
expected: "Track list, cover grid, queue panel all scroll smoothly without visible stuttering"
why_human: "Jank/dropped frames are perceptual — cannot be measured via static code analysis"
- test: "Switch between views (tracks, albums, artists, genres) rapidly — verify instant transitions"
expected: "View switches are instant with no loading delay (data is pre-cached via eagerFetch)"
why_human: "Transition smoothness is a runtime behavior requiring visual confirmation"
- test: "Type rapidly in search bar — verify no input lag and results appear after ~150ms pause"
expected: "Characters appear instantly, filtered results update after typing stops for ~150ms, clearing input instantly clears results"
why_human: "Debounce feel is perceptual timing that requires human interaction"
- test: "Visual consistency across all views — verify coherent sizing and spacing"
expected: "Icons are consistent size per context (sm/md/lg), typography follows scale, sidebar spacing is balanced, no jarring mismatches between views"
why_human: "Visual design coherence requires human aesthetic judgment"
---
# Phase 8: Frontend Performance & UX Verification Report
**Phase Goal:** The app feels smooth and visually consistent — large libraries render without jank, and the UI follows a coherent visual language
**Verified:** 2026-03-05T15:30:00Z
**Status:** human_needed
**Re-verification:** No — initial verification
## Goal Achievement
### Observable Truths
The phase's success criteria from ROADMAP.md are:
1. Track and album lists use Lit `repeat()` directive with stable keys for efficient DOM reuse during scrolling and filtering
2. Store notifications during rapid updates are debounced via `queueMicrotask()` to prevent layout thrashing
3. Visual inconsistencies are audited and follow a consistent pattern across all components
4. Scrolling, view switching, and search filtering in a 10k+ track library are smooth with no visible jank
**Important context:** Success criterion #1 was modified by hotfix `72ef719`. The original Plan 08-02 used `repeat()` as children of `lit-virtualizer`, which **defeated virtualization** (rendered ALL items, causing 2+ minute load times). The hotfix reverted to `.renderItem` + `.keyFunction` — the correct lit-virtualizer API that integrates with its viewport-based rendering. All virtualizers now have stable key functions via `.keyFunction`, achieving the **intent** of the criterion (efficient DOM reuse with stable keys) through the correct API.
| # | Truth | Status | Evidence |
|---|-------|--------|----------|
| 1 | Virtualizers use stable keys for efficient DOM reuse | ✓ VERIFIED | All 7 virtualizers use `.renderItem` + `.keyFunction` with stable entity keys (FilePath, album.ID, QueueTrack.id, artist.ID, genre.name). Hotfix `72ef719` corrected the approach from `repeat()` children (which broke virtualization) to the proper `.keyFunction` API. |
| 2 | Store notifications debounced via queueMicrotask | ✓ VERIFIED | `library-store.ts` lines 343-350: `notifyScheduled` flag + `queueMicrotask()` coalescing. Multiple `notify()` calls within a microtask tick produce 1 subscriber notification. |
| 3 | Search input debounced ~150ms | ✓ VERIFIED | `search-bar.ts` lines 108-126: 150ms setTimeout with instant clear on empty input. |
| 4 | Design tokens defined for icon sizes and type scale | ✓ VERIFIED | `tokens.css.ts` exports `designTokens` with `--yj-icon-sm/md/lg` (14/18/24px) and `--yj-text-xs/sm/md/lg/xl` (11/12/13/15/18px). |
| 5 | All components use design tokens (no em-based spacing, ad-hoc icon/text sizes) | ✓ VERIFIED | 14 components import `designTokens` into `static styles`. Sidebar has zero em-based spacing. Icon sizes use `--yj-icon-*`. Text sizes use `--yj-text-*`. |
| 6 | Render hot path optimized (classMap, no array allocations) | ✓ VERIFIED | `track-list.ts` uses `classMap` at 3 sites (track-row, fav-icon, cell). `queue-panel.ts` uses `classMap` for track-item. Zero `.filter(Boolean).join(' ')` patterns remain. Search term hoisted outside column loop. |
| 7 | Cover-grid dynamic text sizing uses type scale tokens | ✓ VERIFIED | `cover-grid.ts` lines 757-788: Three tiers map to `--yj-text-xs`, `--yj-text-lg`/`--yj-text-sm`, `--yj-text-lg`/`--yj-text-md`. |
| 8 | Scrolling/view switching/search filtering smooth with no jank | ? UNCERTAIN | Requires human testing with a 10k+ track library to verify runtime performance. |
**Score:** 7/8 truths verified (1 needs human)
### Required Artifacts
| Artifact | Expected | Status | Details |
|----------|----------|--------|---------|
| `frontend/src/store/library-store.ts` | queueMicrotask coalescing | ✓ VERIFIED | `notifyScheduled` flag + `queueMicrotask()` in `notify()`. 404 lines, substantive. |
| `frontend/src/styles/tokens.css.ts` | Design token definitions | ✓ VERIFIED | Exports `designTokens` css template with 8 custom properties. 25 lines, complete. |
| `frontend/src/components/search-bar/search-bar.ts` | Debounced search input | ✓ VERIFIED | 150ms debounce timer, instant clear, `designTokens` imported. 180 lines. |
| `frontend/src/components/track-list/track-list.ts` | repeat()/keyFunction + classMap + tokens | ✓ VERIFIED | `.renderItem` + `.keyFunction` (FilePath), `classMap` at 3 sites, `designTokens` imported. |
| `frontend/src/components/queue-panel/queue-panel.ts` | keyFunction + classMap + tokens | ✓ VERIFIED | `.renderItem` + `.keyFunction` (QueueTrack.id), `classMap` for track-item, `designTokens` imported. |
| `frontend/src/components/cover-grid/cover-grid.ts` | 3 keyFunctions + dynamic text tokens | ✓ VERIFIED | 3 virtualizers with `.keyFunction` (album.ID), dynamic text tiers mapped to tokens. |
| `frontend/src/components/artists-view/artists-view.ts` | keyFunction for artist virtualizer | ✓ VERIFIED | `.renderItem` + `.keyFunction` (artist.ID). |
| `frontend/src/components/genres-view/genres-view.ts` | keyFunction for genre virtualizer | ✓ VERIFIED | `.renderItem` + `.keyFunction` (genre.name). |
| `frontend/src/components/sidebar/app-sidebar.ts` | px-based spacing, icon tokens | ✓ VERIFIED | Zero em-based spacing. `--yj-icon-md` for nav icons. `designTokens` imported. |
| `frontend/src/components/now-playing/now-playing.ts` | Icon tokens | ✓ VERIFIED | `--yj-icon-lg` for cover placeholder. `designTokens` imported. |
| `frontend/src/components/audio-player/controls/player-controls.ts` | Icon/type tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/audio-player/seekbar/seek-bar.ts` | Type tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/audio-player/volume-control/volume-control.ts` | Icon tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/audio-player/audio-player.ts` | Tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/cover-grid/cover-grid-styles.ts` | Type tokens in base styles | ✓ VERIFIED | `designTokens` imported, `--yj-text-sm/md` used. |
| `frontend/src/components/track-details/track-details.ts` | Type/icon tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/track-info/track-info.ts` | Type tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/artist-details/artist-details.ts` | Type/icon tokens | ✓ VERIFIED | `designTokens` imported. |
| `frontend/src/components/genre-details/genre-details.ts` | Type/icon tokens | ✓ VERIFIED | `designTokens` imported. |
### Key Link Verification
| From | To | Via | Status | Details |
|------|----|-----|--------|---------|
| library-store.ts | subscribers | queueMicrotask in notify() | ✓ WIRED | Lines 343-350: `queueMicrotask(() => { this.notifyScheduled = false; this.subscribers.forEach(...) })` |
| tokens.css.ts | 14 components | `import { designTokens }` + `static styles = [designTokens, ...]` | ✓ WIRED | 28 import/usage sites across sidebar, now-playing, search-bar, audio-player (4), cover-grid (2), track-list, queue-panel, track-details, track-info, artist-details, genre-details |
| search-bar.ts | search store | 150ms setTimeout debounce | ✓ WIRED | Lines 121-124: `this.searchDebounceTimer = setTimeout(() => { this.searchCtrl.term = value; }, 150)` |
| track-list.ts | lit-virtualizer | .renderItem + .keyFunction | ✓ WIRED | Line 1740-1741: `.renderItem=${this.renderTrackRow}` + `.keyFunction=${(track) => track.FilePath}` |
| cover-grid.ts | lit-virtualizer (×3) | .renderItem + .keyFunction | ✓ WIRED | Lines 1850-1851, 1877-1878, 1906-1907: All use `.renderItem` + `.keyFunction` with `entry.album.ID` |
| queue-panel.ts | lit-virtualizer | .renderItem + .keyFunction | ✓ WIRED | Lines 1283-1284: `.renderItem=${this.renderTrackItem}` + `.keyFunction=${(track) => track.id}` |
| artists-view.ts | lit-virtualizer | .renderItem + .keyFunction | ✓ WIRED | Lines 1219-1220: `.renderItem` + `.keyFunction=${(entry) => entry.artist.ID}` |
| genres-view.ts | lit-virtualizer | .renderItem + .keyFunction | ✓ WIRED | Lines 1171-1172: `.renderItem` + `.keyFunction=${(entry) => entry.genre.name}` |
| track-list.ts renderTrackRow | classMap directive | import + 3 usage sites | ✓ WIRED | Line 29 import, lines 1542, 1559, 1585 usage |
| queue-panel.ts renderTrackItem | classMap directive | import + 1 usage site | ✓ WIRED | Line 19 import, line 1156 usage |
### Requirements Coverage
| Requirement | Source Plan(s) | Description | Status | Evidence |
|-------------|---------------|-------------|--------|----------|
| **PERF-05** | 08-01, 08-02, 08-03 | Frontend track/album lists use stable keys for DOM reuse; store notifications debounced via queueMicrotask() | ✓ SATISFIED | All 7 virtualizers have `.keyFunction` with stable entity keys. Library store uses queueMicrotask coalescing. Search debounced 150ms. classMap eliminates per-row allocations. |
| **UX-01** | 08-01, 08-04 | Visual inconsistencies audited and fixed (spacing, colors, typography, icon sizing follow consistent pattern) | ✓ SATISFIED | Design tokens defined and applied across 14 components. Sidebar em→px conversion complete. Cover-grid dynamic text mapped to type scale. Human-verified during Plan 04 execution. |
| **UX-02** | 08-02, 08-03 | Frontend rendering for large libraries smooth — no jank during scrolling, view switching, search filtering | ? NEEDS HUMAN | Code-level optimizations verified (keyed virtualizers, classMap, search debounce, store coalescing). Runtime smoothness requires human testing with 10k+ library. |
No orphaned requirements — REQUIREMENTS.md maps PERF-05, UX-01, UX-02 to Phase 8, and all three appear in plan frontmatter.
### Anti-Patterns Found
| File | Line | Pattern | Severity | Impact |
|------|------|---------|----------|--------|
| cover-grid.ts | 765 | `'10px'` hardcoded (artist name small tier) | ℹ️ Info | Only one value in the small-card tier doesn't map to a token. 10px is below --yj-text-xs (11px). Acceptable — no token exists for sub-xs sizing. |
No TODOs, FIXMEs, PLACEHOLDERs, or stubs found in any modified file. TypeScript compiles clean (`npx tsc --noEmit` produces zero errors).
### Human Verification Required
### 1. Large Library Scroll Performance
**Test:** Open a library with 10k+ tracks. Scroll through the track list, cover grid, and queue panel rapidly.
**Expected:** Smooth scrolling with no visible jank, stuttering, or dropped frames. DOM inspector should show only ~20-50 rendered rows at any time (virtualization working).
**Why human:** Jank perception is a runtime visual behavior that cannot be verified through static code analysis.
### 2. View Switching Speed
**Test:** Switch rapidly between tracks, albums, artists, and genres views.
**Expected:** Instant view transitions with no loading spinners or blank screens. Data is pre-cached via deferred eagerFetch.
**Why human:** Transition speed is a runtime behavior affected by data size, browser rendering, and perceived responsiveness.
### 3. Search Debounce Feel
**Test:** Type rapidly in the search bar, then stop. Clear the search.
**Expected:** Characters appear instantly in the input. Filtered results update ~150ms after typing stops. Clearing the input instantly clears results (no 150ms delay on clear).
**Why human:** Debounce timing is a subjective UX feel that requires human interaction.
### 4. Visual Consistency Audit
**Test:** Navigate through all views: sidebar, track list, cover grid (small/medium/large cards), queue panel, now-playing, search bar, audio player, artist/genre/track details.
**Expected:** Icons are consistently sized per context (small indicators, medium controls, large placeholders). Typography follows the type scale. Sidebar spacing is balanced after em→px conversion. No jarring size mismatches between views.
**Why human:** Visual design coherence requires human aesthetic judgment.
**Note:** Plan 04 Task 3 was a human-verify checkpoint that was marked "approved" during execution. If the same human verified this, items 3-4 may already be satisfied.
### Gaps Summary
No code-level gaps found. All automated checks pass:
- ✅ All 7 virtualizers use `.renderItem` + `.keyFunction` with stable keys (hotfix `72ef719` confirmed)
- ✅ Library store queueMicrotask coalescing operational
- ✅ Search input 150ms debounce with instant clear
- ✅ Design tokens defined and adopted by 14 components
- ✅ classMap eliminates array allocations in render hot paths
- ✅ Cover-grid dynamic text tiers mapped to type scale tokens
- ✅ Zero em-based spacing in sidebar
- ✅ TypeScript compiles without errors
- ✅ Zero TODOs/FIXMEs/stubs in modified files
- ✅ All 9 phase commits verified in git history
The single remaining concern is runtime performance verification with a large library, which requires human testing.
---
_Verified: 2026-03-05T15:30:00Z_
_Verifier: Claude (gsd-verifier)_