From b221189d328568241e6bf6d571ef561effcdb661 Mon Sep 17 00:00:00 2001 From: Nick Beckley Date: Thu, 5 Nov 2026 14:20:26 +0000 Subject: [PATCH] Refresh saved workspace after extraction and clarify cached review selections --- .../Evidence/2026-11-05-phase35/http.txt | 1 + .../Evidence/2026-11-05-phase35/native.txt | 4 +++- .../Agent/SessionManager.cs | 2 +- PlotDirector.NativeCompanion/Tests/WorkflowTests.cs | 13 ++++++++++++- PlotDirector.NativeCompanion/Vsto/AnalysisWindow.cs | 8 ++++++-- 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 Docs/WordCompanion/Evidence/2026-11-05-phase35/http.txt diff --git a/Docs/WordCompanion/Evidence/2026-11-05-phase35/http.txt b/Docs/WordCompanion/Evidence/2026-11-05-phase35/http.txt new file mode 100644 index 00000000..520b21ba --- /dev/null +++ b/Docs/WordCompanion/Evidence/2026-11-05-phase35/http.txt @@ -0,0 +1 @@ +PASS actual HTTP native pairing, antiforgery, bearer/stamp, book/subscription access, canonical AI and idempotency (synthetic provider, no database) diff --git a/Docs/WordCompanion/Evidence/2026-11-05-phase35/native.txt b/Docs/WordCompanion/Evidence/2026-11-05-phase35/native.txt index f670cb38..55292b8b 100644 --- a/Docs/WordCompanion/Evidence/2026-11-05-phase35/native.txt +++ b/Docs/WordCompanion/Evidence/2026-11-05-phase35/native.txt @@ -125,6 +125,7 @@ PASS ambiguous text and heading levels explain uncertainty instead of approving PASS analysis reuses existing PlotDirector marker interpretation PASS fragment splits do not inflate word or paragraph counts PASS 250000-word many-paragraph manuscript analysed incrementally +Agent synthetic 250000-word analysis: 103ms (not Word extraction/UI timing). PASS review suggestion storage is bounded with explicit truncation PASS analysis results are paginated PASS review page fits bounded IPC frame @@ -176,8 +177,9 @@ PASS cross-page preview selection is bounded without silently dropping selected PASS multiple document saved contexts remain isolated PASS older workspace binding cannot fetch or overwrite a replacement PASS cancelled import preview cannot reappear after delayed completion +PASS new structural snapshot refreshes saved scene at stationary cursor without a selection event PASS server loss clears a previously verified online indicator PASS explicit connection check detects recovery PASS authentication expiry rotates scope and removes verified authentication PASS expired credentials cannot display an old authenticated workspace -Native foundation: 182 checks passed. Linux named-pipe API uses Unix domain sockets; Windows ACL/COM/Word responsiveness NOT verified. +Native foundation: 183 checks passed. Linux named-pipe API uses Unix domain sockets; Windows ACL/COM/Word responsiveness NOT verified. diff --git a/PlotDirector.NativeCompanion/Agent/SessionManager.cs b/PlotDirector.NativeCompanion/Agent/SessionManager.cs index 7a560ea7..cfdbb9dc 100644 --- a/PlotDirector.NativeCompanion/Agent/SessionManager.cs +++ b/PlotDirector.NativeCompanion/Agent/SessionManager.cs @@ -133,7 +133,7 @@ public sealed class SessionManager(CloudGateway? cloud = null,ChapterAiWork? ai document.Boundaries = boundaries; document.SnapshotId = snapshot.Id; document.ContentFingerprint = StructuralParser.Fingerprint(snapshot.Fragments); - ClearPending(document); Resolve(document, answer); + ClearPending(document); Resolve(document, answer);workspace?.Position(message.SessionId,answer.ChapterId,answer.SceneId); if(document.Analysis!=null){answer.Analysis=document.Analysis.Page(0);answer.Status="analysis-complete";answer.Progress=100;} break; case "analysis-page": diff --git a/PlotDirector.NativeCompanion/Tests/WorkflowTests.cs b/PlotDirector.NativeCompanion/Tests/WorkflowTests.cs index 9c3e4703..e98d9dc8 100644 --- a/PlotDirector.NativeCompanion/Tests/WorkflowTests.cs +++ b/PlotDirector.NativeCompanion/Tests/WorkflowTests.cs @@ -33,6 +33,17 @@ internal static class WorkflowTests await Wait(()=>Send(one,"workspace-status",12,replacement).ImportPreview!=null); Send(one,"workspace-cancel-preview",12,replacement);await Task.Delay(100); check(Send(one,"workspace-status",12,replacement).ImportPreview==null,"cancelled import preview cannot reappear after delayed completion"); + var manager=new SessionManager(cloud,null,work);var instance=Guid.NewGuid();var lease=Guid.NewGuid();manager.Attach(instance,lease);long sequence=0; + var third=new DocumentDescriptor{SessionId=Guid.NewGuid(),ManuscriptId=Guid.NewGuid(),Revision=1};var thirdBinding=Guid.NewGuid();var snapshot=Guid.NewGuid(); + Message Apply(Message m){m.WordInstanceId=instance;m.SessionId=third.SessionId;m.Revision=1;m.Sequence=++sequence;return manager.Apply(lease,m);} + Apply(new(){Kind="document",Documents=[third]});Apply(new(){Kind="workspace-select",BookId=11,SnapshotId=thirdBinding,AuthenticationContext=context}); + Apply(new(){Kind="selection",Start=15,End=15});Apply(new(){Kind="snapshot-begin",SnapshotId=snapshot,End=20}); + Apply(new(){Kind="snapshot-fragment",SnapshotId=snapshot,Fragment=new(){ParagraphIndex=1,Start=0,End=10,Text="Chapter",OutlineLevel=1,MarkerTags=["PD-CHAPTER-10"],CompletesParagraph=true}}); + Apply(new(){Kind="snapshot-fragment",SnapshotId=snapshot,Fragment=new(){ParagraphIndex=2,Start=10,End=20,Text="Scene",OutlineLevel=2,MarkerTags=["_PD_SCENE_20"],CompletesParagraph=true}}); + Apply(new(){Kind="snapshot-end",SnapshotId=snapshot}); + await Wait(()=>Apply(new(){Kind="workspace-status",BookId=11,SnapshotId=thirdBinding,AuthenticationContext=context}).Workspace?.SceneId==20); + check(true,"new structural snapshot refreshes saved scene at stationary cursor without a selection event"); + manager.Detach(instance,lease); handler.Offline=true;await cloud.CheckConnection();check(cloud.Status().Health?.Server=="offline","server loss clears a previously verified online indicator"); handler.Offline=false;await cloud.CheckConnection();check(cloud.Status().Health?.Server=="online","explicit connection check detects recovery"); handler.Expired=true;await cloud.CheckConnection();check(cloud.Status().AuthenticationContext!=context&&cloud.Status().Health?.Authentication=="expired","authentication expiry rotates scope and removes verified authentication"); @@ -51,7 +62,7 @@ internal static class WorkflowTests if(Expired)return new(HttpStatusCode.Unauthorized); if(path.EndsWith("/books"))return Ok(new[]{new CompanionBook{BookId=11,Title="One"},new CompanionBook{BookId=12,Title="Two"}}); if(path.EndsWith("/connection"))return Ok(new ConnectionHealth{Server="online",Authentication="verified",Ai="configured",VerifiedUtc=DateTime.UtcNow,ExpiresUtc=DateTime.UtcNow.AddHours(4)}); - if(path.EndsWith("/workspace")){var id=int.Parse(path.Split('/')[4]);return Ok(new SavedWorkspace{BookId=id,State="saved-book",Title="Saved book "+id,Context="Saved context",Intent="Saved goals"});} + if(path.EndsWith("/workspace")){var id=int.Parse(path.Split('/')[4]);return Ok(new SavedWorkspace{BookId=id,SceneId=request.RequestUri.Query.Contains("sceneId=20")?20:null,State=request.RequestUri.Query.Contains("sceneId=20")?"saved-scene":"saved-book",Title="Saved book "+id,Context="Saved context",Intent="Saved goals"});} if(path.EndsWith("/import-preview")){await Task.Delay(80,token);return Ok(new ImportPreview{State="validated-preview",CommitAvailable=false});} return new(HttpStatusCode.NotFound); } diff --git a/PlotDirector.NativeCompanion/Vsto/AnalysisWindow.cs b/PlotDirector.NativeCompanion/Vsto/AnalysisWindow.cs index a629a655..0c42826f 100644 --- a/PlotDirector.NativeCompanion/Vsto/AnalysisWindow.cs +++ b/PlotDirector.NativeCompanion/Vsto/AnalysisWindow.cs @@ -92,8 +92,9 @@ namespace PlotDirector.WordAddIn progress.Value=review?.Progress??0;cancel.Enabled=running||review?.Running==true||binding?.Preview?.State=="loading"; var workspace=binding?.Workspace; var verified=workspace?.State?.StartsWith("saved-",StringComparison.Ordinal)==true; - savedContext.Text=(workspace?.Title??"No book selected")+"\r\nSaved PlotDirector data · read-only · "+(workspace?.State??"unselected")+"\r\n\r\n"+(string.IsNullOrWhiteSpace(workspace?.Context)?"No saved context for this location. Select a book; recognised saved chapter/scene markers are verified against that book. Local/AI suggestions do not create saved context.":workspace.Context); - savedIntent.Text=(workspace?.Title??"No book selected")+"\r\nSaved writing objectives · read-only · "+(workspace?.State??"unselected")+"\r\n\r\n"+(string.IsNullOrWhiteSpace(workspace?.Intent)?"No saved writing objective at this location. Set chapter goals or scene purpose in PlotDirector; no intent is invented or silently saved here.":workspace.Intent); + var cached=health==null||health.Server!="online"||DateTime.UtcNow-health.VerifiedUtc>=TimeSpan.FromSeconds(90)?" · cached/unverified; Check connection":""; + savedContext.Text=(workspace?.Title??"No book selected")+"\r\nSaved PlotDirector data · read-only · "+(workspace?.State??"unselected")+cached+"\r\n\r\n"+(string.IsNullOrWhiteSpace(workspace?.Context)?"No saved context for this location. Select a book; recognised saved chapter/scene markers are verified against that book. Local/AI suggestions do not create saved context.":workspace.Context); + savedIntent.Text=(workspace?.Title??"No book selected")+"\r\nSaved writing objectives · read-only · "+(workspace?.State??"unselected")+cached+"\r\n\r\n"+(string.IsNullOrWhiteSpace(workspace?.Intent)?"No saved writing objective at this location. Set chapter goals or scene purpose in PlotDirector; no intent is invented or silently saved here.":workspace.Intent); openContext.Enabled=verified&&!string.IsNullOrEmpty(workspace.ContextPath);openIntent.Enabled=verified&&!string.IsNullOrEmpty(workspace.IntentPath);openBook.Enabled=verified; var plan=binding?.Preview; if(plan!=null)previewText.Text=plan.State+"\r\nSelected: "+plan.Chapters+" chapters / "+plan.Scenes+" scenes\r\nAlready saved: "+plan.ExistingChapters+" chapters / "+plan.ExistingScenes+" scenes\r\n\r\n"+plan.Message+"\r\n\r\nCreated: 0. Replaced: 0. Native commit is unavailable; use the established PlotDirector workflow."; @@ -128,14 +129,17 @@ namespace PlotDirector.WordAddIn private void Checked(object sender,TreeViewEventArgs args) { if(rebinding||!(args.Node.Tag is StructureSuggestion item))return; + if(item.Kind!="Chapter"&&item.Kind!="Scene"){rebinding=true;args.Node.Checked=false;rebinding=false;details.Text="Error/evidence rows cannot be selected for upload or import.";return;} if(!selection.Set(item,args.Node.Checked)){rebinding=true;args.Node.Checked=false;rebinding=false;details.Text="Preview selection is limited to 80 rows. Use smaller batches.";} if(args.Action!=TreeViewAction.Unknown)foreach(TreeNode child in args.Node.Nodes)child.Checked=args.Node.Checked; + rebinding=true;try{foreach(var tree in new[]{local,ai})foreach(TreeNode node in tree.Nodes){if(node.Tag is StructureSuggestion parent)node.Checked=selection.Contains(parent);foreach(TreeNode child in node.Nodes)if(child.Tag is StructureSuggestion row)child.Checked=selection.Contains(row);}}finally{rebinding=false;}UpdatePages(); } private void UpdatePages() { if(tabs.SelectedIndex>1){previous.Enabled=false;next.Enabled=false;pages.Text="Read-only saved data / preview; no automatic changes";return;} var offset=tabs.SelectedIndex==0?(current?.Offset??0):aiOffset;var total=tabs.SelectedIndex==0?(current?.Total??0):aiItems.Count; pages.Text=total==0?"No results":"Showing "+(offset+1)+"–"+Math.Min(total,offset+40)+" of "+total; + pages.Text+=" · "+selection.Items.Length+" selected across pages (limit 80)"; previous.Enabled=offset>0;next.Enabled=offset+40