fix: queue readiness barrier after fixture activation

This commit is contained in:
codex
2026-08-04 07:29:37 +03:00
parent 98564b807f
commit 2d9fbdd474
2 changed files with 8 additions and 8 deletions
@@ -199,13 +199,13 @@ internal sealed class FirstLimitedApplyAutomationCoordinator
// coordinator receives the returned Document. Confirm the current // coordinator receives the returned Document. Confirm the current
// active document after assignment so that one missed event cannot // active document after assignment so that one missed event cannot
// strand the workflow waiting for another startup Idle. // strand the workflow waiting for another startup Idle.
var activeDocument = AcadApplication.DocumentManager.MdiActiveDocument; // Open was requested for this exact local fixture and it has just
if (activeDocument is not null && string.Equals(activeDocument.Name, document.Name, StringComparison.OrdinalIgnoreCase)) // been made MDI-active. Queue a no-op public command regardless of
{ // wrapper identity/name normalisation; CommandEnded is the actual
fixtureDocumentActivated = true; // readiness proof before any Plant API is used.
transitions.Add("FixtureDocumentActiveAfterOpen"); fixtureDocumentActivated = true;
QueueReadinessBarrier(); transitions.Add("FixtureDocumentActiveAfterOpen");
} QueueReadinessBarrier();
} }
catch (System.Exception ex) { FailFromCallback("Start", ex, "AUTOMATION_START_FAILED"); } catch (System.Exception ex) { FailFromCallback("Start", ex, "AUTOMATION_START_FAILED"); }
} }
@@ -104,7 +104,7 @@ public sealed class FoundationTests
var source = File.ReadAllText(Path.Combine(ProjectRoot, "src", "PRecAnnot.Plant3D2026", "FirstLimitedApplyAutomation.cs")); var source = File.ReadAllText(Path.Combine(ProjectRoot, "src", "PRecAnnot.Plant3D2026", "FirstLimitedApplyAutomation.cs"));
var start = source[source.IndexOf("public void Start()", StringComparison.Ordinal)..source.IndexOf("private void CompleteLifecycleProbe", StringComparison.Ordinal)]; var start = source[source.IndexOf("public void Start()", StringComparison.Ordinal)..source.IndexOf("private void CompleteLifecycleProbe", StringComparison.Ordinal)];
Assert.Contains("FixtureDocumentActiveAfterOpen", start); Assert.Contains("FixtureDocumentActiveAfterOpen", start);
Assert.Contains("string.Equals(activeDocument.Name, document.Name", start); Assert.Contains("fixtureDocumentActivated = true", start);
Assert.Contains("QueueReadinessBarrier();", start); Assert.Contains("QueueReadinessBarrier();", start);
Assert.Contains("ReadinessBarrierCompleted", source); Assert.Contains("ReadinessBarrierCompleted", source);
Assert.Contains("TryActivateProjectAndVerifyContext();", source); Assert.Contains("TryActivateProjectAndVerifyContext();", source);