From 20fcbe7872475f36970e49c1903156946b5ac72d Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Thu, 26 Nov 2026 22:23:09 +0000 Subject: [PATCH] Establish main Relationships isolation contract and scalable baseline fixtures --- .../MainWorkspaceEnhancement-20261126.md | 13 +++++++++++++ PlotLine.Tests/RelationshipWorkspaceTests.cs | 9 +++++++++ PlotLine.Tests/ToolbarBrowserHost.cs | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Docs/Relationships/MainWorkspaceEnhancement-20261126.md diff --git a/Docs/Relationships/MainWorkspaceEnhancement-20261126.md b/Docs/Relationships/MainWorkspaceEnhancement-20261126.md new file mode 100644 index 00000000..e233d09b --- /dev/null +++ b/Docs/Relationships/MainWorkspaceEnhancement-20261126.md @@ -0,0 +1,13 @@ +# Main Relationships enhancement — investigation and isolation contract + +Scope: main `RelationshipMap/Index` only; Development deployment only. Context and Character Details are protected. + +The main view uses its own `_GraphScripts` Cytoscape renderer and `relationship-workspace.js`. No other view includes that graph partial. Context and Character Details use their existing SVG components (`context-relationship-layout.js` and their own renderers). Those scripts, views, styles, controllers and default settings will remain unchanged. Before/after comparisons use the same synthetic data, focus, theme, scene and dimensions, plus existing protected interaction regressions. + +Reuse: canonical RelationshipMap service/state resolver and editor; author-reference family definitions from `ContextRelationshipLenses.Family`; unchanged family layout algorithm via an explicit main-page include; canonical CharacterAttributes Directory/Assign/Undo endpoints and shared definitions; application context menus, toast actions, Scene Explorer and workspace dividers. New behaviour and storage stay under `#rwApp` / main-workspace scripts. No new graph library, AI calls, database store or shared rendering default. + +Existing main state: local v1 project/book layout, manual extra/removed nodes, focus/zoom/pan, 250ms debounce; Cytoscape circle/COSE; three importance palettes, right Details, legend, Scene Explorer, Map/List, PWA ribbon and maximise. Current gaps include Ctrl-wheel centre zoom, single-network layouts, hidden-but-not-removed membership, no pin/layout undo/presets, and no importance assignment between groups. Existing two-sided workspace dividers are already available and will be reused with author/project scoping and no scene-resolution calls on resize. + +Plan/checkpoints: A baseline/isolation; B scoped interaction/menus; C membership/pins/layout undo; D shared importance assignment; E clustered/radial/family/importance layouts; F routing; G presets/history stability; H persistence/dividers; I build/full regression, rendered browser/PWA, all themes, protected comparisons, performance, documentation and Development smoke/deployment. Do not deploy an incomplete checkpoint. Preserve unrelated investigation files and existing author data. + +Acceptance evidence and measured results will be appended after implementation. The user attachment remains the authoritative checklist, including every section 21 criterion and requested screenshots. Any unverified or incomplete requirement must be labelled explicitly in the final matrix. diff --git a/PlotLine.Tests/RelationshipWorkspaceTests.cs b/PlotLine.Tests/RelationshipWorkspaceTests.cs index cee1dac4..e7cadb5f 100644 --- a/PlotLine.Tests/RelationshipWorkspaceTests.cs +++ b/PlotLine.Tests/RelationshipWorkspaceTests.cs @@ -35,6 +35,15 @@ internal static class RelationshipWorkspaceTests "GetAsync" => Task.FromResult(new() { ProjectID = 7, ProjectName = "Cast fixture" }), _ => throw new Exception(m) }), Repository(data)); + public static async Task LargeFixture(int count,string network) + { + var original=Data(); var cast=Enumerable.Range(1,count).Select(i=>new Character{CharacterID=i,ProjectID=7,CharacterName=$"Person {i:000}",CharacterImportance=i%4==0?10:i%4==1?6:i%4==2?2:null}).ToList(); + var pairs=new List<(int A,int B,string Type,string Category)>(); + if(network=="family") { for(var i=2;i<=count;i++)pairs.Add((Math.Max(1,i/2),i,i%7==0?"Adoptive Parent":"Parent","Family")); } + else if(network!="isolated") { for(var i=1;i<=count;i++)for(var step=1;step<=(network=="dense"?6:network=="clusters"?3:1);step++){var target=i+step;if(target<=count&&(network!="clusters"||i/12==target/12||i%12==0&&step==1)&&(network!="sparse"||i%4==0))pairs.Add((i,target,"Friend","Friendship"));} } + var relationships=pairs.Select((p,i)=>new CharacterRelationship{CharacterRelationshipID=i+1,ProjectID=7,CharacterAID=p.A,CharacterBID=p.B,CharacterAName=$"Person {p.A:000}",CharacterBName=$"Person {p.B:000}",RelationshipTypeID=1,RelationshipTypeName=p.Type,RelationshipCategoryName=p.Category,IsInitialRelationship=true,InitialRelationshipStateID=1,InitialRelationshipStateName="Established",IsReciprocal=p.Category!="Family"}).ToList();var data=new RelationshipMapData{Books=original.Books,Chapters=original.Chapters,Scenes=original.Scenes,Characters=cast,Relationships=relationships,RelationshipCategories=original.RelationshipCategories,RelationshipEvents=[]}; + return (await Service(data).GetAsync(7,null,null,null,null,true))!; + } public static async Task Fixture() => (await Service(Data()).GetAsync(7, null, null, null, null, true))!; public static void StateAndEditing() => Run().GetAwaiter().GetResult(); private static async Task Run() diff --git a/PlotLine.Tests/ToolbarBrowserHost.cs b/PlotLine.Tests/ToolbarBrowserHost.cs index 02e69877..3b9933cf 100644 --- a/PlotLine.Tests/ToolbarBrowserHost.cs +++ b/PlotLine.Tests/ToolbarBrowserHost.cs @@ -735,7 +735,7 @@ internal static class ToolbarBrowserHost } if (context.Request.Query["page"] == "relationships") { - var relationships = await RelationshipWorkspaceTests.Fixture(); + var relationships = int.TryParse(context.Request.Query["cast"],out var castSize) ? await RelationshipWorkspaceTests.LargeFixture(Math.Clamp(castSize,1,200),context.Request.Query["network"].ToString()) : await RelationshipWorkspaceTests.Fixture(); surface = await Render("RelationshipMap/Index", relationships); surface += await Render("RelationshipMap/_GraphScripts", relationships); }