diff --git a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/EntryPoint.cs b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/EntryPoint.cs index e0fa900..0037c93 100644 --- a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/EntryPoint.cs +++ b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Plant3D2026/EntryPoint.cs @@ -73,7 +73,11 @@ public sealed class EntryPoint : IExtensionApplication document = AcadApplication.DocumentManager.MdiActiveDocument; var mode = ParseMode(RuntimeDiagnostics.RuntimeMode); - var context = new PlantRuntimeContextReader().ReadCurrentContext(); + // Script-driven commands can run while Plant's implicit current + // document lags behind MDI activation. Bind the planner to the + // command document captured above, which is also the observer's + // fixture identity. + var context = new PlantRuntimeContextReader().ReadCurrentContext(document); var details = new Dictionary { ["ExecutionMode"] = mode.ToString(), diff --git a/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/PxpOaRegistrationTests.cs b/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/PxpOaRegistrationTests.cs index 528f7d9..fac4c70 100644 --- a/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/PxpOaRegistrationTests.cs +++ b/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/PxpOaRegistrationTests.cs @@ -33,4 +33,5 @@ public sealed class PxpOaRegistrationTests [Fact] public void Observer_DoesNotUseManagedDocumentReferenceAsAcceptance() => Assert.DoesNotContain("ReferenceEquals(sender, fixture)", Observer); [Fact] public void Observer_RecordsExactlyTwoSequentialRuns() => Assert.Contains("runs.Count < 2", Observer); [Fact] public void Finalize_ReportsMissingPlanSeparatelyFromMissingRuns() => Assert.True(Observer.IndexOf("AUTOMATION_EXPECTS_EXACTLY_TWO_PXP_OA", StringComparison.Ordinal) < Observer.IndexOf("AUTOMATION_PLAN_IDS_DIFFER", StringComparison.Ordinal)); + [Fact] public void ScriptDrivenPxpOa_BindsPlantContextToCommandDocument() => Assert.Contains("ReadCurrentContext(document)", Entry); }