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:
@@ -33,6 +33,20 @@
|
||||
* The sync button (phase 32) + the live two-job progress contract
|
||||
* (phase 64 task 04) and the table rows (phase 26: same-page modal
|
||||
* links) are unchanged in content — only the boot shape moved.
|
||||
*
|
||||
* Phase 77 (task 02) — the re-show refresh: the shell router
|
||||
* dispatches `bor:view-refresh` on the view's section when the user
|
||||
* RE-SHOWS an already-mounted view (a switch back onto it, a re-click
|
||||
* of the RAG nav link, or back/forward) — the first show (mount) and
|
||||
* boot never (the mount's own load is the first fetch). This module
|
||||
* listens on root and re-runs `loadDocs()`, which is now re-entrant:
|
||||
* a re-load drops the tbody's rows BEFORE the fetch, so a refresh
|
||||
* from a populated list into an empty result replaces the list
|
||||
* (no ghost rows) — the History pattern (task 01). #sources-empty
|
||||
* lives OUTSIDE the tbody (a .empty-state div), so the top clear is
|
||||
* a bare replaceChildren(). The listener is armed only in the ADMIN
|
||||
* branch, after the whoami gate passes: anonymous shows the gate and
|
||||
* never fetches /api/docs (the phase-16 soft rule).
|
||||
*/
|
||||
|
||||
import { fetchIsAdmin } from "./header.js";
|
||||
@@ -469,25 +483,40 @@ export async function mount(root) {
|
||||
}
|
||||
|
||||
|
||||
/* Phase 77 (task 02): re-entrant — the top clear (the History
|
||||
pattern from task 01) drops the tbody's rows BEFORE the fetch,
|
||||
so a re-show refresh from a populated list into an empty result
|
||||
replaces the list instead of leaving ghost rows. #sources-empty
|
||||
lives OUTSIDE the tbody (a .empty-state div, not a row), so the
|
||||
clear is a bare replaceChildren(). Phase 79 (task 04): the clear
|
||||
alone is NOT enough when two loads interleave — the boot re-attach
|
||||
(applySyncSuccess → loadDocs) and the boot-time loadDocs both clear
|
||||
first, then the SLOWER fetch appends after the newer load's clear,
|
||||
duplicating every row (2×). The monotonic seq token invalidates an
|
||||
in-flight load the moment a newer one starts: only the newest load
|
||||
may touch the DOM after its await. */
|
||||
let loadSeq = 0;
|
||||
async function loadDocs() {
|
||||
const my = ++loadSeq;
|
||||
tbody.replaceChildren();
|
||||
let r;
|
||||
try {
|
||||
r = await fetch("/api/docs");
|
||||
} catch {
|
||||
showEmpty();
|
||||
if (my === loadSeq) showEmpty();
|
||||
return;
|
||||
}
|
||||
if (!r.ok) {
|
||||
showEmpty();
|
||||
if (my === loadSeq) showEmpty();
|
||||
return;
|
||||
}
|
||||
const { documents } = await r.json();
|
||||
if (my !== loadSeq) return; // a newer load owns the tbody now
|
||||
if (!documents.length) {
|
||||
showEmpty();
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.replaceChildren();
|
||||
let totalChunks = 0;
|
||||
let last = "";
|
||||
for (const d of documents) {
|
||||
@@ -564,5 +593,12 @@ export async function mount(root) {
|
||||
return;
|
||||
}
|
||||
if (gateEl) gateEl.hidden = true;
|
||||
/* Phase 77 (task 02): a user-initiated re-show of this already-
|
||||
mounted view makes the router dispatch bor:view-refresh on the
|
||||
section — re-load the catalog then (loadDocs is re-entrant).
|
||||
Armed ONLY here, after the whoami gate passed: anonymous shows
|
||||
the gate and must never fetch /api/docs (the phase-16 soft
|
||||
rule the story E2E pins). */
|
||||
root.addEventListener("bor:view-refresh", () => loadDocs());
|
||||
loadDocs();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user