From a21cd1ee573c9de459666e90b6ecda6f2b3f99e8 Mon Sep 17 00:00:00 2001 From: Lexirieru Date: Wed, 11 Nov 2026 15:03:18 +0700 Subject: [PATCH] fix(fe): live view bubbles no longer fly out of reach when they start on nearly the same spot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A new Payments Mind's live view showed six skills and two lines running off the panel; Payments, Daily planner and their apps (wallet, calendar, Meet) were never visible, even after Fit. Skills start 40 from the Mind at angles that can nearly coincide, and the 1/d² push between two bubbles 0.3 apart is about 50,000 a tick: both flew out and the layout cooled with them ~1,000 to 1,400 away, beyond Fit's 35% zoom floor. The push is now capped as if they were 20 apart; the overlap term still separates close bubbles. Not from #241: the code before it does the same. Tests: lint, typecheck, vitest (graph 13/13; the new test fails without the cap: speed 49,741 vs < 100). Offline layout of that Mind: farthest node 1,421 -> 302, every skill 160 to 236 from the Mind. Chrome: every bubble in the panel. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Q5ZrzK8une3S2YyhDG746e --- apps/fe/src/modules/graph/data/sim.ts | 5 ++++- apps/fe/tests/graph.test.ts | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/apps/fe/src/modules/graph/data/sim.ts b/apps/fe/src/modules/graph/data/sim.ts index 9d1d0229..79a06f82 100644 --- a/apps/fe/src/modules/graph/data/sim.ts +++ b/apps/fe/src/modules/graph/data/sim.ts @@ -93,7 +93,10 @@ export function stepSim(sim: Sim, kinds: Map): boolean { const d = Math.sqrt(d2) // Labels sit under the bubbles, so keep more room than the bubbles need. const min = p.r + q.r + 46 - const f = ((5200 / d2) + (d < min ? (min - d) * 0.6 : 0)) * a + // The 1/d² push is capped as if they were 20 apart: two new bubbles placed on nearly the same spot (skills + // start 40 from the Mind at angles that can coincide) once got 5200/0.1 and flew ~1,000 out before the layout + // cooled, out of the live view's reach (11 Nov). The overlap term below still separates close bubbles. + const f = ((5200 / Math.max(d2, 400)) + (d < min ? (min - d) * 0.6 : 0)) * a const fx = (dx / d) * f const fy = (dy / d) * f p.vx -= fx diff --git a/apps/fe/tests/graph.test.ts b/apps/fe/tests/graph.test.ts index 769e852c..794689dc 100644 --- a/apps/fe/tests/graph.test.ts +++ b/apps/fe/tests/graph.test.ts @@ -70,6 +70,21 @@ describe("Mind Graph (#17)", () => { expect(sim.bodies.get("mind:m1")).toMatchObject({ x: 0, y: 0 }) }) + it("two bubbles starting almost on the same spot don't fly out of the view (11 Nov)", () => { + const g = buildGraph({ mindId: "m1", name: "Omaga", skills: ["payments", "daily-planner"], catalog, events: [] }) + const sim = syncSim(null, g.nodes, g.links, "mind:m1") + // Skills start 40 from the Mind at angles that can nearly coincide: put two 0.3 apart. + const a = sim.bodies.get("skill:payments")! + const b = sim.bodies.get("skill:daily-planner")! + b.x = a.x + 0.3 + b.y = a.y + stepSim(sim, new Map(g.nodes.map((n) => [n.id, n.kind]))) + // Before the cap the 1/d² push gave them ~5,000 a tick, and a Payments Mind's two busiest skills ended ~1,000 + // away, beyond what Fit can show at its 35% floor. + expect(Math.hypot(b.vx, b.vy)).toBeLessThan(100) + expect(Math.hypot(b.x, b.y)).toBeLessThan(200) + }) + it("keeps only states that mean something now", () => { const events = [ ev("tool.called", { tool: "send_payment", toolCallId: "old", nodeId: "wallet:m1", runId: "r0" }),