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: keep sequence stage labels clear
tt-a1ia6b8261f3adc
diff --git a/archify.zip b/archify.zipindex 2a18a6c7..c9576556 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/renderers/sequence/render-sequence.mjs b/archify/renderers/sequence/render-sequence.mjsindex d398fce8..8e13cc4d 100644--- a/archify/renderers/sequence/render-sequence.mjs+++ b/archify/renderers/sequence/render-sequence.mjs@@ -50,6 +50,42 @@ const participants = new Map(asArray(sequence.participants).map((participant, in}]));+function messageGeometry(message) {+ const from = participants.get(message.from);+ const to = participants.get(message.to);+ if (!from || !to || typeof message.y !== 'number') return null;+ const direction = to.cx > from.cx ? 1 : -1;+ const start = from.cx + direction * 7;+ const end = to.cx - direction * 7;+ return { start, end, center: (start + end) / 2 };+}++function messageLabelBox(message, relationIndex = null) {+ const geometry = messageGeometry(message);+ if (!geometry) return null;+ const width = Math.max(34, textUnits(message.label) * 5.2 + 12);+ return {+ relation: message,+ relationIndex,+ label: message.label,+ x: geometry.center - width / 2,+ y: message.y - 20,+ width,+ height: layout.labelH,+ };+}++function messageRouteBox(message) {+ const geometry = messageGeometry(message);+ if (!geometry) return null;+ return {+ x: Math.min(geometry.start, geometry.end),+ y: message.y - 2,+ width: Math.abs(geometry.end - geometry.start),+ height: 4,+ };+}+const compositionFrames = asArray(sequence.segments).map((segment, index) => ({id: index,label: segment.label,@@ -184,13 +220,7 @@ function validateSequence() {// Label masks can extend well past the arrow span, so check the actual// label rectangles too — tangent arrows with long labels still collide.const labelRects = asArray(sequence.messages)- .map((m, messageIndex) => {- if (!participants.has(m.from) || !participants.has(m.to) || typeof m.y !== 'number') return null;- const x1 = participants.get(m.from).cx;- const x2 = participants.get(m.to).cx;- const width = Math.max(34, textUnits(m.label) * 5.2 + 12);- return { relation: m, relationIndex: messageIndex, label: m.label, x: (x1 + x2) / 2 - width / 2, y: m.y - 20, width, height: layout.labelH };- })+ .map((m, messageIndex) => messageLabelBox(m, messageIndex)).filter(Boolean);for (let i = 0; i < labelRects.length; i += 1) {for (let j = i + 1; j < labelRects.length; j += 1) {@@ -263,9 +293,17 @@ function renderSegment(segment, index) {function renderSegmentLabel(segment, index) {const labelW = Math.max(42, textUnits(segment.label) * 5.2 + 14);+ const occupied = asArray(sequence.messages)+ .flatMap((message) => [messageLabelBox(message), messageRouteBox(message)])+ .filter(Boolean);+ const label = { x: 56, y: segment.from - 22, width: labelW, height: 18 };+ for (let attempt = 0; attempt < 4; attempt += 1) {+ if (!occupied.some((rect) => rectsOverlap(label, rect, 2))) break;+ label.y -= 22;+ }return ` <g data-graph-role="segment-label" data-segment-id="${index}">- <rect x="56" y="${segment.from - 22}" width="${labelW}" height="18" rx="3" class="c-mask"/>- <text x="62" y="${segment.from - 9}" class="t-dim" font-size="9" font-weight="600">${esc(segment.label)}</text>+ <rect x="${label.x}" y="${label.y}" width="${label.width}" height="${label.height}" rx="3" class="c-mask"/>+ <text x="${label.x + 6}" y="${label.y + 13}" class="t-dim" font-size="9" font-weight="600">${esc(segment.label)}</text></g>`;}@@ -279,9 +317,10 @@ function renderActivation(activation) {}function messageLabel(message, x1, x2) {- const center = (x1 + x2) / 2;+ const box = messageLabelBox(message);+ const center = box ? box.x + box.width / 2 : (x1 + x2) / 2;const y = message.y - 10;- const labelW = Math.max(34, textUnits(message.label) * 5.2 + 12);+ const labelW = box?.width || Math.max(34, textUnits(message.label) * 5.2 + 12);const accent = message.variant === 'security'? 't-security': message.variant === 'dashed'@@ -296,11 +335,7 @@ function messageLabel(message, x1, x2) {}function renderMessage(message, index) {- const from = participants.get(message.from);- const to = participants.get(message.to);- const direction = to.cx > from.cx ? 1 : -1;- const start = from.cx + direction * 7;- const end = to.cx - direction * 7;+ const { start, end } = messageGeometry(message);const [cls, marker] = arrowClass[message.variant || 'default'] || arrowClass.default;const strokeWidth = message.variant === 'emphasis' ? 1.8 : 1.4;const dash = message.variant === 'return' ? ' stroke-dasharray="3,5"' : '';diff --git a/archify/test/layout-rules.test.mjs b/archify/test/layout-rules.test.mjsindex b5a80d33..df085ecd 100644--- a/archify/test/layout-rules.test.mjs+++ b/archify/test/layout-rules.test.mjs@@ -547,4 +547,32 @@ test('sequence: segment titles render as foreground badges above their borders',assert.match(html, new RegExp(`<text x="62" y="${firstSegment.from - 9}"[^>]*>${firstSegment.label}</text>`));});+test('sequence: segment title badge clears a nearby first message label', () => {+ const d = load('sequence');+ const firstSegment = d.segments[0];+ const firstMessage = d.messages[0];+ firstSegment.from = 180;+ firstMessage.y = firstSegment.from + 5;++ const { code, stderr, outPath } = render('sequence', d);+ assert.equal(code, 0, stderr);+ const html = fs.readFileSync(outPath, 'utf8');+ const segment = html.match(+ /<g data-graph-role="segment-label" data-segment-id="0">\s*<rect x="([^"]+)" y="([^"]+)" width="([^"]+)" height="([^"]+)"/,+ );+ const message = html.match(new RegExp(+ `<g [^>]*data-edge-id="${firstMessage.id}"[\\s\\S]*?<rect x="([^"]+)" y="([^"]+)" width="([^"]+)" height="([^"]+)"`,+ ));+ assert.ok(segment, 'expected the first segment badge rectangle');+ assert.ok(message, 'expected the first message label rectangle');++ const [segmentX, segmentY, segmentW, segmentH] = segment.slice(1).map(Number);+ const [messageX, messageY, messageW, messageH] = message.slice(1).map(Number);+ const overlaps = segmentX < messageX + messageW+ && segmentX + segmentW > messageX+ && segmentY < messageY + messageH+ && segmentY + segmentH > messageY;+ assert.equal(overlaps, false, 'segment title badge must not cover the first message label');+});+process.on('exit', () => fs.rmSync(tmp, { recursive: true, force: true }));diff --git a/archify/test/ordinary-model-floor.test.mjs b/archify/test/ordinary-model-floor.test.mjsindex 2bea0d15..c3b17f10 100644--- a/archify/test/ordinary-model-floor.test.mjs+++ b/archify/test/ordinary-model-floor.test.mjs@@ -502,7 +502,7 @@ test('checked-in cases accept equivalent ordinary-model vocabulary without weakemutate(candidate) {Object.assign(candidate.participants.find((node) => node.id === 'browser-tab'), { label: 'Browser', type: 'external' });candidate.participants.find((node) => node.id === 'dashboard-api').label = 'Dashboard API';- candidate.participants.find((node) => node.id === 'token-guard').label = 'JWT Guard';+ candidate.participants.find((node) => node.id === 'token-guard').label = 'Authorizer';candidate.messages.find((message) => message.id === 'verify-jwt').label = 'validate JWT';candidate.messages.find((message) => message.id === 'cache-read').label = 'GET dashboard key';candidate.messages.find((message) => message.id === 'profile-query').label = 'SELECT profile + metrics';diff --git a/benchmarks/ordinary-model-floor/cases/cache-miss.sequence.case.json b/benchmarks/ordinary-model-floor/cases/cache-miss.sequence.case.jsonindex 8c8b738c..0b710d23 100644--- a/benchmarks/ordinary-model-floor/cases/cache-miss.sequence.case.json+++ b/benchmarks/ordinary-model-floor/cases/cache-miss.sequence.case.json@@ -7,7 +7,7 @@"nodes": [{ "key": "web", "labels": ["Web App", "Browser"], "types": ["frontend", "external"] },{ "key": "api", "labels": ["API", "API Server"], "type": "backend" },- { "key": "auth", "labels": ["Auth", "Authentication", "Identity", "JWT Guard", "Token Guard"], "type": "security" },+ { "key": "auth", "labels": ["Auth", "Authentication", "Identity", "Authorizer", "JWT Authorizer", "JWT Guard", "Token Guard"], "type": "security" },{ "key": "redis", "labels": ["Redis", "Cache"], "type": "database" },{ "key": "db", "labels": ["Postgres", "PostgreSQL", "Database"], "type": "database" }],