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
Replan the board when a diagram fit notice appears
tt-a1i8d3b9b312b26
diff --git a/archify/explainer/reader.js b/archify/explainer/reader.jsindex 97217675..e0a7bf5a 100644--- a/archify/explainer/reader.js+++ b/archify/explainer/reader.js@@ -185,8 +185,12 @@const bodySize = parseFloat(getComputedStyle(document.querySelector('.block-prose>p') || document.body).fontSize);return window.innerWidth >= 1440 ? Math.max(10,bodySize * .75) : 10;}- function ensureDiagramReadability() {+ // A fit notice that appears or goes away changes a panel's height after the board was planned,+ // so the board is planned again and the notices rechecked at the new widths.+ function ensureDiagramReadability() { if (fitDiagrams()) { layoutBoard(); fitDiagrams(); } }+ function fitDiagrams() {const minimumText = textFloor();+ let changed = false;// Only a diagram beside its steps stays in view; stacked above them, it would slide over them.all('.guided').forEach(guide=>guide.classList.toggle('beside',guide.firstElementChild.getBoundingClientRect().left >= guide.lastElementChild.getBoundingClientRect().right));all('.diagram-preview>svg').forEach(svg=>{@@ -205,9 +209,11 @@preview.dataset.diagramFit = insufficient ? 'insufficient' : 'fit';preview.dataset.diagramMinimumText = String(minimumText);const status = svg.closest('.block-diagram').querySelector('.diagram-fit-status');+ changed ||= status.hidden === insufficient;status.hidden = !insufficient;status.textContent = insufficient ? say('This diagram cannot fit this page width with readable text. Open the interactive view to inspect it.','此图在当前页宽下放不下且文字会太小,请打开交互图查看。') : '';});+ return changed;}const preference = matchMedia('(prefers-color-scheme: dark)');let theme = 'auto';diff --git a/test/explainer-browser.test.mjs b/test/explainer-browser.test.mjsindex af9d8dac..129b0014 100644--- a/test/explainer-browser.test.mjs+++ b/test/explainer-browser.test.mjs@@ -77,6 +77,8 @@ test('wide frozen native previews keep every node visible at 1280 and reclaim thconst oversized=structuredClone(doc);oversized.meta.id='oversized-native';oversized.panels.at(-1).blocks=oversized.panels.at(-1).blocks.slice(0,1);oversized.panels.at(-1).blocks[0].spec.components.at(-1).pos=[1200,40];const oversizedPrepared=await prepareExplainerDiagrams(oversized,{baseDir:dir,sourcePath:path.join(dir,'oversized.json'),quality:'showcase'}),hugeFile=artifact('oversized-native',renderExplainer(oversized,{sourceText:JSON.stringify(oversized),preparedDiagrams:oversizedPrepared,preparedSources:{sources:{example:{title:'Example'}}}}));const huge=await inspectExplainerBrowser(browser,{artifactPath:hugeFile,width:1440,height:900,theme:'light'});assert.equal(huge.nativeText[0].fit,'insufficient');assert.equal(parseFloat(huge.nativeText[0].minWidth),0);assert.ok(huge.nativeText[0].scrollWidth<=huge.nativeText[0].clientWidth+1);assert.ok(huge.interactionFailures.some(e=>e.name==='diagram-fit'&&e.measurement.requiredWidth>e.measurement.clientWidth),'An actually overwide graph must fail with measured fit evidence');assert.ok(huge.interactionFailures.some(e=>e.name==='diagram-text'));+ await browser.resetPage();await inspectPublicHtml(browser,{artifactPath:hugeFile,width:1280,theme:'light',keyboard:false});+ assert.deepEqual(await pageValue(browser,"Array.from(document.querySelectorAll('.panel')).filter(p=>p.scrollHeight>p.offsetHeight+1).map(p=>p.id)"),[],'a fit notice shown after planning must not clip its panel');const corrupted=artifact('responsive-retained-floor',html.replace('</style>','\n.diagram-preview>svg{min-width:1321px!important}\n</style>'));await browser.resetPage();await inspectPublicHtml(browser,{artifactPath:corrupted,width:1280,theme:'light',keyboard:false});assert.ok((await inspectNativePreviewLayout(browser)).some(e=>e.outsidePreview.length>0),'A retained desktop floor must be detected through actual clipped node bounds');const embedded=Object.fromEntries(Object.entries(unpackPageBundle(await pageValue(browser,"JSON.parse(document.querySelector('#archify-explainer-prepared').textContent)")).preparedDiagrams.diagrams).map(([id,c])=>[id,{html:c.html,sha256:c.sha256,bytes:c.bytes}]));for(const [id,c]of Object.entries(embedded)){assert.equal(hash(c.html),frozen[id].sha256);assert.equal(Buffer.byteLength(c.html),frozen[id].bytes);assert.equal(c.sha256,frozen[id].sha256);assert.equal(c.bytes,frozen[id].bytes);}