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(viewer): stabilize dock after zoomed page flow
tt-a1ia6ba90b87d82
diff --git a/test/desktop-reader-browser.test.mjs b/test/desktop-reader-browser.test.mjsindex a154d218..2e8f2d2a 100644--- a/test/desktop-reader-browser.test.mjs+++ b/test/desktop-reader-browser.test.mjs@@ -74,7 +74,9 @@ test('default sequence and dataflow canvases fit the real desktop reader without} else {assert.equal(result.exitCode, 0, `${type}: ${JSON.stringify(result.receipt.diagnostics)}`);assert.equal(result.receipt.readability.status, 'pass');- assert.ok(result.receipt.containment.viewports.every((v) => v.ok && v.readerFit === 'intrinsic-height'));+ const readerFit = type === 'sequence' ? 'width-first' : 'intrinsic-height';+ assert.ok(result.receipt.containment.viewports.every((v) => v.ok && v.readerFit === readerFit),+ `${type}: ${JSON.stringify(result.receipt.containment.viewports)}`);}}}diff --git a/test/viewer-camera-browser.test.mjs b/test/viewer-camera-browser.test.mjsindex 9d9b1eee..8d2b9731 100644--- a/test/viewer-camera-browser.test.mjs+++ b/test/viewer-camera-browser.test.mjs@@ -91,9 +91,12 @@ test('Camera preserves transactions, rendered state and real caller handoffs', {const container = document.querySelector('.diagram-container');const svg = container.querySelector(':scope > svg');const rect = svg.getBoundingClientRect();+ const box = container.getBoundingClientRect(), nav = container.querySelector('.diagram-nav').getBoundingClientRect();const current = JSON.stringify([Archify.view.state(), getComputedStyle(svg).transform,svg.style.clipPath, container.scrollLeft, container.getAttribute('data-camera-transaction'),- container.style.getPropertyValue('--archify-nav-reserve'), rect.x, rect.y, rect.width, rect.height]);+ container.style.getPropertyValue('--archify-nav-reserve'), rect.x, rect.y, rect.width, rect.height,+ scrollY, document.documentElement.scrollHeight, box.top, box.bottom, nav.top, nav.bottom,+ container.style.getPropertyValue('--archify-dock-lift')]);equal = current === previous ? equal + 1 : 0;previous = current;return equal >= 8 && !container.hasAttribute('data-camera-transaction');@@ -297,25 +300,54 @@ test('Camera preserves transactions, rendered state and real caller handoffs', {});await t.test('long-diagram zoom preserves visible content from middle and bottom scroll positions', async () => {- for (const position of [0.5, 0.85, 'page-bottom']) {- await load('longSequence', { width: 1280, height: 800, reduced: position !== 'page-bottom' });- const scrollTarget = position === 'page-bottom' ? 'document.documentElement.scrollHeight'+ for (const position of ['page-bottom-no-anchor', 0, 0.5, 0.85, 'page-bottom']) {+ await load('longSequence', { width: 1280, height: 800, reduced: typeof position === 'number' && position > 0 });+ if (position === 'page-bottom-no-anchor') await run(`document.documentElement.style.overflowAnchor = 'none'`);+ const scrollTarget = typeof position === 'string' ? 'document.documentElement.scrollHeight': `document.querySelector('.diagram-container > svg').clientHeight * ${position}`;await run(`window.scrollTo(0, ${scrollTarget})`);await stable();+ const initialReserve = await run(`document.querySelector('.diagram-container').style.getPropertyValue('--archify-nav-reserve')`);for (const scale of [0.75, 0.5, 0.25, 0.5, 0.75, 1]) {+ await run(`(() => {+ window.cameraDockTrace = []; window.cameraDockTracing = true;+ function frame() {+ if (!cameraDockTracing) return;+ const c = document.querySelector('.diagram-container'), s = c.querySelector(':scope > svg');+ const nav = c.querySelector('.diagram-nav'), n = nav.getBoundingClientRect(), b = c.getBoundingClientRect();+ cameraDockTrace.push({ time: performance.now(), scale: Archify.view.state().scale,+ paintedScale: s.getBoundingClientRect().height / s.clientHeight, scrollY,+ pageHeight: document.documentElement.scrollHeight, containerTop: b.top, containerBottom: b.bottom,+ navTop: n.top, navBottom: n.bottom, lift: c.style.getPropertyValue('--archify-dock-lift'),+ height: c.style.height });+ requestAnimationFrame(frame);+ }+ requestAnimationFrame(frame);+ })()`);const currentScale = await run('Archify.view.state().scale');await run(`Archify.view.${scale < currentScale ? 'zoomOut' : 'zoomIn'}()`);await stable();const value = await run(`(() => {const s = document.querySelector('.diagram-container > svg'), c = s.parentElement;- const r = s.getBoundingClientRect(), nav = c.querySelector('.diagram-nav').getBoundingClientRect();+ cameraDockTracing = false;+ const r = s.getBoundingClientRect(), nav = c.querySelector('.diagram-nav').getBoundingClientRect(), b = c.getBoundingClientRect();return { state: Archify.view.state(), top: r.top, bottom: r.bottom,- scrollY, navTop: nav.top, navBottom: nav.bottom, windowHeight: innerHeight };+ scrollY, navTop: nav.top, navBottom: nav.bottom, navHeight: nav.height, windowHeight: innerHeight,+ windowWidth: innerWidth, documentWidth: document.documentElement.clientWidth,+ pageHeight: document.documentElement.scrollHeight, containerTop: b.top, containerBottom: b.bottom,+ containerHeight: b.height, baseSvgHeight: s.clientHeight,+ ratio: s.viewBox.baseVal.width / s.viewBox.baseVal.height,+ lift: c.style.getPropertyValue('--archify-dock-lift'), flowHeight: c.style.height,+ reserve: c.style.getPropertyValue('--archify-nav-reserve'),+ trajectory: cameraDockTrace };})()`);+ records.push({ label: `dock-trajectory-${position}-${scale}`, ...value });assert.equal(value.state.scale, scale);+ assert.ok(Math.abs(parseFloat(value.reserve || '0') - parseFloat(initialReserve || '0')) <= 1,+ 'manual zoom preserves the baseline rail within one CSS-pixel rounding: ' + JSON.stringify({ position, requestedScale: scale, ...value }));assert.ok(value.bottom > 0 && value.top < value.windowHeight, 'shrunk content stays on screen');- assert.ok(value.navTop >= 0 && value.navBottom <= value.windowHeight, 'existing dock lift keeps controls usable');+ assert.ok(value.navTop >= 0 && value.navBottom <= value.windowHeight,+ 'existing dock lift keeps controls usable: ' + JSON.stringify({ position, requestedScale: scale, ...value }));await snapshot(`long-scrolled-${position}-${scale}`);await screenshot(`long-scrolled-${position}-${scale}`);}diff --git a/viewer/README.md b/viewer/README.mdindex 0f3bee5b..1c9c5e36 100644--- a/viewer/README.md+++ b/viewer/README.md@@ -653,7 +653,10 @@ absent legend does not disable protection of the SVG stage. `stageRect` removescamera scale/translation from measured geometry; it never rewrites SVG geometry.Resize, load, print, font readiness and the existing observers retain their-original roles. ResizeObserver watches navigation/SVG/legend size;+original roles. ResizeObserver watches navigation/SVG/legend size; a separate+container-size observation updates dock lift when Camera changes page flow,+without remeasuring the baseline rail. The stability waiter includes that lift+frame and its final value.MutationObserver watches legend content and the root embed/presentation/preset/theme attributes. Camera Reset preserves the established rail; viewport, modeand content changes are responsible for baseline reprobes. Optional observer@@ -696,7 +699,9 @@ page-flow height to the painted SVG height plus its existing padding/borders.The SVG retains its intrinsic client size, so zoom and layout cannot repeatedlyshrink the camera base. Size observation follows Reader width and Chrome reservechanges without requiring a window resize. Reset, short diagrams, Embed, Present-and print restore the original inline container height and priority. This outer+and print restore the original inline container height and priority. Reaching+a 100% target restores ordinary flow immediately, so Chrome cannot interpret+a partly shrunk CSS-animation frame as a new baseline rail. This outerlayout state is absent from canonical SVG exports.`reveal` returns a transaction or false, with branch-specific side effects.diff --git a/viewer/viewer-camera.js b/viewer/viewer-camera.jsindex 95acead3..c75c92be 100644--- a/viewer/viewer-camera.js+++ b/viewer/viewer-camera.js@@ -145,7 +145,10 @@var ordinary = html.getAttribute('data-embed') !== 'true' &&html.getAttribute('data-present') !== 'true' &&(!window.matchMedia || !window.matchMedia('print').matches);- if (ordinary && camera.scale < 1 && height > window.innerHeight) {+ // Restore ordinary flow as soon as the target reaches 100%. Chrome+ // uses that target to resume baseline rail measurement; retaining a+ // partially shrunk box during the CSS transition would inflate reserve.+ if (ordinary && state.scale < 1 && camera.scale < 1 && height > window.innerHeight) {var style = getComputedStyle(container);var chrome = ['paddingTop', 'paddingBottom', 'borderTopWidth', 'borderBottomWidth'].reduce(function (total, key) { return total + (parseFloat(style[key]) || 0); }, 0);diff --git a/viewer/viewer-chrome-layout.js b/viewer/viewer-chrome-layout.jsindex d603a809..06d15935 100644--- a/viewer/viewer-chrome-layout.js+++ b/viewer/viewer-chrome-layout.js@@ -285,6 +285,7 @@var legendRect = legend ? legend.getBoundingClientRect() : { top: 0, left: 0 };return [reserve,+ lift,Math.round(containerRect.width * 100) / 100,Math.round(containerRect.height * 100) / 100,Math.round(navRect.left * 100) / 100,@@ -295,7 +296,7 @@lastReceipt ? lastReceipt.stageGap : ''].join('|');}- function layoutPending() { return Boolean(frame || settleFrame || probingBaseline); }+ function layoutPending() { return Boolean(frame || settleFrame || liftFrame || probingBaseline); }function whenStable() {return Archify.waitForStableLayout({schedule: schedule,@@ -315,6 +316,10 @@if (typeof ResizeObserver === 'function') {var resizeObserver = new ResizeObserver(schedule);[nav, svg, legend].forEach(function (element) { if (element) resizeObserver.observe(element); });+ // Camera zoom changes outer page flow without changing intrinsic SVG+ // size. Follow that box for dock placement, independently of scrolling+ // and the baseline stage-rail measurement.+ new ResizeObserver(scheduleLift).observe(container);}if (typeof MutationObserver === 'function') {var contentObserver = new MutationObserver(function (records) {