Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.
HTML agent-skillsai-agentsarchitecture-diagramclaude-codeclaude-skillscodexcoding-agentsdeepseek-harnessdeveloper-toolsdiagramsdiagrams-as-codedsh-pluginflowchartllmmermaidopencodesequence-diagramsoftware-architecturesystem-designvisualization
fix(renderers): stop treating non-finite rects as overlapping (#80)
Ngo Quoc Viet3e0f4d8382c5
diff --git a/archify.zip b/archify.zipindex 249a26a6..bbee8d76 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/renderers/shared/geometry.mjs b/archify/renderers/shared/geometry.mjsindex bcf5c866..fee610c1 100644--- a/archify/renderers/shared/geometry.mjs+++ b/archify/renderers/shared/geometry.mjs@@ -18,6 +18,14 @@ export function isFinitePoint(...coords) {}export function rectsOverlap(a, b, gap = 0) {+ // Non-finite geometry means "unknown", not "overlapping". Every comparison+ // below is false for NaN, so without this guard the negation reports a+ // collision for every pair. Callers surface non-finite pos/size through their+ // own diagnostic; reporting it again as an overlap buries that message under+ // one bogus separation hint per pair.+ if (!isFinitePoint(a.x, a.y, a.width, a.height, b.x, b.y, b.width, b.height)) {+ return false;+ }return !(a.x + a.width + gap <= b.x ||b.x + b.width + gap <= a.x ||diff --git a/archify/test/geometry.test.mjs b/archify/test/geometry.test.mjsindex 960e9863..b7a5e142 100644--- a/archify/test/geometry.test.mjs+++ b/archify/test/geometry.test.mjs@@ -88,6 +88,18 @@ test('rectsOverlap: negative gap shrinks the hit box (label-collision conventionassert.equal(rectsOverlap(rect(0, 0, 10, 10), rect(7, 0, 10, 10), -2), true);});+test('rectsOverlap: non-finite geometry is not an overlap', () => {+ // A component authored without pos lands here as NaN. Every comparison in the+ // negated form is false for NaN, so the unguarded version reported a collision+ // for every pair and buried the real "must include pos" diagnostic.+ const nan = rect(Number.NaN, Number.NaN, 120, 60);+ assert.equal(rectsOverlap(nan, nan, 8), false);+ assert.equal(rectsOverlap(nan, rect(0, 0, 10, 10), 8), false);+ assert.equal(rectsOverlap(rect(0, 0, 10, 10), nan, 8), false);+ assert.equal(rectsOverlap(rect(0, 0, 10, 10), rect(20, 0, Number.NaN, 10)), false);+ assert.equal(rectsOverlap(rect(0, 0, 10, 10), rect(5, 5, 10, Number.POSITIVE_INFINITY)), false);+});+test('segmentIntersectsRect: detects an edge crossing a node box', () => {assert.equal(segmentIntersectsRect({ start: [0, 5], end: [20, 5] }, rect(8, 0, 4, 10)), true);assert.equal(segmentIntersectsRect({ start: [0, 20], end: [20, 20] }, rect(8, 0, 4, 10)), false);