Task 0.1: Create database parent directory before connecting - main.py _lifespan now calls Path(database_path).parent.mkdir(parents=True, exist_ok=True) before aiosqlite.connect() so the app starts cleanly on a fresh Docker volume with a nested database path. Task 0.2: SetupRedirectMiddleware redirects when db is None - Guard now reads: if db is None or not is_setup_complete(db) A missing database (startup still in progress) is treated as setup not complete instead of silently allowing all API routes through. Task 0.3: SetupGuard redirects to /setup on API failure - .catch() handler now sets status to 'pending' instead of 'done'. A crashed backend cannot serve protected routes; conservative fallback is to redirect to /setup. Task 0.4: SetupPage shows spinner while checking setup status - Added 'checking' boolean state; full-screen Spinner is rendered until getSetupStatus() resolves, preventing form flash before redirect. - Added console.warn in catch block; cleanup return added to useEffect. Also: remove unused type: ignore[call-arg] from config.py. Tests: 18 backend tests pass; 117 frontend tests pass.
2.4 KiB
BanGUI — Task List
This document breaks the entire BanGUI project into development stages, ordered so that each stage builds on the previous one. Every task is described in prose with enough detail for a developer to begin work. References point to the relevant documentation.
Stage 0 — First-Run Bootstrap & Startup Fix
These tasks fix a crash-on-first-boot regression and make the setup/login redirect flow reliable. They must be completed before any other feature work because the application cannot start without them.
Task 0.1 — Fix: Create the database parent directory before connecting ✅ DONE
File: backend/app/main.py
Implemented: In _lifespan, resolve settings.database_path to a Path, call .parent.mkdir(parents=True, exist_ok=True) before aiosqlite.connect(). Added debug-level structured log line after mkdir. Tests added in TestLifespanDatabaseDirectoryCreation.
Task 0.2 — Fix: SetupRedirectMiddleware must treat a missing database as "setup not complete" ✅ DONE
File: backend/app/main.py
Implemented: Changed the guard in SetupRedirectMiddleware.dispatch so that db is None also triggers the redirect to /api/setup. The condition is now if db is None or not await setup_service.is_setup_complete(db). The _setup_complete_cached flag is only set after a successful is_setup_complete(db) call with a live db. Tests added in TestSetupRedirectMiddlewareDbNone.
Task 0.3 — Fix: SetupGuard must redirect to /setup on API errors, not allow through ✅ DONE
File: frontend/src/components/SetupGuard.tsx
Implemented: Changed the .catch() handler to set status to "pending" instead of "done". Updated the comment to explain the conservative fallback. Tests added in SetupGuard.test.tsx.
Task 0.4 — Fix: SetupPage must redirect to /login when setup is already complete ✅ DONE
File: frontend/src/pages/SetupPage.tsx
Implemented:
- Added
checkingboolean state (initialised totrue). Whilecheckingis true, a full-screen<Spinner>is rendered instead of the form, preventing the form from flashing. - The
useEffectsetscheckingtofalsein both the.then()(when setup is not complete) and the.catch()branch. Added aconsole.warnin the catch block. Added acancelledflag and cleanup return to the effect. Tests added inSetupPage.test.tsx.