PlotDirector/Docs/Codex/NamesWorkspace.md

49 lines
6.8 KiB
Markdown

# Names workspace
## Recorded usage and catalogue audit
The existing Name Intelligence catalogue stores classification, ambiguous-word flags, notes, locale/era profiles, gender weights, usage/confidence, provenance and related forms. Search ranks exact matches, then usage weight and display name, with bounded pagination. These filters and ordering remain in `GivenName_Search`.
Previously usage decoration joined primary names and aliases through scene membership, offered Book/Project/Library scope and repeated summaries per appearance. Neither the old main page nor Context retrieved manuscript paragraphs: their usage actions retrieved recorded identity associations. Ordinary catalogue searches do not invoke AI.
Migration 325 replaces scene-dependent usage with exact canonical comparison of recorded names and aliases in the authorised current series. It excludes an alias duplicating the same character's primary name. Different characters sharing a spelling remain independent associations. Character Type, species and story importance are returned from canonical records. No manuscript word occurrence establishes assignment.
## Shared presentation
`_NamesWorkspace`, `_NamesResults`, `_NameDetails`, `NamesWorkspace` and `names-workspace.js` implement the compact results and selected-name panel. Details use existing recognition metadata and the existing association repository only after selection. Catalogue searches retain pagination and never retrieve biographies or per-result occurrence lists.
The main page opts into the existing full-width shell. The selected panel is sticky, with bounded scrolling; narrow containers show details with Back to Results. Main-page interaction state uses session storage scoped to series. Main-page character actions navigate to canonical Details/Editor in the same window; returning restores workspace state. Context actions retain separate-window navigation.
Usage icons come from the existing SVG library: primary name uses the shared Character Type icon (including Animal paw), aliases use `name-alias`, available uses `name-available`. Selected details distinguish confirmed associations from textual matches. Explicit paragraph occurrence lookup and AI verification are subsequent phases of this implementation.
## Phase gates
Phase 1: Character Type migration 324 and SQL regression passed on a disposable Development clone. Build and full executable harness passed. Actual Chromium and installed Chromium PWA fixture interactions passed at 10/100/500 characters, including the new Type bulk assignment/Undo and existing interactions.
Phase 2: migration 325 and recorded-usage SQL regression passed on the disposable clone. Build and full executable harness passed. `Browser/names-workspace.cjs` passed normal and installed Chromium with compiled Razor, synthetic animal/alias details, all seven themes and viewport widths 390/768/1280/1920/2560/3840. Screenshots and measurements are in `/tmp/pd-names-workspace`. These are isolated fixture checks, not authenticated Development deployment acceptance.
No migrations have been applied to Development and no deployment has occurred during these phase gates.
## Context reuse
The pre-existing Names tab now mounts the same shared workspace. Its adapter only supplies authorised Context endpoints and retains component state keyed by series and pane. Separate windows have separate JavaScript state. Book-scoped Context refresh policy ignores paragraph/scene movement; character invalidation continues through the workspace's established connection and remount lifecycle. Character links open canonical records elsewhere. No new connections or manuscript-focus commands are introduced.
## Query plan stability
Authenticated Development acceptance exposed a timeout when a cached catalogue plan was reused across different prefix/default/locale/usage filters on a small cast. Forward-only migration 333 recompiles the final catalogue statement for the current parameters, without changing matching, metadata, ordering or pagination. Migration 325 remains immutable. Qualification now alternates narrow and broad searches, locale/era criteria and assigned/available filters with a two-character cast, in addition to the 500-character fixture. The benchmark restores the latest procedure after measuring historical SQL, so tests do not leave the database on an earlier definition.
Context Names state is keyed by series and pane, so switching books within the same series retains the author's search and selection. Requests still use the current authorised Context book; moving to another series uses independent state.
## Targeted UI refinements (26 November 2026)
The shared primary control row includes Clear Filters and Sort order. The search placeholder explains complete names or starting letters; prefix semantics are unchanged. Clear resets search, usage, locale/year, gender prior, classification and minimum usage, then requests page one. It preserves the current project/book, page size and sort. Existing book defaults are reapplied by the normal read service; no saved book profile is written. The action remains outside the collapsible advanced filters.
Sort codes are `suggested`, `name-asc`, `name-desc`, `common-desc`, `common-asc`. Suggested retains exact matches first, then the selected catalogue profile's usage weight and display name. Commonness uses that existing `UsageWeight`, with unrecorded weights last. All modes have deterministic display-name/ID tie breaks and are applied before SQL pagination. Changing sort returns to page one; searches, Clear and history restoration retain it.
Migration 334 is required by the existing stored-procedure pagination architecture: sorting only a fetched page would be incorrect, and loading the whole catalogue to sort in application code would regress performance. It adds one optional, validated sort parameter to `GivenName_Search`; earlier numbered migrations remain immutable. No name-matching, occurrence retrieval, AI, allowance, character-data or catalogue-data migration is involved.
Main details links contain no separate-window or Context bridge attributes. The Context controller explicitly opts its shared details model into those attributes. State includes the actual application/pane scroll host, not merely window scroll, and cached-history returns refresh through the existing workspace without replacing Context or changing manuscript focus.
The main Names page mounts the existing `PlotDirectorWorkspaceSurface.split` divider for results/details. Its independent user-scoped local workspace preference survives refresh, navigation and PWA restart. Pointer/keyboard resizing changes only grid sizing; it does not call the search/verification lifecycle. Displayed widths are bounded by the available space without saving viewport clamps. The existing container breakpoint and Context pane architecture are unchanged.