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): settle the adaptive reader when card height follows its width
tt-a1i4ec1022608ad
diff --git a/archify/assets/template.html b/archify/assets/template.htmlindex 28fe75fe..ef07b28d 100644--- a/archify/assets/template.html+++ b/archify/assets/template.html@@ -11260,6 +11260,10 @@ OTHER DEALINGS IN THE FONT SOFTWARE.var frame = 0;var settleFrame = 0;var lastWidth = 0;+ // Widest reader the overflow settle has accepted for this viewport. Card+ // copy rewraps as the reader narrows, so recomputing from fixed heights+ // alone would widen again and oscillate; only a resize lifts the cap.+ var settledCap = Infinity;var WIDE_RATIO = 1.55;var MIN_DESKTOP_WIDTH = 1024;var MIN_READER_WIDTH = 960;@@ -11321,6 +11325,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.html.removeAttribute('data-reader-layout');html.removeAttribute('data-reader-overflow');lastWidth = 0;+ settledCap = Infinity;}function chromeMetrics() {var bodyStyle = window.getComputedStyle(body);@@ -11353,6 +11358,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.) - window.innerHeight;if (overflow > 1 && lastWidth > Math.ceil(minWidth)) {applyWidth(Math.max(minWidth, lastWidth - overflow * ratio - 4), minWidth);+ settledCap = lastWidth;html.setAttribute('data-reader-overflow', 'reduced');} else if (overflow > 1) {html.setAttribute('data-reader-overflow', 'authored');@@ -11390,7 +11396,7 @@ OTHER DEALINGS IN THE FONT SOFTWARE.outerHeight(header) + outerHeight(guided) + outerHeight(cards);var availableSvgHeight = Math.max(1, window.innerHeight - fixedHeight);var desiredWidth = availableSvgHeight * ratio + chrome.diagramX;- var width = Math.max(minWidth, Math.min(maxWidth, desiredWidth));+ var width = Math.max(minWidth, Math.min(maxWidth, desiredWidth, settledCap));applyWidth(width, minWidth);settleOverflow(minWidth);return {@@ -11432,7 +11438,10 @@ OTHER DEALINGS IN THE FONT SOFTWARE.}archifyLayoutOwners.reader = { schedule: schedule, pending: layoutPending, snapshot: stableSnapshot };- window.addEventListener('resize', schedule, { passive: true });+ window.addEventListener('resize', function () {+ settledCap = Infinity;+ schedule();+ }, { passive: true });window.addEventListener('load', schedule, { once: true });if (document.fonts && document.fonts.ready) document.fonts.ready.then(schedule).catch(function () {});if (typeof ResizeObserver === 'function') {diff --git a/archify/bin/visual-check.mjs b/archify/bin/visual-check.mjsindex 8edff00b..7d9d7ebf 100644--- a/archify/bin/visual-check.mjs+++ b/archify/bin/visual-check.mjs@@ -1711,7 +1711,29 @@ export class ChromeVisualBrowser {spaceBelowNodesPx: bottom === null ? null : Math.round(rect.bottom - bottom)};}).sort(function (a, b) { return b.heightPx - a.heightPx; }).slice(0, 6) : [];+ // Vertical page budget: every block that stacks above or below the SVG,+ // so an overflow receipt can say which part must give up how many pixels.+ function outerHeight(element) {+ if (!element) return 0;+ var style = window.getComputedStyle(element);+ if (element.hidden || style.display === 'none') return 0;+ return element.getBoundingClientRect().height+ + (parseFloat(style.marginTop) || 0) + (parseFloat(style.marginBottom) || 0);+ }+ var bodyStyle = window.getComputedStyle(document.body);+ var diagramStyle = diagram ? window.getComputedStyle(diagram) : null;+ var svgHeight = svg ? svg.getBoundingClientRect().height : 0;+ var pageComposition = {+ bodyPaddingPx: Math.round((parseFloat(bodyStyle.paddingTop) || 0) + (parseFloat(bodyStyle.paddingBottom) || 0)),+ headerPx: Math.round(outerHeight(reader && reader.querySelector('.header'))),+ guidedViewsPx: Math.round(outerHeight(reader && reader.querySelector('.guided-views'))),+ diagramChromePx: Math.round(outerHeight(diagram) - svgHeight),+ svgPx: Math.round(svgHeight),+ cardsPx: Math.round(outerHeight(reader && reader.querySelector('.cards'))),+ viewBoxHeight: viewBox ? viewBox.height : 0+ };return {+ pageComposition: pageComposition,innerWidth: window.innerWidth,innerHeight: window.innerHeight,scrollWidth: Math.ceil(document.documentElement.scrollWidth),@@ -1847,6 +1869,7 @@ function observation({ width, height, theme, metrics }) {ok: containmentOk,readerWidth: Number(metrics.readerWidth) || null,diagramWidth: Number(metrics.diagramWidth) || null,+ ...(metrics.pageComposition ? { pageComposition: metrics.pageComposition } : {}),viewBoxWidth: Number(metrics.viewBoxWidth) || null,...(metrics.workflowLanes?.length ? { workflowLanes: metrics.workflowLanes } : {}),minimumProjectedNodeTextPx,@@ -1940,10 +1963,36 @@ function resolveSidecarDirectory(artifactPath, outputs, compareParents) {};}+// Turn a measured vertical overflow into the pixel budget an author can act on:+// which stacked block holds the height, and what the SVG or cards must shrink to.+export function verticalBudgetFixes(entry) {+ const page = entry.pageComposition;+ if (!entry.overflowY || !page) return [];+ const excess = entry.scrollHeight - entry.innerHeight;+ const fixes = [];+ const stacked = `${page.bodyPaddingPx}px body padding + ${page.headerPx}px header + ${page.guidedViewsPx}px guided views + ${page.diagramChromePx}px diagram chrome + ${page.svgPx}px SVG + ${page.cardsPx}px cards = ${entry.scrollHeight}px against ${entry.innerHeight}px`;+ if (page.svgPx > 0 && page.viewBoxHeight > 0) {+ const targetSvg = page.svgPx - excess;+ const targetViewBoxHeight = Math.floor(page.viewBoxHeight * targetSvg / page.svgPx);+ if (entry.readerLayout === 'adaptive') {+ fixes.push(targetSvg > 0+ ? `the page is ${excess}px too tall (${stacked}); the Reader already narrowed the stage to its ${entry.diagramWidth}px minimum, so the SVG height only follows meta.viewBox: keep every node and relationship and reduce the viewBox height to at most ${targetViewBoxHeight} (from ${page.viewBoxHeight}) by tightening vertical gaps and empty rows`+ : `the page is ${excess}px too tall (${stacked}) and the SVG alone exceeds the viewport at the minimum reader width; split the diagram into two`);+ } else {+ fixes.push(`the page is ${excess}px too tall (${stacked}); the SVG spans the full ${entry.diagramWidth}px reader width because its viewBox ratio is below 1.55 and it declares no intrinsic-height fit, so the Reader can neither narrow it nor accept readable vertical scroll: either remove meta.viewBox so the renderer sizes the canvas and declares the fit, or make the viewBox at least 1.55x wider than tall`);+ }+ }+ if (page.cardsPx >= excess) {+ fixes.push(`alternatively, conclusion cards occupy ${page.cardsPx}px below the diagram; shortening card copy or dropping a card row so cards take at most ${page.cardsPx - excess}px also fits`);+ }+ return fixes;+}+function observationDiagnostics({ artifact, allObservations, readabilityObservations }) {const diagnostics = [];for (const entry of allObservations) {if (!entry.ok) {+ const budgetFixes = verticalBudgetFixes(entry);diagnostics.push(failureDiagnostic({code: 'viewer/viewport-overflow',message: `The rendered artifact overflows the ${entry.width}x${entry.height} ${entry.theme} viewport.`,@@ -1959,17 +2008,22 @@ function observationDiagnostics({ artifact, allObservations, readabilityObservatreaderLayout: entry.readerLayout,readerOverflow: entry.readerOverflow,readerFit: entry.readerFit,+ ...(entry.overflowY && entry.pageComposition ? {+ pageComposition: entry.pageComposition,+ pageCompositionMeasurement: 'CSS pixels at this viewport; body padding, header, guided-views strip, diagram chrome, SVG and cards stack vertically and sum to scrollHeight',+ } : {}),...(entry.overflowY && entry.workflowLanes?.length ? {workflowLanes: entry.workflowLanes,measurement: 'CSS pixels; rendered node boxes geometrically contained in each lane frame; spaces include headers and routing, not guaranteed removable space',} : {}),},supportedFixes: [+ ...budgetFixes,...(entry.overflowY && entry.workflowLanes?.length ? ['run validate workflow <source.json> --layout-json and compare the tallest rendered lane frames with source lanes, col and yOffset; frame IDs are rendered indices, not source lane IDs','where ownership and explicit geometry permit, distribute stacked steps across logical columns and meaningful lanes before increasing yOffset; preserve nodes, branches, labels and hard pins','read references/authoring-contract.md#workflow-viewport-repair, then validate and deliver the changed source before rerunning visual-check on the new artifact; this is inspection guidance, not a verified coordinate fix',- ] : [`contain the rendered layout within ${entry.width}x${entry.height}, then rerun visual-check`]),+ ] : budgetFixes.length ? [] : [`contain the rendered layout within ${entry.width}x${entry.height}, then rerun visual-check`]),],}));}diff --git a/archify/test/fixtures/architecture-viewport/portrait-cards.architecture.json b/archify/test/fixtures/architecture-viewport/portrait-cards.architecture.jsonnew file mode 100644index 00000000..c3c00b99--- /dev/null+++ b/archify/test/fixtures/architecture-viewport/portrait-cards.architecture.json@@ -0,0 +1,361 @@+{+ "schema_version": 1,+ "diagram_type": "architecture",+ "meta": {+ "title": "Tall showcase fixture",+ "output": "portrait-cards.html",+ "quality_profile": "showcase",+ "views": [+ {+ "id": "v0",+ "label": "View 0",+ "focus": [+ "n0",+ "n1"+ ]+ },+ {+ "id": "v1",+ "label": "View 1",+ "focus": [+ "n3",+ "n4"+ ]+ },+ {+ "id": "v2",+ "label": "View 2",+ "focus": [+ "n6",+ "n7"+ ]+ },+ {+ "id": "v3",+ "label": "View 3",+ "focus": [+ "n9",+ "n10"+ ]+ }+ ]+ },+ "components": [+ {+ "id": "n0",+ "type": "frontend",+ "label": "Service 0",+ "sublabel": "owns step 0",+ "pos": [+ 60,+ 60+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n1",+ "type": "frontend",+ "label": "Service 1",+ "sublabel": "owns step 1",+ "pos": [+ 360,+ 60+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n2",+ "type": "frontend",+ "label": "Service 2",+ "sublabel": "owns step 2",+ "pos": [+ 660,+ 60+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n3",+ "type": "backend",+ "label": "Service 3",+ "sublabel": "owns step 3",+ "pos": [+ 60,+ 210+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n4",+ "type": "backend",+ "label": "Service 4",+ "sublabel": "owns step 4",+ "pos": [+ 360,+ 210+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n5",+ "type": "backend",+ "label": "Service 5",+ "sublabel": "owns step 5",+ "pos": [+ 660,+ 210+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n6",+ "type": "database",+ "label": "Service 6",+ "sublabel": "owns step 6",+ "pos": [+ 60,+ 360+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n7",+ "type": "database",+ "label": "Service 7",+ "sublabel": "owns step 7",+ "pos": [+ 360,+ 360+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n8",+ "type": "database",+ "label": "Service 8",+ "sublabel": "owns step 8",+ "pos": [+ 660,+ 360+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n9",+ "type": "cloud",+ "label": "Service 9",+ "sublabel": "owns step 9",+ "pos": [+ 60,+ 510+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n10",+ "type": "cloud",+ "label": "Service 10",+ "sublabel": "owns step 10",+ "pos": [+ 360,+ 510+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n11",+ "type": "cloud",+ "label": "Service 11",+ "sublabel": "owns step 11",+ "pos": [+ 660,+ 510+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n12",+ "type": "security",+ "label": "Service 12",+ "sublabel": "owns step 12",+ "pos": [+ 60,+ 660+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n13",+ "type": "security",+ "label": "Service 13",+ "sublabel": "owns step 13",+ "pos": [+ 360,+ 660+ ],+ "size": [+ 180,+ 64+ ]+ },+ {+ "id": "n14",+ "type": "security",+ "label": "Service 14",+ "sublabel": "owns step 14",+ "pos": [+ 660,+ 660+ ],+ "size": [+ 180,+ 64+ ]+ }+ ],+ "connections": [+ {+ "from": "n0",+ "to": "n1",+ "label": "call 0"+ },+ {+ "from": "n1",+ "to": "n2",+ "label": "call 1"+ },+ {+ "from": "n0",+ "to": "n3",+ "label": "next row 0"+ },+ {+ "from": "n3",+ "to": "n4",+ "label": "call 3"+ },+ {+ "from": "n4",+ "to": "n5",+ "label": "call 4"+ },+ {+ "from": "n3",+ "to": "n6",+ "label": "next row 1"+ },+ {+ "from": "n6",+ "to": "n7",+ "label": "call 6"+ },+ {+ "from": "n7",+ "to": "n8",+ "label": "call 7"+ },+ {+ "from": "n6",+ "to": "n9",+ "label": "next row 2"+ },+ {+ "from": "n9",+ "to": "n10",+ "label": "call 9"+ },+ {+ "from": "n10",+ "to": "n11",+ "label": "call 10"+ },+ {+ "from": "n9",+ "to": "n12",+ "label": "next row 3"+ },+ {+ "from": "n12",+ "to": "n13",+ "label": "call 12"+ },+ {+ "from": "n13",+ "to": "n14",+ "label": "call 13"+ }+ ],+ "cards": [+ {+ "dot": "cyan",+ "title": "Card 0",+ "items": [+ "Statement 0.1 about the system",+ "Statement 0.2 with a bit more copy to wrap lines"+ ]+ },+ {+ "dot": "cyan",+ "title": "Card 1",+ "items": [+ "Statement 1.1 about the system",+ "Statement 1.2 with a bit more copy to wrap lines"+ ]+ },+ {+ "dot": "cyan",+ "title": "Card 2",+ "items": [+ "Statement 2.1 about the system",+ "Statement 2.2 with a bit more copy to wrap lines"+ ]+ },+ {+ "dot": "cyan",+ "title": "Card 3",+ "items": [+ "Statement 3.1 about the system",+ "Statement 3.2 with a bit more copy to wrap lines"+ ]+ }+ ]+}diff --git a/archify/test/reader-layout-settle-browser.test.mjs b/archify/test/reader-layout-settle-browser.test.mjsnew file mode 100644index 00000000..e05ef77c--- /dev/null+++ b/archify/test/reader-layout-settle-browser.test.mjs@@ -0,0 +1,77 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { execFileSync } from 'node:child_process';+import { fileURLToPath, pathToFileURL } from 'node:url';++import { ChromeVisualBrowser, findChrome } from '../bin/visual-check.mjs';++const skillRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const chromeConfigured = Object.prototype.hasOwnProperty.call(process.env, 'ARCHIFY_CHROME');+const chromePath = chromeConfigured ? findChrome() : null;+if (chromeConfigured && !chromePath) {+ throw new Error(`ARCHIFY_CHROME does not resolve to an executable browser: ${process.env.ARCHIFY_CHROME}`);+}++// A portrait architecture whose conclusion cards rewrap as the Reader narrows.+// Before the settled-width cap, measure() widened the stage from the shorter+// cards, settle() narrowed it from the resulting overflow, and the two never+// met: whenStable() timed out and visual-check reported a runtime failure+// instead of a layout verdict.+test('Reader Layout settles when card height depends on the reader width', {+ skip: chromePath ? false : 'Set ARCHIFY_CHROME to run the real browser regression.',+}, async () => {+ const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'archify-reader-settle-'));+ const output = path.join(scratch, 'portrait-cards.html');+ execFileSync(process.execPath, [+ path.join(skillRoot, 'renderers/architecture/render-architecture.mjs'),+ path.join(skillRoot, 'test/fixtures/architecture-viewport/portrait-cards.architecture.json'),+ output,+ ]);+ const browser = new ChromeVisualBrowser(chromePath);+ try {+ const session = await browser.sessionPromise;+ for (const [width, height] of [[1440, 900], [2048, 1320]]) {+ await browser.cdp.send('Emulation.setDeviceMetricsOverride', { width, height, deviceScaleFactor: 1, mobile: false }, session);+ const url = pathToFileURL(output);+ url.searchParams.set('theme', 'light');+ const loaded = browser.cdp.waitFor('Page.loadEventFired', session);+ loaded.catch(() => {});+ await browser.cdp.send('Page.navigate', { url: url.href }, session);+ await loaded;+ const result = await browser.cdp.send('Runtime.evaluate', {+ awaitPromise: true,+ returnByValue: true,+ expression: `(function () {+ // Same page state visual-check establishes before its joint wait.+ document.documentElement.setAttribute('data-motion', 'still');+ var panel = document.querySelector('.diagram-container');+ if (panel) panel.setAttribute('data-detail-level', 'read');+ return Archify.layoutStability.whenStable();+ })().then(function (value) {+ var html = document.documentElement;+ return {+ sampledFrames: value.sampledFrames,+ readerWidth: html.style.getPropertyValue('--archify-reader-width'),+ overflow: html.getAttribute('data-reader-overflow'),+ scrollHeight: Math.ceil(html.scrollHeight),+ innerHeight: window.innerHeight+ };+ })`,+ }, session, 20000);+ assert.equal(result.exceptionDetails, undefined, result.exceptionDetails?.exception?.description);+ const value = result.result.value;+ assert.ok(value.sampledFrames < 60, `${width}x${height} settled in ${value.sampledFrames} frames`);+ assert.match(value.readerWidth, /^\d+px$/);+ if (value.overflow === 'reduced') {+ assert.ok(value.scrollHeight <= value.innerHeight + 1,+ `${width}x${height}: a reduced reader must actually fit (${value.scrollHeight} vs ${value.innerHeight})`);+ }+ }+ } finally {+ await browser.close();+ fs.rmSync(scratch, { recursive: true, force: true });+ }+});diff --git a/archify/test/visual-check.test.mjs b/archify/test/visual-check.test.mjsindex ed7c70b8..4802ba4c 100644--- a/archify/test/visual-check.test.mjs+++ b/archify/test/visual-check.test.mjs@@ -11,6 +11,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';import {CHROME_STARTUP_TIMEOUT_MS,+ verticalBudgetFixes,ChromeVisualBrowser,VISUAL_CHECK_VIEWPORTS,chromeVisualBrowserArgs,@@ -47,6 +48,7 @@ function stagingDirectories(directory) {function fakeBrowser({overflowAt,+ tallAt,readableScrollAt,unreadableAt,chromeCollisionAt,@@ -67,6 +69,7 @@ function fakeBrowser({else fs.writeFileSync(screenshotPath, png, { flag: 'wx' });}const overflow = overflowAt?.({ width, height, theme }) || false;+ const tall = tallAt?.({ width, height, theme }) || false;const readableScroll = readableScrollAt?.({ width, height, theme }) || false;const unreadable = unreadableAt?.({ width, height, theme }) || false;const chromeCollision = chromeCollisionAt?.({ width, height, theme }) || false;@@ -77,8 +80,14 @@ function fakeBrowser({innerWidth: width,innerHeight: height,scrollWidth: width + (overflow ? 1 : 0),- scrollHeight: height + (readableScroll ? 240 : 0),+ scrollHeight: height + (readableScroll ? 240 : 0) + (tall ? 300 : 0),resolvedTheme: theme,+ ...(tall ? {+ pageComposition: {+ bodyPaddingPx: 12, headerPx: 40, guidedViewsPx: 60, diagramChromePx: 76,+ svgPx: 800, cardsPx: 212, viewBoxHeight: 1000,+ },+ } : {}),readerLayout: readableScroll ? 'adaptive' : null,readerOverflow: readableScroll ? 'authored' : null,readerFit: readableScroll ? 'intrinsic-height' : null,@@ -2583,6 +2592,45 @@ test('visual-check returns 1 and preserves evidence when any viewport overflows'assert.equal(fs.existsSync(sidecarPaths(input).contactSheet), true);});+test('vertical overflow fixes state the stacked page budget and the actionable target', () => {+ const page = { bodyPaddingPx: 12, headerPx: 40, guidedViewsPx: 60, diagramChromePx: 76, svgPx: 800, cardsPx: 212, viewBoxHeight: 1000 };+ const base = { overflowY: true, innerHeight: 900, scrollHeight: 1200, diagramWidth: 930, pageComposition: page };++ const atMinimum = verticalBudgetFixes({ ...base, readerLayout: 'adaptive', readerOverflow: 'authored' });+ assert.match(atMinimum[0], /300px too tall/);+ assert.match(atMinimum[0], /12px body padding \+ 40px header \+ 60px guided views \+ 76px diagram chrome \+ 800px SVG \+ 212px cards = 1200px against 900px/);+ assert.match(atMinimum[0], /reduce the viewBox height to at most 625 \(from 1000\)/, 'SVG height follows viewBox height at the fixed minimum width: 1000 * 500 / 800');+ assert.equal(atMinimum.length, 1, 'cards (212px) cannot absorb a 300px excess, so no card alternative is offered');++ const fullWidth = verticalBudgetFixes({ ...base, readerLayout: null, readerOverflow: null });+ assert.match(fullWidth[0], /viewBox ratio is below 1\.55/);+ assert.match(fullWidth[0], /remove meta\.viewBox|1\.55x wider than tall/);++ const cardsAbsorb = verticalBudgetFixes({ ...base, scrollHeight: 1000, readerLayout: 'adaptive', readerOverflow: 'authored' });+ assert.match(cardsAbsorb[1], /cards take at most 112px/);++ assert.deepEqual(verticalBudgetFixes({ ...base, pageComposition: undefined }), [], 'old artifacts without composition metrics keep the generic fix');+ assert.deepEqual(verticalBudgetFixes({ ...base, overflowY: false }), []);+});++test('visual-check reports the page composition when a viewport overflows vertically', async () => {+ const input = artifact('tall-overflow.html');+ const result = await runVisualCheck({+ artifactPath: input,+ chromePath: '/fake/chrome',+ browserFactory: async () => fakeBrowser({ tallAt: ({ width }) => width === 1440 }),+ });++ assert.equal(result.exitCode, 1);+ const diagnostic = result.receipt.diagnostics.find((entry) => entry.code === 'viewer/viewport-overflow');+ assert.equal(diagnostic.evidence.pageComposition.svgPx, 800);+ assert.match(diagnostic.evidence.pageCompositionMeasurement, /sum to scrollHeight/);+ assert.match(diagnostic.supportedFixes[0], /300px too tall/);+ assert.equal(diagnostic.supportedFixes.some((fix) => /contain the rendered layout within/.test(fix)), false, 'the numeric budget replaces the generic instruction');+ const viewport = result.receipt.containment.viewports.find(({ width }) => width === 1440);+ assert.equal(viewport.pageComposition.cardsPx, 212);+});+test('visual-check accepts only Reader-declared readable vertical page scrolling', async () => {const input = artifact('readable-scroll.html');const target = ({ width, theme }) => width === 1440 && theme === 'light';diff --git a/scripts/run-browser-tests.mjs b/scripts/run-browser-tests.mjsindex de38d10c..6277f498 100644--- a/scripts/run-browser-tests.mjs+++ b/scripts/run-browser-tests.mjs@@ -11,6 +11,7 @@ const testFiles = ['desktop-reader-browser.test.mjs','reader-readability-maintained-browser.test.mjs','reader-layout-browser.test.mjs',+ 'reader-layout-settle-browser.test.mjs','joint-layout-browser.test.mjs','sequence-header-clearance.test.mjs','lifecycle-rail-browser.test.mjs',diff --git a/viewer/reader-layout.js b/viewer/reader-layout.jsindex 6e1ce08c..2e42254e 100644--- a/viewer/reader-layout.js+++ b/viewer/reader-layout.js@@ -13,6 +13,10 @@var frame = 0;var settleFrame = 0;var lastWidth = 0;+ // Widest reader the overflow settle has accepted for this viewport. Card+ // copy rewraps as the reader narrows, so recomputing from fixed heights+ // alone would widen again and oscillate; only a resize lifts the cap.+ var settledCap = Infinity;var WIDE_RATIO = 1.55;var MIN_DESKTOP_WIDTH = 1024;var MIN_READER_WIDTH = 960;@@ -74,6 +78,7 @@html.removeAttribute('data-reader-layout');html.removeAttribute('data-reader-overflow');lastWidth = 0;+ settledCap = Infinity;}function chromeMetrics() {var bodyStyle = window.getComputedStyle(body);@@ -106,6 +111,7 @@) - window.innerHeight;if (overflow > 1 && lastWidth > Math.ceil(minWidth)) {applyWidth(Math.max(minWidth, lastWidth - overflow * ratio - 4), minWidth);+ settledCap = lastWidth;html.setAttribute('data-reader-overflow', 'reduced');} else if (overflow > 1) {html.setAttribute('data-reader-overflow', 'authored');@@ -143,7 +149,7 @@outerHeight(header) + outerHeight(guided) + outerHeight(cards);var availableSvgHeight = Math.max(1, window.innerHeight - fixedHeight);var desiredWidth = availableSvgHeight * ratio + chrome.diagramX;- var width = Math.max(minWidth, Math.min(maxWidth, desiredWidth));+ var width = Math.max(minWidth, Math.min(maxWidth, desiredWidth, settledCap));applyWidth(width, minWidth);settleOverflow(minWidth);return {@@ -185,7 +191,10 @@}archifyLayoutOwners.reader = { schedule: schedule, pending: layoutPending, snapshot: stableSnapshot };- window.addEventListener('resize', schedule, { passive: true });+ window.addEventListener('resize', function () {+ settledCap = Infinity;+ schedule();+ }, { passive: true });window.addEventListener('load', schedule, { once: true });if (document.fonts && document.fonts.ready) document.fonts.ready.then(schedule).catch(function () {});if (typeof ResizeObserver === 'function') {