Skip to content

Turn any idea, plan, or codebase into a beautiful interactive diagram. An agent skill for Claude Code, Codex, and more.

docs(sequence): fit automatic canvas height to timeline content

tt-a1id70c72d8b7ac
diff --git a/archify/renderers/sequence/README.md b/archify/renderers/sequence/README.md
index 81005538..2f1ea990 100644
--- a/archify/renderers/sequence/README.md
+++ b/archify/renderers/sequence/README.md
@@ -55,7 +55,8 @@ not create edge facts.
The legend sits below all timeline content: the last message and its note,
activation bars, and segment frames, with a 12px gap. Without `meta.viewBox`
-the canvas grows to keep that gap. With an authored `viewBox` that is too short,
+the canvas height fits that content (no fixed 760px floor) and grows when late
+messages need more room. With an authored `viewBox` that is too short,
`showcase` fails with the exact height to set, and `standard` hides the implicit
legend rather than drawing it over content. Lifelines stop above the legend.
Message labels use their line's color; gray default and return lines keep the
@@ -65,7 +66,7 @@ muted text color.
| Constant | Value |
|----------|-------|
-| viewBox | default `[920, 760]`, taller when late content needs legend room; schema minimum `[480, 480]` |
+| viewBox | automatic height fits content + legend (minimum 327px readable band); taller when late content needs more room; width defaults to 920 (wider for crowded spread). Schema minimum `[480, 480]` |
| Participant boxes | `spread` (default): viewBox-relative width from 86px up to 190px; `fixed`: 86px wide; both 60px tall at y 72 |
| Participant columns | `fixed`: centers at x = 62 + index×108; `spread`: columns distribute across the available viewBox width with at least a 16px card gutter |
| Participant count | the last box must end at or before width − 40; layouts that cannot fit fail closed |
diff --git a/archify/renderers/sequence/render-sequence.mjs b/archify/renderers/sequence/render-sequence.mjs
index 10c197fa..ab3bc04b 100644
--- a/archify/renderers/sequence/render-sequence.mjs
+++ b/archify/renderers/sequence/render-sequence.mjs
@@ -78,10 +78,15 @@ function automaticCanvasWidth() {
const count = Math.max(1, asArray(sequence.participants).length);
return Math.min(readableCanvasWidth, Math.max(920, Math.ceil((Math.min(190, needed) + 25) * count + 124)));
}
-// A renderer-sized canvas grows to keep the legend clear of late messages;
-// an authored viewBox is honored and validated below.
+// A renderer-sized canvas grows to keep the legend clear of late messages and
+// shrinks when the timeline is short: the old 760px floor left ~600px of empty
+// lifeline under typical 4–8 message drafts. Keep a readable minimum band
+// (lifelineTop 142 + 120px timeline + 65px footer = 327) so short diagrams stay
+// usable; an authored viewBox is honored and validated below.
+const SEQUENCE_MIN_AUTO_HEIGHT = 327;
const automaticWidth = sequence.meta?.viewBox ? null : automaticCanvasWidth();
-const viewBox = sequence.meta?.viewBox || [automaticWidth, Math.max(760, legendRequiredHeight(automaticWidth))];
+const automaticHeight = Math.max(SEQUENCE_MIN_AUTO_HEIGHT, legendRequiredHeight(automaticWidth));
+const viewBox = sequence.meta?.viewBox || [automaticWidth, automaticHeight];
// The timeline scales with viewBox height: a taller viewBox gains message room,
// a shorter one shrinks the readable band (validated below) instead of clipping.
// `column_fit: "spread"` widens the lanes with the viewBox instead of keeping
diff --git a/test/sequence-column-fit.test.mjs b/test/sequence-column-fit.test.mjs
index 468a0240..31f62294 100644
--- a/test/sequence-column-fit.test.mjs
+++ b/test/sequence-column-fit.test.mjs
@@ -242,7 +242,7 @@ test('eight participants fit the automatic 920px canvas with default and explici
assert.equal(boxes[0].x, 62);
assert.equal(boxes.at(-1).x + boxes.at(-1).width, 880);
for (let i = 1; i < boxes.length; i++) assert.ok(boxes[i].x - boxes[i - 1].x - boxes[i - 1].width >= 16);
- assert.match(html, /viewBox="0 0 920 760"/);
+ assert.match(html, /viewBox="0 0 920 327"/);
assert.deepEqual(doc, original);
assert.equal(html, render({ ...doc, meta: { ...doc.meta, column_fit: 'spread' } }, true));
const fixedBoxes = participantBoxes(render({ ...doc, meta: { ...doc.meta, column_fit: 'fixed' } }, true));