diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index eda5690..60bd8f3 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -28,7 +28,7 @@ Requirements for v1.1 Multi-Library Support milestone. Each maps to roadmap phas - [x] **LIB-03**: User can remove a library — tracks are deleted from DB, shared entities (artists, albums, genres) are cleaned up only if no other library references them - [x] **LIB-04**: Libraries are stored in SQLite (not TOML config) with CRUD through the UI - [x] **LIB-05**: Existing single-directory config is migrated seamlessly to the libraries table on first run after upgrade -- [ ] **LIB-06**: Library list is displayed in a management UI (settings or sidebar section) +- [x] **LIB-06**: Library list is displayed in a management UI (settings or sidebar section) ### Library Scanning @@ -185,7 +185,7 @@ Which phases cover which requirements. Updated during roadmap creation. | LIB-03 | Phase 12 | Complete | | LIB-04 | Phase 10 | Complete | | LIB-05 | Phase 10 | Complete | -| LIB-06 | Phase 12 | Pending | +| LIB-06 | Phase 12 | Complete | | LSCAN-01 | Phase 11 | Complete | | LSCAN-02 | Phase 11 | Complete | | LSCAN-03 | Phase 11 | Complete | @@ -205,8 +205,8 @@ Which phases cover which requirements. Updated during roadmap creation. | DATA-04 | Phase 10 | Complete | **Coverage:** -- v1.1 requirements: 31 total (19 complete + 12 pending) -- Mapped to phases: 31/31 ✓ (Phase 9: 8, Phase 10: 5, Phase 11: 4, Phase 12: 6 of 7 — 12 pending in Phase 12-13) +- v1.1 requirements: 31 total (20 complete + 11 pending) +- Mapped to phases: 31/31 ✓ (Phase 9: 8, Phase 10: 5, Phase 11: 4, Phase 12: 7 of 7 — 11 pending in Phase 13) - No orphaned requirements --- diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index b94555c..5a071ef 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -31,7 +31,7 @@ - [x] **Phase 9: Scan Cancellation & Keyboard Shortcuts** — Cancellable library scans and configurable keyboard shortcuts - [x] **Phase 10: Schema & Migration** — Libraries table, library_id FK, playlist_tracks phantom rebuild, config migration (completed 2026-03-09) - [x] **Phase 11: Per-Library Scan Pipeline** — Scan pipeline refactored for per-library scanning with sequential coordination (completed 2026-03-09) -- [ ] **Phase 12: Library CRUD & Data Integrity** — Library management API, orphan cleanup, queue/playlist lifecycle, library manager UI +- [x] **Phase 12: Library CRUD & Data Integrity** — Library management API, orphan cleanup, queue/playlist lifecycle, library manager UI (completed 2026-03-15) - [ ] **Phase 13: Library Views & Phantom Tracks** — Filtered presentation across all views, search, browse, and phantom track display ## Phase Details @@ -96,7 +96,7 @@ Plans: **Plans:** 2 plans Plans: - [x] 12-01-PLAN.md — Backend CRUD API + orphan cleanup + queue compaction + events -- [ ] 12-02-PLAN.md — Frontend library management UI in settings + sidebar cleanup +- [x] 12-02-PLAN.md — Frontend library management UI in settings + sidebar cleanup ### Phase 13: Library Views & Phantom Tracks **Goal:** Users experience a unified multi-library presentation with optional filtering and graceful playlist preservation @@ -142,7 +142,7 @@ Plans: | 9. Scan Cancellation & Keyboard Shortcuts | v1.1 | 5/5 | Complete | 2026-03-07 | | 10. Schema & Migration | 2/2 | Complete | 2026-03-09 | - | | 11. Per-Library Scan Pipeline | 3/3 | Complete | 2026-03-09 | - | -| 12. Library CRUD & Data Integrity | v1.1 | 1/2 | In Progress | - | +| 12. Library CRUD & Data Integrity | v1.1 | 2/2 | Complete | 2026-03-15 | | 13. Library Views & Phantom Tracks | v1.1 | 0/? | Not started | - | | 14. Performance Optimization | 4/4 | Complete | 2026-03-15 | - | diff --git a/.planning/STATE.md b/.planning/STATE.md index 96aa94c..ebfe3e6 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,13 +2,13 @@ gsd_state_version: 1.0 milestone: v1.1 milestone_name: Multi-Library Support -status: unknown -last_updated: "2026-03-15T12:11:53.757Z" +status: in-progress +last_updated: "2026-03-15T14:21:35Z" progress: total_phases: 5 - completed_phases: 4 + completed_phases: 5 total_plans: 16 - completed_plans: 15 + completed_plans: 16 --- # YellowJacket — Project State @@ -22,11 +22,11 @@ See: .planning/PROJECT.md (updated 2026-03-08) ## Current Position -Phase: 14 — Performance Optimization -Plan: 4 of 4 in Phase (Plans 01, 02, 03 complete; 04 awaiting checkpoint) -Status: Plan 14-03 complete — render & store optimization; 14-04 awaiting checkpoint -Progress: ████████████████████ Phase 14 in progress (3/4 plans complete, 1 checkpoint pending) -Last activity: 2026-03-14 — Completed 14-03 render & store optimization +Phase: 12 — Library CRUD & Data Integrity (completed), 13 next +Plan: 2 of 2 in Phase 12 (complete) +Status: Plan 12-02 complete — frontend library management UI verified +Progress: ████████████████████ Phase 12 complete (2/2 plans), Phase 14 complete (4/4 plans) +Last activity: 2026-03-15 — Completed 12-02 frontend library management UI ### Phase Overview @@ -35,9 +35,9 @@ Last activity: 2026-03-14 — Completed 14-03 render & store optimization | 9. Scan Cancellation & Keyboard Shortcuts | Complete (5/5 plans) ✅ | | 10. Schema & Migration | Complete (2/2 plans) ✅ | | 11. Per-Library Scan Pipeline | Complete (3/3 plans) ✅ | -| 12. Library CRUD & Data Integrity | In progress (1/2 plans) | +| 12. Library CRUD & Data Integrity | Complete (2/2 plans) ✅ | | 13. Library Views & Phantom Tracks | Not started | -| 14. Performance Optimization | In progress (4/4 plans, checkpoint pending) | +| 14. Performance Optimization | Complete (4/4 plans) ✅ | ## Performance Metrics @@ -61,6 +61,7 @@ Last activity: 2026-03-14 — Completed 14-03 render & store optimization | Phase 14-03 P03 | 4 min | 2 tasks | 5 files | | Phase 14-01 P01 | 3 min | 2 tasks | 7 files | | Phase 14-04 P04 | 2 min | 2 tasks | 3 files | +| Phase 12-02 P02 | 38 min | 3 tasks | 19 files | ## Accumulated Context @@ -123,6 +124,10 @@ Decisions from v1.0 are archived in PROJECT.md Key Decisions table. Key patterns | querySingleInt64 helper for hand-crafted SQL aggregates | DB type has QueryContext (returns *sql.Rows) but no QueryRowContext; helper wraps scan-close cycle | | Sentinel errors for all validation per err113 | errLibraryNameEmpty, errLibraryNameTooLong, errLibraryNameDuplicate, errLibraryPathNotExist | | Pre-populate phantom metadata BEFORE cascade delete | Avoids lost join data — playlist_tracks need track metadata after audio_files rows are gone | +| Selectable library checkboxes for scan targeting | User selects which libraries to scan instead of scan-all-or-nothing; Set model with select-all/indeterminate | +| Inline progress bar per library row | Each library row shows scan phase and percentage, replacing global-only indicator | +| Collapsible config sections with chevron dropdown | Keeps settings page organized as it grows; new config-section component | +| Library store invalidation on LibraryRemoved event | Ensures all data views refresh after library removal | ### Phase 14 Decisions @@ -164,10 +169,10 @@ Decisions from v1.0 are archived in PROJECT.md Key Decisions table. Key patterns ### Last Session -**Date:** 2026-03-14 -**What happened:** Executed Phase 14, Plan 03 — event delegation eliminates per-scroll-frame closures, queueMicrotask batching for queue store, changeGeneration counter for library store. Plan 04 Tasks 1-2 were completed earlier, awaiting checkpoint. -**Where we stopped:** Completed 14-03-PLAN.md — Plans 01, 02, 03 complete; 14-04 awaiting human-verify checkpoint -**Next action:** User verifies scroll smoothness and navigation speed across all views (14-04 Task 3 checkpoint) +**Date:** 2026-03-15 +**What happened:** Finalized Plan 12-02 — frontend library management UI. Code was implemented across 25 commits in previous sessions; this session created SUMMARY.md after human verification checkpoint passed (all 9 checks approved). +**Where we stopped:** Completed 12-02-PLAN.md — Phase 12 complete (2/2 plans) +**Next action:** Plan Phase 13: Library Views & Phantom Tracks --- *State initialized: 2026-02-27* @@ -180,4 +185,4 @@ Decisions from v1.0 are archived in PROJECT.md Key Decisions table. Key patterns | 18 | add multi-column metadata display to playlist-details | 2026-03-08 | ce23177 | [18-add-multi-column-metadata-display-to-pla](./quick/18-add-multi-column-metadata-display-to-pla/) | Last activity: 2026-03-08 - Completed quick task 18: add multi-column metadata display to playlist-details -*Last updated: 2026-03-14 — Completed 14-03-PLAN.md (Phase 14 Plan 03 complete)* +*Last updated: 2026-03-15 — Completed 12-02-PLAN.md (Phase 12 complete)* diff --git a/.planning/phases/12-library-crud-data-integrity/12-02-SUMMARY.md b/.planning/phases/12-library-crud-data-integrity/12-02-SUMMARY.md new file mode 100644 index 0000000..79f7ac4 --- /dev/null +++ b/.planning/phases/12-library-crud-data-integrity/12-02-SUMMARY.md @@ -0,0 +1,194 @@ +--- +phase: 12-library-crud-data-integrity +plan: 02 +subsystem: ui +tags: [lit, wails, library-management, config-page, sidebar, folder-picker, toast, overflow-menu] + +# Dependency graph +requires: + - phase: 12-library-crud-data-integrity + provides: AddLibrary, RenameLibrary, RemoveLibrary, GetRemovalImpact backend API, LibraryAdded/Renamed/Removed events + - phase: 11-per-library-scan-pipeline + provides: ScanLibrary, ScanAllLibraries, scan queue coordinator, per-library progress events +provides: + - Full library management UI in settings page (list, add, rename, remove with confirmation + toast) + - Selectable library checkboxes for targeted scanning + - Inline per-library progress bar during scan + - Collapsible config sections + - Sidebar cleaned up (no Libraries nav item) +affects: [13-library-views-phantom-tracks] + +# Tech tracking +tech-stack: + added: [] + patterns: + - "Checkbox selection model for multi-library scan targeting" + - "Inline progress bar per library row during scan" + - "Collapsible config-section with chevron dropdown" + - "Overflow menu with document click dismiss" + - "Toast notification with auto-dismiss timer" + +key-files: + created: [] + modified: + - frontend/src/components/config-page/config-page.ts + - frontend/src/components/config-page/config-section.ts + - frontend/src/components/sidebar/app-sidebar.ts + - frontend/index.ts + - frontend/src/store/library-store.ts + - backend/library/crud.go + - backend/library/metrics.go + - backend/library/query.go + - backend/library/rescan.go + - backend/library/scan_queue.go + +key-decisions: + - "Selectable library checkboxes — user selects which libraries to scan instead of scan-all-or-nothing" + - "Scan buttons above library list with selection count indicator" + - "Inline progress bar per library row — replaces global-only progress" + - "Collapsible config sections with chevron dropdown — keeps settings page organized" + - "8-second toast auto-dismiss timer for removal summaries" + - "Library store invalidation on LibraryRemoved event to refresh all views" + +patterns-established: + - "Checkbox selection model: Set with select-all/indeterminate header" + - "Collapsible config-section component with chevron toggle" + +requirements-completed: [LIB-01, LIB-02, LIB-03, LIB-06] + +# Metrics +duration: 38min +completed: 2026-03-15 +--- + +# Phase 12 Plan 02: Frontend Library Management UI Summary + +**Full library management UI in settings with add/rename/remove, selectable scan targeting, inline per-library progress bars, and collapsible config sections** + +## Performance + +- **Duration:** 38 min (execution across previous session + finalization) +- **Started:** 2026-03-15T13:43:37Z +- **Completed:** 2026-03-15T14:21:35Z +- **Tasks:** 3 (2 auto + 1 human-verify checkpoint) +- **Files modified:** 19 + +## Accomplishments + +- Library management UI in settings page: list with name, path, track count per library; Add Library with folder picker; inline rename with Enter/Escape; overflow menu (Rename, Rescan, Remove); removal confirmation dialog with real impact counts; toast notification with removal summary +- Selectable library checkboxes with select-all/indeterminate header for targeted scan operations +- Inline scan progress bar per library row showing phase and percentage +- Collapsible config-section component with chevron dropdown for all settings sections +- Sidebar "Libraries" nav item removed; library-manager component import removed from router +- Library store invalidated on LibraryRemoved event to refresh all data views + +## Task Commits + +Tasks were committed atomically with extensive follow-up refinements: + +1. **Task 1: Replace config-page library section with library management UI** — `ffc5d96` (feat) + 20 follow-up fix/feat/perf commits +2. **Task 2: Remove Libraries sidebar nav item and view routing** — `e199712` (feat) +3. **Task 3: Verify library management UI end-to-end** — Human verified ✅ (all 9 checks passed) + +Key follow-up commits: +- `13a42ae` feat: selectable library list with checkbox scan targeting +- `df824c6` feat: show scan progress bar inline in library list entry +- `12c6782` feat: make config sections collapsible with chevron dropdown +- `890284d` fix: delete artist_credit_artist before artist_credit in removal pipeline +- `30f4461` perf: skip FTS5 rebuild during library removal +- `21ea71e` perf: increase scan batch size from 50 to 300 +- `b093fbb` fix: invalidate library store cache on LibraryRemoved event + +Full commit list (25 commits): `ffc5d96..12c6782` + +## Files Created/Modified + +- `frontend/src/components/config-page/config-page.ts` — Full library management UI with CRUD, selection, progress, toast, overflow menus +- `frontend/src/components/config-page/config-section.ts` — Collapsible section component with chevron toggle +- `frontend/src/components/sidebar/app-sidebar.ts` — Removed 'libraries' from View type and nav items +- `frontend/index.ts` — Removed library-manager import and routing case +- `frontend/src/store/library-store.ts` — Added LibraryRemoved invalidation handler +- `backend/library/crud.go` — Bug fixes in orphan cleanup ordering +- `backend/library/metrics.go` — ScanWarning.Err serialized as string +- `backend/library/query.go` — GetAllLibrariesWithTrackCounts binding +- `backend/library/rescan.go` — Scan batch size increase, soft scan optimization +- `backend/library/scan_queue.go` — Wait for scan stop before removal +- `frontend/wailsjs/go/library/Library.d.ts` — Regenerated bindings +- `frontend/wailsjs/go/library/Library.js` — Regenerated bindings +- `frontend/wailsjs/go/models.ts` — Regenerated model types + +## Decisions Made + +- **Selectable library checkboxes:** Added a Set selection model with select-all/indeterminate header checkbox. Users select specific libraries before clicking Scan, rather than scan-all-or-nothing. Selection count shown on button. +- **Scan buttons above library list:** Moved scan actions (Add Library, Scan, Full Rescan, Pause, Cancel) above the library list instead of below, with none selected by default. +- **Inline progress bar per library row:** Each library row shows its scan phase and progress percentage inline, replacing the global-only progress indicator. +- **Collapsible config sections:** All config-section elements now collapse with a chevron dropdown, keeping the settings page organized as it grows. +- **8-second toast timer:** Toast auto-dismisses after 8 seconds (longer than typical 4s) since removal summaries contain important information. +- **Library store invalidation on LibraryRemoved:** Ensures all data views (tracks, albums, artists, genres) refresh after library removal. + +## Deviations from Plan + +### Auto-fixed Issues + +**1. [Rule 1 - Bug] Fixed orphan cleanup FK ordering** +- **Found during:** Task 1 refinement +- **Issue:** artist_credit_artist rows must be deleted before artist_credit rows (FK constraint) +- **Fix:** Reordered DELETE statements in removal pipeline +- **Files modified:** backend/library/crud.go +- **Committed in:** `890284d` + +**2. [Rule 1 - Bug] ScanWarning.Err serialized as error interface** +- **Found during:** Task 1 refinement +- **Issue:** Go error interface doesn't serialize to JSON string — frontend got empty object +- **Fix:** Serialize Err field as string in ScanWarning +- **Files modified:** backend/library/metrics.go +- **Committed in:** `ac8cbb3` + +**3. [Rule 1 - Bug] Library store not invalidated on LibraryRemoved** +- **Found during:** Task 1 refinement +- **Issue:** Removing a library left stale tracks/albums/artists in library store cache +- **Fix:** Added LibraryRemoved event listener to library store that triggers full invalidation +- **Files modified:** frontend/src/store/library-store.ts +- **Committed in:** `b093fbb` + +**4. [Rule 2 - Missing Critical] Phantom tracks from empty library root** +- **Found during:** Task 1 verification +- **Issue:** TOML cleanup left empty DirectoryPath, causing all tracks to appear as phantom +- **Fix:** Resolved empty library root detection and cleanup +- **Files modified:** backend/library/crud.go +- **Committed in:** `717e249` + +**5. [Rule 3 - Blocking] Replaced removed Scan() import** +- **Found during:** Task 2 +- **Issue:** Removing library-manager import broke a reference to deleted Scan() method +- **Fix:** Replaced with ScanAllLibraries() call +- **Files modified:** frontend/index.ts +- **Committed in:** `0559822` + +--- + +**Total deviations:** 5 auto-fixed (3 bugs, 1 missing critical, 1 blocking) +**Impact on plan:** All auto-fixes necessary for correctness. No scope creep. Additional features (selectable scanning, inline progress, collapsible sections) were discovered needs during verification. + +## Issues Encountered + +None — all issues were resolved through iterative refinement. + +## User Setup Required + +None — no external service configuration required. + +## Next Phase Readiness + +- Phase 12 complete — all library CRUD backend and frontend implemented +- Ready for Phase 13: Library Views & Phantom Tracks +- All library management operations verified end-to-end through human checkpoint +- Library store properly invalidates on CRUD events, ready for filtered views + +## Self-Check: PASSED + +All key files verified present on disk, all referenced commits verified in git log. + +--- +*Phase: 12-library-crud-data-integrity* +*Completed: 2026-03-15*