docs(11-03): complete wire auto-scan and legacy cleanup plan

- SUMMARY.md documents auto-scan wiring and legacy code removal
- STATE.md updated: plan 3/3 complete, Phase 11 done, session continuity
- ROADMAP.md updated: Phase 11 complete (3/3 plans)
This commit is contained in:
2026-03-09 16:19:59 -04:00
parent 1aaf53630d
commit ead68cfb5d
3 changed files with 133 additions and 12 deletions
+3 -3
View File
@@ -29,7 +29,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)
- [ ] **Phase 11: Per-Library Scan Pipeline** — Scan pipeline refactored for per-library scanning with sequential coordination
- [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
- [ ] **Phase 13: Library Views & Phantom Tracks** — Filtered presentation across all views, search, browse, and phantom track display
@@ -76,7 +76,7 @@ Plans:
2. Only one library scans at a time — requesting a second scan while one is running either queues it or is rejected with clear feedback
3. Scan progress UI identifies which library is currently being scanned (library name visible in progress indicator)
4. Existing cancel and pause/resume controls work correctly for per-library scans — cancelling one library's scan doesn't affect others
**Plans:** 2/3 plans executed
**Plans:** 3/3 plans complete
Plans:
- [ ] 11-01-PLAN.md — Backend scan queue coordinator, per-library scan methods, CreateAudioFile with library_id
- [ ] 11-02-PLAN.md — Frontend progress UI with library name, cancel scope modal, Scan All button
@@ -120,7 +120,7 @@ Plans:
| 8. Frontend Performance & UX | v1.0 | 4/4 | Complete | 2026-03-05 |
| 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 | 2/3 | In Progress| | - |
| 11. Per-Library Scan Pipeline | 3/3 | Complete | 2026-03-09 | - |
| 12. Library CRUD & Data Integrity | v1.1 | 0/? | Not started | - |
| 13. Library Views & Phantom Tracks | v1.1 | 0/? | Not started | - |
+13 -9
View File
@@ -23,10 +23,10 @@ See: .planning/PROJECT.md (updated 2026-03-08)
## Current Position
Phase: 11 — Per-Library Scan Pipeline
Plan: 2 of 3 in Phase (Plan 02 complete)
Status: Phase 11 in progress — 1 plan remaining
Progress: ████████████░░░░░░░░ 2/5 phases complete (Phase 11 in progress)
Last activity: 2026-03-09 — Completed 11-02 frontend scan UI
Plan: 3 of 3 in Phase (Plan 03 complete)
Status: Phase 11 complete — all plans done
Progress: ████████████████░░░░ 3/5 phases complete (Phase 11 complete)
Last activity: 2026-03-09 — Completed 11-03 wire auto-scan and legacy cleanup
### Phase Overview
@@ -34,7 +34,7 @@ Last activity: 2026-03-09 — Completed 11-02 frontend scan UI
|-------|--------|
| 9. Scan Cancellation & Keyboard Shortcuts | Complete (5/5 plans) ✅ |
| 10. Schema & Migration | Complete (2/2 plans) ✅ |
| 11. Per-Library Scan Pipeline | In Progress (2/3 plans) |
| 11. Per-Library Scan Pipeline | Complete (3/3 plans) |
| 12. Library CRUD & Data Integrity | Not started |
| 13. Library Views & Phantom Tracks | Not started |
@@ -53,6 +53,7 @@ Last activity: 2026-03-09 — Completed 11-02 frontend scan UI
| Phase 10-01 P01 | 11 min | 2 tasks | 10 files |
| Phase 10-02 P02 | 5 min | 2 tasks | 9 files |
| Phase 11-01 P01 | 7 min | 2 tasks | 11 files |
| Phase 11-03 P03 | 10 min | 1 task | 3 files |
| Phase 11-02 P02 | 4 min | 2 tasks | 2 files |
## Accumulated Context
@@ -103,6 +104,9 @@ Decisions from v1.0 are archived in PROJECT.md Key Decisions table. Key patterns
| Backward-compatible Scan() wrapper | Keeps handleConfigUpdate and FullRescan working without changes |
| Queue-aware cancel dialog scope choice | Two-option "Cancel This Library / Cancel All" only when queuedCount > 0; single-scan keeps existing pattern |
| handleScanComplete defers reset when queue draining | Prevents premature scanning=false before next library starts |
| FullRescan uses first library from GetAllLibraries | Per-library rescan deferred to Phase 12; preserves backward compatibility for config-page "Rescan" button |
| LibraryConfigChanged handler removed entirely | Multi-library model uses CRUD API (Phase 12), not event-driven config updates |
| Scan() wrapper deleted | Only callers were handleConfigUpdate (deleted) and FullRescan (updated to scanInternal) |
### Warnings (carry forward)
@@ -126,9 +130,9 @@ Decisions from v1.0 are archived in PROJECT.md Key Decisions table. Key patterns
### Last Session
**Date:** 2026-03-09
**What happened:** Executed Phase 11, Plan 02updated config-page and library-manager with per-library progress display (library name + queue count), queue-aware cancel dialog with scope choice (Cancel This Library / Cancel All Scanning), Scan All Libraries button in both components.
**Where we stopped:** Completed 11-02-PLAN.md
**Next action:** Execute Phase 11, Plan 03
**What happened:** Executed Phase 11, Plan 03wired auto-scan on app launch via ScanAllLibraries goroutine in OnDomReady, removed legacy LibraryConfigChanged handler, handleConfigUpdate, and deprecated Scan() wrapper. Updated FullRescan to resolve library from DB via GetAllLibraries.
**Where we stopped:** Completed 11-03-PLAN.md — Phase 11 complete
**Next action:** Plan Phase 12 (Library CRUD & Data Integrity)
---
*State initialized: 2026-02-27*
@@ -141,4 +145,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-09 — Completed 11-02-PLAN.md*
*Last updated: 2026-03-09 — Completed 11-03-PLAN.md (Phase 11 complete)*
@@ -0,0 +1,117 @@
---
phase: 11-per-library-scan-pipeline
plan: 03
subsystem: library
tags: [scan-pipeline, startup, auto-scan, legacy-cleanup]
# Dependency graph
requires:
- phase: 11-per-library-scan-pipeline
provides: ScanLibrary, ScanAllLibraries, scanInternal, scan queue coordinator
provides:
- Auto-scan all libraries on app launch via ScanAllLibraries in OnDomReady
- FullRescan using DB-sourced library (not config DirectoryPath)
- Cleaned-up Library with no legacy single-directory handler
affects: [12-library-crud-data-integrity]
# Tech tracking
tech-stack:
added: []
patterns:
- "Auto-scan goroutine in OnDomReady — non-blocking startup scan"
- "FullRescan resolves library from DB via GetAllLibraries"
key-files:
created: []
modified:
- backend/app.go
- backend/library/library.go
- backend/library/rescan.go
key-decisions:
- "FullRescan uses first library from GetAllLibraries — per-library rescan deferred to Phase 12"
- "LibraryConfigChanged handler removed entirely rather than updated — multi-library model uses CRUD API"
- "Scan() wrapper deleted — only callers were handleConfigUpdate and FullRescan, both updated"
patterns-established:
- "Auto-scan pattern: goroutine in OnDomReady calling ScanAllLibraries"
requirements-completed: [LSCAN-01, LSCAN-02]
# Metrics
duration: 10min
completed: 2026-03-09
---
# Phase 11 Plan 03: Wire Auto-Scan and Clean Up Legacy Code Summary
**Auto-scan all libraries on app launch via ScanAllLibraries goroutine, FullRescan from DB-sourced library, legacy single-directory handlers removed**
## Performance
- **Duration:** 10 min
- **Started:** 2026-03-09T20:07:03Z
- **Completed:** 2026-03-09T20:17:10Z
- **Tasks:** 1
- **Files modified:** 3
## Accomplishments
- Auto-scan on startup calls `ScanAllLibraries()` in a goroutine from `OnDomReady` — same codepath as UI button
- Legacy `LibraryConfigChanged` event handler removed from `registerEventHandlers`
- Legacy `handleConfigUpdate` method deleted (single-directory model)
- Deprecated `Scan()` wrapper deleted (replaced by `ScanLibrary`/`ScanAllLibraries`)
- `errLibraryDirNotConfigured` sentinel error removed
- `FullRescan` now resolves library from DB via `GetAllLibraries` instead of config DirectoryPath
- `FullRescan` calls `scanInternal` directly instead of the removed `Scan()` wrapper
## Task Commits
Each task was committed atomically:
1. **Task 1: Wire auto-scan on startup and clean up legacy single-directory code** - `1aaf536` (feat)
_Note: Code changes were included in the 11-02 metadata commit due to staging overlap. All changes are verified present and correct._
## Files Created/Modified
- `backend/app.go` - Added ScanAllLibraries goroutine in OnDomReady, added early return after startupErr
- `backend/library/library.go` - Removed LibraryConfigChanged handler, handleConfigUpdate, Scan(), errLibraryDirNotConfigured; updated NewLibrary doc comment
- `backend/library/rescan.go` - FullRescan resolves first library from DB, calls scanInternal directly, added errNoLibrariesConfigured sentinel
## Decisions Made
- **FullRescan uses first library from DB:** Per-library full rescan will be added in Phase 12. For now, `FullRescan()` takes the first library from `GetAllLibraries()` — this preserves backward compatibility for the config-page "Rescan" button in the single-library case.
- **Complete removal of LibraryConfigChanged handler:** Rather than updating the handler for multi-library, it was removed entirely. In the multi-library model, libraries are managed through the CRUD API (Phase 12) and scanning is triggered explicitly via `ScanLibrary`/`ScanAllLibraries`.
- **Scan() wrapper deleted:** The only callers were `handleConfigUpdate` (deleted) and `FullRescan` (updated to use `scanInternal` directly). No backward-compatible wrapper needed.
## Deviations from Plan
### Auto-fixed Issues
**1. [Rule 3 - Blocking] Fixed golangci-lint wsl and err113 violations**
- **Found during:** Task 1 (commit attempt)
- **Issue:** Pre-commit hook flagged: (1) wsl — block ending with comment in registerEventHandlers, (2) err113 — dynamic errors.New in rescan.go
- **Fix:** (1) Moved comment to function doc comment, removed empty return before close brace. (2) Created static `errNoLibrariesConfigured` sentinel error variable.
- **Files modified:** backend/library/library.go, backend/library/rescan.go
- **Verification:** golangci-lint passes with 0 issues
- **Committed in:** 1aaf536 (part of task commit)
---
**Total deviations:** 1 auto-fixed (blocking — lint compliance)
**Impact on plan:** Necessary for pre-commit hook compliance. No scope creep.
## Issues Encountered
None
## User Setup Required
None - no external service configuration required.
## Next Phase Readiness
- Phase 11 complete — all 3 plans executed
- Per-library scan pipeline fully wired: ScanLibrary(id), ScanAllLibraries(), auto-scan on launch
- Ready for Phase 12: Library CRUD & Data Integrity
- Frontend already has per-library progress display and queue-aware cancel dialog (Plan 02)
- Phase 12 can build library management UI (add/rename/remove) on top of existing scan infrastructure
---
*Phase: 11-per-library-scan-pipeline*
*Completed: 2026-03-09*