From 46d851a2f8ae2c722fb1ff6abb2e52fe660f1a40 Mon Sep 17 00:00:00 2001 From: Vorflux AI Date: Sat, 28 Mar 2026 22:58:59 +0000 Subject: [PATCH] fix: distribute document clusters across canvas instead of clumping - Exclude 'extends' edges from force simulation (visual-only, no pull) - Apply same filter in update() to prevent re-adding extends on refresh - Stronger derives link strength (0.35) to keep memories near parent doc - Each document forms its own mini-cluster with orbiting memories - Clusters spread evenly across the entire canvas --- packages/memory-graph/src/canvas/simulation.ts | 12 ++++++++---- packages/memory-graph/src/constants.ts | 16 ++++++++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/memory-graph/src/canvas/simulation.ts b/packages/memory-graph/src/canvas/simulation.ts index 3a859dde..44271793 100644 --- a/packages/memory-graph/src/canvas/simulation.ts +++ b/packages/memory-graph/src/canvas/simulation.ts @@ -9,6 +9,11 @@ export class ForceSimulation { this.destroy() try { + // Only use structural edges (derives, updates) for the force layout. + // "extends" edges are visual-only -- they connect documents sharing a + // spaceId but should not pull documents together into a single mass. + const structuralEdges = edges.filter((e) => e.edgeType !== "extends") + this.sim = d3 .forceSimulation(nodes) .alphaDecay(FORCE_CONFIG.alphaDecay) @@ -18,7 +23,7 @@ export class ForceSimulation { this.sim.force( "link", d3 - .forceLink(edges) + .forceLink(structuralEdges) .id((d) => d.id) .distance((link) => link.edgeType === "derives" @@ -30,8 +35,6 @@ export class ForceSimulation { return FORCE_CONFIG.linkStrength.docMemory if (link.edgeType === "updates") return FORCE_CONFIG.linkStrength.version - if (link.edgeType === "extends") - return FORCE_CONFIG.linkStrength.docDocBase return FORCE_CONFIG.linkStrength.fallback }), ) @@ -70,7 +73,8 @@ export class ForceSimulation { if (!this.sim) return this.sim.nodes(nodes) const linkForce = this.sim.force>("link") - if (linkForce) linkForce.links(edges) + if (linkForce) + linkForce.links(edges.filter((e) => e.edgeType !== "extends")) } reheat(): void { diff --git a/packages/memory-graph/src/constants.ts b/packages/memory-graph/src/constants.ts index 97364f09..89a0a7d3 100644 --- a/packages/memory-graph/src/constants.ts +++ b/packages/memory-graph/src/constants.ts @@ -9,22 +9,22 @@ export const MEMORY_BORDER_KEYS = { export const FORCE_CONFIG = { linkStrength: { - docMemory: 0.12, - version: 0.5, - docDocBase: 0.08, - fallback: 0.08, + docMemory: 0.35, + version: 0.6, + docDocBase: 0.0, + fallback: 0.05, }, linkDistance: 300, - docMemoryDistance: 220, - chargeStrength: -2500, + docMemoryDistance: 180, + chargeStrength: -2000, collisionRadius: { document: 70, memory: 35 }, collisionStrength: 0.7, - centeringStrength: 0.08, + centeringStrength: 0.06, alphaDecay: 0.025, alphaMin: 0.001, velocityDecay: 0.45, alphaTarget: 0.3, - preSettleTicks: 250, + preSettleTicks: 150, } export const GRAPH_SETTINGS = {