Commit Graph
100 Commits
Author SHA1 Message Date
john-okeefe 4a436f414c Fix integration test code in backend progress tracking plan
Fixed 4 issues identified during PROJECT_GUIDELINES.md compliance review:

1. Fixed test assertions to use s.T() instead of t in test suite methods
2. Replaced non-existent createTestLibraryWithFolder() helper with:
   - Existing setup.CreateLibrary() method from test_helpers.go
   - Manual folder creation via POST /api/libraries/{id}/folders API
3. Replaced weak unit test with comprehensive tests:
   - TestWorker_JobResult_HasStatsFields: Verifies stats fields are stored
   - TestWorker_ProgressCallback_UpdatesJobResult: Verifies real-time updates
4. Documented database pool configuration (setupTestServer already uses max_conns=1)

Changes ensure integration tests will work correctly when implemented:
- Use TestServerSetup.CreateLibrary() for library creation
- Create folders via API call before triggering scans
- Use proper s.T() test reference in all assertions
- Include both unit and integration tests for full coverage

Verified against PROJECT_GUIDELINES.md:
- Uses setupTestServer() from test_helpers.go ✓
- Database pool uses max_conns=1 ✓
- Follows service layer pattern ✓
- No database schema changes ✓
- All assertions use correct test reference ✓
2026-02-25 10:45:13 -05:00
john-okeefe bd9715c272 Fix and refine frontend scan button implementation plan
Updated TASKS-scanning-progress.md Part 1 with critical fixes and
clarifications for implementing the admin page scan button functionality.

Fixes Applied:
- Converted inline JavaScript to TypeScript using existing web/src/admin.ts
- Fixed animation implementation to use TailwindCSS classes instead of custom CSS
- Added missing implementation steps:
  * Include admin.js in admin.templ
  * Remove old quickScan() function after migration
  * Build frontend assets step
- Fixed animation trigger by removing opacity/transform classes that prevented display
- Corrected API endpoint usage (/api/libraries/{id}/scan not /api/scanner/scan)

Root Cause Analysis:
- Original quickScan() sent empty folder_paths array causing 400 errors
- No "scan all libraries" endpoint exists - must scan each library individually
- Frontend had admin.ts but wasn't including it in templates

Implementation Approach:
- Fetch all libraries via GET /api/libraries
- Trigger scan for each library via POST /api/libraries/{id}/scan
- Display consolidated progress UI with animation
- Handle errors gracefully per library
- Use TypeScript for type safety
- Leverage TailwindCSS for all styling (no custom CSS)

Documentation Structure:
- Part 1: Admin scan button implementation (frontend)
- Part 2: Dashboard diagnosis and fixes (to be completed after backend work)

This plan is now ready for implementation after backend progress tracking
is completed (as documented in TASKS-backend-progress-tracking.md).
2026-02-25 10:40:10 -05:00
john-okeefe a35a08928c Add comprehensive plan for backend scan progress tracking
Created detailed implementation guide (704 lines) for adding real-time progress
reporting to the scanning system, addressing user request to track files_scanned,
new_items, and errors during scan operations.

Problem:
- Current scan API only returns 0% then 100% progress
- No visibility into how many files have been scanned
- No tracking of new items discovered or errors encountered
- Frontend cannot display meaningful progress to users

Solution Overview:
- Extend JobResult with progress details: TotalFiles, FilesScanned, NewItems, Errors
- Add progress callback to MediaScanner for real-time updates
- Implement batching (every 10 files) to reduce mutex contention
- Update scan status API to expose new metrics
- Add comprehensive integration tests using test_helpers.go

Implementation Plan (8 steps):
1. Extend JobResult struct with new fields
2. Add progress callback mechanism to WorkerService
3. Track scan statistics in MediaScanner
4. Report progress in real-time during scan
5. Update scan status API response
6. Update unit tests
7. Add integration tests with test_helpers.go
8. Build and test in container

Key Design Decisions:
- Batch progress updates every 10 files for performance (reduces mutex contention)
- Use callback pattern to decouple scanner from job management
- Maintain backward compatibility with existing scan API
- Follow service layer pattern (no business logic in handlers)
- All integration tests use setupTestServer() from test_helpers.go

Testing Strategy:
- Unit tests for WorkerService progress tracking
- Integration tests for end-to-end scan with progress updates
- Container-only testing for scanner functionality
- Verified against PROJECT_GUIDELINES.md constraints

Document is ready for immediate implementation - all code examples included
and validated against project standards.
2026-02-25 10:40:02 -05:00
john-okeefe eddaae3ccd Fix watch mode automatic startup on server launch
Fixed a critical bug where watch mode failed to start automatically during container
initialization, despite comments in app.go:79 claiming it would start "after 2-second delay."

Root Cause:
- StartWatchModeForAllLibraries() function existed but was never invoked
- Comment in app.go claimed watch mode started automatically, but no startup code existed

Changes:
- Added "context" import to internal/router/router.go
- Added goroutine in configureRouter() that:
  * Waits 2 seconds after server initialization
  * Calls StartWatchModeForAllLibraries() to activate monitoring
  * Logs startup status or errors

This ensures watch mode begins scanning for new media files automatically when the
container starts, rather than requiring manual intervention.

Testing: Verified watch mode now activates automatically in container logs.
2026-02-25 10:39:56 -05:00
john-okeefe e8effeb666 docs: add comprehensive scanning progress implementation plan
Add detailed implementation plan for fixing Scan Library button and
diagnosing dashboard display issues. Documents investigation findings,
implementation steps, and testing requirements.

Content Sections:
- Fixed Issues: Bruno JSON syntax correction
- Issue 1: Scan Library Button (frontend fix needed)
- Issue 2: Scanned Books Not Showing on Dashboard (diagnosis needed)
- Complete Implementation Plan with code examples
- Diagnostic Steps for dashboard issue
- Potential fixes for all scenarios
- Testing checklist
- Related files and dependencies

Key Findings Documented:
1. Scan Library Button
   - Current: Sends folder_paths: [] → 400 error
   - Fix: Fetch all libraries, scan each, track progress
   - Includes full JavaScript implementation

2. Dashboard Display Issue
   - Books exist in database after scan
   - Not appearing on dashboard UI
   - Root cause requires diagnosis
   - Multiple hypotheses provided

3. Implementation Priority
   - HIGH: Fix Scan button (2-3 hours)
   - MEDIUM: Diagnose dashboard (30 min)
   - LOW: Fix dashboard (unknown)

Implementation Details:
- Complete quickScan() rewrite with error handling
- Progress UI with real-time polling
- Per-library progress tracking
- Results summary display
- CSS animations and styling
- Full diagnostic checklist

Benefits:
- Single source of truth for scanning work
- Can resume implementation at any time
- Documents all investigation findings
- Includes copy-paste ready code examples
- Testing checklist for validation

File: TASKS-scanning-progress.md
Lines: 600+
Related: templates/admin.templ, templates/dashboard.templ
2026-02-24 21:33:55 -05:00
john-okeefe a830e0e2b9 docs: remove completed planning documents
Remove outdated planning documents that have been implemented or are no
longer relevant. All features have been completed and documented elsewhere.

Removed Files:
- THEME_FIX_PLAN.md
- WOOD_PANELING_FONT_FIX_PLAN.md
- WOOD_PANELING_PLAN.md

Reason:
- Wood paneling feature is complete and in production
- Theme fixes have been implemented
- Font color issues resolved
- Documentation consolidated into TASKS-scanning-progress.md

Migration:
- See TASKS-scanning-progress.md for current implementation plans
- Wood paneling is documented in code comments
- Theme system is functional with multiple color schemes

Impact:
- Cleaner repository structure
- Reduced documentation maintenance burden
- Single source of truth for pending work
2026-02-24 21:33:45 -05:00
john-okeefe 836f77582b chore(bruno): update environment variables for testing
Update Bruno environment configuration with current library and job IDs
to support API testing workflows.

Changes:
- Update library_id to current active library
- Update job_id to recent scan job
- Add collection_id variable for collection testing

Variables Updated:
- library_id: 551ac19c-896a-4406-b479-353fc489b295
- job_id: 450094c6-a8f1-4125-aea7-77df80223877
- collection_id: 11e8d915-ef95-4257-98b3-b8eeacfd59b9 (new)

Impact:
- Bruno requests reference current test data
- Supports testing scan functionality
- Enables collection endpoint testing
- Maintains test environment consistency

File: bruno/environments/Bookhoard.yml
2026-02-24 21:33:36 -05:00
john-okeefe 7db5d56577 fix(ui): make wood paneling text colors consistent and visible
Fix text color display issues on wood gradient backgrounds in the
dashboard's collections container, ensuring small text matches big text
and "View All" links stand out with proper wood-specific colors.

Changes:
- Remove .text-sm from grey text rule to match big text colors
- Keep .text-secondary as only grey text class
- Links maintain wood-specific standout colors via specific selectors

Problem:
- Small text (.text-sm) was forced to grey (--wood-text-secondary)
- "View All" links inherited grey instead of wood link colors
- Inconsistent text sizing created visual hierarchy issues

Root Cause:
input.css:243-247 applied --wood-text-secondary to .text-sm
This overrode wood-specific link colors at lines 250-257

Solution:
Remove .text-sm and p.text-sm from the grey text rule:
- Before: .text-sm, .text-secondary, p.text-sm → grey
- After: .text-secondary only → grey
- .text-sm now uses --wood-text-primary (matches big text)
- Links (including "View All") use wood-specific blue colors

Impact:
- All small text now matches big text color on wood backgrounds
- "View All" links stand out with proper colors (#0066cc for light wood, #66ccff for dark)
- Improved readability and visual consistency
- Better user experience on wood gradient themes

Wood Theme Colors:
- Wood Light: #0066cc (dark blue for contrast on light background)
- Wood Dark: #66ccff (light blue for visibility on dark background)
- Wood Mahogany: #66ccff (light blue for visibility on dark background)

Files: web/static/input.css
Lines Modified: 243-247 (removed selectors)
Related: templates/dashboard.templ:100 (View All link)
2026-02-24 21:33:28 -05:00
john-okeefe b4421b0500 fix(bruno): correct JSON syntax in Scan Media Items request
Fix critical bug where library_id variable was not quoted in the request
body, causing invalid JSON that was rejected by the API parser.

Changes:
- Quote library_id variable: {{library_id}} → "{{library_id}}"
- Add explicit Content-Type header
- Update request body format to use proper YAML multi-line string

Root Cause:
- Unquoted UUID in JSON: {"library_id": 551ac19c-896a-...}
- Produced invalid JSON that failed c.Bind() in scanner handler
- Handler returned 400 "invalid request" error

Impact:
- Bruno requests for scanning now work correctly
- API scan endpoint accepts request successfully
- Enables proper testing of scan functionality via Bruno

Testing:
- Verified scan request completes successfully
- Job ID returned correctly
- Scanner processes files as expected

File: bruno/scanner/Scan Media Items.yml
2026-02-24 21:33:16 -05:00
john-okeefe 875e4abb46 fix: preserve wood paneling on dashboard refresh and improve colors
- Fix View All link flashing by preserving data-wood attribute when dashboard re-renders
- Update wood-dark text color to match wood-mahogany (#f5f5f5) for better consistency
- Add smart link colors for wood paneling (#0066cc for light wood, #66ccff for dark woods)
- Fix carousel arrow gradients to be less harsh on wood backgrounds (0.6 for light, 0.3 for dark)
- Remove accent color preservation rule that was conflicting with wood-specific link colors
2026-02-24 17:00:11 -05:00
john-okeefe 4571a19159 feat: add smart font colors for wood paneling backgrounds
- Add data-wood attribute to collections container for CSS targeting
- Update woodPaneling.ts and woodPanelingInit.ts to set/remove attribute
- Add CSS variables for wood-specific text colors (dark text on light wood, light text on dark wood)
- Add !important rules to override theme colors when wood is active
- Replace wood-dark and wood-mahogany textures with darker variants
- Add subtle borders to book cards on wood backgrounds
2026-02-24 16:36:49 -05:00
john-okeefe c50f58dafc docs: add wood paneling font color fix plan
- Create comprehensive implementation plan for smart font colors on wood paneling backgrounds
- Addresses readability issues where current theme colors don't contrast well with wood textures
- Includes CSS strategy, TypeScript changes, texture replacements, and testing checklist
- Ready to implement when needed
2026-02-24 16:10:36 -05:00
john-okeefe 30d053d908 fix: resolve library management issues
- Fix library edit form to use type_name instead of library_type_id for type dropdown
- Clear library-id input after successful delete to prevent create-then-delete bug
- This fixes the issue where creating a new library after deleting one would fail with 'Unknown error' due to stale library-id
2026-02-24 16:10:33 -05:00
john-okeefe 519633ff87 chore(templates): add generated admin_sidebar templ file 2026-02-24 13:43:01 -05:00
john-okeefe 9426df01fc refactor(theme): separate wood paneling from color themes
- Remove wood themes (wood-light, wood-dark, wood-mahogany) from profile theme selector
- Add wood paneling as separate section in header theme dropdown
- Update script references to include new theme management files
- Change header layout to full-width design
2026-02-24 13:41:24 -05:00
john-okeefe 4b43116f13 refactor(templates): apply activeClass helper and full-width layout
- Replace inline ternary operators with activeClass helper function
- Change layout containers from max-w-7xl to w-full for full-width design
- Update file path references in error messages for better debugging
2026-02-24 13:41:19 -05:00
john-okeefe 3128ae05a6 feat(assets): add wood texture images for paneling
- Add wood-light.png, wood-dark.png, wood-mahogany.png textures
- Rebuild CSS with wood background utilities and indicator classes
2026-02-24 13:06:07 -05:00
john-okeefe 8b8af87504 docs(user): add themes and wood paneling guide
- Document all available color themes with descriptions
- Explain wood paneling feature and available textures
- Provide step-by-step instructions for changing themes
- Add tips for theme/texture pairing
2026-02-24 13:03:12 -05:00
john-okeefe c341679aaa refactor(layout): apply full-width layout to all pages
- Remove max-w-7xl containers from all page templates
- Replace with w-full for full-screen width utilization
- Maintain padding for readability
- Admin templates: modify inner content div only (preserve sidebar layout)
2026-02-24 13:03:01 -05:00
john-okeefe 3870168452 refactor(dashboard): apply full-width layout and wood paneling
- Remove max-w-7xl constraints from library selector and collections
- Include woodPanelingInit.js script for early paneling application
- Prevent flash of wrong background on page load
- Wood paneling applied only to #collections-container
2026-02-24 13:02:34 -05:00
john-okeefe 0327d367f2 refactor(header): separate wood paneling from color themes
- Remove max-w-7xl constraint, use full-width layout
- Replace wood theme buttons with wood paneling section
- Add visual previews for wood textures in dropdown
- Section labeled "Bookshelf Background" for clarity
- Include woodPaneling.js and themeDropdown.js scripts
2026-02-24 13:01:45 -05:00
john-okeefe b1dcb3889e feat(styles): add active indicator classes for dropdown buttons
- Add bg-theme-active/inactive for theme buttons
- Add bg-wood-active/inactive for wood paneling buttons
- Use CSS variables already defined in input.css
- Use !important to override inline styles
2026-02-24 13:01:10 -05:00
john-okeefe 3575396e5c feat(tailwind): add wood texture background utilities
- Add bg-wood-light, bg-wood-dark, bg-wood-mahogany utilities
- Reference texture files in web/static/textures/
- Extend theme.backgroundImage for seamless texture support
2026-02-24 13:00:48 -05:00
john-okeefe 245c775f54 feat(theme): add active indicators for theme dropdown
- Create themeDropdown.ts to manage active state highlighting
- Show which theme/wood option is currently selected
- Use CSS classes instead of inline styles for indicators
- Wrap existing functions to update indicators on toggle
- Auto-initialize indicators on DOM ready
2026-02-24 13:00:14 -05:00
john-okeefe fffa87009a feat(wood-paneling): create wood paneling management system
- Add woodPaneling.ts with localStorage-based paneling preferences
- Add woodPanelingInit.ts for early initialization (prevents flash)
- Support none, wood-light, wood-dark, wood-mahogany options
- Apply paneling to #collections-container only (not full body)
- Use Tailwind utility classes for backgrounds
- Use CSS variable classes for active indicators
- Export functions for HTML onclick handlers
- Auto-initialize on DOM ready
2026-02-24 12:59:48 -05:00
john-okeefe 891b1f3a3e refactor(profile): remove wood themes from profile settings
- Remove wood-light, wood-dark, wood-mahogany from theme dropdown
- Wood paneling is now browser-only (localStorage preference)
- Users select wood paneling from header dropdown, not profile
- Profile form only controls server-synced color themes
2026-02-24 12:58:57 -05:00
john-okeefe 9eebf6675b refactor(css): remove wood theme CSS variables
- Remove .theme-wood-light, .theme-wood-dark, .theme-wood-mahogany
- Wood paneling will use separate background utilities
2026-02-24 12:58:29 -05:00
john-okeefe 6407c2f299 refactor(tailwind): remove wood themes from safelist
- Remove theme-wood-light, theme-wood-dark, theme-wood-mahogany
- Wood themes no longer exist as color themes
2026-02-24 12:58:12 -05:00
john-okeefe 3d3af8bd92 refactor(theme): remove wood themes from core theme system
- Remove wood-light, wood-dark, wood-mahogany from ThemeType
- Remove wood theme gradient logic from applyTheme()
- Wood themes will be reimplemented as separate paneling feature
- Paneling will target dashboard bookshelf background only
2026-02-24 12:57:54 -05:00
john-okeefe 67f08ba75e docs(wood-paneling): fix line reference and build commands
- Phase 5: Change line number to structural reference (before closing brace)
- Fix all TypeScript build commands from 'npm run build' to 'npm run build:ts'
- Ensures plan aligns with actual package.json scripts
- Prevents execution failures during implementation
2026-02-24 12:55:17 -05:00
john-okeefe ee3e2147c2 docs(wood-paneling): fix JavaScript violations and add profile form updates
- Add Phase 1b to remove wood themes from profile_form.templ
- Add woodPanelingInit.ts to Phase 2 for early initialization
- Remove inline JavaScript from Phase 7, use TypeScript instead
- Update Critical Requirements to prohibit inline scripts entirely
- Update Files Summary with new files and modifications
- All changes align with PROJECT_GUIDELINES.md requirements
2026-02-24 12:35:06 -05:00
john-okeefe f2577ef96d chore: update gitignore for IDE support
- Add .zed/ to gitignore (Zed editor config)
- Add .opencode/ to gitignore (opencode tool data)
- Remove .zed/settings.json from version control
- Keeps repository clean of IDE-specific files
2026-02-24 12:01:04 -05:00
john-okeefe e8bb1496cf docs(wood-paneling): comprehensive plan update with TypeScript and documentation
- Add Implementation Principles section (critical requirements)
- Add Git Commit Strategy section (sequential commands, verification)
- Split implementation into 10 detailed phases (0-10)
- Convert all JavaScript to TypeScript (no inline scripts except simple init)
- Use CSS variable classes instead of inline styles for indicators
- Add explicit verification steps after each file edit
- Add documentation phase (Phase 9) for user-facing features
- Add final testing phase (Phase 10) with comprehensive checklist
- Preserve admin template sidebar layout instructions
- All git commits structured sequentially (no && chaining)
- Post-edit verification mandatory after each file change

Addresses issues found during analysis:
- Missing documentation updates
- Inline JavaScript should be TypeScript
- No explicit git commit structure
- Missing post-edit verification checkpoints
- Use CSS variables already defined in input.css
2026-02-24 11:55:43 -05:00
john-okeefe 9b4eee0c1f docs: add git workflow guidelines for sequential command execution 2026-02-24 10:46:30 -05:00
john-okeefe 665e2533f6 build: compile templates and JavaScript after theme fixes
- Regenerate admin_library_templ.go with admin sidebar integration
- Regenerate admin_users_templ.go with sidebar layout and theme fixes
- Regenerate bookshelf_templ.go with dynamic theme rendering
- Regenerate index_templ.go with progressive enhancement script
- Regenerate login_templ.go with progressive enhancement script
- Regenerate register_templ.go with progressive enhancement script
- Compile header.js with consolidated theme logic
2026-02-24 10:26:31 -05:00
john-okeefe 65b737ec2c fix(theme): ensure theme.js loaded before header.js
- Add theme.js script include to header template
- Fixes theme selector not working on pages using Header component
- Ensures applyTheme() is defined before changeThemeTo() calls it
2026-02-24 10:25:10 -05:00
john-okeefe 7a420ef975 refactor(theme): fix theme consistency and persistence
- Apply server-side theme rendering to authenticated pages
  - bookshelf.templ: use dynamic theme-{ user.Theme }
  - admin pages: use dynamic theme rendering
- Add progressive enhancement for public pages
  - index.templ, login.templ, register.templ: inline localStorage check
  - Prevents theme flash on page load
- Consolidate wood theme logic into theme.ts
  - Move wood gradient handling from header.ts to theme.ts
  - Apply wood themes consistently via applyTheme()
- Export applyTheme to window for use by header.ts
- Fix theme selector by adding theme.js to header template
2026-02-24 10:25:06 -05:00
john-okeefe 4be69861bd refactor(admin): integrate reusable sidebar into admin pages
- Update admin.templ to use @AdminSidebar component
- Update admin_library.templ to use @AdminSidebar component
- Update admin_users.templ to use @AdminSidebar component
- Add sidebar layout wrapper to admin_users.templ (previously missing)
- Fix theme rendering to use user.Theme in all admin templates
- Remove duplicated sidebar markup across admin pages
2026-02-24 10:24:50 -05:00
john-okeefe 3b0fee4281 feat(frontend): add reusable admin sidebar component
- Create AdminSidebar component for admin panel navigation
- Support active state highlighting based on currentPath
- Consistent navigation across all admin pages
- Replaces duplicated sidebar markup in admin templates
2026-02-24 10:24:21 -05:00
john-okeefe 79d10b5b37 docs: add theme fix and admin sidebar implementation plans
- Add THEME_FIX_PLAN.md: comprehensive plan for theme system consistency
- Add ADMIN_SIDEBAR_PLAN.md: reusable admin sidebar component plan
- Add WOOD_PANELING_PLAN.md: wood paneling and full-width layout plan
2026-02-24 10:24:05 -05:00
john-okeefe 97d22687ed docs(theme): add comprehensive theme system consistency fix plan
- Document root cause of theme flashing issue
- Detail implementation plan for server-side theme rendering
- Include testing checklist and rollback strategy
- Cover wood theme gradient persistence fix
2026-02-24 08:05:04 -05:00
john-okeefe e16c277caa docs: remove completed admin library implementation plan
-- Delete ADMIN_LIBRARY_IMPROVEMENTS_PLAN.md
-- All features from the plan have been implemented
-- Plan is no longer needed as reference
2026-02-23 20:24:20 -05:00
john-okeefe e68a53651a refactor(devops): reorganize rebuild targets for clarity
-- Rename 'build' to 'rebuild' for clarity (rebuilds all containers)
-- Rename 'build-force' to 'rebuild-force' for consistency
-- Add 'rebuild-app-force' target for app-only rebuild without cache
-- Add 'rebuild-force-db' target that DELETES database for clean rebuild
-- Improve help text to clarify what each target does
-- Remove circular dependency (rebuild no longer depends on clean)
-- All rebuild targets now preserve database unless explicitly stated
2026-02-23 20:24:16 -05:00
john-okeefe e7f30a00c0 style(templates): fix code formatting with consistent indentation
-- Reformat all generated template Go files with consistent indentation
-- Standardize code style across templates/
-- No functional changes, formatting only
-- Generated by templ tool during development
2026-02-23 20:24:10 -05:00
john-okeefe 85ba3d4060 feat(frontend): add delete confirmation modal for library management
-- Add dedicated delete confirmation modal to admin/library page
-- Refactor deleteLibrary() to use modal instead of inline confirm()
-- Add showDeleteModal(), hideDeleteModal(), confirmDeleteLibrary() functions
-- Modal displays clear warning about what gets deleted
-- Improves UX by making the confirmation dialog more prominent and informative
2026-02-23 20:23:56 -05:00
john-okeefe be49bc13a7 test(bruno): add manual API contract test for folder browsing
- Create bruno/library/browse-folders.yml
- Single manual test case for admin context
- Unit/integration tests cover all scenarios (no auth, user, admin)
- Bruno provides quick manual API contract verification

Fixes: Issue 2 (manual testing)
2026-02-23 17:03:49 -05:00
john-okeefe f91b1bf54b docs(api): document library folder browsing endpoint
- Add docs/developer/api/libraries/browse-folders.md
- Document security features (path traversal protection, admin-only)
- Include usage examples and error responses
- Clarify browses server filesystem, not client's

docs(user): add admin library folder browser documentation

- Add docs/user/admin-library-management.md
- Document how to use the folder browser UI
- Include security notes and manual entry instructions
- Explain server filesystem browsing behavior

Fixes: Issue 2 (documentation)
2026-02-23 17:03:35 -05:00
john-okeefe 22e10fa460 test(backend): add unit and integration tests for folder browsing
- Add unit tests in internal/services/library_service_test.go
  - Test path traversal protection
  - Test non-existent path handling
  - Test file vs directory validation
  - Test successful directory listing
- Add integration tests in cmd/server/tests/library_browse_test.go
  - Use setupTestServer() helper from test_helpers.go
  - Test no authentication returns 401
  - Test regular user returns 403 forbidden
  - Test admin can browse directories
  - Test path traversal blocking
- All tests use table-driven approach with t.Run()

Fixes: Issue 2 (tests)
2026-02-23 17:03:03 -05:00
john-okeefe 2af035d87f feat(backend): add server-side directory browsing API
- Add BrowseDirectories() to library service with path traversal protection
- Add BrowseDirectories handler with proper error handling
- Register GET /api/libraries/browse endpoint (admin-only)
- Returns current path, parent path, and list of subdirectories
- Security: blocks "..", validates path exists, checks is directory

Fixes: Issue 2 (backend)
2026-02-23 17:02:52 -05:00
john-okeefe c333c82c6b fix(frontend): add data parameter support to apiDelete
- Add optional data parameter to apiDelete() with generic type safety
- Enables DELETE requests with request bodies (needed for folder deletion)
- 100% backward compatible (optional parameter)
- Supports type-safe request body passing

Part of: Issue 1
2026-02-23 17:02:35 -05:00
john-okeefe 509423b46e feat(frontend): implement library edit functionality
- Reuse Create Library modal for edit mode
- Add hidden library-id input to track create vs edit
- Update handleCreateLibrarySubmit to detect mode and use PUT vs POST
- Implement editLibrary() to populate modal with existing data
- Pass library data to Edit button via data attributes
- Reset modal title when opening for create mode

Fixes: Issue 3
2026-02-23 17:02:01 -05:00
john-okeefe a137d3ea76 docs: add admin library page improvements implementation plan
- Document 4 improvements to /admin/library page
- Issue 1: Fix folder list display bugs (toggle logic, DELETE request body)
- Issue 2: Add server-side folder browser with full-stack implementation
- Issue 3: Implement edit library functionality
- Issue 4: Clarify delete confirmation message

Key changes:
- Add os import for BrowseDirectories service function
- Use event delegation pattern for folder browser UI
- Add DeleteFolderRequest interface for type safety
- Include comprehensive testing strategy (unit, integration, Bruno)
- Follow PROJECT_GUIDELINES.md throughout
- Procedural/imperative style, no OOP
- Progressive enhancement maintained
2026-02-23 16:12:25 -05:00
john-okeefe ce50312e1b feat(frontend): Add TypeScript for admin library page
Add web/src/library.ts with complete functionality for /admin/library
page interactivity.

Features:
- reloadLibraries() - fetch and render library list after changes
- renderLibraries() - SSR replacement with proper data.data handling
- loadUserVisibility() - load and display user library permissions
- setLibraryVisibility() - toggle library visibility for users
- handleCreateLibrarySubmit() - form submission with fetch API
- deleteLibrary() - delete with confirmation
- showLibraryFolders() - folder management
- addLibraryFolder() / removeLibraryFolder() - folder CRUD
- editLibrary() - placeholder for future implementation
- Modal controls (show/hide)
- Event delegation for dynamic buttons
- XSS protection with escapeHtmlLocal()

TypeScript Features:
- Proper type definitions (Library, User, LibraryFolder)
- Async/await with error handling
- Procedural style (no OOP, per PROJECT_GUIDELINES)
- Exports functions to window for global access

Bug Fixes:
- Fixed data.data API response handling
- Replaced broken HTMX form with fetch()
- Proper error messages with toast notifications

Lines: 394
2026-02-22 21:07:06 -05:00
john-okeefe f39cf3904d fix(frontend): Remove ES6 exports from api.ts
Remove ES6 export statement from api.ts that was causing CommonJS
compilation in browsers, breaking window.api initialization.

Issue: TypeScript compiled 'export { ... }' to CommonJS format
(exports.apiGet = ...), which browsers don't support.

Fix: Remove export statement, rely on existing window.api assignment.
This produces browser-compatible JavaScript.

Before: export { getAuthHeader, apiGet, ... } → CommonJS exports
After: (window as any).api = { ... } → browser global

Resolves: 'Uncaught ReferenceError: exports is not defined'
Resolves: 'Uncaught TypeError: window.api is undefined'
2026-02-22 21:06:47 -05:00
john-okeefe 638f1a901d feat(frontend): Convert admin library to SSR with TypeScript
Complete refactor of /admin/library page to use server-side rendering
and TypeScript, fixing broken Create Library button and improving UX.

Backend Integration:
- Update template signature to accept libraries and users parameters
- Add SSR rendering of library list (no empty state)
- Add SSR rendering of user select dropdown
- Data fetched in router handler and passed to template

TypeScript Conversion:
- Create web/src/library.ts (394 lines) - complete rewrite of inline JS
- Convert all inline JavaScript to TypeScript
- Fix critical data.data API response bug
- Replace broken HTMX form with fetch() API calls
- Implement event delegation for dynamic button clicks
- Add missing editLibrary() function (placeholder)
- Add proper error handling with toast notifications

Template Changes:
- Remove 229 lines of inline JavaScript
- Update Create Library button: onclick → data-action
- Update form: remove HTMX attributes, add onsubmit handler
- Remove duplicate script tags from <head> section
- Keep all script loading at end of <body> for performance

Bug Fixes:
- Fix API response handling: data → data.data
- Replace broken hx-headers (JavaScript not supported in HTMX)
- Fix modal z-index and visibility classes

Progressive Enhancement:
- Page works without JavaScript (SSR content visible)
- JavaScript enhances with interactive features
- Follows PROJECT_GUIDELINES: procedural style, no OOP
2026-02-22 21:06:36 -05:00
john-okeefe f096b86032 feat(router): SSR libraries and users on /admin/library page
Update the /admin/library route handler to fetch and pass data to
template for server-side rendering, improving page load performance.

Changes:
- Fetch all libraries using ListLibrariesData() helper
- Fetch all users for visibility management
- Convert database rows to template types (LibraryData, User)
- Pass data to AdminLibrary template for SSR
- Follows existing pattern from dashboard and custom-section pages

Benefits:
- Faster initial page load (no AJAX fetch)
- Better UX (content visible immediately)
- Progressive enhancement (works without JS)
2026-02-22 21:06:20 -05:00
john-okeefe 3174ec16bc feat(backend): Add SSR data helper for admin library page
Add ListLibrariesData() method to LibraryHandler to support
server-side rendering of all libraries on the /admin/library page.

This follows the existing pattern of GetUserVisibleLibrariesData() and
GetLibraryTypeData() methods, which return data structures instead of
JSON for template rendering.

Changes:
- Add ListLibrariesData() method (3 lines)
- Returns []database.ListLibrariesRow for template consumption
- Called by frontend route handler for SSR
2026-02-22 21:05:57 -05:00
john-okeefe f7e1eab31d refactor(templates): fix admin sidebar navigation link
Update admin dashboard sidebar to point to user administration page
instead of profile settings:
- Change link from /profile to /admin/users
- Update label from 'Profile Settings' to 'User Administration'

This completes the admin navigation refactoring to use dedicated
admin pages instead of the main user profile page.
2026-02-22 19:48:50 -05:00
john-okeefe cb04dbb542 fix(devops): force container recreation on rebuild to ensure template changes appear
Add --force-recreate flag to all build targets that create containers:
- build: Force recreation when building all containers
- rebuild-app: Force recreation of app container only (fixes template update issue)
- build-force: Force recreation even when using --no-cache
- test-env-up: Force recreation in test environment

This fixes a critical issue where 'make rebuild-app' would build a new image
but continue running the old container, causing template changes to not appear.

Root cause: podman-compose up --build doesn't recreate containers if they're
already running, even when a new image is built. The --force-recreate flag
ensures containers are recreated with the new image.

BuildKit caching still works as expected - cache is used during image build,
while --force-recreate ensures the new image is actually deployed.

Changes:
- build: Add --force-recreate flag
- rebuild-app: Add --force-recreate flag, update success message
- build-force: Add --force-recreate flag
- test-env-up: Add --force-recreate flag

Verified: Template changes now appear immediately after rebuild.
2026-02-22 19:48:36 -05:00
john-okeefe 37cb279a15 chore(templates): regenerate Go code after template changes
Run templ generate to update *_templ.go files after admin header
refactoring and template signature changes.
2026-02-22 19:06:32 -05:00
john-okeefe fd08e8c613 fix(router): update AdminUsers call to match new signature
Fix function call to pass currentUser as first parameter instead of
templateUsers, matching the refactored AdminUsers template signature.
2026-02-22 19:06:29 -05:00
john-okeefe 844910a54b refactor(templates): complete admin header extraction
- Add theme.js to admin_users page for proper theme support
- Pass currentUser to Header instead of hardcoded Admin user
- Fix currentUserID reference bug (use currentUser.ID)
- Remove duplicate theme loading script (now in Header)
- Complete header refactoring for admin_users page
2026-02-22 19:06:18 -05:00
john-okeefe d4d93bc0e3 feat(auth): add interactive password requirements validation to registration
- Add password requirements checklist with visual indicators (✓/○)
- Implement real-time validation for length, case, numbers, special chars
- Add confirm password field with matching validation
- Disable submit button until all requirements are met
- Add TypeScript client-side validation with password manager compatibility
2026-02-22 18:40:22 -05:00
john-okeefe d28aa5af4b refactor(templates): extract shared header from admin pages
- Replace inline nav code with @Header component in admin.templ
- Replace inline nav code with @Header component in admin_library.templ
- DRY up navigation, theme switcher, and user menu across admin pages
2026-02-22 18:40:18 -05:00
john-okeefe 55440e0dc8 feat(devops): improve Docker build caching and add dev workflow targets
- Optimize Dockerfile layer caching with --mount=type=cache for Go modules and npm
- Reorganize Dockerfile layers for better cache hit rates
- Improve .dockerignore organization with categorized comments
- Add Makefile targets: up, down, rebuild-app, restart, ps
- Enhance Makefile help output with categorized sections
2026-02-22 18:40:16 -05:00
john-okeefe 48937e9777 feat(auth): improve registration form theming and add name fields
- Add theme.js script for proper theme support
- Update form to use CSS variables (--bg-primary, --text-secondary, etc.)
- Replace hardcoded colors with theming system
- Add optional first_name and last_name fields
- Update button to use .btn-primary class
- All form inputs now properly themed
2026-02-22 16:51:27 -05:00
john-okeefe 807d7b36ef refactor: update sevenzip import to use vendored package
Updated import path from github.com/bodgit/sevenzip to
bookhoard/internal/sevenzip to use the vendored package.
2026-02-22 16:29:28 -05:00
john-okeefe 82efb0d635 chore: remove go4.org dependency and associated telemetry packages
Removed go4.org and its transitive dependencies from go.mod and go.sum:
- go4.org (unused dependency)
- google.golang.org/api/* packages
- google.golang.org/genproto/* packages
- cloud.google.com/go/* packages
- gocloud.dev/* packages

Total reduction: ~4.9 MB of unnecessary telemetry dependencies.
All functionality preserved through vendored sevenzip package.
2026-02-22 16:29:25 -05:00
john-okeefe 46ae45ee92 feat: vendor bodgit/sevenzip package to remove go4.org dependency
Vendored the sevenzip package to eliminate dependency chain:
- sevenzip -> go4.org -> 25+ Google/Cloud/telemetry packages

Changes:
- Added internal/sevenzip/ with full package source
- Inlined go4.org/readerutil into multireaderat.go
- Updated all internal imports to use bookhoard/internal/sevenzip
- Preserved .cb7 comic archive support

This reduces bloat by ~4.9 MB and removes unused telemetry
dependencies while maintaining all functionality.
2026-02-22 16:29:21 -05:00
john-okeefe c6cf038c8e chore(deps): upgrade @tailwindcss/forms to v0.5.11
- Upgrade @tailwindcss/forms from 0.5.7 to 0.5.11 (latest)
- Regenerate minified CSS with new forms plugin
- Build and tests passing
2026-02-22 13:32:51 -05:00
john-okeefe 94e179d9bf removed finished plans
- Carousel has been implemented and tested
- API Consolidation has been implemented and tested
2026-02-22 13:18:03 -05:00
john-okeefe 87e28d18ff chore(deps): upgrade indirect dependencies
Upgrades indirect dependencies:
- davecgh/go-spew: v1.1.1 → v1.1.2
- kr/pretty: v0.3.0 → v0.3.1
- pmezard/go-difflib: v1.0.0 → v1.0.1
- stretchr/objx: v0.5.2 → v0.5.3
- xyproto/randomstring: v1.0.5 → v1.2.0

Also upgrades related cloud, opentelemetry, and grpc
dependencies to their latest compatible versions.

Build and all tests passing.
2026-02-22 13:13:43 -05:00
john-okeefe 9e420b63ad chore(deps): upgrade core dependencies
- pgx/v5: v5.4.3 → v5.8.0
- golang-jwt/jwt/v5: v5.3.0 → v5.3.1
- echo/v4: v4.13.4 → v4.15.1
- google/uuid: v1.4.0 → v1.6.0
- golang.org/x/crypto: v0.46.0 → v0.48.0
- golang.org/x/text: v0.33.0 → v0.34.0

Also updates indirect dependencies including puddle/v2, brotli,
regexp2, and other transitive deps.

Build and tests passing with pgx v5.8.0 (internal/anynil package
removed but not used by our code).
2026-02-22 13:11:06 -05:00
john-okeefe 31e286a14b fix(handlers): check user existence before deletion in DeleteUser
Add explicit check to verify target user exists in database before
attempting deletion. Previously, the handler would return 200 OK when
trying to delete non-existent users.

Changes:
- Add userFound flag to track if target user was found in user list
- Explicitly check pgtype.UUID.Bytes against all users' IDs
- Return 404 Not Found if user doesn't exist (before last admin check)
- Supports both JSON and HTML (HTMX) response formats

This fixes the failing test:
- TestDeleteUserConsolidated/DELETE_/api/auth/profile/:id_-_Delete_non-existent_user

The check uses the existing ListUsers result, so no additional database
query is required. The pgtype.UUID.Bytes comparison ensures exact
16-byte UUID matching.
2026-02-22 12:17:50 -05:00
john-okeefe 19e389f966 test: fix password mismatch test to use valid complex passwords
The test was using simple passwords ('password1', 'password2') that
failed complexity validation before the mismatch check could run.

Changed to use valid complex passwords that don't match:
- new_password: 'NewPassword123!'
- confirm_password: 'DifferentPass123!'

This properly tests the mismatch validation path. All 4 subtests in
TestUpdatePasswordAdminMode now pass.
2026-02-22 11:43:42 -05:00
john-okeefe 4cee9966c3 docs: add testing guide for developers
Add comprehensive testing documentation covering:
- Test email domain usage (@tests.bookhoard.internal)
- Standard test users and their credentials
- Test lifecycle and cleanup process
- How to write tests properly
- Running tests (make targets, specific tests)
- Test organization and helper functions

This helps developers understand the testing infrastructure and
prevents accidental data loss when running tests.
2026-02-22 11:21:25 -05:00
john-okeefe 70dd89ceac test(bruno): update API tests to use @tests.bookhoard.internal
Update test email domain in Bruno API collection files:
- Login User.yml
- Register User.yml
- Update Profile.yml

Ensures API tests use the dedicated test domain and won't conflict
with real user data when developers run tests.
2026-02-22 11:21:15 -05:00
john-okeefe 89732b041b test: update test files to use @tests.bookhoard.internal domain
Update email domain in remaining test files:
- device_cap_test.go
- device_test.go
- queue_test.go
- refresh_token_test.go
- seven_day_session_test.go

All test files now consistently use the dedicated test domain
to prevent conflicts with real user data.
2026-02-22 11:21:00 -05:00
john-okeefe 8ba8601841 test(user): fix TestUpdateProfileAdminMode test failures
- Fix username conflict: use unique name 'updateduser-admin-test'
- Fix 'last admin' test: explicitly delete regular user and verify admin count
- Add missing Content-Type header to PUT request
- Fix assertion: match actual validator error message ('oneof')
- Update email domain references to @tests.bookhoard.internal

All 5 subtests now pass:
- Admin update username ✓
- Admin promote user to admin ✓
- Try to demote last admin ✓
- Non-admin tries update ✓
- Invalid role ✓
2026-02-22 11:20:31 -05:00
john-okeefe cbf80037c4 test(improve): use dedicated test domain and improve cleanup
- Change test email domain from @example.com to @tests.bookhoard.internal
- This prevents accidental deletion of real user data when self-hosters run tests
- Improve test cleanup: delete ALL users with test domains before each test
- Ensures complete test isolation by cleaning up users from previous tests
- Handles edge cases where tests promote users to admin or modify accounts

The @tests.bookhoard.internal domain is clearly for testing only and
won't conflict with real user emails.
2026-02-22 11:20:15 -05:00
john-okeefe 334af53749 chore(templates): remove obsolete admin profile template files
Remove admin_profile.templ and admin_profile_templ.go as they have been
replaced by the new consolidated user management templates.
2026-02-22 02:00:47 -05:00
john-okeefe 2b92d5c6c1 test(bruno): update API collections for consolidated endpoints
Add collections for Delete User, Reset User Password, and Update User
endpoints. Remove obsolete collections for individual profile update
operations. Update Update Profile collection to reflect new consolidated
API structure.
2026-02-22 01:59:58 -05:00
john-okeefe ff25454901 docs: update API documentation for consolidated user management
Add documentation for delete_user and reset_user_password endpoints.
Update update_profile to reflect consolidated endpoint. Remove obsolete
documentation for individual update operations. Add profile guide for
end-users. Update API_CONSOLIDATION_PLAN.md with implementation status.
2026-02-22 01:59:52 -05:00
john-okeefe 9ea0ec5a3e feat(templates): consolidate admin and profile templates
Add admin_users.templ for user management interface with delete, password
reset, and edit capabilities. Add profile.templ and related components for
user profile management. Remove admin_profile.templ. Update all templates
to use new consolidated API endpoints.
2026-02-22 01:58:02 -05:00
john-okeefe 930d020ec1 feat(router): add routes for consolidated user management
Add DELETE /api/auth/users/:id, PUT /api/auth/users/:id/password, and
PUT /api/auth/users/:id routes. Remove individual profile update routes
in favor of consolidated endpoints.
2026-02-22 01:57:56 -05:00
john-okeefe bb0970dfd0 feat(handlers): implement consolidated user profile endpoints
Implement DeleteUser, ResetUserPassword, and UpdateUserAdmin handlers.
Update collections handler to check soft-deleted users. Update dashboard
service to exclude deleted users from statistics.
2026-02-22 01:57:49 -05:00
john-okeefe e3a3aa124f feat(api): consolidate user profile update endpoints
Add delete_user, reset_user_password, and update_user endpoints to replace
individual update operations. Update database schema to include deleted_at
column for soft deletion. Add DeleteUser, ResetUserPassword, and
UpdateUserAdmin queries. Update Querier with new methods for user management.
2026-02-22 01:57:42 -05:00
john-okeefe 86cc9b4e59 test(opds): fix token invalidation by restructuring tests
Restructure TestOPDSEndpoints and TestOPDSConversion to follow the Kobo
test pattern. Create all media items at parent level before any subtests
run, avoiding token invalidation when setupDeviceTest is called. Subtests
now use pre-created media IDs and device.AuthToken for authentication.
2026-02-22 01:57:28 -05:00
john-okeefe f54508e4dd test: improve test isolation and setup management
Add Token and RegularToken fields to TestServerSetup for pre-authenticated
access. Update setupTestServer to create fresh users with valid tokens at
initialization time. Simplify createTestMediaItemID to use setup.Token.
Remove loginTestUser, loginRegularUser, loginAdminUser functions in favor
of setup.Token/setup.RegularToken. Update createTestUserOnce and
getTestUserID/getRegularUserID to be idempotent. Update all test files to
use setup.Token instead of calling login helpers.
2026-02-22 01:57:22 -05:00
john-okeefe 9a09161f24 build: update tailwind config to include TypeScript sources
- Add ./web/src/**/*.ts to tailwind content paths
- Regenerate CSS with updated config
2026-02-21 00:59:51 -05:00
john-okeefe b5899af3c3 refactor(templates): consolidate header.js loading
- Move header.js script from individual templates to header.templ
- Removes duplicate script tags from bookshelf, collections, progress, etc.
- Fixes indentation in docs.templ
2026-02-21 00:59:42 -05:00
john-okeefe a47ef18669 docs: add inline JS exception to guidelines
Inline JS function calls in HTML attributes (e.g., onclick="myFunction()")
are acceptable for simple interactions
2026-02-21 00:59:34 -05:00
john-okeefe d0a2042344 docs: add API consolidation implementation plan
- Comprehensive 8-phase plan for consolidating profile endpoints
- Self-service profile: PUT /api/auth/profile for users
- Admin user management: profile updates, password resets, deletions
- Frontend: universal /profile page, /admin/users with modal editing
- Security: last-admin protection throughout
- Follows KISS principle: copy/paste logic, no over-engineering
2026-02-21 00:58:50 -05:00
john-okeefe 66e0b61200 test(collections): replace broken unit tests with integration tests
Removed unit tests that couldn't work without a database (nil db would
panic). Added comprehensive integration tests for the PreviewCollection
endpoint covering:
- Authentication (no auth, valid auth)
- Input validation (missing/invalid library ID, invalid JSON)
- Manual book selection
- Rule-based filtering
- Limit parameter handling
- Duplicate and invalid book ID handling
2026-02-20 17:04:15 -05:00
john-okeefe 33fcc416b9 fix(collections): add authentication check to PreviewCollection handler
The PreviewCollection endpoint was missing authentication verification,
allowing unauthenticated access to the preview functionality. Added
check for user in context, returning 401 Unauthorized if missing.
2026-02-20 17:04:02 -05:00
john-okeefe 542fbea313 fix(auth): correct JWT token lookup to strip Bearer prefix
The TokenLookup config was missing the Bearer prefix stripper, causing
all authenticated requests to fail with 'token is malformed'. The JWT
library was trying to decode 'Bearer eyJh...' as a token, failing at
the space character.

Changed from: 'cookie:token,header:Authorization'
Changed to:   'cookie:token,header:Authorization:Bearer '

This fixes all integration tests that use Bearer token authentication.
2026-02-20 17:03:53 -05:00
john-okeefe 1095609302 test: fix Bruno auth test sequence and add registration data
Correct the sequence numbers for logout and refresh token tests.
Add sample registration data to the Register User test.
2026-02-20 13:26:51 -05:00
john-okeefe 4988eb8b27 docs: add exception for inline CSS in error template
Allow inline CSS in templates/error.templ since error pages must work
when the main app fails (404, server errors, CSS fails to load).
2026-02-20 13:26:40 -05:00
john-okeefe 0c515a277c refactor(templates): add error toast support to page templates
Update all page templates to accept an optional error message parameter
and display it via the ErrorToast component when data loading fails.
2026-02-20 13:25:49 -05:00
john-okeefe 7c652d5a3a feat(router): improve error handling with dedicated error pages
- Add renderErrorPage helper for consistent error rendering
- Add ensureUserExistsMiddleware to detect deleted users and redirect to login
- Add catch-all 404 handler for unknown routes
- Gracefully handle data loading failures with error messages instead of crashing
- Log errors for debugging while still rendering pages
2026-02-20 13:25:41 -05:00