Agent-driven creation of editable, tastefully crafted visual artifacts.
Python
fix: synchronize replay motion runtime
Junyanye52f143a20f39
diff --git a/skills/editable-design/SKILL.md b/skills/editable-design/SKILL.mdindex 8b5e326..8db0ab4 100644--- a/skills/editable-design/SKILL.md+++ b/skills/editable-design/SKILL.md@@ -562,8 +562,17 @@ the HTML, editor, PNG, layer breakdown, or Replay delivery.## Deliver-Give the location of the PNG, `index.html`, `editor.html`, `layers.html`, and-`replay/index.html`, the canvas size and the font families used, and the text+Use these stable English labels in the user-facing handoff, regardless of the+language used inside the design:++- **Final Design** — `out/poster.png`+- **Editable Source** — `index.html`+- **Visual Editor** — `editor.html`+- **Layer Breakdown** — `layers.html`+- **Agent Design Replay** — `replay/index.html`++Give the location of each available output, the canvas size and the font+families used, and the textyou read line by line off the render. Tell theuser that `editor.html` supports mouse dragging, eight-handle width/heightresizing, double-click text editing, and scan/explode/collapse views.diff --git a/skills/editable-design/assets/replay/replay-motion.js b/skills/editable-design/assets/replay/replay-motion.jsindex df577ad..b71fc14 100644--- a/skills/editable-design/assets/replay/replay-motion.js+++ b/skills/editable-design/assets/replay/replay-motion.js@@ -9,7 +9,7 @@if (document.body.dataset.motionMounted === 'true') return;document.body.dataset.motionMounted = 'true';- const { data, world, flowLines, detailPanel, selectStage, initialStage, getViewState } = viewer;+ const { data, world, flowLines, detailPanel, selectStage, initialStage, restartLayerAnimation, getViewState } = viewer;const playButton = document.getElementById('play-replay');const playLabel = playButton?.querySelector('b');const playIcon = playButton?.querySelector('span');@@ -114,10 +114,12 @@});animations.push(wait(4350).then(() => status?.classList.add('is-lit')));+ animations.push(wait(3650).then(() => restartLayerAnimation?.()));await Promise.allSettled(animations);const remaining = INTRO_DURATION - (performance.now() - introStarted);if (remaining > 0) await wait(remaining);document.body.classList.remove('is-intro');+ document.body.dataset.motionState = 'ambient';setPlayState(false, false);if (initialStage) selectStage(initialStage.id, false);startAmbient();@@ -384,14 +386,25 @@if (reducedMotion) {mode = 'reduced';+ document.body.dataset.motionState = 'reduced';status?.classList.add('is-lit');+ if (status) status.textContent = '系统已减少动态';setPlayState(false, true);if (playButton) playButton.title = '已按系统设置关闭动画';if (initialStage) selectStage(initialStage.id, false);} else {- runIntro();+ document.body.dataset.motionState = 'intro';+ runIntro().catch(() => {+ document.body.classList.remove('is-intro');+ document.body.dataset.motionState = 'recovered';+ setPlayState(false, false);+ status?.classList.add('is-lit');+ mode = 'ambient';+ startAmbient();+ });}}window.__POSTER_REPLAY_MOTION__ = { mount };+ if (window.__POSTER_REPLAY_VIEWER__) mount(window.__POSTER_REPLAY_VIEWER__);})();diff --git a/skills/editable-design/assets/replay/replay.css b/skills/editable-design/assets/replay/replay.cssindex d9dfdf3..ce2cc34 100644--- a/skills/editable-design/assets/replay/replay.css+++ b/skills/editable-design/assets/replay/replay.css@@ -252,6 +252,12 @@ button { font: inherit; }}.external-artifact:hover { transform: translateY(-3px); box-shadow: 0 21px 46px rgba(66,57,44,.17); }.external-artifact img, .external-artifact iframe { display: block; width: 100%; height: 100%; border: 0; object-fit: cover; background: #f0eee8; pointer-events: none; }+.animation-preview { display: grid; width: 100%; height: 100%; place-content: center; justify-items: center; gap: 10px; background: linear-gradient(145deg,#edf5f0,#dceae1); color: #52725f; }+.animation-preview > span { display: grid; width: 54px; height: 54px; place-items: center; border: 2px solid #78a087; border-radius: 50%; background: rgba(255,255,255,.82); font-size: 18px; }+.animation-preview > strong { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }+.animation-preview[data-animation-state="playing"] > span,+.animation-preview[data-animation-state="playing"] > strong { display: none; }+.animation-preview iframe { width: 100%; height: 100%; }.external-artifact[data-contain="true"] img { object-fit: contain; }.external-artifact figcaption { position: absolute; left: 7px; right: 7px; bottom: 7px; display: flex; justify-content: space-between; gap: 6px; padding: 6px 8px; border-radius: 7px; background: rgba(255,255,255,.94); color: #555149; font-size: 8px; font-weight: 800; }.external-artifact figcaption span:last-child { color: #99938a; font-family: ui-monospace, monospace; }diff --git a/skills/editable-design/assets/replay/replay.js b/skills/editable-design/assets/replay/replay.jsindex 04640f1..072da06 100644--- a/skills/editable-design/assets/replay/replay.js+++ b/skills/editable-design/assets/replay/replay.js@@ -167,6 +167,23 @@document.getElementById('media-lightbox-close')?.focus({ preventScroll: true });}+ function animationUrl(src) {+ const url = new URL(src, location.href);+ url.searchParams.delete('motion');+ url.searchParams.set('replay', String(Date.now()));+ return url.href;+ }++ function restartLayerAnimation() {+ const host = document.querySelector('.external-artifact.layers [data-animation-src]');+ if (!host) return;+ const iframe = document.createElement('iframe');+ iframe.src = animationUrl(host.dataset.animationSrc);+ iframe.title = host.dataset.animationTitle || 'Layer animation';+ host.replaceChildren(iframe);+ host.dataset.animationState = 'playing';+ }+function artifactCard({ className, x, y, w, h, src, label, code, contain = false, iframe = false, stage, openMode = 'detail' }) {if (!src) return;const figure = document.createElement('figure');@@ -174,7 +191,7 @@figure.dataset.stage = stage;figure.dataset.contain = contain ? 'true' : 'false';figure.style.cssText = `left:${x}px;top:${y}px;width:${w}px;height:${h}px`;- figure.innerHTML = `${iframe ? `<iframe src="${esc(src)}" title="${esc(label)}"></iframe>` : `<img src="${esc(src)}" alt="${esc(label)}">`}<figcaption><span>${esc(label)}</span><span>${esc(code)}</span></figcaption>`;+ figure.innerHTML = `${iframe ? `<div class="animation-preview" data-animation-src="${esc(src)}" data-animation-title="${esc(label)}" data-animation-state="waiting"><span>▶</span><strong>Layer animation</strong></div>` : `<img src="${esc(src)}" alt="${esc(label)}">`}<figcaption><span>${esc(label)}</span><span>${esc(code)}</span></figcaption>`;figure.addEventListener('click', (event) => {event.stopPropagation();if (openMode === 'image') openMedia(src, label, 'image');@@ -287,6 +304,7 @@phaseNav?.querySelectorAll('button').forEach((button) => button.classList.toggle('is-active', button.dataset.phase === stage.phase));detailContent.innerHTML = detailFor(stage);detailPanel.classList.add('is-open');+ if (id === 'layers') restartLayerAnimation();if (updateUrl) {const url = new URL(location.href);url.searchParams.set('stage', stage.order.replace(/^0/, ''));@@ -345,8 +363,10 @@const requestedStage = requested ? data.stages.find((item) => item.order.replace(/^0/, '') === requested || item.id === requested) : null;const defaultStage = document.body.dataset.defaultStage ? stageById.get(document.body.dataset.defaultStage) : null;const initialStage = requestedStage || defaultStage;+ const viewer = { data, viewport, world, flowLines, phaseNav, detailPanel, selectStage, initialStage, restartLayerAnimation, getViewState: () => ({ scale, tx, ty }) };+ window.__POSTER_REPLAY_VIEWER__ = viewer;if (window.__POSTER_REPLAY_MOTION__?.mount) {- window.__POSTER_REPLAY_MOTION__.mount({ data, viewport, world, flowLines, phaseNav, detailPanel, selectStage, initialStage, getViewState: () => ({ scale, tx, ty }) });+ window.__POSTER_REPLAY_MOTION__.mount(viewer);} else if (initialStage) {selectStage(initialStage.id, false);}diff --git a/skills/editable-design/references/replay-contract.md b/skills/editable-design/references/replay-contract.mdindex 76dcc70..6a4c759 100644--- a/skills/editable-design/references/replay-contract.md+++ b/skills/editable-design/references/replay-contract.md@@ -152,8 +152,11 @@ path remains the visible repair loop. This keeps evidence readable withoutplacing an artifact between flow nodes or over their connectors.When the layer output is `layers.html`, Replay embeds its live HTML animation,-not a GIF and not its `?motion=0` screenshot state. It auto-plays when loaded and-offers a clearly named control to play the layer animation again.+not a GIF and not its `?motion=0` screenshot state. Do not load its iframe at+page startup: start it when the intro reaches the Layers output, and restart it+whenever formal playback reaches Layers or the user opens that stage. This keeps+the layer motion synchronized with the surrounding Replay instead of letting it+finish behind the 4.7-second intro. The lightbox reloads it on every open.The stage detail panel is a wide, independently scrolling surface; wheel inputinside it never changes canvas zoom. Clicking the reference or final-renderdiff --git a/skills/editable-design/scripts/verify-replay.mjs b/skills/editable-design/scripts/verify-replay.mjsindex b6107f5..0864025 100755--- a/skills/editable-design/scripts/verify-replay.mjs+++ b/skills/editable-design/scripts/verify-replay.mjs@@ -49,6 +49,8 @@ if (!failed) {const feedbackLabelOK = replayJS.includes('class="flow-label prove-label"') && replayCSS.includes('.flow-label text { fill: #47765c');const layersStage = data.stages.find((stage) => stage.id === 'layers');const liveLayerAnimationOK = !layersStage?.preview?.includes('motion=0') && replayJS.includes('可编辑分层动画(HTML)');+ const synchronizedLayerAnimationOK = replayJS.includes('data-animation-src') && replayJS.includes('restartLayerAnimation') && replayJS.includes("id === 'layers'") && motionJS.includes('wait(3650)');+ const motionHandshakeOK = replayJS.includes('__POSTER_REPLAY_VIEWER__') && motionJS.includes('__POSTER_REPLAY_VIEWER__') && motionJS.includes("document.body.dataset.motionState = 'recovered'");const referencePlacementOK = replayJS.includes("reference: { x: 820, y: 110, w: 450, h: 330 }") && replayJS.includes("x: 1538, y: 110, w: 270, h: 360") && replayJS.includes('class="flow-artifact flow-path think"') && replayJS.includes('d="M1270 290 L2075 290"') && !replayJS.includes('L1900 70 C2030 70 2010 275 2075 275');const rightColumnPlanOK = replayJS.includes("plan: { x: 2075, y: 110, w: 420, h: 360 }") && replayJS.includes("x: 2075, y: 670, w: 420, h: 560") && replayJS.includes("x: 2075, y: 1320, w: 420, h: 360");const featuredMediaOK = replayJS.includes("x: 2075, y: 670, w: 420, h: 560") && replayJS.includes("x: 2075, y: 1320, w: 420, h: 360");@@ -77,13 +79,15 @@ if (!failed) {console.log(` ${assetShowcaseOK ? '✅' : '❌'} 700ms Assets gallery showcase with 4-6s rest`);console.log(` ${feedbackLabelOK ? '✅' : '❌'} feedback label on green observation path`);console.log(` ${liveLayerAnimationOK ? '✅' : '❌'} live HTML layer animation`);+ console.log(` ${synchronizedLayerAnimationOK ? '✅' : '❌'} layer animation synchronized with intro and playback`);+ console.log(` ${motionHandshakeOK ? '✅' : '❌'} resilient motion initialization handshake`);console.log(` ${referencePlacementOK ? '✅' : '❌'} centered reference on a straight dashed connector`);console.log(` ${rightColumnPlanOK ? '✅' : '❌'} Design Plan aligned with the right output column`);console.log(` ${featuredMediaOK ? '✅' : '❌'} enlarged right-side output column`);console.log(` ${detailPanelOK ? '✅' : '❌'} wide independently scrolling detail panel`);console.log(` ${mediaLightboxOK ? '✅' : '❌'} image and animation lightbox behaviors`);console.log(` ${fullPngContainOK ? '✅' : '❌'} full uncropped PNG in image lightbox`);- failed ||= !schemaOK || !stagesOK || !offlineOK || !sourceOK || !phaseNavOK || !phaseIconsOK || !noDefaultDetailOK || !arrowSizingOK || !motionOK || !reducedMotionOK || !playbackPathOK || !ambientCadenceOK || !introTimingOK || !assetOverviewOK || !planMatrixOK || !scaledPhaseNavOK || !largePhaseNavOK || !assetStageOK || !adaptiveAssetsOK || !assetShowcaseOK || !feedbackLabelOK || !liveLayerAnimationOK || !referencePlacementOK || !rightColumnPlanOK || !featuredMediaOK || !detailPanelOK || !mediaLightboxOK || !fullPngContainOK;+ failed ||= !schemaOK || !stagesOK || !offlineOK || !sourceOK || !phaseNavOK || !phaseIconsOK || !noDefaultDetailOK || !arrowSizingOK || !motionOK || !reducedMotionOK || !playbackPathOK || !ambientCadenceOK || !introTimingOK || !assetOverviewOK || !planMatrixOK || !scaledPhaseNavOK || !largePhaseNavOK || !assetStageOK || !adaptiveAssetsOK || !assetShowcaseOK || !feedbackLabelOK || !liveLayerAnimationOK || !synchronizedLayerAnimationOK || !motionHandshakeOK || !referencePlacementOK || !rightColumnPlanOK || !featuredMediaOK || !detailPanelOK || !mediaLightboxOK || !fullPngContainOK;const missing = data.stages.filter((stage) => /缺失|不完整|未生成/.test(stage.statusLabel));if (missing.length) console.log(` ⚠️ missing evidence is shown, not reconstructed: ${missing.map((stage) => stage.id).join(', ')}`);