From cc6c302e9210ae12354cfe19aa318dbeda8b63a2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 9 Sep 2026 06:21:34 +0000 Subject: [PATCH] Bump the ktsu ImGui suite to 3.30.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Picks up the tuned force-directed layout defaults, where six of the fifteen layout settings were measured against a benchmark corpus rather than inherited. Also carries a fix for a repulsion setting of zero producing NaN node positions rather than a merely crowded graph. The graph editor is the consumer that sees the difference, and it is visible in the one test that had to change. The sample function used to settle into a box 880 across and 440 tall; it now settles into one 1150 across and 220 tall. Trading that height for width is the whole point — it is what makes a graph read left to right — but it means the ends of a row now hang over the sides of a 1000 by 600 canvas where before they did not, and Editor_KeepsTheLayoutInsideTheView was measuring per-node bounds sized for the old shape. Widened the horizontal bound, and added the claim those bounds were only ever a proxy for: the settled graph is still centred on the canvas. That is the thing the test exists to protect, since a document dragged towards the origin takes its centre hundreds of units with it, and unlike a per-node bound it does not need revisiting every time the layout settles into a different shape. Verified it fails when the expected centre is moved, rather than passing because everything passes. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_018b2bn5CKSzpjRV4nxv3c3y --- Coder.Test/Graph/AstGraphEditorTests.cs | 34 +++++++++++++++++++++++-- Directory.Packages.props | 12 ++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Coder.Test/Graph/AstGraphEditorTests.cs b/Coder.Test/Graph/AstGraphEditorTests.cs index fa577cd..f847d1f 100644 --- a/Coder.Test/Graph/AstGraphEditorTests.cs +++ b/Coder.Test/Graph/AstGraphEditorTests.cs @@ -265,6 +265,19 @@ public void Editor_PullsOverlappingNodesApartAsItRuns() /// an origin left at zero drags the whole document off the edge — with nothing on screen to say /// which way it went. The editor aims it at the middle of the canvas instead, and this is what /// says so. + /// + /// The horizontal tolerance is wider than the vertical because a settled graph is wider than the + /// canvas and much shorter than it. This document lays out as a row about 1150 across and 220 tall + /// on a canvas of 1000 by 600, so its ends necessarily hang over the sides while its top and bottom + /// sit well inside. That is the layout doing its job — the same six nodes used to settle 880 across + /// and 440 tall, and trading that height for width is what makes a graph read left to right. + /// + /// + /// What the bounds are for is a document that has drifted rather than one that is merely wide, and + /// the two are far apart: a graph pulled off towards the origin ends up hundreds to thousands of + /// units away and takes its centre with it, which is why the centre is asserted too. Widening these + /// to fit a shape is fine; a centre that has wandered is not. + /// /// [TestMethod] public void Editor_KeepsTheLayoutInsideTheView() @@ -274,14 +287,31 @@ public void Editor_KeepsTheLayoutInsideTheView() using ImGuiAppHarness harness = ImGuiAppHarness.Start(ConfigFor(editor), Options); harness.Step(300); + float left = float.MaxValue; + float right = float.MinValue; + float top = float.MaxValue; + float bottom = float.MinValue; + foreach (ktsu.ImGui.NodeEditor.Node node in editor.Graph.Engine.Nodes) { // One assertion per bound rather than a range: it says which edge the node went over. - Assert.IsGreaterThan(-200f, node.Position.X, $"{node.Name} drifted off the left to x {node.Position.X}"); - Assert.IsLessThan(1200f, node.Position.X, $"{node.Name} drifted off the right to x {node.Position.X}"); + Assert.IsGreaterThan(-400f, node.Position.X, $"{node.Name} drifted off the left to x {node.Position.X}"); + Assert.IsLessThan(1400f, node.Position.X, $"{node.Name} drifted off the right to x {node.Position.X}"); Assert.IsGreaterThan(-200f, node.Position.Y, $"{node.Name} drifted off the top to y {node.Position.Y}"); Assert.IsLessThan(800f, node.Position.Y, $"{node.Name} drifted off the bottom to y {node.Position.Y}"); + + left = Math.Min(left, node.Position.X); + right = Math.Max(right, node.Position.X + node.Dimensions.X); + top = Math.Min(top, node.Position.Y); + bottom = Math.Max(bottom, node.Position.Y + node.Dimensions.Y); } + + // The claim the bounds above are a proxy for, asserted directly: whatever shape the graph + // settles into, it is still aimed at the middle of the canvas rather than heading for the + // origin. This holds when a widened bound would not, because a drifting document takes its + // centre with it. + Assert.AreEqual(500f, (left + right) / 2f, 250f, "the settled graph should still be centred on the canvas horizontally"); + Assert.AreEqual(300f, (top + bottom) / 2f, 200f, "and vertically"); } /// diff --git a/Directory.Packages.props b/Directory.Packages.props index 6e9fc6d..e906696 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,14 +10,14 @@ - + - - - + + + - - + +