fix(desktop): paint the cut planner before it captures the plates

Plan capture runs on the UI thread, so the panel stayed blank for several
seconds when planning every plate of a large nest. Paint the window with
its "Planning..." status first.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Sonnet 5.5 committed 2026-11-28 14:45:50 -05:00
1 parent e54a9456f4
commit 8b77d52f98
2 files changed
+32

No files matched your search

@@ -613,6 +613,27 @@ public class CuttingInspectionPanelTests
panel.RequestClose();
});
[Fact]
public void PlanningStatusIsPaintedBeforePlanningHoldsTheUiThread() => RunSta(() =>
{
using var editor = Editor();
editor.Show();
editor.PlateManager.LoadAt(0);
editor.OpenCuttingInspection();
var panel = editor.CuttingInspection!;
PumpUntil(() => panel.Proposal != null && !panel.IsPlanning);
var status = Field<Label>(panel, "statusLabel");
var painted = new List<string>();
status.Paint += (_, _) => painted.Add(status.Text);
Field<Button>(panel, "planButton").PerformClick();
// No messages have been pumped, so only a paint made while starting can be here.
Assert.Contains(painted, text => text.StartsWith("Planning", StringComparison.Ordinal));
PumpUntil(() => panel.Proposal != null && !panel.IsPlanning);
panel.RequestClose();
});
[Fact]
public void BusyMenuRefusesPlanningAndFreeMenuOpensDockedPanel() => RunSta(() =>
{
+11
View File
@@ -831,6 +831,8 @@ internal sealed class CuttingInspectionPanel : UserControl
SetPlanning(true);
planningClock.Restart();
SetPlanningStatus("Planning…");
// Capture holds the UI thread for seconds on a large nest, so show the panel first.
PaintNow(TopLevelControl ?? this);
try
{
// Capture on the owner thread; no worker recapture of the live plate or settings.
@@ -857,6 +859,15 @@ internal sealed class CuttingInspectionPanel : UserControl
}
}
// Paints pending areas without pumping messages, so no input can arrive mid-start.
// Update reaches only its own window, so each child is painted too.
private static void PaintNow(Control control)
{
control.Update();
foreach (Control child in control.Controls)
PaintNow(child);
}
private static string PhaseText(CuttingPlanPhase phase) => phase switch
{
CuttingPlanPhase.Reordering => "finding a part order",