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(architecture): straighten bent routes through facing sides
tt-a1icec32bba69f5
diff --git a/archify/renderers/architecture/routing.mjs b/archify/renderers/architecture/routing.mjsindex f768da18..f2e8ed9c 100644--- a/archify/renderers/architecture/routing.mjs+++ b/archify/renderers/architecture/routing.mjs@@ -1194,37 +1194,44 @@ export function createRouter(components, connections = [], {reservedLabels = reservedLabels.filter((label) => label.conn !== conn);if (best.rect) reservedLabels.push({ conn, rect: best.rect });}- // A dogleg between facing sides whose nodes overlap across the route- // can run straight inside that overlap. Every other route, slot and- // label stays fixed, and the straight lane must pass the same checks.+ // A bent route between nodes that overlap across the gap separating+ // them can run straight through facing sides inside that overlap.+ // Authored sides must already face; every other route, slot and label+ // stays fixed, and the straight lane must pass the same checks.for (const entry of resolvedRoutes) {const { conn } = entry;- if (entry.points.length !== 4 || jointlyImproved.has(conn)+ if (entry.points.length < 4 || jointlyImproved.has(conn)|| hasAuthoredRouteGeometry(conn) || hasAuthoredLabelPlacement(conn)) continue;- const sides = selectedSides.get(conn);- const facing = `${sides.fromSide}>${sides.toSide}`;- const axis = facing === 'right>left' || facing === 'left>right' ? 1- : facing === 'bottom>top' || facing === 'top>bottom' ? 0 : null;- if (axis === null) continue;- const geometry = connectionGeometry(conn, sides);+ const from = components.get(conn.from);+ const to = components.get(conn.to);+ const facing = from.x + from.width <= to.x ? { fromSide: 'right', toSide: 'left' }+ : to.x + to.width <= from.x ? { fromSide: 'left', toSide: 'right' }+ : from.y + from.height <= to.y ? { fromSide: 'bottom', toSide: 'top' }+ : to.y + to.height <= from.y ? { fromSide: 'top', toSide: 'bottom' } : null;+ if (!facing) continue;+ const axis = facing.fromSide === 'right' || facing.fromSide === 'left' ? 1 : 0;const [origin, size] = axis === 1 ? ['y', 'height'] : ['x', 'width'];- const low = Math.max(geometry.from[origin], geometry.to[origin]) + AUTOMATIC_PORT_CORNER_GUTTER;- const high = Math.min(geometry.from[origin] + geometry.from[size], geometry.to[origin] + geometry.to[size])- - AUTOMATIC_PORT_CORNER_GUTTER;- if (high < low) continue;- const start = entry.points[0];- const end = entry.points.at(-1);+ const low = Math.max(from[origin], to[origin]) + AUTOMATIC_PORT_CORNER_GUTTER;+ const high = Math.min(from[origin] + from[size], to[origin] + to[size]) - AUTOMATIC_PORT_CORNER_GUTTER;+ if (high < low+ || (conn.fromSide && conn.fromSide !== 'auto' && conn.fromSide !== facing.fromSide)+ || (conn.toSide && conn.toSide !== 'auto' && conn.toSide !== facing.toSide)) continue;+ const sides = facing;+ const geometry = connectionGeometry(conn, sides);+ const start = geometry.start;+ const end = geometry.end;const clamp = (value) => Math.min(high, Math.max(low, value));const others = resolvedRoutes.filter((other) => other !== entry);const otherLabels = reservedLabels.filter((label) => label.conn !== conn);const crossingsBefore = crossingCount(conn, entry.points, others);+ const sidesOf = (candidate) => (candidate === conn ? sides : selectedSides.get(candidate));for (const lane of new Set([start[axis], end[axis], (start[axis] + end[axis]) / 2, (low + high) / 2].map(clamp))) {const points = [[...start], [...end]];points[0][axis] = lane;points[1][axis] = lane;const routed = { conn, points, d: roundedPath(points, 8) };if (!points.every(withinScene)- || !endpointSlotsClear([routed], others, (candidate) => selectedSides.get(candidate))+ || !endpointSlotsClear([routed], others, sidesOf)|| !routeIsClear(conn, routed, geometry, others)|| crossingCount(conn, points, others) > crossingsBefore) continue;const rect = labelRectFor?.(conn, points, {