From c3bf588f5adff727fa5b5c067c8c62f379c839b2 Mon Sep 17 00:00:00 2001 From: Asish Kumar Date: Sun, 24 May 2026 14:36:43 +0530 Subject: [PATCH] fix(agent-service): align auto-layout rank separation --- agent-service/src/agent/util/auto-layout.test.ts | 14 ++++++++++++++ agent-service/src/agent/util/auto-layout.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/agent-service/src/agent/util/auto-layout.test.ts b/agent-service/src/agent/util/auto-layout.test.ts index 5ca2b586cc9..76e971add39 100644 --- a/agent-service/src/agent/util/auto-layout.test.ts +++ b/agent-service/src/agent/util/auto-layout.test.ts @@ -90,6 +90,20 @@ describe("autoLayoutWorkflow", () => { expect(b.x).toBeLessThan(c.x); }); + test("matches the frontend rank separation for linked operators", () => { + const state = new WorkflowState(); + state.addOperator(makeOperator("a"), SENTINEL_POS); + state.addOperator(makeOperator("b"), SENTINEL_POS); + state.addLink(makeLink("l1", "a", "b")); + + autoLayoutWorkflow(state); + + const a = state.getOperatorPosition("a")!; + const b = state.getOperatorPosition("b")!; + // dagre stores node centers, so the gap is node width (200) + ranksep (80). + expect(b.x - a.x).toBe(280); + }); + test("assigns positions to disconnected operators as well", () => { const state = new WorkflowState(); // Seeding each disconnected node with the same sentinel forces the diff --git a/agent-service/src/agent/util/auto-layout.ts b/agent-service/src/agent/util/auto-layout.ts index b17fed4e084..3a27ac3a09b 100644 --- a/agent-service/src/agent/util/auto-layout.ts +++ b/agent-service/src/agent/util/auto-layout.ts @@ -25,7 +25,7 @@ import type { WorkflowState } from "../workflow-state"; const LAYOUT_CONFIG: dagre.GraphLabel = { nodesep: 100, edgesep: 150, - ranksep: 100, + ranksep: 80, ranker: "tight-tree", rankdir: "LR", };