All verification is complete — this pass needed no code changes. Final report: **Phase 91 — Admin Theme tab: final verification pass (all 6 tasks already in `complete/`)** - Verified pre-paint theming end-to-end: `ui_settings` store + resolver, admin `GET/PUT /api/ui-settings`, `CachingMiddleware` inline-`<style id="bor-theme">` injection before `</head>` (incl. `/shared/<token>` prefix branch, unit-pinned), CSP sha256 exemption for the inline tag, Theme tab shell + `theme.js` editor, CSS-file theming fully retired. - No defects found; zero changes made — working tree left exactly as the task executors left it. - Tests: `uv run pytest --cov=app` → 1841 passed, 0 failed (TOTAL coverage **99%**; theming/ui_settings/caching all 100%); `uv run pytest tests/e2e/test_admin_theme_tab.py -v --no-cov` → **5 passed** in isolation. - Lint/types: `uv run ruff check .` → All checks passed; `uv run pyright` → 0 errors, 0 warnings. - Criteria: (1) unset deployment byte-identical, no `#bor-theme` anywhere — ✓ (unit no-op test + E2E reset byte-compare); `rg "BOR_THEME|themes/"` → single hit is the permitted doc-history comment in `frontend/index.html`. (2) admin-only gate + 403s for anonymous and token users — ✓ (E2E test 3). (3) saved theme inline before `</head>` on every page incl. `/shared/<token>`, computed `--brand` on first paint for admin + anonymous — ✓ (E2E test 2 + unit). (4) reset → byte-identical; 5 contrast pairs warn <4.5:1, non-blocking — ✓ (E2E tests 4–5). (5) suite green, >90% coverage, lint clean — ✓. (6) commit deferred to harness per rules. - Notable: `.agents/PLAN.md` is absent from the repo — the phase overview's Design section was used as the binding spec; no deviation resulted. - Next pending phase: **none** — 91 is the last phase in `todo/`.
55 lines
2.4 KiB
Python
55 lines
2.4 KiB
Python
"""Public app metadata (display name + version) for the frontend brand
|
|
layer, the phase-59 docs-push flag (the "Save as doc" gating), and the
|
|
phase-62 UI customization strings (composer placeholder, footer line).
|
|
|
|
Phase 91 (task 01): the three UI strings are now the EFFECTIVE values —
|
|
the ``ui_settings`` row (admin Theme tab) over the env values (B1: DB
|
|
wins when set, env is the fallback), resolved by the SAME
|
|
:func:`app.core.theming.effective_settings` resolver the
|
|
``/api/ui-settings`` API uses, so the brand layer and the tab can never
|
|
disagree. The route opens a short-lived session (the sync-endpoint
|
|
house pattern — the route is sync, matching the middleware world).
|
|
|
|
Phase 91 (task 03): the retired CSS-file theming's ``theme`` key is
|
|
deleted with the mechanism — the five keys below are the entire
|
|
contract (the colors never rode this endpoint; the server injects
|
|
them pre-paint, :mod:`app.core.theming`).
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from app.config import Settings, get_settings
|
|
from app.core import theming
|
|
from app.db import SessionLocal
|
|
|
|
router = APIRouter(tags=["config"])
|
|
|
|
|
|
@router.get("/config")
|
|
def app_config(settings: Settings = Depends(get_settings)) -> dict[str, str | bool]: # noqa: B008
|
|
"""Public app metadata for the frontend brand layer (phase 39) +
|
|
the phase-59 ``docs_repo_configured`` flag + the phase-62 UI
|
|
customization keys (``input_placeholder``, ``footer_text``) — all
|
|
display strings, the SAME boot fetch (no new network surface) and
|
|
the same public posture as ``app_name`` (no secrets). Phase 91:
|
|
``app_name`` / ``input_placeholder`` / ``footer_text`` are the
|
|
EFFECTIVE values (the admin Theme tab's ``ui_settings`` row over
|
|
the env values — DB-over-env, B1); the frontend brand layer treats
|
|
an empty string as "keep the template default" (the unset =>
|
|
byte-identical contract). Phase 91 (task 03): the retired
|
|
CSS-file theming's ``theme`` key is gone — the five keys are the
|
|
entire response."""
|
|
db = SessionLocal()
|
|
try:
|
|
effective = theming.effective_settings(db, settings)
|
|
finally:
|
|
db.close()
|
|
return {
|
|
"app_name": effective["app_name"],
|
|
"version": settings.app_version,
|
|
"docs_repo_configured": settings.docs_configured,
|
|
"input_placeholder": effective["input_placeholder"],
|
|
"footer_text": effective["footer_text"],
|
|
}
|