Exception handlers run outside FastAPI's dependency injection, so the error handler never resolved the session and always passed user=None, making every error page (e.g. a 404 hit while signed in) show the 'Sign In with Forgejo' header instead of the account menu.
Resolve the session by hand from the request cookie via lookup_session, degrading to None on any failure so error rendering can never itself raise. A missing or invalid cookie (a real 401) still yields None and the correct signed-out header.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The base.html live-reload poller is now wrapped in {% if debug %} so it
never ships to production. dev.sh exports DEBUG=true and uses 'entr -d' in
a loop so newly created templates are picked up (the old 'find | entr'
snapshot missed them), with a fallback when entr is not installed.
Move page routes to routers/dashboard.py, the content-negotiated error
handler to errors.py (register_error_handlers), and the dev css-mtime
endpoint to routers/dev.py (included only when debug). main.py shrinks to
lifespan + wiring + the / landing route.
Dashboard repos now load lazily via an htmx fragment so a slow/unreachable
Forgejo instance never blocks first paint; Forgejo html_url is sanitized
against non-http(s) schemes before rendering into href.
Centralize all Forgejo HTTP in app/services/forgejo.py (get/post +
authorize_url/exchange_code/fetch_user, typed ForgejoError, defensive
base-URL join). Centralize credential encryption in app/auth/tokens.py
(decrypt_pat/set_pat, set_client_secret/decrypt_client_secret) so the
get_fernet()+crypto+column pattern no longer leaks into routers.
auth/settings/setup now delegate to these modules; the duplicated
client-secret encrypt block and per-call httpx clients are gone.
Mirror the session.py dependency trio: current_app_settings (honest
optional accessor), get_app_settings (required; raises 500 if reached
unconfigured), and set_app_settings (single write path). Middleware reads
through the accessor instead of poking app.state directly.
get_app_settings takes request and calls current_app_settings internally
rather than declaring it as a sub-Depends — a Depends param typed with a
TYPE_CHECKING-only forward ref makes FastAPI drop the marker and treat it
as a query param.
Dark-only Tailwind v4 @theme tokens, cinematic landing hero, operational
dashboard styling, and the Firebreak logo/wordmark assets. Templates use
semantic component classes instead of inline styles and color literals.