14 KiB
Relationships Workspace
Investigation and implementation boundary
The previous RelationshipMap/Index page offered GET selectors for book, chapter, scene and character focus; a Cytoscape graph; category legend; detail/history pane; and conventional relationship listing. Circle/COSE layouts and node dragging existed, but there was no saved layout. Cytoscape already supplied panning and zooming. The page had no direct editing workflow and did not render the graph when there were no links.
RelationshipMapService reads ICharacterRepository.GetRelationshipMapAsync, groups canonical RelationshipEvent records by relationship, and resolves state in manuscript order. CharacterRelationship holds the factual type, optional initial book, initial state/intensity, reciprocal status and notes. Events hold a scene, state/intensity, awareness and description. Existing character detail forms use ICharacterService.SaveInitialRelationshipAsync; scene editing uses AddRelationshipEventAsync and UpdateRelationshipEventAsync. The workspace uses these same services and stored-procedure repositories. No schema, SQL or migration is added.
Existing graph category colours, labels, intensity widths, hover text, selected-line styling and history rendering are retained in _GraphScripts. Focus Mode still displays the chosen character's immediate network or dims the unrelated full network. Client navigation now applies that same rule without a page reload. Map and list update from the same server response. Timeline reads the existing state resolver rather than computing a second relationship state in JavaScript. The resolver also excludes archived records and relationships before their recorded starting scene/book.
Characters have numeric CharacterImportance; existing graph thresholds are 8+ and 4+. Palettes use those thresholds: Major at the top, every Supporting character on the left and Minor at the bottom. The right rail is Details only. Names and avatar/portrait paths come from the existing character records. Find character searches all three palettes; the redundant importance filter controls are removed. Each character has one palette entry with a lazy portrait. The timeline uses a native range input and change markers instead of hundreds of labels.
Character analysis exposes a generated Summary and run/completion metadata (CharacterEnrichmentCharacterStatus), and structured enrichment results. Summary length is measurable but is a generated output with no calibrated relationship to importance. A separate suggestion feature should combine scene presence and POV evidence with analysis coverage, evaluate ranking across several books, and require author acceptance. This pass deliberately does not infer or change author importance.
PWA context menus discover commands from data-pd-context regions and invoke their original controls. Palette, canvas and detail actions participate in this existing system; graph context gestures select a node/line and route to the appropriate region. Browser fallback and touch/keyboard users have explicit buttons and native select controls. No new menu framework or browser confirmation is used.
Layout and limits
Positions, extra/removed nodes, focus, pan, zoom and palette collapse are stored locally by project and selected book, with a 250ms debounce. Browser profiles provide local user separation; settings do not roam between devices. Reset layout is local and never deletes canonical characters or relationships.
On narrow displays, the correction pass below replaces the four palettes with one searchable character drawer. All desktop palettes can be collapsed. Explicit zoom controls and Ctrl/Cmd-wheel avoid taking over ordinary wheel scrolling. Touch users can pinch and use the relationship dialog without dragging.
The timeline spans project manuscript order, consistent with the existing scene selectors. Initial means project start; End resolves the last scene. Book-specific initial boundaries on existing records are preserved. Changes to an existing relationship at a scene update its canonical event at that scene; additional changes create events on that relationship. Different factual types remain separate relationships. Ambiguous duplicate records produce a conflict for review rather than an arbitrary overwrite. Concurrent creation from separate browser sessions remains subject to the existing stored procedure's concurrency guarantees; no new database uniqueness constraint is claimed.
Not included: cross-device layout storage, automatic importance suggestions, timeline animation playback, deleting canonical relationships from the canvas, or a rewrite of character/continuity systems. Character detail editing remains the place for archival and advanced canonical metadata. Scene changes affect state, intensity and awareness; mutual status belongs to the relationship itself. Database-backed live smoke testing and deployment are separate operational steps.
Verification
RelationshipWorkspaceTests exercises a 75-character, 74-relationship, 300-scene fixture, importance ordering, temporal carry-forward, canonical map/list correspondence, existing Focus Mode, reciprocal edits, same-scene updates and invalid project selections. Browser coverage is in PlotLine.Tests/Browser/relationship-workspace.cjs, using the isolated compiled Razor host and mocked HTTP responses for interaction checks. No live manuscript/database writes are required.
Visual/layout correction pass
The page is now a single bounded application surface beneath the existing ribbon in browser and PWA mode. A page-scoped shell class removes content-width limits and gutters. Height follows the actual ribbon and viewport via ResizeObserver; internal palettes, history and List scroll without extending the document. The application maximise mode has an explicit restore button and Escape fallback, with no browser fullscreen API.
The toolbar contains Map/List, a named focus chip with clear action, Auto-arrange, Layout and Display. The colour key is pinned beneath the right rail. Display contains the original story-point selectors, network visibility and update action directly in a stacked panel; the PWA ribbon also includes maximise/restore. The map's fit, zoom, centre and select/pan controls form a floating vertical toolbar. The right rail is dedicated to contextual detail, with no Supporting/Details tabs. Character detail is built from the same canonical response and includes existing avatar, importance, relationship count and selectable connections/history. List is a separate workspace view; no standalone list remains beneath the map.
The timeline retains its existing state resolver, range keyboard navigation and scene defaults. Presentation adds explicit Initial/End buttons, change dots, progress and selected-scene output. Relationship dialogs retain their form and save path, with avatar pairs and subordinate endpoint selectors. Graph nodes retain Cytoscape and category line colours, adding existing portrait paths or generated initials. Node, label, focus, palette and timeline surfaces use the application's semantic theme tokens and update when the active theme changes.
At 800px and below, the four permanent palettes become one drawer: existing character entries move into it and return to their desktop homes on resize. No repeated portrait lists are introduced. Selecting a character dismisses the drawer; Details is independently available. The v1 position/pan/zoom/focus storage and canonical server/save code are unchanged in this pass.
Browser regression coverage additionally checks viewport bounds, complete mobile cast access, Map/List replacement, focus clearing, select/pan controls, maximise/restore and all four principal themes (True Light/Dark use modern-light/modern-dark theme keys). The normal 75-character/300-scene interactions remain covered. Visual checks use the isolated compiled-Razor fixture; live authenticated author data has not been changed. No schema work or automatic importance inference was added.
PWA ribbon integration
Relationships declares its existing toolbar controls as normal data-pwa-context contributions. The shell binds commands and form fields to their live sources; there is no second focus, view or maximise state. Layout and Display request the existing compact ribbon menus. A small shared renderer extension honours data-pwa-compact for such contributions and copies explicitly declared passive legend content without IDs or interactive controls. Help uses the standard page-help contribution.
Only in standalone mode, accounted contributions suppress the entire secondary toolbar and remove its grid row. The existing viewport measurement gives the space to the canvas. Browser presentation and all importance thresholds, cast assignment, graph, timeline, dialog and persistence logic remain unchanged. PWA maximise keeps the ribbon reachable so its Restore command remains available. relationships-ribbon.cjs covers command/state binding, menus, recovered height, mobile overflow and navigation cleanup; the existing relationship and PWA browser suites remain regression gates.
Ribbon presentation refinement
Workspace commands explicitly select distinct icons from the existing SVG icon catalogue, including new diagram/navigation glyphs where no suitable icon existed. Layout and Display summaries declare their own icons rather than inheriting the first child command's icon. The shared form renderer also honours an explicitly declared field icon.
Display contains the original Book, Chapter, Scene and Character focus selectors directly, with simple stacked labels, network visibility and Update Map. The PWA uses an opt-in data-pwa-fields="stacked" presentation of the same source form: native select lists remain dropdowns even with hundreds of scenes, avoiding nested popup pickers. Browser presentation matches the earlier stacked panel. The intermediate Story point dialog has been removed. The colour key remains fixed below the right rail; neither Display presentation uses a scroll container. Browser tests verify selector visibility, binding to source fields, actual GET submission of book/chapter/scene, and non-scrolling desktop/mobile panels.
PWA maximise correction
Maximise contributes a separate essential Workspace ribbon group, outside Display, so the command does not collapse into a dropdown. Browser placement is unchanged. The old PWA maximised bounds matched the already full-height normal workspace, making the state toggle appear ineffective. Maximising now temporarily hides the title and ribbon-heading rows while preserving the command row, allowing the existing header ResizeObserver to give the reclaimed height to the canvas. The same canonical class, Restore action and Escape handler restore the normal view; no native fullscreen or saved ribbon preference is involved. Browser tests assert direct command placement and a measurable canvas-height increase, as well as Restore and Escape.
PWA focus stability
Instrumentation reproduced a contextual-ribbon rebuild on every Focus caption text change. The main-content MutationObserver treated the label replacement as a structural contribution change and called refresh, which cleared and rebuilt the ribbon. Display briefly rendered its stacked form in the expanded layout before the next animation-frame fitting pass restored the compact menu. At 1440px the measured header jumped from 179px to 348px and the workspace moved down 169px for a frame; the same focus sequence in ordinary browser mode retained its bounds. Cytoscape and the canvas DOM were not remounted.
The observer now distinguishes text/decorative caption updates on already bound buttons from actual contribution-structure changes. It updates existing command bindings and full-label tooltips in place without clearing ribbon nodes or accounting markers and without rerunning the ribbon fitting pass. Expanded Focus controls reserve fixed label/clear-action space and truncate long names; compact-menu visibility rules are preserved. Genuine additions/removals of commands, fields or contributions still trigger composition. No delays, overlays, fades, animation or interaction blocking are involved.
Maximise retains its existing PWA ribbon placement and behaviour; the browser control is also unchanged.
relationship-focus-stability.cjs exercises diagram-node focus changes, short/long captions, rapid sequences and clearing focus in browser/PWA presentation at 1440px and 1700px. It samples the header, workspace, four palettes/panels, canvas and timeline on every animation frame, asserts the ribbon nodes remain identical with zero rebuilds, and checks graph instance, node positions, zoom, Details and Focus updates. Existing ribbon, workspace and shared-toolbar tests remain regression gates.
Focus action spacing
The initial stability styling reserved unequal 150px/65px slots, leaving an uneven group and clipping the long Clear caption. Expanded PWA Focus actions now use equal compact widths with the normal ribbon gap. The label is explicitly Clear focus. Its ribbon binding stays visible but disabled while its canonical source is hidden (no character focused), avoiding an empty reserved slot or a width change. The web control retains its existing hiding behaviour. Regression checks cover balanced geometry, the complete Clear label, enabling/disabling and unchanged workspace bounds at 1440/1700/1920px.
Simplified character palettes
The existing 8+/4–7/below-4 classifications and Model.Cast order are unchanged. Supporting entries are no longer split by alternating index: the complete existing collection renders on the left. Major and Minor entries keep their top and bottom homes. The left keeps Find character and a Supporting count, with the dropdown and three importance filter buttons removed. Search still matches every cast entry using the existing accent/case normalization, and palette-local scrolling brings a focused result into view without scrolling the outer workspace.
The right is Details only, with the existing character/relationship content and colour key. Clear focus resets the contextual content instead of switching to a Supporting list. Collapsing character palettes retains Details. The mobile drawer continues to move all existing character entries into one list, then restore their desktop homes on resize; no duplicate portraits or records are introduced. Tests cover complete Supporting population/order, absence of the removed controls/tab, search/focus across all classes, Supporting drag/drop, Details, mobile and existing map/ribbon stability.