Skip to content

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

fix(lifecycle): preserve diagnostics for same-label transitions

tt-a1i471d00a60545
diff --git a/archify.zip b/archify.zip
index 3a1e3d91..7187c803 100644
Binary files a/archify.zip and b/archify.zip differ
diff --git a/archify/renderers/lifecycle/render-lifecycle.mjs b/archify/renderers/lifecycle/render-lifecycle.mjs
index 760730ff..9820a3af 100644
--- a/archify/renderers/lifecycle/render-lifecycle.mjs
+++ b/archify/renderers/lifecycle/render-lifecycle.mjs
@@ -297,7 +297,7 @@ function validateLifecycle() {
for (const rect of labelRects) {
for (const title of bandGeometry()) {
if (!rectsOverlap(rect, title)) continue;
- const message = `Transition label "${rect.label}" overlaps lifecycle band title "${title.label}" — move the label with labelAt/labelDx/labelDy/labelSegment or provide more space.`;
+ const message = `Transition ${rect.relationIndex} label "${rect.label}" overlaps lifecycle band title "${title.label}" — move the label with labelAt/labelDx/labelDy/labelSegment or provide more space.`;
recordDiagnostic({
code: 'composition/label-band-title-overlap', severity: 'error', message,
subject: { diagramType: 'lifecycle', collection: 'transitions', index: rect.relationIndex, from: rect.relation.from, to: rect.relation.to },
diff --git a/archify/test/lifecycle-band-title.test.mjs b/archify/test/lifecycle-band-title.test.mjs
index 85284b29..a941c07a 100644
--- a/archify/test/lifecycle-band-title.test.mjs
+++ b/archify/test/lifecycle-band-title.test.mjs
@@ -36,6 +36,28 @@ for (const [index, y] of [100, 252, 424].entries()) {
assert.equal(box.y + 11, y - 5);
});
}
+test('same-label collisions retain a diagnostic for each transition', t => {
+ const doc = structuredClone(fixture);
+ const indexes = [];
+ doc.transitions.forEach((transition, index) => {
+ if (transition.label !== '申请退款') return;
+ indexes.push(index);
+ transition.labelAt = [100 + indexes.length * 5, 95];
+ });
+ assert.equal(indexes.length, 2);
+ const result = run(t, doc);
+ assert.equal(result.status, 1, result.stdout);
+ const diagnostics = JSON.parse(result.stdout).diagnostics.filter(d => d.code === 'composition/label-band-title-overlap');
+ assert.deepEqual(diagnostics.map(d => d.subject.index), indexes);
+ diagnostics.forEach((diagnostic, i) => {
+ const transition = doc.transitions[indexes[i]];
+ assert.equal(diagnostic.subject.from, transition.from);
+ assert.equal(diagnostic.subject.to, transition.to);
+ assert.equal(diagnostic.evidence.bandTitle.index, 0);
+ const box = diagnostic.evidence.labelRect;
+ assert.equal(box.x + box.width / 2, transition.labelAt[0]);
+ });
+});
test('standard preserves authored label placement', t => {
const doc = structuredClone(fixture);
doc.meta.quality_profile = 'standard';