phase: 93_theme_semantic_completion
Build and Push Containers / build-and-push-app (push) Successful in 1m56s
Build and Push Containers / build-and-push-db (push) Successful in 11s

All verification is complete. Final report:

**Phase 93 — Theme semantic completion: FINAL VERIFICATION PASS — ALL GREEN**

- Verified full implementation in tree: migration `0016` (8 nullable semantic columns, applied at head), 17-var `BUILTIN_COLORS`/`COLOR_FIELDS`/`effective_settings`, API validation, `#view-theme` State-colors fieldset (17 pickers), `theme.js` FIELDS/PAIRS (5→8), `.page-head` surface panel (6 shell views + doc-edit + shared.html; login card / document sticky header audited as already-surfaced), mock_llm `content: None` fix
- Fixed 2 pre-existing defects (both fail identically on baseline `d4f38ad`, proven via worktree A/B): `test_nav_rename_sources` — expected nav tail missing the phase-91 "Theme" link; `test_stale_ui_copy` — now truncates `saved_chats` before/after (house `test_suggestion_chips` pattern) so the seed-chip contract is deterministic on the shared dev DB (owner's 22 saved chats triggered phase-80 last-3-questions)
- Tests: `uv run pytest --cov=app --cov-report=term-missing` → **1868 passed, app/ 99%** (>90% ✓); `uv run ruff check .` → clean; `uv run pyright` → **0 errors**
- E2E: dedicated `uv run pytest tests/e2e/test_theme_semantic_completion.py -v --no-cov` → **8/8 in isolation** (all-gray 17-color theme: zero residual color on saved-result/Stale/Revoked/Local/tool-call elements, text labels intact, gray heads non-transparent, pre-paint tag, Reset → byte-identical no-tag); 15 theme/header/nav/responsive suites green in isolation; full 85-file combined run: only the 2 fixed pre-existing failures + 1 combined-run artifact (`test_sync_upload_progress`, green in isolation)
- Completion criteria: (1) monochrome E2E ✓ (2) default byte-identical, no `#bor-theme` tag ✓ (3) all page heads on solid surface ✓ (4) suite/coverage/lint/E2E green ✓ (5) phases 01–92 no behavior change ✓ (6) commit left to harness per protocol
- Notable: cleaned stray uvicorn leftovers from prior implementation pass (owner's `--reload` dev server untouched); no deviations from the phase design
- Next pending phase: `94_ls_tree_drilldown`
This commit is contained in:
2026-09-10 16:43:08 -04:00
parent d4f38ad3ce
commit 9188be259b
44 changed files with 3019 additions and 196 deletions
+56 -4
View File
@@ -1,11 +1,14 @@
"""Unit: the admin UI-settings API (phase 91, task 01).
Covers ``app/api/ui_settings.py`` — the PUT validation + normalization
contract and the GET/PUT persistence on the single ``ui_settings`` row:
contract and the GET/PUT persistence on the single ``ui_settings`` row
(all 17 palette colors since phase 93, task 01 — the 9 identity +
the 8 semantic state):
* PUT validation — the 422s NAME the offending field (fixed details):
a >300-char string after the trim, a non-``#rrggbb`` color (wrong
prefix, 3-digit shorthand, 8 hex chars, missing ``#``);
prefix, 3-digit shorthand, 8 hex chars, missing ``#``) — identity AND
semantic fields alike (the loops are ``COLOR_FIELDS``-driven);
* normalization — colors are lowercased on store; a color EQUAL to its
built-in is stored as NULL (the owner-locked rule: "save the defaults"
must leave the row empty — the no-op injection contract); an empty /
@@ -38,6 +41,10 @@ ALL_NULL_BODY: dict[str, str | None] = {
"bg": None, "surface": None, "ink": None, "ink_soft": None,
"line": None, "grid_line": None, "brand": None, "brand_soft": None,
"brand_ink": None,
# The 8 semantic state colors (phase 93, task 01).
"ok_bg": None, "ok_ink": None, "err_bg": None, "err_ink": None,
"err_line": None, "accent_bg": None, "accent_ink": None,
"accent_line": None,
}
@@ -80,8 +87,8 @@ def test_put_too_long_string_422_names_the_field(
def test_put_bad_hex_422_names_the_field(admin_client: TestClient) -> None:
"""Each of the 9 colors: anything not ``^#[0-9a-fA-F]{6}$`` is a 422
naming that field — 3-digit shorthand, 8 hex digits, a bare hex
"""Each of the 17 colors: anything not ``^#[0-9a-fA-F]{6}$`` is a
422 naming that field — 3-digit shorthand, 8 hex digits, a bare hex
without ``#``, a named color, and the empty string (the color clear
operation is ``null``, not ``""``)."""
for field in theming.COLOR_FIELDS:
@@ -95,6 +102,15 @@ def test_put_bad_hex_422_names_the_field(admin_client: TestClient) -> None:
r = admin_client.put("/api/ui-settings", json={"grid_line": "nope"})
assert r.status_code == 422, r.text
assert r.json()["detail"] == "grid_line must be a #rrggbb hex color"
# Phase 93 (task 01): the semantic state fields name their 422 the
# same fixed way (the loop covers all 8 via COLOR_FIELDS; the
# explicit case pins a semantic field name in the detail).
r = admin_client.put("/api/ui-settings", json={"err_line": "nope"})
assert r.status_code == 422, r.text
assert r.json()["detail"] == "err_line must be a #rrggbb hex color"
r = admin_client.put("/api/ui-settings", json={"accent_ink": "#12345678"})
assert r.status_code == 422, r.text
assert r.json()["detail"] == "accent_ink must be a #rrggbb hex color"
def test_put_lowercases_colors_on_store(
@@ -158,6 +174,42 @@ def test_put_grid_line_built_in_is_stored_as_null(
assert row.grid_line == "#123123" # non-built-in is stored as-is
def test_put_semantic_built_in_is_stored_as_null(
admin_client: TestClient, db: Session
) -> None:
"""Phase 93 (task 01): the 8 semantic state colors get the same
owner-locked normalization as the 9 identity colors — a value equal
to its built-in stores NULL (the response still reports the
built-in; the compare happens AFTER the lowercase — one value is
PUT uppercase, proving it); a NON-built-in value is stored as-is
(lowercased)."""
r = admin_client.put("/api/ui-settings", json={"ok_ink": "#6EE7A8"})
assert r.status_code == 200, r.text
assert r.json()["ok_ink"] == theming.BUILTIN_COLORS["ok_ink"]
row = _row(db)
assert row is not None
assert row.ok_ink is None # built-in (uppercase in) → NULL
r = admin_client.put("/api/ui-settings", json={"err_bg": "#2D0A0A"})
assert r.status_code == 200, r.text
db.expire_all() # drop the test session's pre-second-PUT view (house pattern)
row = _row(db)
assert row is not None
assert row.err_bg is None # the second built-in (uppercase) → NULL too
r = admin_client.put("/api/ui-settings", json={"accent_ink": "#CCCCCC"})
assert r.status_code == 200, r.text
assert r.json()["accent_ink"] == "#cccccc"
db.expire_all()
row = _row(db)
assert row is not None
assert row.accent_ink == "#cccccc" # non-built-in stored as-is, lowercased
# A semantic field NOT in the body clears back to NULL (full
# replacement — the built-in returns via the resolver).
assert row.ok_ink is None
assert r.json()["ok_ink"] == theming.BUILTIN_COLORS["ok_ink"]
def test_put_empty_string_is_the_clear_operation(
admin_client: TestClient, db: Session
) -> None: