The design language that makes your AI harness better at design.
JavaScript
Sync generated provider output
github-actions[bot]9b25a75ced12
diff --git a/.agent/skills/impeccable/scripts/live-browser-dom.js b/.agent/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.agent/skills/impeccable/scripts/live-browser-dom.js+++ b/.agent/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.agent/skills/impeccable/scripts/live-browser.js b/.agent/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.agent/skills/impeccable/scripts/live-browser.js+++ b/.agent/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.agents/skills/impeccable/scripts/live-browser-dom.js b/.agents/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.agents/skills/impeccable/scripts/live-browser-dom.js+++ b/.agents/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.agents/skills/impeccable/scripts/live-browser.js b/.agents/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.agents/skills/impeccable/scripts/live-browser.js+++ b/.agents/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.claude/skills/impeccable/scripts/live-browser-dom.js b/.claude/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.claude/skills/impeccable/scripts/live-browser-dom.js+++ b/.claude/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.claude/skills/impeccable/scripts/live-browser.js b/.claude/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.claude/skills/impeccable/scripts/live-browser.js+++ b/.claude/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.cursor/skills/impeccable/scripts/live-browser-dom.js b/.cursor/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.cursor/skills/impeccable/scripts/live-browser-dom.js+++ b/.cursor/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.cursor/skills/impeccable/scripts/live-browser.js b/.cursor/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.cursor/skills/impeccable/scripts/live-browser.js+++ b/.cursor/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.dsh/skills/impeccable/scripts/live-browser-dom.js b/.dsh/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.dsh/skills/impeccable/scripts/live-browser-dom.js+++ b/.dsh/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.dsh/skills/impeccable/scripts/live-browser.js b/.dsh/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.dsh/skills/impeccable/scripts/live-browser.js+++ b/.dsh/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.gemini/skills/impeccable/scripts/live-browser-dom.js b/.gemini/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.gemini/skills/impeccable/scripts/live-browser-dom.js+++ b/.gemini/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.gemini/skills/impeccable/scripts/live-browser.js b/.gemini/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.gemini/skills/impeccable/scripts/live-browser.js+++ b/.gemini/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.github/skills/impeccable/scripts/live-browser-dom.js b/.github/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.github/skills/impeccable/scripts/live-browser-dom.js+++ b/.github/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.github/skills/impeccable/scripts/live-browser.js b/.github/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.github/skills/impeccable/scripts/live-browser.js+++ b/.github/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.grok/skills/impeccable/scripts/live-browser-dom.js b/.grok/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.grok/skills/impeccable/scripts/live-browser-dom.js+++ b/.grok/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.grok/skills/impeccable/scripts/live-browser.js b/.grok/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.grok/skills/impeccable/scripts/live-browser.js+++ b/.grok/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.hermes/skills/impeccable/scripts/live-browser-dom.js b/.hermes/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.hermes/skills/impeccable/scripts/live-browser-dom.js+++ b/.hermes/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.hermes/skills/impeccable/scripts/live-browser.js b/.hermes/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.hermes/skills/impeccable/scripts/live-browser.js+++ b/.hermes/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.kiro/skills/impeccable/scripts/live-browser-dom.js b/.kiro/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.kiro/skills/impeccable/scripts/live-browser-dom.js+++ b/.kiro/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.kiro/skills/impeccable/scripts/live-browser.js b/.kiro/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.kiro/skills/impeccable/scripts/live-browser.js+++ b/.kiro/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.opencode/skills/impeccable/scripts/live-browser-dom.js b/.opencode/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.opencode/skills/impeccable/scripts/live-browser-dom.js+++ b/.opencode/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.opencode/skills/impeccable/scripts/live-browser.js b/.opencode/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.opencode/skills/impeccable/scripts/live-browser.js+++ b/.opencode/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.pi/skills/impeccable/scripts/live-browser-dom.js b/.pi/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.pi/skills/impeccable/scripts/live-browser-dom.js+++ b/.pi/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.pi/skills/impeccable/scripts/live-browser.js b/.pi/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.pi/skills/impeccable/scripts/live-browser.js+++ b/.pi/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.qoder/skills/impeccable/scripts/live-browser-dom.js b/.qoder/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.qoder/skills/impeccable/scripts/live-browser-dom.js+++ b/.qoder/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.qoder/skills/impeccable/scripts/live-browser.js b/.qoder/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.qoder/skills/impeccable/scripts/live-browser.js+++ b/.qoder/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.rovodev/skills/impeccable/scripts/live-browser-dom.js b/.rovodev/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.rovodev/skills/impeccable/scripts/live-browser-dom.js+++ b/.rovodev/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.rovodev/skills/impeccable/scripts/live-browser.js b/.rovodev/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.rovodev/skills/impeccable/scripts/live-browser.js+++ b/.rovodev/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.trae-cn/skills/impeccable/scripts/live-browser-dom.js b/.trae-cn/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.trae-cn/skills/impeccable/scripts/live-browser-dom.js+++ b/.trae-cn/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.trae-cn/skills/impeccable/scripts/live-browser.js b/.trae-cn/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.trae-cn/skills/impeccable/scripts/live-browser.js+++ b/.trae-cn/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.trae/skills/impeccable/scripts/live-browser-dom.js b/.trae/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.trae/skills/impeccable/scripts/live-browser-dom.js+++ b/.trae/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.trae/skills/impeccable/scripts/live-browser.js b/.trae/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.trae/skills/impeccable/scripts/live-browser.js+++ b/.trae/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.veto/skills/impeccable/scripts/live-browser-dom.js b/.veto/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.veto/skills/impeccable/scripts/live-browser-dom.js+++ b/.veto/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.veto/skills/impeccable/scripts/live-browser.js b/.veto/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.veto/skills/impeccable/scripts/live-browser.js+++ b/.veto/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/.vibe/skills/impeccable/scripts/live-browser-dom.js b/.vibe/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/.vibe/skills/impeccable/scripts/live-browser-dom.js+++ b/.vibe/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/.vibe/skills/impeccable/scripts/live-browser.js b/.vibe/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/.vibe/skills/impeccable/scripts/live-browser.js+++ b/.vibe/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js b/cursor-plugin/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js+++ b/cursor-plugin/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/cursor-plugin/skills/impeccable/scripts/live-browser.js b/cursor-plugin/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/cursor-plugin/skills/impeccable/scripts/live-browser.js+++ b/cursor-plugin/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);diff --git a/plugin/skills/impeccable/scripts/live-browser-dom.js b/plugin/skills/impeccable/scripts/live-browser-dom.jsindex e85c95c43..63e222180 100644--- a/plugin/skills/impeccable/scripts/live-browser-dom.js+++ b/plugin/skills/impeccable/scripts/live-browser-dom.js@@ -100,8 +100,108 @@return doc.body;}+ // A modal <dialog> (showModal) paints in the top layer and makes every+ // node outside its subtree inert, so chrome on <body> can be neither seen+ // nor clicked while one is open, and no z-index reaches it (issue #879).+ // While a modal is open the chrome parks inside the topmost one, in one+ // popover: inside the dialog it is not inert, and a popover shown after+ // the dialog paints above it. One popover for all of it, because+ // top-layer entries stack by show order, which would drop the z-index+ // order between the roots. The detect overlay (browser-bundle/+ // 40-overlay.js) mounts its outlines here too: it finds the host by this+ // id and places its outlines again on the event of the same name, fired+ // on every move.+ const topLayerHost = doc.createElement('div');+ topLayerHost.id = prefix + '-top-layer';+ // Same box as the SvelteKit shadow host: 0x0, fixed, chrome overflows it.+ // `all: initial` also clears the popover UA box.+ for (const [name, value] of Object.entries({+ all: 'initial', position: 'fixed', top: '0', left: '0', width: '0', height: '0', overflow: 'visible',+ })) topLayerHost.style.setProperty(name, value, 'important');+ const pageRoots = new WeakSet(); // chrome nodes mounted on the page itself+ const openModals = []; // in the order they opened; last is topmost++ // Modals that were open before watching began have no readable top-layer+ // order, but the topmost one's backdrop covers the viewport, so a hit+ // test lands in it. Raise that one to the top of the stack.+ function raiseHitModal() {+ const i = openModals.indexOf(doc.elementFromPoint(0, 0)?.closest('dialog:modal'));+ if (i !== -1) openModals.push(...openModals.splice(i, 1));+ }++ function syncTopLayerHost(records = []) {+ for (const { type, target, oldValue } of records) {+ if (type !== 'attributes' || oldValue !== null || !target.matches('dialog:modal')) continue;+ // Opened, or closed and reopened in one task (the observer sees only+ // the end state): either way it is back on top of the top layer, so+ // a host shown inside it earlier has to be shown again. A write to an+ // `open` that was already set (oldValue not null) moved nothing.+ const i = openModals.indexOf(target);+ if (i !== -1) openModals.splice(i, 1);+ openModals.push(target);+ if (topLayerHost.parentNode === target) topLayerHost.remove();+ }+ // A closed dialog, or one removed from the document while open, stops+ // matching :modal. Whichever is now on top may predate the watch.+ const before = openModals.length;+ for (let i = openModals.length - 1; i >= 0; i--) {+ if (!openModals[i].matches('dialog:modal')) openModals.splice(i, 1);+ }+ if (openModals.length < before && openModals.length > 1) raiseHitModal();+ const modal = openModals[openModals.length - 1] || null;+ if (topLayerHost.parentNode === modal) return;+ if (modal) {+ modal.appendChild(topLayerHost);+ for (const el of [...doc.body.children]) if (pageRoots.has(el)) topLayerHost.appendChild(el);+ topLayerHost.showPopover();+ } else {+ doc.body.append(...topLayerHost.childNodes);+ topLayerHost.remove();+ }+ doc.dispatchEvent(new Event(topLayerHost.id));+ }++ // Returns the function that stops watching and puts the chrome back.+ function watchModalDialogs() {+ if (typeof topLayerHost.showPopover !== 'function') return () => {};+ topLayerHost.popover = 'manual';+ // Parked in the page's dialog, chrome clicks would bubble into its own+ // handlers, such as a click-outside-the-box close. Live listens in capture.+ topLayerHost.addEventListener('click', (e) => e.stopPropagation());+ openModals.push(...doc.querySelectorAll('dialog:modal'));+ raiseHitModal();+ const observer = new MutationObserver(syncTopLayerHost);+ observer.observe(doc, { subtree: true, childList: true, attributes: true, attributeOldValue: true, attributeFilter: ['open'] });+ syncTopLayerHost();+ return () => {+ observer.disconnect();+ openModals.length = 0;+ syncTopLayerHost();+ };+ }++ // A copy of a page element without the chrome parked inside it, which a+ // picked modal dialog contains.+ function cloneWithoutChrome(el) {+ const clone = el.cloneNode(true);+ if (el.contains(topLayerHost)) clone.querySelector('#' + cssId(topLayerHost.id)).remove();+ return clone;+ }++ // Mount a chrome node on the page itself: <body>, or the top-layer host+ // while the chrome is parked in a modal.+ function uiAppendToPage(el) {+ pageRoots.add(el);+ (topLayerHost.parentNode ? topLayerHost : doc.body).appendChild(el);+ return el;+ }+function uiAppend(el) {- liveUiRoot().appendChild(el);+ const uiRoot = liveUiRoot();+ if (uiRoot === doc.body) return uiAppendToPage(el);+ // An adapter shadow root: its host is the node that sits on the page.+ if (uiRoot.host) pageRoots.add(uiRoot.host);+ uiRoot.appendChild(el);return el;}@@ -153,6 +253,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,diff --git a/plugin/skills/impeccable/scripts/live-browser.js b/plugin/skills/impeccable/scripts/live-browser.jsindex 2b149cbd9..8a0318ccb 100644--- a/plugin/skills/impeccable/scripts/live-browser.js+++ b/plugin/skills/impeccable/scripts/live-browser.js@@ -265,6 +265,7 @@let editBadgeEl = null;let editBadgeProxyRoot = null;let editBadgeProxyByTarget = new Map();+ let stopModalWatch = null;//// Helpers@@ -291,6 +292,10 @@cssId,liveUiRoot,uiAppend,+ uiAppendToPage,+ topLayerHost,+ watchModalDialogs,+ cloneWithoutChrome,uiAppendStyle,uiGetById,activeElementDeep,@@ -967,11 +972,12 @@}}- function sanitizedContextOuterHTML(el, maxLength) {- if (!el || !el.cloneNode) return '';- const clone = el.cloneNode(true);+ // The element as the agent reads it, text and markup alike: no parked+ // chrome (a picked modal dialog contains it) and no edit runtime state.+ function sanitizedContextClone(el) {+ const clone = cloneWithoutChrome(el);stripManualEditRuntimeState(clone);- return clone.outerHTML ? clone.outerHTML.slice(0, maxLength) : '';+ return clone;}function extractContext(el) {@@ -1001,12 +1007,13 @@: (anchorClasses.length ? el.tagName.toLowerCase() + '.' + anchorClasses.join('.') : null);let anchorMatches = null;if (anchor) { try { anchorMatches = document.querySelectorAll(anchor).length; } catch { anchorMatches = null; } }+ const clone = sanitizedContextClone(el);return {tagName: el.tagName.toLowerCase(), id: el.id || null,classes: [...el.classList],anchor, anchorMatches,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 10000),+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 10000),computedStyles: {'font-family': cs.fontFamily, 'font-size': cs.fontSize,'font-weight': cs.fontWeight, 'line-height': cs.lineHeight,@@ -3710,6 +3717,7 @@function copyEditLeafContext(el, originalText, newText) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,@@ -3717,8 +3725,8 @@classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],originalText,newText,- textContent: (el.textContent || '').slice(0, 500),- outerHTML: sanitizedContextOuterHTML(el, 3000) || null,+ textContent: (clone.textContent || '').slice(0, 500),+ outerHTML: (clone.outerHTML || '').slice(0, 3000) || null,};}@@ -3744,13 +3752,14 @@function copyEditContainerContext(el) {if (!el) return null;+ const clone = sanitizedContextClone(el);return {ref: documentRefForElement(el),tagName: el.tagName ? el.tagName.toLowerCase() : null,id: el.id || null,classes: el.classList ? [...el.classList].filter((cls) => cls.indexOf('impeccable-') !== 0) : [],- textContent: (el.textContent || '').slice(0, 1000),- outerHTML: sanitizedContextOuterHTML(el, 10000) || null,+ textContent: (clone.textContent || '').slice(0, 1000),+ outerHTML: (clone.outerHTML || '').slice(0, 10000) || null,};}@@ -4540,7 +4549,7 @@for (const [name, value] of Object.entries(styles)) {setImportantStyle(editBadgeProxyRoot, name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()), value);}- document.body.appendChild(editBadgeProxyRoot);+ uiAppendToPage(editBadgeProxyRoot);}function styleEditBadgeProxy(proxy, target) {@@ -8032,8 +8041,8 @@let depth = 0;while (node && depth < 12) {// 1. Active dialog / modal- if (node.getAttribute && node.getAttribute('role') === 'dialog'- && node.getAttribute('aria-modal') === 'true') {+ if (node.tagName === 'DIALOG' || (node.getAttribute && node.getAttribute('role') === 'dialog'+ && node.getAttribute('aria-modal') === 'true')) {showToast('Heads up: this element lives inside a dialog. If state resets during generation, you may need to re-open it.', 6000);return;}@@ -8645,6 +8654,7 @@const opts = {scale: Math.min(window.devicePixelRatio || 1, 2),font: fontCssText ? { cssText: fontCssText } : undefined,+ filter: (node) => node !== topLayerHost,};if (shouldUseAncestorCropShaderProxy(el)) {try {@@ -12249,6 +12259,7 @@ void main() {pagePickSkipClick = false;cleanup();hideBar();+ if (stopModalWatch) { stopModalWatch(); stopModalWatch = null; }if (pendingDockResizeObserver) { pendingDockResizeObserver.disconnect(); pendingDockResizeObserver = null; }window.removeEventListener('resize', positionPendingDock);if (pendingIntroAnimation) { pendingIntroAnimation.cancel(); pendingIntroAnimation = null; }@@ -13466,6 +13477,7 @@ void main() {attachSteerFocusDebug();attachSteerFocusGuard();initDesignPanel();+ stopModalWatch = watchModalDialogs();fetchPendingCount();document.addEventListener('mousemove', handleMouseMove, true);document.addEventListener('click', handleClick, true);