Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix: await frame monitors and register owned decorations

Barack Sokullu35b525da9323
diff --git a/docs/page-feedback-monitor.md b/docs/page-feedback-monitor.md
index a3cea5d26..db4293156 100644
--- a/docs/page-feedback-monitor.md
+++ b/docs/page-feedback-monitor.md
@@ -21,6 +21,10 @@ Steer or grant authorization. Enter and Alt+Enter retain their existing behavior
document token. Background validates the actual sender's tab, frame, browser
document identity when available and monotonic sequence. Full navigation
invalidates the previous document and its frames.
+ Run startup addresses every existing accessible frame and waits for its ready
+ acknowledgement; cleanup sends the owning run token to all frames. Restricted
+ frames do not prevent a run, and frame enumeration failures retain broadcast
+ delivery.
- Native CDP/BiDi and content actions register their target, input operation and
actual dispatch before changing the page. Target and native-event phase
matching suppress their observed effects. CDP resolves the receiving document
@@ -33,7 +37,10 @@ Steer or grant authorization. Enter and Alt+Enter retain their existing behavior
- Meaningful visible content, control state, visibility and geometry changes are
coalesced. Visible subtree identity changes invalidate targets even when the
replacement has identical text and geometry. CSS animation and extension
- decoration are ignored. A MAIN-world attachment signal observes new open
+ decoration are ignored. Extension UI roots register their actual node
+ references in the isolated content-script world, preserved across monitor
+ replacement; page-owned IDs and attributes cannot suppress observations.
+ A MAIN-world attachment signal observes new open
shadow roots on existing hosts before their initial rendering; shadow-root
child-list mutations are also monitored. Inaccessible frames and closed shadow roots retain the
existing browser-access limitations.
@@ -93,5 +100,8 @@ Visibility regressions include fixed-size ancestors changing class or CSS custom
properties to reveal or hide non-interactive content. Native preparation fixtures
also exercise the real companion code across an asynchronous target lookup while
the user edits the same field.
+Frame lifecycle regressions cover delayed child acknowledgements and inaccessible
+frames. Browser fixtures also cover page-owned marker attributes and the real
+extension indicators across monitor replacement.
The monitor regressions are also included in `npm run test:runtime-lifecycle`.
diff --git a/src/chrome/src/agent/page-feedback.js b/src/chrome/src/agent/page-feedback.js
index 13e6a1738..34595e0fb 100644
--- a/src/chrome/src/agent/page-feedback.js
+++ b/src/chrome/src/agent/page-feedback.js
@@ -6,6 +6,24 @@ const clean = (value, limit = 240) => String(value ?? '').replace(/[\u0000-\u001
const token = () => globalThis.crypto.randomUUID();
const apiFor = () => globalThis.browser || globalThis.chrome;
+async function notifyPageMonitorFrames(api, tabId, message, knownFrames = []) {
+ if (!api?.tabs?.sendMessage) return;
+ const frameIds = new Set([0, ...knownFrames]);
+ let enumerated = false;
+ try {
+ const frames = await api.webNavigation?.getAllFrames?.({ tabId });
+ if (Array.isArray(frames)) {
+ enumerated = true;
+ for (const frame of frames) if (Number.isSafeInteger(frame.frameId) && frame.frameId >= 0) frameIds.add(frame.frameId);
+ }
+ } catch { /* Restricted documents may not expose their frame tree. */ }
+ // A broadcast reaches every frame but resolves on the first response. Address
+ // enumerated frames separately so startup waits for each accessible monitor.
+ const deliveries = [...frameIds].map(frameId => Promise.resolve().then(() => api.tabs.sendMessage(tabId, message, { frameId })));
+ if (!enumerated) deliveries.push(Promise.resolve().then(() => api.tabs.sendMessage(tabId, message)));
+ await Promise.allSettled(deliveries);
+}
+
export const hasPageAgentDispatchOwner = tabId => dispatchOwners.has(tabId);
export function pageFeedbackPendingResult() {
@@ -81,7 +99,7 @@ export const pageFeedbackMethods = {
} });
const api = apiFor();
try { run.url = (await api.tabs.get(tabId)).url || ''; } catch {}
- try { await api.tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_state', active: true }); } catch {}
+ await notifyPageMonitorFrames(api, tabId, { target: 'content', action: 'page_monitor_state', active: true }, run.frames.keys());
},
_finishPageFeedbackRun(tabId) {
@@ -94,8 +112,8 @@ export const pageFeedbackMethods = {
}); } catch { /* UI delivery cannot retain run ownership. */ }
this._pageFeedbackRuns.delete(tabId);
if (dispatchOwners.get(tabId)?.runToken === run.token) dispatchOwners.delete(tabId);
- try { Promise.resolve(apiFor().tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_state',
- active: false, runToken: run.token })).catch(() => {}); } catch {}
+ void notifyPageMonitorFrames(apiFor(), tabId, { target: 'content', action: 'page_monitor_state',
+ active: false, runToken: run.token }, run.frames.keys()).catch(() => {});
},
pageMonitorState(sender, documentToken) {
diff --git a/src/chrome/src/content/agent-visual-indicator.js b/src/chrome/src/content/agent-visual-indicator.js
index e4dd5f11a..00f9a3570 100644
--- a/src/chrome/src/content/agent-visual-indicator.js
+++ b/src/chrome/src/content/agent-visual-indicator.js
@@ -104,6 +104,7 @@
function createBorder() {
const el = document.createElement('div');
el.id = 'webbrain-agent-glow-border';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.style.cssText = `
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
@@ -123,6 +124,7 @@
function createStopButton() {
const container = document.createElement('div');
container.id = 'webbrain-agent-stop-container';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(container);
container.style.cssText = `
position: fixed;
bottom: 16px;
@@ -194,6 +196,7 @@
function createTargetOutline() {
const el = document.createElement('div');
el.id = 'webbrain-agent-target-outline';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.style.cssText = `
position: fixed;
pointer-events: none;
@@ -216,6 +219,7 @@
function createTargetCursor() {
const el = document.createElement('div');
el.id = 'webbrain-agent-target-cursor';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.setAttribute('aria-hidden', 'true');
el.innerHTML = `
<svg width="48" height="56" viewBox="0 0 48 56" fill="none" xmlns="http://www.w3.org/2000/svg">
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index 93b271ccb..e7de5e04d 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -4303,6 +4303,7 @@
const labelText = String(params?.label || '').trim().slice(0, 100);
const overlay = document.createElement('div');
overlay.setAttribute('data-webbrain-dev-highlight', '');
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(overlay);
Object.assign(overlay.style, {
position: 'fixed',
pointerEvents: 'none',
diff --git a/src/chrome/src/content/ollama-launch-handoff.js b/src/chrome/src/content/ollama-launch-handoff.js
index 066148743..29487db23 100644
--- a/src/chrome/src/content/ollama-launch-handoff.js
+++ b/src/chrome/src/content/ollama-launch-handoff.js
@@ -29,6 +29,7 @@
if (!el) {
el = document.createElement('div');
el.id = 'webbrain-ollama-launch-status';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.style.cssText = [
'position:fixed',
'z-index:2147483647',
diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.js
index 80442de92..92b1b90be 100644
--- a/src/chrome/src/content/page-monitor.js
+++ b/src/chrome/src/content/page-monitor.js
@@ -22,8 +22,22 @@
};
const compact = (value, max = 120) => String(value || '').replace(/[\u0000-\u001f]/g, ' ').slice(0, max);
const editable = el => !!el?.closest?.('input,textarea,[contenteditable]:not([contenteditable="false"])');
- const ignored = el => !el || el.nodeType !== 1 || /^(SCRIPT|STYLE|LINK|META|HEAD)$/.test(el.tagName)
- || !!el.closest?.('[id^="webbrain-"],[id^="wb-agent-"],[data-webbrain-ui],[data-webbrain-dev-highlight],[data-webbrain-attention]');
+ // Owned references survive reinjection in the isolated content-script world.
+ // Page-controlled IDs and attributes cannot establish extension ownership.
+ const decorations = window.__wbPageMonitorDecorations ??= new WeakSet();
+ const registerDecoration = el => {
+ if (el?.nodeType === 1 && el.ownerDocument === document && el !== document.body && el !== document.documentElement) decorations.add(el);
+ return el;
+ };
+ const ignored = el => {
+ if (!el || el.nodeType !== 1 || /^(SCRIPT|STYLE|LINK|META|HEAD)$/.test(el.tagName)) return true;
+ for (let node = el; node; node = node.parentElement || node.getRootNode?.().host) {
+ // Reparenting the page under a real indicator cannot silence the page.
+ if (node === document.body || node === document.documentElement) return false;
+ if (decorations.has(node)) return true;
+ }
+ return false;
+ };
const visible = el => {
if (ignored(el)) return false;
const style = getComputedStyle(el);
@@ -462,7 +476,7 @@
}
};
api.runtime.onMessage.addListener(onMessage);
- window.__wbPageMonitor = { beginContentAction, beforeLocalDispatch, dispatch,
+ window.__wbPageMonitor = { beginContentAction, beforeLocalDispatch, dispatch, registerDecoration,
dispose() { disposed = true; requestGeneration++; stop(); api.runtime.onMessage.removeListener?.(onMessage); } };
void requestState();
// A document restored from BFCache needs a fresh run/document handshake.
diff --git a/src/chrome/src/content/selection-shortcut.js b/src/chrome/src/content/selection-shortcut.js
index c97895386..2c581d811 100644
--- a/src/chrome/src/content/selection-shortcut.js
+++ b/src/chrome/src/content/selection-shortcut.js
@@ -185,6 +185,7 @@ host.lang = localization.locale;
if (host?.isConnected) return;
host = document.createElement('div');
host.id = 'webbrain-selection-shortcut-host';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(host);
host.style.cssText = 'position:fixed;inset:0;width:100vw;height:100vh;display:block;pointer-events:none;z-index:2147483647';
shadow = host.attachShadow({ mode: 'closed' });
shadow.innerHTML = `
diff --git a/src/chrome/src/content/teacher-capture.js b/src/chrome/src/content/teacher-capture.js
index aab6bd520..3e420ce71 100644
--- a/src/chrome/src/content/teacher-capture.js
+++ b/src/chrome/src/content/teacher-capture.js
@@ -138,6 +138,7 @@
if (!active || !document.documentElement) return;
const indicator = document.createElement('div');
indicator.id = INDICATOR_ID;
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(indicator);
indicator.setAttribute('role', 'status');
indicator.setAttribute('aria-live', 'polite');
indicator.textContent = `● WebBrain Teach${sessionName ? ` · ${sessionName}` : ''}`;
diff --git a/src/firefox/src/agent/page-feedback.js b/src/firefox/src/agent/page-feedback.js
index 13e6a1738..34595e0fb 100644
--- a/src/firefox/src/agent/page-feedback.js
+++ b/src/firefox/src/agent/page-feedback.js
@@ -6,6 +6,24 @@ const clean = (value, limit = 240) => String(value ?? '').replace(/[\u0000-\u001
const token = () => globalThis.crypto.randomUUID();
const apiFor = () => globalThis.browser || globalThis.chrome;
+async function notifyPageMonitorFrames(api, tabId, message, knownFrames = []) {
+ if (!api?.tabs?.sendMessage) return;
+ const frameIds = new Set([0, ...knownFrames]);
+ let enumerated = false;
+ try {
+ const frames = await api.webNavigation?.getAllFrames?.({ tabId });
+ if (Array.isArray(frames)) {
+ enumerated = true;
+ for (const frame of frames) if (Number.isSafeInteger(frame.frameId) && frame.frameId >= 0) frameIds.add(frame.frameId);
+ }
+ } catch { /* Restricted documents may not expose their frame tree. */ }
+ // A broadcast reaches every frame but resolves on the first response. Address
+ // enumerated frames separately so startup waits for each accessible monitor.
+ const deliveries = [...frameIds].map(frameId => Promise.resolve().then(() => api.tabs.sendMessage(tabId, message, { frameId })));
+ if (!enumerated) deliveries.push(Promise.resolve().then(() => api.tabs.sendMessage(tabId, message)));
+ await Promise.allSettled(deliveries);
+}
+
export const hasPageAgentDispatchOwner = tabId => dispatchOwners.has(tabId);
export function pageFeedbackPendingResult() {
@@ -81,7 +99,7 @@ export const pageFeedbackMethods = {
} });
const api = apiFor();
try { run.url = (await api.tabs.get(tabId)).url || ''; } catch {}
- try { await api.tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_state', active: true }); } catch {}
+ await notifyPageMonitorFrames(api, tabId, { target: 'content', action: 'page_monitor_state', active: true }, run.frames.keys());
},
_finishPageFeedbackRun(tabId) {
@@ -94,8 +112,8 @@ export const pageFeedbackMethods = {
}); } catch { /* UI delivery cannot retain run ownership. */ }
this._pageFeedbackRuns.delete(tabId);
if (dispatchOwners.get(tabId)?.runToken === run.token) dispatchOwners.delete(tabId);
- try { Promise.resolve(apiFor().tabs.sendMessage(tabId, { target: 'content', action: 'page_monitor_state',
- active: false, runToken: run.token })).catch(() => {}); } catch {}
+ void notifyPageMonitorFrames(apiFor(), tabId, { target: 'content', action: 'page_monitor_state',
+ active: false, runToken: run.token }, run.frames.keys()).catch(() => {});
},
pageMonitorState(sender, documentToken) {
diff --git a/src/firefox/src/content/agent-visual-indicator.js b/src/firefox/src/content/agent-visual-indicator.js
index bf441f787..2281d5d46 100644
--- a/src/firefox/src/content/agent-visual-indicator.js
+++ b/src/firefox/src/content/agent-visual-indicator.js
@@ -104,6 +104,7 @@
function createBorder() {
const el = document.createElement('div');
el.id = 'webbrain-agent-glow-border';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.style.cssText = `
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
@@ -123,6 +124,7 @@
function createStopButton() {
const container = document.createElement('div');
container.id = 'webbrain-agent-stop-container';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(container);
container.style.cssText = `
position: fixed;
bottom: 16px;
@@ -194,6 +196,7 @@
function createTargetOutline() {
const el = document.createElement('div');
el.id = 'webbrain-agent-target-outline';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.style.cssText = `
position: fixed;
pointer-events: none;
@@ -216,6 +219,7 @@
function createTargetCursor() {
const el = document.createElement('div');
el.id = 'webbrain-agent-target-cursor';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.setAttribute('aria-hidden', 'true');
el.innerHTML = `
<svg width="48" height="56" viewBox="0 0 48 56" fill="none" xmlns="http://www.w3.org/2000/svg">
diff --git a/src/firefox/src/content/ollama-launch-handoff.js b/src/firefox/src/content/ollama-launch-handoff.js
index b5aca3d73..e33823b4f 100644
--- a/src/firefox/src/content/ollama-launch-handoff.js
+++ b/src/firefox/src/content/ollama-launch-handoff.js
@@ -21,6 +21,7 @@
if (!el) {
el = document.createElement('div');
el.id = 'webbrain-ollama-launch-status';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
el.style.cssText = [
'position:fixed',
'z-index:2147483647',
diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.js
index 80442de92..92b1b90be 100644
--- a/src/firefox/src/content/page-monitor.js
+++ b/src/firefox/src/content/page-monitor.js
@@ -22,8 +22,22 @@
};
const compact = (value, max = 120) => String(value || '').replace(/[\u0000-\u001f]/g, ' ').slice(0, max);
const editable = el => !!el?.closest?.('input,textarea,[contenteditable]:not([contenteditable="false"])');
- const ignored = el => !el || el.nodeType !== 1 || /^(SCRIPT|STYLE|LINK|META|HEAD)$/.test(el.tagName)
- || !!el.closest?.('[id^="webbrain-"],[id^="wb-agent-"],[data-webbrain-ui],[data-webbrain-dev-highlight],[data-webbrain-attention]');
+ // Owned references survive reinjection in the isolated content-script world.
+ // Page-controlled IDs and attributes cannot establish extension ownership.
+ const decorations = window.__wbPageMonitorDecorations ??= new WeakSet();
+ const registerDecoration = el => {
+ if (el?.nodeType === 1 && el.ownerDocument === document && el !== document.body && el !== document.documentElement) decorations.add(el);
+ return el;
+ };
+ const ignored = el => {
+ if (!el || el.nodeType !== 1 || /^(SCRIPT|STYLE|LINK|META|HEAD)$/.test(el.tagName)) return true;
+ for (let node = el; node; node = node.parentElement || node.getRootNode?.().host) {
+ // Reparenting the page under a real indicator cannot silence the page.
+ if (node === document.body || node === document.documentElement) return false;
+ if (decorations.has(node)) return true;
+ }
+ return false;
+ };
const visible = el => {
if (ignored(el)) return false;
const style = getComputedStyle(el);
@@ -462,7 +476,7 @@
}
};
api.runtime.onMessage.addListener(onMessage);
- window.__wbPageMonitor = { beginContentAction, beforeLocalDispatch, dispatch,
+ window.__wbPageMonitor = { beginContentAction, beforeLocalDispatch, dispatch, registerDecoration,
dispose() { disposed = true; requestGeneration++; stop(); api.runtime.onMessage.removeListener?.(onMessage); } };
void requestState();
// A document restored from BFCache needs a fresh run/document handshake.
diff --git a/src/firefox/src/content/selection-shortcut.js b/src/firefox/src/content/selection-shortcut.js
index c97895386..2c581d811 100644
--- a/src/firefox/src/content/selection-shortcut.js
+++ b/src/firefox/src/content/selection-shortcut.js
@@ -185,6 +185,7 @@ host.lang = localization.locale;
if (host?.isConnected) return;
host = document.createElement('div');
host.id = 'webbrain-selection-shortcut-host';
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(host);
host.style.cssText = 'position:fixed;inset:0;width:100vw;height:100vh;display:block;pointer-events:none;z-index:2147483647';
shadow = host.attachShadow({ mode: 'closed' });
shadow.innerHTML = `
diff --git a/src/firefox/src/content/teacher-capture.js b/src/firefox/src/content/teacher-capture.js
index aab6bd520..3e420ce71 100644
--- a/src/firefox/src/content/teacher-capture.js
+++ b/src/firefox/src/content/teacher-capture.js
@@ -138,6 +138,7 @@
if (!active || !document.documentElement) return;
const indicator = document.createElement('div');
indicator.id = INDICATOR_ID;
+ (window.__wbPageMonitorDecorations ??= new WeakSet()).add(indicator);
indicator.setAttribute('role', 'status');
indicator.setAttribute('aria-live', 'polite');
indicator.textContent = `● WebBrain Teach${sessionName ? ` · ${sessionName}` : ''}`;
diff --git a/test/page-feedback.mjs b/test/page-feedback.mjs
index 58c39a540..4f9879522 100644
--- a/test/page-feedback.mjs
+++ b/test/page-feedback.mjs
@@ -87,6 +87,38 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(agent._pageFeedbackRuns.size, 0);
});
+ test(`${build}: run startup awaits every accessible frame and cleanup stops all of them`, async () => {
+ const agent = setup(Agent), tab = nextTab++, entered = deferred(), release = deferred();
+ const states = new Map([[0, false], [2, false]]);
+ const previousNavigation = api.webNavigation, previousMessage = api.tabs.sendMessage;
+ api.webNavigation = { getAllFrames: async () => [{ frameId: 0 }, { frameId: 2 }, { frameId: 9 }] };
+ const sendFrame = async (frameId, message) => {
+ if (frameId === 9) throw new Error('Restricted frame');
+ if (message.action !== 'page_monitor_state') return {};
+ if (frameId === 2 && message.active) { entered.resolve(); await release.promise; }
+ states.set(frameId, message.active); return { ready: true };
+ };
+ // Model real broadcast semantics: all frames receive the message, but the
+ // caller only waits for the first responding frame unless it targets each.
+ api.tabs.sendMessage = async (_tab, message, options) => options?.frameId === undefined
+ ? Promise.any([0, 2, 9].map(frameId => sendFrame(frameId, message))) : sendFrame(options.frameId, message);
+ let complete = false;
+ const starting = agent._claimRunEntry(tab, 'interactive').then(() => { complete = true; });
+ try {
+ await entered.promise;
+ await new Promise(resolve => setImmediate(resolve));
+ assert.equal(complete, false, 'A top-frame response must not bypass a delayed child acknowledgement');
+ release.resolve(); await starting;
+ assert.deepEqual([...states.values()], [true, true]);
+ agent._releaseRunEntry(tab);
+ await new Promise(resolve => setImmediate(resolve));
+ assert.deepEqual([...states.values()], [false, false]);
+ } finally {
+ release.resolve(); await starting; agent._releaseRunEntry(tab);
+ api.webNavigation = previousNavigation; api.tabs.sendMessage = previousMessage;
+ }
+ });
+
test(`${build}: navigation bursts and DOM storms remain bounded and retain navigation intent`, async () => {
const agent = setup(Agent), tab = nextTab++;
await agent._claimRunEntry(tab, 'interactive');
diff --git a/test/page-monitor-ui.mjs b/test/page-monitor-ui.mjs
index f5de6bdd9..b5b78ec88 100644
--- a/test/page-monitor-ui.mjs
+++ b/test/page-monitor-ui.mjs
@@ -365,6 +365,7 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
await page.evaluate(() => {
feedback = [];
const decoration = document.createElement('div'); decoration.dataset.webbrainUi = 'indicator';
+ __wbPageMonitor.registerDecoration(decoration);
decoration.textContent = 'Agent decoration'; document.body.appendChild(decoration);
const root = decoration.attachShadow({ mode: 'open' }); root.innerHTML = '<span>Shadow decoration</span>';
window.animationUpdates = setInterval(() => {
@@ -379,6 +380,48 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
} finally { await browser.close(); }
});
+ test(`${build}: page-owned marker attributes and ID prefixes cannot silence monitoring`, async () => {
+ const { browser, page } = await fixture(engine, build);
+ try {
+ for (const [name, value] of [['id', 'webbrain-layout'], ['id', 'wb-agent-layout'], ['data-webbrain-ui', 'page'],
+ ['data-webbrain-dev-highlight', 'page'], ['data-webbrain-attention', 'page']]) {
+ await page.evaluate(({ name, value }) => {
+ document.body.setAttribute(name, value); feedback = [];
+ }, { name, value });
+ await page.locator('#human').click();
+ assert.ok((await page.evaluate(() => feedback)).some(event => event.kind === 'click' && event.source === 'user'),
+ `${name} is page data, not proof of extension ownership`);
+ await page.evaluate(() => { feedback = []; document.getElementById('status').textContent += ' changed'; });
+ await page.waitForFunction(() => feedback.some(event => event.kind === 'dom'), null, { timeout: 1000 });
+ await page.evaluate(name => document.body.removeAttribute(name), name);
+ }
+ } finally { await browser.close(); }
+ });
+
+ test(`${build}: actual extension indicator nodes remain excluded after monitor replacement`, async () => {
+ const { browser, page } = await fixture(engine, build);
+ try {
+ await page.addScriptTag({ content: read(build, 'content/agent-visual-indicator.js') });
+ await page.evaluate(() => {
+ feedback = [];
+ messageListeners.forEach(listener => listener({ type: 'WB_SHOW_AGENT_INDICATORS' }, {}, () => {}));
+ });
+ await page.waitForTimeout(400);
+ assert.equal((await page.evaluate(() => feedback)).length, 0);
+ await page.addScriptTag({ content: read(build, 'content/page-monitor.js') });
+ await page.waitForTimeout(200);
+ await page.evaluate(() => {
+ feedback = [];
+ document.getElementById('webbrain-agent-stop-container').style.left = '40%';
+ });
+ await page.locator('#webbrain-agent-stop-button').click();
+ await page.waitForTimeout(200);
+ assert.equal((await page.evaluate(() => feedback)).length, 0);
+ await page.locator('#human').click();
+ assert.ok((await page.evaluate(() => feedback)).some(event => event.source === 'user'));
+ } finally { await browser.close(); }
+ });
+
test(`${build}: companion native markers renew per key without hiding a later human edit`, async () => {
const { browser, page } = await fixture(engine, build);
try {