Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion apps/fe/src/modules/graph/data/sim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export function stepSim(sim: Sim, kinds: Map<string, NodeKind>): 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
Expand Down
15 changes: 15 additions & 0 deletions apps/fe/tests/graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }),
Expand Down
Loading