feat: phases 77–80 — navbar view refresh, static background, API tokens, history suggestion chips
Single consolidated commit for four completed, validated phases (77, 78, 79, 80). The pipeline run left all work uncommitted because the harness commits only with PHASE_COMMIT=1 while child executors are forbidden from committing; the phases themselves all passed validation and moved to .agents/phases/complete/. Phase 77 — navbar view refresh - router.js dispatches bor:view-refresh on re-show / active re-click / popstate (gated on wasMounted; first show and boot exempt) - History / RAG / Sources / Tuning re-fetch on refresh (admin branch); Chat deliberately excluded (stream survival) - History "Refresh" button (admin-only, in-flight disable + status line) - New story suite tests/e2e/test_navbar_refresh.py (7 tests) Phase 78 — static background - Removed the animated glow layers; static 44px grid over the flat --bg canvas; default and reduced-motion renders byte-identical - Updated background/theme E2E suites; removed bg-glow test pins Phase 79 — API tokens - api_tokens model + migration 0012; hash-only token service - Admin tokens API + Tokens admin view; POST /api/token-auth; live-revoking require_user on chat / suggestions / document content - Frontend token gate with localStorage cache; anonymous E2E suites migrated to token login - New story suite tests/e2e/test_api_tokens.py (9 tests) Phase 80 — history suggestion chips - last_questions() endpoint with SEED fallback; startNewChat() refetch - Seed-semantics docs (config.py, .env.example, README) - Integration state matrix + E2E suite rewritten to the 4 chip states Also included: phase-76 report artifacts and the repo restore-test-db skill (previously untracked), scripts/* ruff fixes from phase 77. Final gate state (phase 80 final pass, covers everything above): - uv run pytest --cov=app → 1637 passed, 0 failed, app/ coverage 99% - uv run ruff check . && uv run pyright → clean, 0 errors - Per-phase story E2E suites green in isolation
This commit is contained in:
@@ -36,8 +36,9 @@ The admin edits through the REAL browser flow (form login → the
|
||||
viewer's Edit button → the inline editor → Save); the re-embed itself
|
||||
is then verified against the live database (the chunk's NEW content, a
|
||||
FRESH non-NULL vector, the content chunks byte-for-byte untouched — the
|
||||
D4 re-embed scope) and against the public content endpoint (no cookie —
|
||||
the viewer stays public, phase 16).
|
||||
D4 re-embed scope) and against the content endpoint (phase 79 superseded the
|
||||
phase-16 soft rule: the endpoint is require_user, so the pin runs
|
||||
under the admin session — the shape is unchanged).
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -57,7 +58,7 @@ from app.db import SessionLocal
|
||||
from app.models import Chunk, Document
|
||||
from app.rag.importer import ImportSummary, import_sources
|
||||
from app.rag.llm import LLMClient
|
||||
from e2e.auth_helpers import login
|
||||
from e2e.auth_helpers import ADMIN_PASSWORD, login
|
||||
from e2e.mock_llm import TOKEN_RE
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
@@ -183,12 +184,16 @@ def _chunk_state() -> dict[str, Any]:
|
||||
|
||||
|
||||
def _api_summary(app_url: str) -> str | None:
|
||||
"""The public content endpoint's ``summary`` — NO cookie (the viewer
|
||||
stays public, phase 16; a fresh httpx client carries no session)."""
|
||||
r = httpx.get(
|
||||
"""The content endpoint's ``summary``. Phase 79: the endpoint is
|
||||
require_user (the phase-16 soft rule is superseded) — the fresh
|
||||
httpx client signs in as the admin first (every caller is an
|
||||
admin-flow test)."""
|
||||
client = httpx.Client(timeout=10)
|
||||
r = client.post(f"{app_url}/api/login", json={"password": ADMIN_PASSWORD})
|
||||
assert r.status_code == 204
|
||||
r = client.get(
|
||||
f"{app_url}/api/documents/content",
|
||||
params={"source": SOURCE, "path": DOC_PATH},
|
||||
timeout=10,
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
return r.json()["summary"]
|
||||
@@ -334,27 +339,19 @@ def test_anonymous_cannot(page: Page, app_url: str) -> None:
|
||||
page.set_default_timeout(30_000)
|
||||
content = (FIXTURES / DOC_PATH).read_text(encoding="utf-8")
|
||||
expected = _expected_summary(content, SOURCE, DOC_PATH)
|
||||
digest_line, _ = expected.split("\n", 1)
|
||||
|
||||
# Fresh context (the function-scoped page fixture — no login): the
|
||||
# panel renders the digest, but the edit affordance is ABSENT — no
|
||||
# button, no header row, no editor wiring. The section keeps the
|
||||
# phase-36 byte-for-byte shape: a bare h2 + the text-node <p>.
|
||||
# Fresh context (the function-scoped page fixture — no login).
|
||||
# Phase 79 (task 05): the content endpoint is require_user — the
|
||||
# anonymous viewer meets the inline token gate (the content fetch
|
||||
# never runs — no summary panel, no not-found card either), so the
|
||||
# edit affordance is absent by construction.
|
||||
page.goto(_doc_url(app_url))
|
||||
panel = page.locator(".doc-summary")
|
||||
expect(panel).to_have_count(1)
|
||||
expect(panel).to_be_visible()
|
||||
expect(panel).to_contain_text(digest_line)
|
||||
expect(page.locator("#doc-auth-gate")).to_be_visible(timeout=15_000)
|
||||
expect(page.locator("#doc-title")).to_have_text("Loading…")
|
||||
expect(page.locator(".doc-summary")).to_have_count(0)
|
||||
expect(page.locator(".doc-summary-edit")).to_have_count(0)
|
||||
expect(page.locator(".doc-summary-head")).to_have_count(0)
|
||||
expect(page.locator(".doc-summary-editor")).to_have_count(0)
|
||||
children = page.evaluate(
|
||||
"() => [...document.querySelector('.doc-summary').children]"
|
||||
".map((el) => el.className)"
|
||||
)
|
||||
assert children == ["doc-summary-title", "doc-summary-text"], (
|
||||
f"anonymous panel drifted from the phase-36 shape: {children}"
|
||||
)
|
||||
|
||||
# The endpoint is admin-gated (D4): an anonymous PATCH → 403
|
||||
# "admin only" (a fresh httpx client carries no session), and the
|
||||
|
||||
Reference in New Issue
Block a user