Data UI Backlog

Embedded child region: 4. Post scope

The escape hatch: finding routes to the comments tab, never to new region state. The scope is its own state slot and its own URL dimension in the urlState.ts closed set — UrlState, QueryFields, parseHash, canonicalize (absent and default both drop, or the writer loops), urlStatesEqual, and a writer path that never goes through the filters maps; a new field, never a reuse of id. fetchList emits the scope as the fk-eq row; the filter bar renders the chip "Post: <title> ×" through the active-chips path, and the × is a scope-slot clearer that never calls toggleChipFilter. Title resolution is one cached /api/item fetch, failing closed. The footer link ("All N comments »", N from the region fetch's total) lands here and performs the hop; the hop closes the parent form on purpose. The 12,000-comment figure is the story; the seed is 200 rows. Gate: the plan's full acceptance script, all six steps.

Plan: 04-post-scope.org

Implemented per the plan. urlState.ts: discriminated ScopeState (none / valid {via, id} / invalid {raw}) with pure parseScope (exactly one :, two nonempty halves; post:garbage structurally valid for the server) / scopeToParam / shared SCOPE_NONE constant; UrlState grows the scalar fk?: string (presence significant even when empty); QueryFields.scope required (all literals updated); parseHash uses getAll (one param → raw, duplicates → the empty invalid marker); canonicalize requires type exactly as id, lowercases only the id half of a valid pair, and keeps an invalid raw present — including fk: '' — never canonicalizing malformed input to absence; buildUrlState routes the ScopeState through scopeToParam; writeUrl serializes every canonical present fk (the %3A → : unescape keeps the shared-link spelling fk=post:<uuid>) so the writer loop and the duplicate-URL equality gate hold; urlStatesEqual untouched (scalar walk). App.tsx: scope is its own state slot (never listFilters, never id); fetchList emits [listedType, via, "fk-eq", id] independently of formReady and before the nonempty check (a cold scoped request carries fk-eq on the first request — no unscoped bootstrap, no pendingFormRefetch arming), and an invalid scope stands down before apiFetch (sequence allocated, error + envelope cleared, no fetch, no stale rows); resetListQuery clears it; the hop onShowAll(spec, parentId) (one explicit Region callback prop — Region owns the link and its current total, App owns navigation: mark push, changeType exactly once, then setData(null) + install valid {via, id} after the reset; writer effect creates the hash entry; parent form closes through changeType → clearRecordTarget, no hashchange wait); clearScope (scope × and the invalid-surface Clear control: synchronous listSeq bump, envelope clear, push mark, scope → none, page 1, selection clear — never toggleChipFilter, never a stale-closure fetch; the fetch effect's scope dep owns exactly one replacement fetch; search/chips/bools preserved); Clear filters now also synchronously invalidates, marks push, clears the scope (plus the envelope when a scope stood), still restores authored bool defaults and preserves q / notq; anyFilterActive gains the scope-present arm (scope-only bar lights the button); the filter bar mounts on scope presence and renders Post: <title> × / Post × (never the uuid) through the shared ScopeChip; the no-data shell renders the generic Post × beside the no-records/error line and the neutral "Invalid post scope" + Clear scope notice for structural garbage. Title resolution: raw FK metadata from the arrived list form only when type-key matches (viaMeta.target / viaMeta.column — never buildChipFieldMeta, never Field.table); one /api/item?type=…&form=view-form fetch per (session epoch, target type, id) with an epoch-keyed cache + in-flight dedup; success requires OK + non-array object record + case-insensitive id match + type match when present + nonblank record[titleKey] — anything else caches a failure and renders Post ×; visible commits fenced by (epoch, latest title sequence, current key ref assigned during render — the fetchListRef pattern — so A→B and A→clear responses populate only their own cache entry and a delayed privileged response after guest login writes nothing); resetSessionState advances the epoch, clears cache/in-flight/visible, fences outstanding work. Scope rides the login seed's full assignment (both arms), the history listener's full assignment + equality-gate object + dep array, the writer effect's object + deps, and the fetch effect's deps; a scope-changing history arrival clears the old envelope synchronously beside the listener's listSeq bump (no stale rows under a pending scoped request). Record opens from the scoped tab keep fk beside id; copyBestLink untouched (copies type + id only). Region: onShowAll optional prop; footer link "All N <type> »" beside the pager, gated !inFlight && !failed (never a stale or failed total), absent in the render-nothing empty state by construction. urlState.test.mjs grew to 60 checks (23 new: valid/non-UUID/bare/empty-half/extra-colon/empty-string parse, duplicate-param marker, fk-beside-id, canonical lowercasing of only the id half, no-type drop, raw survival through parse → canonicalize → state → build → write incl. the empty marker, duplicate-URL no-push, scoped/unscoped inequality, full round trip); npm run test:url-state (60), test:region (37), npm run build (374.10 kB) all green. Live-REPL smoke on seeded blog-test: comments list-form :post carries :target :posts + :column "title" (the title-resolution metadata path), a parsed fk-eq row over parse-filters returns the honest scoped :total (3 on the seeded post, 0 on an unknown uuid), and be-rec view-form emits the region spec. Full suite green (2667 checks, 49 groups). The plan's six-step browser acceptance script (hop/history shape, fail-closed hand edits, composition, title sessions/races, return) and the temporary no-search/no-chip variant are manual passes — no JS test harness exists; the fixture is loaded in the development image for them. One reading pinned: the Region footer link renders only in the non-empty main path ("beside the pager"), so a zero-comment create-allowed region shows the Add-only empty state without the link.

Slot
4400
Status
60 Done
Tags
mvp, backend, frontend, model, blog
Contributors
Donnie