Skip to content

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

Merge latest dev and preserve finite waterfall time labels

tt-a1i07c3654c29d3
diff --cc archify.zip
index 3676ad8a,1e8e6e2a..73a02989
Binary files differ
diff --cc archify/renderers/waterfall/render-waterfall.mjs
index 2ce70834,826d6403..71c4f406
--- a/archify/renderers/waterfall/render-waterfall.mjs
+++ b/archify/renderers/waterfall/render-waterfall.mjs
@@@ -192,16 -192,6 +192,17 @@@ for (let index = 0; index < tickCount;
if (ticks.at(-1)?.t !== t) ticks.push({ t, x: xOf(t) });
}
+// Absolute times need enough precision for the axis and the shortest recorded
+// span, rather than the duration formatter's fixed significant-digit floor.
+const timeResolution = Math.min(tickStep, ...spans.filter(row => row.duration > 0).map(row => row.duration));
+function timeNumber(value) {
+ const ordinary = number(value);
+ if (Math.abs(value) < 1e21 && Math.abs(Number(ordinary.replaceAll(',', '')) - value) <= timeResolution / 100) return ordinary;
+ const digits = value === 0 ? 1 : Math.min(17, Math.max(1, Math.floor(Math.log10(Math.abs(value))) - Math.floor(Math.log10(timeResolution)) + 2));
- return Number(value.toPrecision(digits)).toString();
++ const rounded = Number(value.toPrecision(digits));
++ return Number.isFinite(rounded) ? rounded.toString() : value.toString();
+}
+
const LABEL_GAP = 7;
const parentIds = new Set(rows.map((row) => row.parent).filter((id) => id !== undefined));
const placed = rows.map((row, index) => {
diff --cc test/waterfall-rendering.test.mjs
index b0c6c7ba,ba6df92f..66ddf15e
--- a/test/waterfall-rendering.test.mjs
+++ b/test/waterfall-rendering.test.mjs
@@@ -106,12 -92,12 +106,14 @@@ test('waterfall: unrepresentable derive
});
test('waterfall: finite very large timing labels do not overflow while formatting', () => {
-- const diagram = clone(small);
-- diagram.spans = [{ id: 'request', name: 'Request', start: 1e307, end: 1.1e307 }];
-- const result = run(diagram);
-- assert.equal(result.status, 0, result.stderr || result.error?.message);
-- const html = fs.readFileSync(result.output, 'utf8');
-- assert.doesNotMatch(html, /(?:NaN|Infinity|∞)/);
++ for (const timing of [{ start: 1e307, end: 1.1e307 }, { start: 0, end: Number.MAX_VALUE }]) {
++ const diagram = clone(small);
++ diagram.spans = [{ id: 'request', name: 'Request', ...timing }];
++ const result = run(diagram);
++ assert.equal(result.status, 0, result.stderr || result.error?.message);
++ const html = fs.readFileSync(result.output, 'utf8');
++ assert.doesNotMatch(html, /(?:NaN|Infinity|∞)/);
++ }
});
test('waterfall: percentages name their denominator and are never summed into the parent', () => {