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(delta): splice nested srcdoc by slot instead of global tokens
uygnoeycb6248732f4b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8801410d..6c7a5199 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,7 +10,7 @@ All notable changes are documented here. Format loosely follows [Keep a Changelo- **Korean Viewer locale (`ko`) (#458).** All five renderers accept the optional `meta.locale` value `ko` alongside `en` and `zh-CN`, localizing renderer-owned Viewer UI, accessibility copy, default legends, document titles, and language metadata without translating authored content. Hangul in the monospace Viewer stack uses bundled D2Coding after JetBrains Mono; the editorial preset’s serif headings use Pretendard SemiBold ahead of the existing CJK serif fallback. Omitted locale remains backward-compatible English. Unsupported locale values still fail schema validation.### Fixed-- **Compare nested `srcdoc` trim.** Architecture-delta HTML no longer strips trailing whitespace inside the two nested viewer documents embedded in `<iframe srcdoc>`. The previous whole-document trim could corrupt verbatim nested payloads (exposed here by Pretendard’s OFL text).+- **Compare nested `srcdoc` trim.** Architecture-delta HTML no longer strips trailing whitespace inside the two nested viewer documents embedded in `<iframe srcdoc>`. Nested explorers are spliced into empty `srcdoc` slots by index after that trim, so authored copy cannot collide with a restoration token. The previous whole-document trim could corrupt verbatim nested payloads (exposed here by Pretendard’s OFL text).- **Architecture Delta baseline arrowheads (#433).** Removed and rerouted baseline relationships retain their marker definitions in the composed Delta SVG, preserving their authored direction alongside current relationships.- **Compare rollback recovery (#438).** If restoring a previous output fails, compare preserves its recovery directory and reports backup-to-target paths instead of deleting the remaining backups during cleanup.- **固定提交的来源校验 (#420)。** 校验忽略本地 Git replacement refs,始终读取指定提交的原始对象,避免替换后的文件或行范围造成误接受或误拒绝;保留原有来源链接、诊断与用户 Git 配置。diff --git a/archify.zip b/archify.zipindex 055573cb..0e1e99b6 100644Binary files a/archify.zip and b/archify.zip differdiff --git a/archify/delta/architecture-delta.mjs b/archify/delta/architecture-delta.mjsindex 284a6c7b..8b150c34 100644--- a/archify/delta/architecture-delta.mjs+++ b/archify/delta/architecture-delta.mjs@@ -712,19 +712,14 @@ export function renderArchitectureDeltaHtml({ receipt, baseSvg, deltaSvg, headSvconst targetSignature = expectedReviewTargetSignature(row);return `<li data-change-status="${esc(row.status)}"><button class="change-row" type="button" data-change-index="${index}" data-change-key="${esc(row.key)}" data-change-kind="${esc(row.kindKey)}" data-change-id="${esc(row.id)}" data-change-label="${esc(label)}" data-change-status="${esc(row.status)}" data-change-classifications="${esc(row.classifications.join(', '))}" data-change-target-signature="${esc(targetSignature)}"><span class="token">${esc(markerFor(row.status) || '~')}</span><span>${esc(row.kind)}</span><strong>${esc(label)}</strong><code>${esc(row.id)}</code><span>${esc(row.classifications.join(', '))}</span><span>${esc(row.changedFields.join(', ') || 'identity')}</span></button></li>`;}).join('\n') : '<li class="empty">No authored architecture changes.</li>';- // The trailing-whitespace cleanup below runs against the whole document, but- // srcdoc carries a complete nested HTML document verbatim (including embedded- // font CSS/licenses, which can legitimately end a line in a space). Protect- // the escaped nested documents behind placeholders and restore them after- // the cleanup so it only touches this delta shell's own markup.- const BASE_VIEW_PLACEHOLDER = ' ARCHIFY_DELTA_BASE_VIEW ';- const HEAD_VIEW_PLACEHOLDER = ' ARCHIFY_DELTA_HEAD_VIEW ';- const baseView = baseHtml- ? `<iframe class="snapshot-frame" title="Before architecture explorer" srcdoc="${BASE_VIEW_PLACEHOLDER}"></iframe>`- : baseSvg;- const headView = headHtml- ? `<iframe class="snapshot-frame" title="After architecture explorer" srcdoc="${HEAD_VIEW_PLACEHOLDER}"></iframe>`- : headSvg;+ // Trailing-whitespace cleanup runs against the delta shell only. Nested+ // explorer documents go into srcdoc after that trim, by slot index rather+ // than a global token replace, so authored copy cannot collide with a+ // placeholder and the trim cannot touch font licenses inside the frames.+ const BASE_VIEW_SLOT = '<iframe class="snapshot-frame" title="Before architecture explorer" srcdoc=""></iframe>';+ const HEAD_VIEW_SLOT = '<iframe class="snapshot-frame" title="After architecture explorer" srcdoc=""></iframe>';+ const baseView = baseHtml ? BASE_VIEW_SLOT : baseSvg;+ const headView = headHtml ? HEAD_VIEW_SLOT : headSvg;const html = `<!doctype html><html lang="en" data-theme="dark" data-preset="${esc(receipt.view.visualPreset)}"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${esc(receipt.head.title)} Architecture Delta</title>@@ -1170,9 +1165,28 @@ html[data-theme="dark"] body{background:#071019!important;background-image:none!updateControls();}})();</script></body></html>`;- return html.replace(/[ \t]+$/gm, '')- .replace(BASE_VIEW_PLACEHOLDER, () => esc(baseHtml))- .replace(HEAD_VIEW_PLACEHOLDER, () => esc(headHtml));+ return fillDeltaSrcdoc(html.replace(/[ \t]+$/gm, ''), [+ [BASE_VIEW_SLOT, baseHtml],+ [HEAD_VIEW_SLOT, headHtml],+ ]);+}++function fillDeltaSrcdoc(html, slots) {+ const fills = [];+ for (const [token, nested] of slots) {+ if (!nested) continue;+ const index = html.indexOf(token);+ if (index === -1) continue;+ fills.push({ index, token, nested: esc(nested) });+ }+ fills.sort((left, right) => right.index - left.index);+ let result = html;+ for (const fill of fills) {+ result = result.slice(0, fill.index)+ + fill.token.replace('srcdoc=""', `srcdoc="${fill.nested}"`)+ + result.slice(fill.index + fill.token.length);+ }+ return result;}export function validateArchitectureDeltaHtml(html, receipt) {diff --git a/archify/test/architecture-delta.test.mjs b/archify/test/architecture-delta.test.mjsindex 66709217..a53ae995 100644--- a/archify/test/architecture-delta.test.mjs+++ b/archify/test/architecture-delta.test.mjs@@ -11,6 +11,7 @@ import {architectureDeltaChangeRows,canonicalArchitectureJson,compareArchitecture,+ renderArchitectureDeltaHtml,validateArchitectureDeltaHtml,} from '../delta/architecture-delta.mjs';@@ -150,6 +151,38 @@ test('compare reports locale-only changes as presentation changes', () => {assert.deepEqual(receipt.changes, { components: [], connections: [], boundaries: [] });});+test('nested srcdoc restore ignores colliding tokens and keeps trailing spaces', () => {+ const receipt = compareArchitecture(read(baseFixture), read(headFixture));+ const poison = '\0ARCHIFY_DELTA_HEAD_VIEW\0';+ const baseHtml = `<!doctype html><title>base</title><!-- ${poison} --><p>keep \n</p>`;+ const headHtml = '<!doctype html><title>head-only</title>';+ const html = renderArchitectureDeltaHtml({+ receipt,+ baseSvg: '<svg viewBox="0 0 1 1"></svg>',+ deltaSvg: '<svg viewBox="0 0 1 1" role="img"></svg>',+ headSvg: '<svg viewBox="0 0 1 1"></svg>',+ baseHtml,+ headHtml,+ artifactCss: '',+ });+ const frames = [...html.matchAll(/title="([^"]+)" srcdoc="([^"]*)"/g)]+ .map(([, title, value]) => [title, value+ .replaceAll('"', '"')+ .replaceAll(''', "'")+ .replaceAll('<', '<')+ .replaceAll('>', '>')+ .replaceAll('&', '&')]);+ assert.deepEqual(frames.map(([title]) => title), [+ 'Before architecture explorer',+ 'After architecture explorer',+ ]);+ assert.equal(frames[0][1], baseHtml);+ assert.equal(frames[1][1], headHtml);+ assert.match(frames[0][1], /keep {2}\n/);+ assert.equal(frames[0][1].includes(poison), true);+ assert.equal(frames[0][1].includes('head-only'), false);+});+test('change navigator order is exact-ID based, complete, unique, and stable', () => {const receipt = compareArchitecture(read(baseFixture), read(headFixture));const rows = architectureDeltaChangeRows(receipt);