Skip to content

An agentic browser harness: an AI side panel & orb in your own logged-in Chrome, Edge, Arc, Brave or even Firefox run by the agent/subscription you already use (Claude Code, Codex, Antigravity). Free, open source, no API key. Also an MCP server.

fix(extension): action cues stay out of the page's way — the caption's font rule is valid again, a page's ::backdrop rule can no longer dim the screen, a trusted click leaves the cue host's attributes alone, a field is named by its label without its own text, a lit frame is remembered past a hidden tab's throttled fade so a later screenshot still quenches it, and a hidden tab answers without waiting for frames that never come

Shahriar9ed6f5f49c5d
diff --git a/docs/guide/features/action-cues.md b/docs/guide/features/action-cues.md
index 43b5f23..5b8ae0d 100644
--- a/docs/guide/features/action-cues.md
+++ b/docs/guide/features/action-cues.md
@@ -36,9 +36,10 @@ It is off until you switch it on, in any of three places — they are one settin
- **It never shows what is typed.** The caption names a field by its label — **Fill · Password** —
never by its contents, and the agent's input never reaches the page's layer at all: only where
an action lands does.
-- **It is never in a screenshot.** Before the agent takes a screenshot, or the captcha solver
- photographs a challenge, every ring on the tab is taken off first, so the agent never sees its
- own cue.
+- **It stays out of screenshots.** Before the agent takes a screenshot, or the captcha solver
+ photographs a challenge, every ring on the tab is taken off first and the page is given a moment
+ to repaint, so the agent does not see its own cue. A page too busy to repaint in that moment is
+ the one exception.
- **It is never drawn on a [blocked site](blocked-sites.md)** — the action is refused before
anything reaches the page.
diff --git a/docs/internals/extension.md b/docs/internals/extension.md
index 01aa22d..f78b5b5 100644
--- a/docs/internals/extension.md
+++ b/docs/internals/extension.md
@@ -401,18 +401,23 @@ refused by `guardTarget` before `dispatch` runs, so they are never ringed. The s
top-frame return in `content.ts`), and the first cue in a document mounts `#browsentic-cues` on
`documentElement` with its attributes already set — one childList mutation for the page's
observers, and none after it, because every ring, caption and fade is inside a closed shadow root.
-Nothing in it takes a pointer, and it never focuses, scrolls or listens to the page. While a cue is
-on screen a requestAnimationFrame loop follows the element's box; a target that has not appeared
-yet (`waitForElement`) is looked for again every 250 ms.
+Nothing in it takes a pointer, so a trusted click's inert pass (`markOverlaysInert`) leaves it out,
+and it never focuses or scrolls. Its one listener is `pageshow`, to clear a ring a back/forward
+restore brings back. While a cue is on screen a requestAnimationFrame loop follows the element's
+box; a target that has not appeared yet (`waitForElement`) is looked for again every 250 ms.
**It rides in the top layer.** The host is a `popover="manual"`, shown while a cue is up and hidden
when none is, and raised again when a modal dialog, another popover or a fullscreen element has
-appeared — so a ring on a cookie banner's button sits above the banner.
+appeared — so a ring on a cookie banner's button sits above the banner. Showing and hiding it fires
+the popover's `toggle` events on the host, which a page listening in the capture phase can hear, and
+its `::backdrop` is switched off from inside the shadow root so a page's own `::backdrop` rule never
+dims the screen.
**A capture quenches first.** `screenshot`, `findCaptcha`, `solveCaptcha` and `pickElement` carry
`quench` in the table, so `cued()` clears every frame still lit on that tab — the background keeps
-which ones, for as long as a cue lingers — and the host answers after two frames, once the page has
-repainted without it. A tab with nothing lit is not messaged at all.
+which ones until a few seconds after the cue settles, longer than a hidden tab's throttled timers
+take to fade it — and the host answers after two frames, once the page has repainted without it, or
+at once in a hidden tab. A tab with nothing lit is not messaged at all.
## Tab scoping
diff --git a/src/lib/bridge/action-cues.ts b/src/lib/bridge/action-cues.ts
index 7710eef..6ae8fd2 100644
--- a/src/lib/bridge/action-cues.ts
+++ b/src/lib/bridge/action-cues.ts
@@ -10,7 +10,9 @@ export const CUE_LEAD_MS = 120;
const QUENCH_WAIT_MS = 300;
-const LIT_FOR_MS = CUE_LINGER_MS + CUE_FADE_MS + 200;
+const THROTTLED_TIMER_SLACK_MS = 5_000;
+
+const LIT_FOR_MS = CUE_LINGER_MS + CUE_FADE_MS + THROTTLED_TIMER_SLACK_MS;
type Unsent<T> = T extends unknown ? Omit<T, 'channel'> : never;
diff --git a/src/lib/bridge/trusted-input.ts b/src/lib/bridge/trusted-input.ts
index 57591d2..4719abe 100644
--- a/src/lib/bridge/trusted-input.ts
+++ b/src/lib/bridge/trusted-input.ts
@@ -4,6 +4,7 @@ import { dragElement } from '@/lib/actions/page/drag-element';
import { APPROACH_STEPS, pathBetween, type Point } from '@/lib/actions/page/pointer';
import { trustedClick } from '@/lib/actions/page/trusted-click';
import { failure, success, type ActionResult } from '@/lib/actions/protocol';
+import { CUE_HOST_ID } from '@/lib/cues/events';
import { OVERLAY_ATTRIBUTE } from '@/lib/overlay';
import { send, settle, withDebugger, type DebuggerSession } from './cdp';
import { FRAME_GONE_HINT, frameOffset } from './frame-focus';
@@ -92,10 +93,10 @@ async function markOverlaysInert(tabId: number, inert: boolean): Promise<void> {
await browser.scripting
.executeScript({
target: { tabId },
- func: (attribute: string, on: boolean) => {
- for (const host of document.querySelectorAll(`[${attribute}]`)) host.toggleAttribute('inert', on);
+ func: (attribute: string, untouched: string, on: boolean) => {
+ for (const host of document.querySelectorAll(`[${attribute}]:not(#${untouched})`)) host.toggleAttribute('inert', on);
},
- args: [OVERLAY_ATTRIBUTE, inert],
+ args: [OVERLAY_ATTRIBUTE, CUE_HOST_ID, inert],
})
.catch(() => undefined);
}
diff --git a/src/lib/cues/events.ts b/src/lib/cues/events.ts
index b2213ff..104be0c 100644
--- a/src/lib/cues/events.ts
+++ b/src/lib/cues/events.ts
@@ -2,6 +2,8 @@ import type { ThemeId } from '@/lib/settings/theme';
export const CUE_CHANNEL = 'browsentic/cue';
+export const CUE_HOST_ID = 'browsentic-cues';
+
export const CUE_LINGER_MS = 700;
export const CUE_FADE_MS = 220;
diff --git a/src/lib/cues/host.test.ts b/src/lib/cues/host.test.ts
index 1c1ed32..ddcb381 100644
--- a/src/lib/cues/host.test.ts
+++ b/src/lib/cues/host.test.ts
@@ -1,4 +1,4 @@
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest';
import { fakeBrowser } from 'wxt/testing';
import { OVERLAY_ATTRIBUTE } from '@/lib/overlay';
import { CUE_CHANNEL, CUE_FADE_MS, CUE_LINGER_MS, type CueCommand, type CuePlan } from './events';
@@ -115,7 +115,11 @@ describe('action cues on the page', () => {
laidOut(onPage('<button id="go">Sign in</button>'));
const focus = vi.spyOn(HTMLElement.prototype, 'focus');
const scrollIntoView = vi.fn();
+ const original = Element.prototype.scrollIntoView;
Element.prototype.scrollIntoView = scrollIntoView;
+ onTestFinished(() => {
+ Element.prototype.scrollIntoView = original;
+ });
await show('a', click('#go'));
await vi.advanceTimersByTimeAsync(500);
@@ -138,6 +142,17 @@ describe('action cues on the page', () => {
expect(root!.textContent).not.toContain('hunter2');
});
+ it('names a field inside its label by the label alone, and a wrapper by its text outside the editor', async () => {
+ laidOut(onPage('<label>Notes <textarea id="notes">my private note</textarea></label>').querySelector('textarea')!);
+ await show('a', { kind: 'element', verb: 'Fill', anchors: [{ target: { selector: '#notes', nth: 0 } }] });
+ expect(chip()).toBe('Fill · Notes');
+
+ laidOut(onPage('<div id="editor">Draft <div contenteditable="true">my private draft</div></div>'));
+ await show('b', click('#editor'));
+ expect(chip()).toBe('Click · Draft');
+ expect(root!.textContent).not.toContain('private');
+ });
+
it('glows around the page when there is no element, or the element is not there', async () => {
await show('a', { kind: 'page', verb: 'Go to', detail: 'example.com', anchors: [] });
expect($('.edge').classList.contains('hidden')).toBe(false);
diff --git a/src/lib/cues/host.ts b/src/lib/cues/host.ts
index 9ae9f86..5629c0a 100644
--- a/src/lib/cues/host.ts
+++ b/src/lib/cues/host.ts
@@ -3,18 +3,16 @@ import { resolveTarget } from '@/lib/actions/page/dom';
import { OVERLAY_ATTRIBUTE } from '@/lib/overlay';
import { RAIL_PALETTES, RAIL_TONES } from '@/lib/rail/events';
import type { ThemeId } from '@/lib/settings/theme';
-import { CUE_FADE_MS, CUE_LINGER_MS, isCueCommand, type CueAnchor, type CuePlan } from './events';
+import { CUE_FADE_MS, CUE_HOST_ID, CUE_LINGER_MS, isCueCommand, type CueAnchor, type CuePlan } from './events';
import { cueLabel } from './label';
import { CUE_GLOW, HOST_STYLE, STYLES } from './styles';
-export { CUE_CHANNEL } from './events';
-
-export const CUE_HOST_ID = 'browsentic-cues';
+export { CUE_CHANNEL, CUE_HOST_ID } from './events';
const RING_PAD = 4;
const POINT_SIZE = 28;
const CHIP_GAP = 6;
-const CHIP_HEIGHT = 22;
+const CHIP_HEIGHT = 24;
const EDGE_CHIP_TOP = 12;
const VIEW_MARGIN = 8;
const RESOLVE_EVERY_MS = 250;
@@ -56,8 +54,7 @@ interface Layer {
/**
* Where the agent is acting, drawn into the frame it acts in. The page gets one element on
* its first cue and never another change: every ring, caption and fade lives in a closed
- * shadow root, nothing in it takes a pointer, and nothing here focuses, scrolls or listens
- * to the page.
+ * shadow root, nothing in it takes a pointer, and nothing here focuses or scrolls the page.
*/
export function exposeCues(): void {
let layer: Layer | null = null;
@@ -84,6 +81,7 @@ export function exposeCues(): void {
}
function painted(): Promise<void> {
+ if (document.visibilityState === 'hidden') return Promise.resolve();
return new Promise((resolve) => {
const timer = setTimeout(resolve, PAINT_WAIT_MS);
requestAnimationFrame(() =>
diff --git a/src/lib/cues/label.ts b/src/lib/cues/label.ts
index 3ec6d8e..9fb45f0 100644
--- a/src/lib/cues/label.ts
+++ b/src/lib/cues/label.ts
@@ -2,15 +2,30 @@ import { accessibleText, computedRole } from '@/lib/actions/page/dom';
export const LABEL_MAX = 40;
+const TYPED_INTO = 'input, textarea, select, [contenteditable]:not([contenteditable="false"])';
+
+const BUTTON_TYPES = new Set(['submit', 'button', 'reset']);
+
+type FormField = HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
+
/** What a sighted user would call the element. Something the agent can type into is named, never read aloud. */
export function cueLabel(el: Element): string {
const role = computedRole(el);
const typedInto = !isFormField(el) && (isEditable(el) || role === 'textbox' || role === 'searchbox');
- const name = typedInto ? quietName(el) : accessibleText(el);
+ const name = typedInto ? quietName(el) : spokenName(el);
return clip(name || role || el.tagName.toLowerCase());
}
-function isFormField(el: Element): boolean {
+function spokenName(el: Element): string {
+ const aria = el.getAttribute('aria-label')?.trim();
+ if (aria) return aria;
+ if (isFormField(el) && !(el instanceof HTMLInputElement && BUTTON_TYPES.has(el.type))) {
+ return textOutsideFields(el.labels?.[0]) || el.getAttribute('placeholder')?.trim() || el.name;
+ }
+ return el.querySelector(TYPED_INTO) ? textOutsideFields(el) : accessibleText(el);
+}
+
+function isFormField(el: Element): el is FormField {
return el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement;
}
@@ -28,6 +43,17 @@ function quietName(el: Element): string {
);
}
+function textOutsideFields(root: Element | null | undefined): string {
+ if (!root) return '';
+ const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
+ let text = '';
+ while (walker.nextNode()) {
+ const field = walker.currentNode.parentElement?.closest(TYPED_INTO);
+ if (!field || !root.contains(field)) text += walker.currentNode.textContent ?? '';
+ }
+ return text.trim();
+}
+
export function clip(text: string): string {
const flat = text.replace(/\s+/g, ' ').trim();
return flat.length > LABEL_MAX ? `${flat.slice(0, LABEL_MAX - 1).trimEnd()}…` : flat;
diff --git a/src/lib/cues/styles.ts b/src/lib/cues/styles.ts
index cfe5963..0d59ab0 100644
--- a/src/lib/cues/styles.ts
+++ b/src/lib/cues/styles.ts
@@ -29,6 +29,7 @@ export const HOST_STYLE = [
export const STYLES = `
:host { all: initial; }
+ :host::backdrop { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; pointer-events: none; }
.layer {
position: fixed;
@@ -74,7 +75,9 @@ export const STYLES = `
border-radius: 999px;
background: var(--ground2);
color: var(--ink);
- font: 600 11px/1.3 inherit;
+ font-size: 11px;
+ font-weight: 600;
+ line-height: 1.3;
letter-spacing: 0.01em;
white-space: nowrap;
overflow: hidden;