Skip to content

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

Agent indicator: Neural circuit page effect by default, four more in Settings

Claudeeffcdc8dfa36
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20b6cfa96..957be5873 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,12 @@ This changelog was generated from the repository Git history and release tags. V
## [Unreleased]
+### Added
+- Settings → General → **Agent activity effect** chooses how a tab looks while WebBrain works on it: **Neural circuit**, the new default, where circuit traces grow in from the edges and signals run along them toward each element WebBrain acts on; **Aurora**, a soft purple band that drifts around the frame; **Scan**, corner brackets with a slow scanning beam; **Gears**, meshing cog trains turning in the corners; or **Classic glow**, the pulsing border used until now. Every style lets clicks, typing and scrolling through to the page, is hidden while WebBrain takes a screenshot, and holds still when your system asks to reduce motion. A new choice applies to a running task at once and is included in settings export and import. Chrome and Firefox.
+
+### Changed
+- The agent cursor no longer disappears three seconds after an action. It now keeps one, smaller size: it glides from target to target, presses once with a ripple when WebBrain clicks, and between actions stays where it last acted, slowly fading in and out until the task ends. The ring around the target still fades after a moment. Chrome and Firefox.
+
## [44.0.0] - 2026-10-27
### Added
diff --git a/docs/architecture.md b/docs/architecture.md
index 8f4a3b162..1cfd47c32 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -57,7 +57,7 @@ This doc covers the shared architecture and calls out where the builds diverge.
│ │
│ accessibility-tree.js — AX tree builder + ref_ids │
│ content.js — DOM reader, clicker, typer │
-│ agent-visual-indicator.js — pulsing border + Stop │
+│ agent-visual-indicator.js — edge effect + Stop │
└─────────────────────────────────────────────────────┘
```
diff --git a/docs/fr/architecture.md b/docs/fr/architecture.md
index 01545e274..a126ad334 100644
--- a/docs/fr/architecture.md
+++ b/docs/fr/architecture.md
@@ -53,7 +53,7 @@ Ce document couvre l'architecture partagée et signale où les builds divergent.
│ │
│ accessibility-tree.js — constructeur arbre AX │
│ content.js — lecteur DOM, cliqueur, │
-│ agent-visual-indicator.js — bordure clignotante │
+│ agent-visual-indicator.js — effet de bordure + Stop │
└─────────────────────────────────────────────────────┘
```
diff --git a/docs/zh-CN/architecture.md b/docs/zh-CN/architecture.md
index bc4497d90..0321d5276 100644
--- a/docs/zh-CN/architecture.md
+++ b/docs/zh-CN/architecture.md
@@ -53,7 +53,7 @@ WebBrain 是一个浏览器扩展,让 LLM 能够控制用户当前活动的浏
│ │
│ accessibility-tree.js — AX 树构建器 + ref_ids │
│ content.js — DOM 读取器、点击器、输入器 │
-│ agent-visual-indicator.js — 脉冲边框 + 停止按钮 │
+│ agent-visual-indicator.js — 边缘效果 + 停止按钮 │
└─────────────────────────────────────────────────────┘
```
diff --git a/src/chrome/src/config-transfer.js b/src/chrome/src/config-transfer.js
index f61148bb1..57ef02c12 100644
--- a/src/chrome/src/config-transfer.js
+++ b/src/chrome/src/config-transfer.js
@@ -27,6 +27,7 @@ export const DEFAULT_CONFIG_SETTINGS = Object.freeze({
[UI_SCALE_STORAGE_KEY]: 100,
verboseMode: false,
composerDeliveryMode: 'queue',
+ agentIndicatorStyle: 'circuit',
selectionShortcutEnabled: true,
[AUTO_GROUP_TABS_KEY]: true,
helpImproveWebBrain: true,
@@ -198,6 +199,7 @@ const NUMBER_KEYS = new Set([
]);
const STRING_KEYS = new Set([
'composerDeliveryMode',
+ 'agentIndicatorStyle',
'clarifyTimeoutPolicy',
'leanMode',
'visionMode',
@@ -262,6 +264,7 @@ function validSettingValue(key, value) {
// 'on' is Auto's name from before the option was renamed (currentSettingValue).
if (key === 'visionMode') return ['auto', 'on', 'off'].includes(value);
if (key === 'visionQuality') return ['economy', 'balanced', 'sharp'].includes(value);
+ if (key === 'agentIndicatorStyle') return ['circuit', 'aurora', 'scan', 'gears', 'classic'].includes(value);
if (key === 'decisionBaseUrl') {
if (typeof value !== 'string') return false;
try { resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl: value }); return true; }
diff --git a/src/chrome/src/content/agent-visual-indicator.js b/src/chrome/src/content/agent-visual-indicator.js
index c20aeb782..c77e786f8 100644
--- a/src/chrome/src/content/agent-visual-indicator.js
+++ b/src/chrome/src/content/agent-visual-indicator.js
@@ -1,15 +1,24 @@
/**
* WebBrain Agent Visual Indicator (content script)
*
- * Renders an animated purple inset glow around the page viewport while
- * the agent is operating on this tab, a "Stop WebBrain" floating button,
- * and a large WebBrain-purple cursor/outline on the element currently
- * being acted on. The base indicator follows Anthropic's Claude-for-Chrome
- * extension pattern, recolored for WebBrain's accent (#6c63ff).
+ * While the agent is operating on this tab it draws:
+ * - an effect around the viewport edges, chosen in Settings → General →
+ * "Agent activity effect" (storage key `agentIndicatorStyle`):
+ * circuit (default) — circuit traces grow in from the edges; signals run
+ * along them and their pads fire neighbouring pads
+ * aurora — a soft light band drifts around the frame
+ * scan — corner brackets and a slow scanning beam
+ * gears — meshing cog trains turn in the corners
+ * classic — the original pulsing inset glow
+ * - a "Stop WebBrain" floating button,
+ * - the agent cursor and a ring on the element being acted on. The cursor
+ * keeps one size: it glides to each target, presses once with a ripple on
+ * clicks, and between actions rests where it last acted, slowly fading in
+ * and out instead of disappearing.
*
* Lifecycle messages from the service worker:
*
- * WB_SHOW_AGENT_INDICATORS — agent run started → fade in border + button
+ * WB_SHOW_AGENT_INDICATORS — agent run started → fade in effect + button
* WB_HIDE_AGENT_INDICATORS — agent run ended → fade out + remove
* WB_AGENT_INDICATOR_HEARTBEAT — refresh the active-run lease without
* changing screenshot visibility
@@ -22,43 +31,61 @@
* agent.abort(tabId) the same way the sidepanel's Stop button does.
*
* Self-contained — no imports, runs in the page's content-script world.
- * z-index uses the max signed 32-bit value so the indicator sits above
- * site overlays/modals but never accidentally swallows page input
- * (border has pointer-events: none; button uses pointer-events: auto).
+ * z-index uses the max signed 32-bit range so the indicator sits above
+ * site overlays/modals but never accidentally swallows page input: every
+ * element is pointer-events: none except the Stop button. Every element is
+ * registered in window.__wbPageMonitorDecorations so the page monitor ignores
+ * it. Canvas effects animate with requestAnimationFrame and the cursor with
+ * CSS transitions and the Web Animations API, because the page monitor
+ * observes `style` attributes: a running indicator must not write DOM
+ * attributes every frame. prefers-reduced-motion gets still frames.
*/
(function () {
if (window.__webbrainAgentIndicatorInjected) return;
window.__webbrainAgentIndicatorInjected = true;
- const TARGET_CURSOR_TTL_MS = 3000;
- // The background refreshes this lease every 20 seconds. If its service
- // worker disappears before the normal HIDE message, the page-owned UI
- // cleans itself up instead of leaving a permanent glow and Stop button.
+ // How long the target ring and the fully opaque cursor stay after an
+ // action before the cursor settles into its resting state.
+ const TARGET_RING_TTL_MS = 1400;
+ // The background refreshes this lease every 20 seconds. If the background
+ // stops before the normal HIDE message, the page-owned UI cleans itself up
+ // instead of leaving a permanent effect and Stop button.
const INDICATOR_HEARTBEAT_TIMEOUT_MS = 65_000;
- let borderEl = null;
+ const STYLE_STORAGE_KEY = 'agentIndicatorStyle';
+ const DEFAULT_STYLE = 'circuit';
+ const STYLES = ['circuit', 'aurora', 'scan', 'gears', 'classic'];
+
+ let effectStyle = DEFAULT_STYLE;
+ let styleLoaded = false;
+ let effect = null;
let stopContainerEl = null;
- let targetCursorEl = null;
let targetOutlineEl = null;
+ let cursor = null;
let targetElement = null;
let targetRectOverride = null;
- let targetTimer = null;
+ let ringTimer = null;
let targetRaf = 0;
let indicatorHeartbeatTimer = null;
let indicatorsActive = false;
+ let suspendedForToolUse = false;
// Saved visibility state during HIDE_FOR_TOOL_USE so SHOW_AFTER_TOOL_USE
// can restore the right thing (don't want to show indicators that
// weren't on before the screenshot).
- let savedBorderVisible = false;
let savedStopVisible = false;
- let savedTargetCursorVisible = false;
let savedTargetOutlineVisible = false;
+ const decorations = () => (window.__wbPageMonitorDecorations ??= new WeakSet());
+ const reduceMotionQuery = typeof window.matchMedia === 'function'
+ ? window.matchMedia('(prefers-reduced-motion: reduce)')
+ : { matches: false };
+ const prefersReducedMotion = () => reduceMotionQuery.matches === true;
+
function injectStyles() {
if (document.getElementById('webbrain-agent-styles')) return;
const style = document.createElement('style');
style.id = 'webbrain-agent-styles';
- (window.__wbPageMonitorDecorations ??= new WeakSet()).add(style);
+ decorations().add(style);
style.textContent = `
@keyframes webbrain-pulse {
0% {
@@ -81,11 +108,6 @@
}
}
- @keyframes webbrain-target-pop {
- 0% { opacity: 0; }
- 100% { opacity: 1; }
- }
-
@keyframes webbrain-target-ring {
0%, 100% {
box-shadow:
@@ -102,30 +124,1407 @@
(document.head || document.documentElement).appendChild(style);
}
- 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;
- pointer-events: none;
- z-index: 2147483646;
- opacity: 0;
- transition: opacity 0.3s ease-in-out;
- animation: webbrain-pulse 2s ease-in-out infinite;
- box-shadow:
- inset 0 0 10px rgba(108, 99, 255, 0.5),
- inset 0 0 20px rgba(108, 99, 255, 0.3),
- inset 0 0 30px rgba(108, 99, 255, 0.1);
- `;
- return el;
+ /* ------------------------------------------------------------------------
+ * Edge effects
+ * ---------------------------------------------------------------------- */
+
+ const TAU = Math.PI * 2;
+ // WebBrain purples (#6c63ff family) only.
+ const C = {
+ base: [108, 99, 255], // #6c63ff accent
+ soft: [141, 134, 255], // #8d86ff
+ pale: [169, 163, 255], // #a9a3ff
+ mist: [199, 195, 255], // #c7c3ff
+ deep: [90, 82, 213], // #5a52d5
+ core: [244, 242, 255], // signal highlight
+ };
+ const rgba = (c, a) => `rgba(${c[0]},${c[1]},${c[2]},${a <= 0 ? 0 : a >= 1 ? 1 : a.toFixed(4)})`;
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
+ const lerp = (a, b, t) => a + (b - a) * t;
+ const rand = (a, b) => a + Math.random() * (b - a);
+ const randInt = (a, b) => Math.floor(a + Math.random() * (b - a + 1));
+ const pick = list => list[Math.floor(Math.random() * list.length)];
+ const easeOutCubic = t => 1 - Math.pow(1 - t, 3);
+ const easeInOutSine = t => -(Math.cos(Math.PI * t) - 1) / 2;
+ const easeOutBack = t => { const c1 = 1.70158, c3 = c1 + 1; return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2); };
+
+ function sprite(color, size, stops) {
+ const canvas = document.createElement('canvas');
+ canvas.width = canvas.height = size;
+ const ctx = canvas.getContext('2d');
+ const r = size / 2;
+ const grad = ctx.createRadialGradient(r, r, 0, r, r, r);
+ for (const [offset, alpha] of stops) grad.addColorStop(offset, rgba(color, alpha));
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, size, size);
+ return canvas;
+ }
+
+ // Soft inset edge light, a quieter cousin of the classic box-shadow glow.
+ function vignette(ctx, w, h, alpha, size) {
+ if (alpha <= 0.002) return;
+ const s = Math.min(size, w / 2, h / 2);
+ for (const [x, y, bw, bh, x0, y0, x1, y1] of [
+ [0, 0, w, s, 0, 0, 0, s],
+ [0, h - s, w, s, 0, h, 0, h - s],
+ [0, 0, s, h, 0, 0, s, 0],
+ [w - s, 0, s, h, w, 0, w - s, 0],
+ ]) {
+ const g = ctx.createLinearGradient(x0, y0, x1, y1);
+ g.addColorStop(0, rgba(C.base, alpha));
+ g.addColorStop(0.45, rgba(C.base, alpha * 0.32));
+ g.addColorStop(1, rgba(C.base, 0));
+ ctx.fillStyle = g;
+ ctx.fillRect(x, y, bw, bh);
+ }
+ }
+
+ function makePath(pts) {
+ const n = pts.length;
+ const xs = new Float32Array(n), ys = new Float32Array(n), cum = new Float32Array(n);
+ let len = 0;
+ for (let k = 0; k < n; k++) {
+ xs[k] = pts[k][0]; ys[k] = pts[k][1];
+ if (k) len += Math.hypot(xs[k] - xs[k - 1], ys[k] - ys[k - 1]);
+ cum[k] = len;
+ }
+ return { xs, ys, cum, len, n };
+ }
+ function pointAt(p, s, out) {
+ if (s <= 0) { out.x = p.xs[0]; out.y = p.ys[0]; return out; }
+ if (s >= p.len) { out.x = p.xs[p.n - 1]; out.y = p.ys[p.n - 1]; return out; }
+ let k = 1;
+ while (k < p.n - 1 && p.cum[k] < s) k++;
+ const seg = p.cum[k] - p.cum[k - 1] || 1;
+ const u = (s - p.cum[k - 1]) / seg;
+ out.x = p.xs[k - 1] + (p.xs[k] - p.xs[k - 1]) * u;
+ out.y = p.ys[k - 1] + (p.ys[k] - p.ys[k - 1]) * u;
+ return out;
+ }
+ const subPathPoint = { x: 0, y: 0 };
+ function subPath(ctx, p, s0, s1) {
+ s0 = clamp(s0, 0, p.len); s1 = clamp(s1, 0, p.len);
+ if (s1 - s0 < 0.01) return false;
+ pointAt(p, s0, subPathPoint); ctx.moveTo(subPathPoint.x, subPathPoint.y);
+ for (let k = 1; k < p.n - 1; k++) if (p.cum[k] > s0 && p.cum[k] < s1) ctx.lineTo(p.xs[k], p.ys[k]);
+ pointAt(p, s1, subPathPoint); ctx.lineTo(subPathPoint.x, subPathPoint.y);
+ return true;
+ }
+
+ // One full-viewport, click-through canvas. Layout properties are !important
+ // so page rules such as `canvas { max-width: 100%; height: auto }` cannot
+ // resize or reposition it.
+ class Layer {
+ constructor(id, scale = 1) {
+ this.id = id; this.scale = scale;
+ this.el = null; this.ctx = null; this.w = 0; this.h = 0;
+ }
+ mount(root) {
+ if (this.el) return;
+ const el = document.createElement('canvas');
+ el.id = this.id;
+ el.setAttribute('aria-hidden', 'true');
+ decorations().add(el);
+ el.style.cssText = [
+ 'position: fixed !important', 'top: 0 !important', 'left: 0 !important',
+ 'right: 0 !important', 'bottom: 0 !important', 'width: 100% !important', 'height: 100% !important',
+ 'max-width: none !important', 'max-height: none !important', 'margin: 0 !important',
+ 'padding: 0 !important', 'border: 0 !important', 'transform: none !important',
+ 'background: transparent !important', 'pointer-events: none !important',
+ 'z-index: 2147483646 !important', 'display: none !important',
+ 'opacity: 0', 'transition: opacity 0.45s ease',
+ ].join('; ');
+ root.appendChild(el);
+ this.el = el;
+ this.ctx = el.getContext('2d');
+ }
+ setDisplay(on) { this.el?.style.setProperty('display', on ? 'block' : 'none', 'important'); }
+ fit() {
+ const w = this.el.clientWidth, h = this.el.clientHeight;
+ if (!w || !h) return false;
+ const ratio = Math.min(window.devicePixelRatio || 1, 2) * this.scale;
+ const pw = Math.max(1, Math.round(w * ratio)), ph = Math.max(1, Math.round(h * ratio));
+ const changed = pw !== this.el.width || ph !== this.el.height || w !== this.w || h !== this.h;
+ this.w = w; this.h = h;
+ if (pw !== this.el.width) this.el.width = pw;
+ if (ph !== this.el.height) this.el.height = ph;
+ this.ctx.setTransform(pw / w, 0, 0, ph / h, 0, 0);
+ return changed;
+ }
+ clear() {
+ if (!this.ctx) return;
+ this.ctx.save();
+ this.ctx.setTransform(1, 0, 0, 1, 0, 0);
+ this.ctx.clearRect(0, 0, this.el.width, this.el.height);
+ this.ctx.restore();
+ }
+ remove() { this.el?.remove(); this.el = null; this.ctx = null; }
+ }
+
+ class Effect {
+ constructor() {
+ this.layers = [];
+ this.active = false; this.mounted = false; this.suspended = false;
+ this.raf = 0; this.t = 0; this.last = 0; this.acc = 0; this.w = 0; this.h = 0;
+ this.minFrame = 0; // seconds between drawn frames; 0 = every display frame
+ this.hideTimer = 0; this.fitRaf = 0;
+ this.onResize = () => this.requestFit();
+ }
+ get still() { return prefersReducedMotion(); }
+ mount(root) {
+ if (this.mounted) return;
+ for (const layer of this.layers) layer.mount(root);
+ this.mounted = true;
+ window.addEventListener('resize', this.onResize);
+ }
+ requestFit() {
+ if (this.fitRaf || !this.active) return;
+ this.fitRaf = requestAnimationFrame(() => { this.fitRaf = 0; this.fit(false); });
+ }
+ fit(fresh) {
+ let changed = false;
+ for (const layer of this.layers) changed = layer.fit() || changed;
+ const first = this.layers[0];
+ if (!first.w) return;
+ this.w = first.w; this.h = first.h;
+ if (changed || fresh) this.layout(first.w, first.h, fresh);
+ if (this.active && !this.raf) this.draw(0);
+ }
+ show(root) {
+ this.mount(root);
+ clearTimeout(this.hideTimer);
+ const wasActive = this.active;
+ this.active = true;
+ if (!this.suspended) for (const layer of this.layers) layer.setDisplay(true);
+ if (!wasActive) { this.t = 0; this.onShow(); this.fit(true); }
+ this.loop();
+ requestAnimationFrame(() => requestAnimationFrame(() => {
+ if (this.active) for (const layer of this.layers) if (layer.el) layer.el.style.opacity = '1';
+ }));
+ }
+ hide() {
+ if (!this.active) return;
+ this.active = false;
+ for (const layer of this.layers) if (layer.el) layer.el.style.opacity = '0';
+ clearTimeout(this.hideTimer);
+ this.hideTimer = setTimeout(() => {
+ if (this.active) return;
+ this.halt();
+ for (const layer of this.layers) { layer.clear(); layer.setDisplay(false); }
+ }, 500);
+ }
+ // Screenshot capture: hide instantly and stop drawing, then continue.
+ suspend() {
+ this.suspended = true;
+ for (const layer of this.layers) layer.setDisplay(false);
+ this.halt();
+ }
+ resume() {
+ this.suspended = false;
+ if (!this.active) return;
+ for (const layer of this.layers) layer.setDisplay(true);
+ this.fit(false);
+ this.loop();
+ }
+ loop() {
+ if (this.raf || this.suspended || !this.active) return;
+ if (this.still) { this.draw(0); return; }
+ this.last = performance.now();
+ this.acc = 0;
+ const tick = now => {
+ this.raf = requestAnimationFrame(tick);
+ this.acc += Math.max((now - this.last) / 1000, 0);
+ this.last = now;
+ if (this.acc < this.minFrame - 0.002) return;
+ const dt = Math.min(this.acc, 1 / 20);
+ this.acc = 0;
+ this.t += dt;
+ this.step(dt);
+ this.draw(dt);
+ };
+ this.raf = requestAnimationFrame(tick);
+ }
+ halt() { if (this.raf) cancelAnimationFrame(this.raf); this.raf = 0; }
+ refreshMotion() { if (!this.active) return; this.halt(); this.loop(); }
+ destroy() {
+ this.halt();
+ clearTimeout(this.hideTimer);
+ if (this.fitRaf) cancelAnimationFrame(this.fitRaf);
+ this.fitRaf = 0;
+ window.removeEventListener('resize', this.onResize);
+ for (const layer of this.layers) layer.remove();
+ this.mounted = false; this.active = false;
+ }
+ onShow() {}
+ layout() {}
+ step() {}
+ draw() {}
+ target() {}
+ }
+
+ /* circuit: traces on a grid (orthogonal and 45° runs, no crossings) grow in
+ from every edge. Signals travel them; pads flash when hit and fire
+ neighbouring pads through faint synapse links in short cascades. */
+ class NeuralCircuit extends Effect {
+ constructor() {
+ super();
+ this.layer = new Layer('webbrain-agent-effect', 1);
+ this.layers = [this.layer];
+ this.cache = document.createElement('canvas');
+ this.sprHead = sprite(C.soft, 64, [[0, 1], [0.18, 0.7], [0.45, 0.18], [1, 0]]);
+ this.sprCore = sprite(C.core, 32, [[0, 1], [0.35, 0.65], [1, 0]]);
+ this.sprFlash = sprite(C.base, 96, [[0, 0.9], [0.22, 0.45], [0.55, 0.1], [1, 0]]);
+ this.traces = []; this.pads = []; this.vias = []; this.links = []; this.pulses = []; this.edges = [];
+ this.bands = null; this.rx = 1; this.ry = 1;
+ this.spawnAcc = 0; this.intro = 0; this.introDur = 1.4; this.maxPulses = 56; this.rate = 8;
+ this.tmpA = { x: 0, y: 0 }; this.tmpB = { x: 0, y: 0 }; this.heads = [];
+ }
+ onShow() { this.intro = 0; this.pulses.length = 0; this.spawnAcc = 0; }
+ layout(w, h, fresh) {
+ const g = 8;
+ const cols = Math.max(6, Math.round(w / g)), rows = Math.max(6, Math.round(h / g));
+ const sx = w / cols, sy = h / rows;
+ const depthPx = clamp(Math.min(w, h) * 0.13, 50, 130);
+ const maxCells = Math.max(4, Math.round(depthPx / Math.max(sx, sy)));
+ this.depthPx = depthPx;
+ const W1 = cols + 1;
+ const occ = new Int32Array(W1 * (rows + 1)).fill(-1);
+ const inside = (i, j) => i >= 0 && j >= 0 && i <= cols && j <= rows;
+ const interior = (i, j) => i > 0 && j > 0 && i < cols && j < rows;
+ const clearAt = (i, j, id) => {
+ for (let dj = -1; dj <= 1; dj++) for (let di = -1; di <= 1; di++) {
+ const ii = i + di, jj = j + dj;
+ if (!inside(ii, jj)) continue;
+ const o = occ[jj * W1 + ii];
+ if (o !== -1 && o !== id) return false;
+ }
+ return true;
+ };
+ const mark = (i, j, id) => { occ[j * W1 + i] = id; };
+ const unmark = cells => { for (const [i, j] of cells) occ[j * W1 + i] = -1; };
+ const edges = [
+ { len: cols, at: k => [k, 0], inw: [0, 1], alg: [1, 0], dep: (i, j) => j },
+ { len: cols, at: k => [k, rows], inw: [0, -1], alg: [1, 0], dep: (i, j) => rows - j },
+ { len: rows, at: k => [0, k], inw: [1, 0], alg: [0, 1], dep: i => i },
+ { len: rows, at: k => [cols, k], inw: [-1, 0], alg: [0, 1], dep: i => cols - i },
+ ];
+ this.edges = edges;
+ const route = (e, i, j, plan, id, maxD) => {
+ const cells = [];
+ for (const [[dx, dy], n] of plan) {
+ let moved = 0;
+ for (let s = 0; s < n; s++) {
+ const ni = i + dx, nj = j + dy;
+ if (!interior(ni, nj) || e.dep(ni, nj) > maxD || !clearAt(ni, nj, id)) break;
+ i = ni; j = nj; mark(i, j, id); cells.push([i, j]); moved++;
+ }
+ if (moved < n) break;
+ }
+ return cells;
+ };
+
+ const raw = [];
+ let id = 0;
+ for (const e of edges) {
+ const [ix, iy] = e.inw, [ax, ay] = e.alg;
+ let k = randInt(2, 4);
+ while (k <= e.len - 2) {
+ const [i0, j0] = e.at(k);
+ if (Math.random() < 0.74 && clearAt(i0, j0, id)) {
+ mark(i0, j0, id);
+ const side = Math.random() < 0.5 ? -1 : 1;
+ const diag = [ix + side * ax, iy + side * ay];
+ const par = [side * ax, side * ay];
+ const back = [ix - side * ax, iy - side * ay];
+ const r = Math.random();
+ const plan = [[[ix, iy], randInt(2, 6)]];
+ if (r < 0.38) plan.push([diag, randInt(1, 4)], [[ix, iy], randInt(1, 6)]);
+ else if (r < 0.72) plan.push([diag, randInt(1, 3)], [par, randInt(3, 10)]);
+ else if (r < 0.88) plan.push([diag, randInt(2, 4)], [back, randInt(1, 3)], [[ix, iy], randInt(1, 3)]);
+ else plan.push([[ix, iy], randInt(2, 7)]);
+ const maxD = Math.max(3, Math.round(maxCells * rand(0.45, 1)));
+ const cells = route(e, i0, j0, plan, id, maxD);
+ if (cells.length >= 3) {
+ raw.push({ id, edge: e, side, cells: [[i0, j0], ...cells] });
+ id++;
+ k += randInt(2, 6);
+ continue;
+ }
+ unmark(cells);
+ occ[j0 * W1 + i0] = -1;
+ }
+ k += randInt(1, 3);
+ }
+ }
+ for (const tr of raw) {
+ if (tr.cells.length < 7 || Math.random() > 0.36) continue;
+ const m = randInt(2, tr.cells.length - 4);
+ const [bi, bj] = tr.cells[m];
+ const e = tr.edge, s = -tr.side;
+ const [ix, iy] = e.inw, [ax, ay] = e.alg;
+ const plan = Math.random() < 0.55
+ ? [[[ix + s * ax, iy + s * ay], randInt(2, 4)], [[ix, iy], randInt(1, 4)]]
+ : [[[ix + s * ax, iy + s * ay], 1], [[s * ax, s * ay], randInt(2, 6)]];
+ const cells = route(e, bi, bj, plan, tr.id, maxCells);
+ if (cells.length >= 3) tr.branch = { at: m, cells: [[bi, bj], ...cells] };
+ else unmark(cells);
+ }
+
+ const px = ([i, j]) => [i * sx, j * sy];
+ const simplify = cells => {
+ if (cells.length < 3) return cells.slice();
+ const out = [cells[0]];
+ for (let k = 1; k < cells.length - 1; k++) {
+ const a = cells[k - 1], b = cells[k], c = cells[k + 1];
+ if (b[0] - a[0] !== c[0] - b[0] || b[1] - a[1] !== c[1] - b[1]) out.push(b);
+ }
+ out.push(cells[cells.length - 1]);
+ return out;
+ };
+ const depthAlpha = (x, y) => lerp(0.62, 0.16, clamp(Math.min(x, y, w - x, h - y) / depthPx, 0, 1));
+ const traces = [], pads = [], vias = [], links = [];
+ for (const r of raw) {
+ const pts = simplify(r.cells).map(px);
+ pts[0] = [pts[0][0] - r.edge.inw[0] * 3, pts[0][1] - r.edge.inw[1] * 3]; // start just off-screen
+ const path = makePath(pts);
+ const end = pts[pts.length - 1];
+ const neuron = Math.random() < 0.17;
+ const tr = {
+ edge: r.edge, path, lw: Math.random() < 0.22 ? 1.6 : 1.1,
+ along: r.edge.alg[0] ? pts[0][0] : pts[0][1], x0: pts[0][0], y0: pts[0][1],
+ delay: rand(0, 0.34), grow: clamp(path.len / 230, 0.22, 0.72), booted: false, branch: null,
+ };
+ tr.pad = { x: end[0], y: end[1], r: neuron ? rand(2.7, 3.3) : rand(1.6, 2.2), neuron, flash: 0, links: [], trace: tr, branch: null, a: depthAlpha(end[0], end[1]) };
+ pads.push(tr.pad);
+ for (let k = 1; k < pts.length - 1; k++) if (Math.random() < 0.16) vias.push({ x: pts[k][0], y: pts[k][1], a: depthAlpha(pts[k][0], pts[k][1]) * 0.9 });
+ if (r.branch) {
+ let s = 3;
+ for (let k = 1; k <= r.branch.at; k++) s += Math.hypot((r.cells[k][0] - r.cells[k - 1][0]) * sx, (r.cells[k][1] - r.cells[k - 1][1]) * sy);
+ const bpts = simplify(r.branch.cells).map(px);
+ const bpath = makePath(bpts);
+ const bend = bpts[bpts.length - 1];
+ const br = { path: bpath, s, booted: false };
+ br.t0 = tr.delay + (1 - Math.cbrt(1 - clamp(s / path.len, 0, 0.999))) * tr.grow;
+ br.grow = clamp(bpath.len / 230, 0.18, 0.5);
+ br.pad = { x: bend[0], y: bend[1], r: rand(1.5, 2), neuron: false, flash: 0, links: [], trace: tr, branch: br, a: depthAlpha(bend[0], bend[1]) };
+ pads.push(br.pad);
+ tr.branch = br;
+ }
+ traces.push(tr);
+ }
+ for (let a = 0; a < pads.length; a++) {
+ const A = pads[a];
+ for (let b = a + 1; b < pads.length; b++) {
+ const B = pads[b];
+ if (A.trace === B.trace || A.links.length > 1 || B.links.length > 1) continue;
+ const dx = B.x - A.x, dy = B.y - A.y, d = Math.hypot(dx, dy);
+ if (d < 16 || d > 54 || Math.random() < 0.4) continue;
+ const bend = rand(-0.35, 0.35) * d;
+ const cx = (A.x + B.x) / 2 - (dy / d) * bend, cy = (A.y + B.y) / 2 + (dx / d) * bend;
+ const pts = [];
+ for (let q = 0; q <= 12; q++) {
+ const t = q / 12, u = 1 - t;
+ pts.push([u * u * A.x + 2 * u * t * cx + t * t * B.x, u * u * A.y + 2 * u * t * cy + t * t * B.y]);
+ }
+ const link = { a: A, b: B, path: makePath(pts), alpha: Math.min(A.a, B.a) };
+ A.links.push(link); B.links.push(link); links.push(link);
+ }
+ }
+ this.traces = traces; this.pads = pads; this.vias = vias; this.links = links;
+ this.introDur = Math.max(0.6, ...traces.map(t => Math.max(t.delay + t.grow, t.branch ? t.branch.t0 + t.branch.grow : 0))) + 0.3;
+ this.rate = (w + h) * 2 / 520;
+ this.pulses.length = 0;
+ if (!fresh) this.intro = Infinity;
+
+ const cacheCtx = this.cache.getContext('2d');
+ for (const tr of traces) { tr.gMain = this.depthGrad(this.layer.ctx, tr); tr.gCache = this.depthGrad(cacheCtx, tr); }
+ this.paintCache();
+
+ // Everything this effect draws stays within `band` of an edge, so only
+ // those four strips are cleared and composited (in whole device pixels,
+ // so the cache copies 1:1).
+ const W = this.layer.el.width, H = this.layer.el.height;
+ this.rx = W / w; this.ry = H / h;
+ const band = depthPx + 40;
+ const bx = Math.ceil(band * this.rx), by = Math.ceil(band * this.ry);
+ this.bands = 2 * bx >= W || 2 * by >= H
+ ? [[0, 0, W, H]]
+ : [[0, 0, W, by], [0, H - by, W, by], [0, by, bx, H - 2 * by], [W - bx, by, bx, H - 2 * by]];
+ }
+ depthGrad(ctx, tr) {
+ const [ix, iy] = tr.edge.inw;
+ const x0 = ix ? (ix > 0 ? 0 : this.w) : tr.x0;
+ const y0 = iy ? (iy > 0 ? 0 : this.h) : tr.y0;
+ const g = ctx.createLinearGradient(x0, y0, x0 + ix * this.depthPx, y0 + iy * this.depthPx);
+ g.addColorStop(0, rgba(C.base, 0.56));
+ g.addColorStop(0.5, rgba(C.base, 0.3));
+ g.addColorStop(1, rgba(C.base, 0.08));
+ return g;
+ }
+ paintCache() {
+ const L = this.layer, c = this.cache;
+ c.width = L.el.width; c.height = L.el.height;
+ const x = c.getContext('2d');
+ x.setTransform(L.el.width / L.w, 0, 0, L.el.height / L.h, 0, 0);
+ x.lineCap = 'round'; x.lineJoin = 'round';
+ for (const tr of this.traces) {
+ x.strokeStyle = tr.gCache; x.lineWidth = tr.lw;
+ x.beginPath(); subPath(x, tr.path, 0, tr.path.len); x.stroke();
+ if (tr.branch) { x.lineWidth = 1; x.beginPath(); subPath(x, tr.branch.path, 0, tr.branch.path.len); x.stroke(); }
+ }
+ this.paintExtras(x, 1);
+ for (const p of this.pads) this.paintPad(x, p, 1);
+ }
+ paintExtras(x, alpha) {
+ x.globalAlpha = alpha;
+ x.setLineDash([1.5, 3.5]); x.lineWidth = 1;
+ for (const lk of this.links) { x.strokeStyle = rgba(C.soft, lk.alpha * 0.6); x.beginPath(); subPath(x, lk.path, 0, lk.path.len); x.stroke(); }
+ x.setLineDash([]);
+ for (const v of this.vias) { x.strokeStyle = rgba(C.base, v.a); x.beginPath(); x.arc(v.x, v.y, 2.3, 0, TAU); x.stroke(); }
+ x.globalAlpha = 1;
+ }
+ paintPad(x, p, scale) {
+ const r = p.r * scale;
+ if (r <= 0.05) return;
+ if (p.neuron) {
+ x.globalAlpha = clamp(p.a * 0.85 * scale, 0, 1);
+ x.drawImage(this.sprFlash, p.x - 13, p.y - 13, 26, 26);
+ x.globalAlpha = 1;
+ }
+ x.fillStyle = rgba(C.base, Math.min(1, p.a * 1.5));
+ x.beginPath(); x.arc(p.x, p.y, r, 0, TAU); x.fill();
+ x.strokeStyle = rgba(C.base, p.a * 0.75); x.lineWidth = 1;
+ x.beginPath(); x.arc(p.x, p.y, r + 2.4 * scale, 0, TAU); x.stroke();
+ }
+ step(dt) {
+ if (this.intro < this.introDur) {
+ this.intro += dt;
+ for (const tr of this.traces) {
+ if (!tr.booted && this.intro >= tr.delay + tr.grow) { tr.booted = true; tr.pad.flash = Math.max(tr.pad.flash, 0.75); }
+ const br = tr.branch;
+ if (br && !br.booted && this.intro >= br.t0 + br.grow) { br.booted = true; br.pad.flash = Math.max(br.pad.flash, 0.6); }
+ }
+ }
+ if (this.intro > this.introDur * 0.75) {
+ this.spawnAcc += dt * this.rate;
+ while (this.spawnAcc >= 1) { this.spawnAcc -= 1; this.spawn(); }
+ }
+ for (let k = this.pulses.length - 1; k >= 0; k--) {
+ const q = this.pulses[k];
+ if (q.wait > 0) { q.wait -= dt; continue; }
+ const prev = q.s;
+ q.s += q.dir * q.speed * dt;
+ const br = q.trace && q.trace.branch;
+ if (br && q.dir > 0 && prev < br.s && q.s >= br.s && Math.random() < 0.55) {
+ this.add(br.path, 1, { end: br.pad, speed: q.speed * 0.92, tail: q.tail * 0.8, gen: q.gen });
+ }
+ if (!q.arrived && (q.dir > 0 ? q.s >= q.path.len : q.s <= 0)) { q.arrived = true; this.arrive(q); }
+ if (q.dir > 0 ? q.s - q.tail >= q.path.len : q.s + q.tail <= 0) this.pulses.splice(k, 1);
+ }
+ const decay = dt * 1.6;
+ for (const p of this.pads) if (p.flash > 0) p.flash = Math.max(0, p.flash - decay);
+ }
+ add(path, dir, o = {}) {
+ if (this.pulses.length >= this.maxPulses) return null;
+ const q = {
+ path, dir, s: dir > 0 ? 0 : path.len,
+ speed: o.speed ?? rand(150, 235), tail: o.tail ?? rand(36, 64),
+ end: o.end || null, spark: !!o.spark, gen: o.gen || 0, wait: o.wait || 0,
+ trace: o.trace || null, arrived: false,
+ };
+ this.pulses.push(q);
+ return q;
+ }
+ spawn() {
+ if (!this.traces.length) return;
+ const tr = pick(this.traces);
+ if (Math.random() < 0.7) this.add(tr.path, 1, { end: tr.pad, trace: tr });
+ else { tr.pad.flash = Math.max(tr.pad.flash, 0.7); this.add(tr.path, -1, {}); }
+ }
+ arrive(q) {
+ const p = q.end;
+ if (!p) return;
+ p.flash = 1;
+ if (q.spark) {
+ if (Math.random() < 0.7) this.add((p.branch || p.trace).path, -1, { gen: q.gen });
+ return;
+ }
+ if (q.gen < 3 && p.links.length && Math.random() < 0.55) {
+ const lk = pick(p.links), fwd = lk.a === p;
+ this.add(lk.path, fwd ? 1 : -1, { end: fwd ? lk.b : lk.a, spark: true, speed: rand(300, 380), tail: rand(14, 22), gen: q.gen + 1, wait: 0.06 });
+ }
+ }
+ draw() {
+ const L = this.layer, x = L.ctx, w = L.w, h = L.h;
+ if (!w || !this.bands) return;
+ const rx = this.rx, ry = this.ry;
+ for (const b of this.bands) x.clearRect(b[0] / rx, b[1] / ry, b[2] / rx, b[3] / ry);
+ const still = this.still;
+ const inIntro = !still && this.intro < this.introDur;
+ const breathe = still ? 1 : 0.8 + 0.2 * Math.sin(this.t * TAU / 3.6);
+ vignette(x, w, h, 0.12 * breathe * (inIntro ? clamp(this.intro / 0.5, 0, 1) : 1), 28);
+ if (inIntro) this.drawIntro(x);
+ else {
+ x.globalAlpha = 0.86 + 0.14 * breathe;
+ for (const b of this.bands) x.drawImage(this.cache, b[0], b[1], b[2], b[3], b[0] / rx, b[1] / ry, b[2] / rx, b[3] / ry);
+ x.globalAlpha = 1;
+ }
+ if (still) return;
+ x.globalCompositeOperation = 'lighter';
+ for (const p of this.pads) {
+ if (p.flash <= 0) continue;
+ const f = p.flash, size = 10 + 34 * f;
+ x.globalAlpha = f * 0.95;
+ x.drawImage(this.sprFlash, p.x - size / 2, p.y - size / 2, size, size);
+ }
+ x.globalAlpha = 1;
+ x.globalCompositeOperation = 'source-over';
+ for (const p of this.pads) {
+ if (p.flash <= 0) continue;
+ const f = p.flash;
+ x.strokeStyle = rgba(C.base, 0.55 * f * f); x.lineWidth = 1.2;
+ x.beginPath(); x.arc(p.x, p.y, p.r + 3 + (1 - f) * 15, 0, TAU); x.stroke();
+ x.fillStyle = rgba(C.mist, f);
+ x.beginPath(); x.arc(p.x, p.y, p.r * (1 + 0.3 * f), 0, TAU); x.fill();
+ }
+ for (const q of this.pulses) this.drawPulse(x, q);
+ }
+ drawIntro(x) {
+ const T = this.intro, heads = this.heads;
+ heads.length = 0;
+ x.lineCap = 'round'; x.lineJoin = 'round';
+ for (const tr of this.traces) {
+ const k = clamp((T - tr.delay) / tr.grow, 0, 1);
+ if (k <= 0) continue;
+ const s1 = easeOutCubic(k) * tr.path.len;
+ x.strokeStyle = tr.gMain; x.lineWidth = tr.lw;
+ x.beginPath(); subPath(x, tr.path, 0, s1); x.stroke();
+ if (k < 1) heads.push(pointAt(tr.path, s1, { x: 0, y: 0 }));
+ else this.paintPad(x, tr.pad, easeOutBack(clamp((T - tr.delay - tr.grow) / 0.3, 0, 1)));
+ const br = tr.branch;
+ if (br) {
+ const kb = clamp((T - br.t0) / br.grow, 0, 1);
+ if (kb > 0) {
+ const sb = easeOutCubic(kb) * br.path.len;
+ x.strokeStyle = tr.gMain; x.lineWidth = 1;
+ x.beginPath(); subPath(x, br.path, 0, sb); x.stroke();
+ if (kb < 1) heads.push(pointAt(br.path, sb, { x: 0, y: 0 }));
+ else this.paintPad(x, br.pad, easeOutBack(clamp((T - br.t0 - br.grow) / 0.3, 0, 1)));
+ }
+ }
+ }
+ const late = clamp((T - (this.introDur - 0.55)) / 0.45, 0, 1);
+ if (late > 0) this.paintExtras(x, late);
+ x.globalCompositeOperation = 'lighter';
+ for (const p of heads) {
+ x.drawImage(this.sprHead, p.x - 9, p.y - 9, 18, 18);
+ x.drawImage(this.sprCore, p.x - 3, p.y - 3, 6, 6);
+ }
+ x.globalCompositeOperation = 'source-over';
+ }
+ drawPulse(x, q) {
+ if (q.wait > 0) return;
+ const P = q.path;
+ const head = clamp(q.s, 0, P.len), tailS = clamp(q.s - q.dir * q.tail, 0, P.len);
+ if (Math.abs(head - tailS) > 0.5) {
+ const A = pointAt(P, tailS, this.tmpA), B = pointAt(P, head, this.tmpB);
+ const g = x.createLinearGradient(A.x, A.y, B.x, B.y);
+ g.addColorStop(0, rgba(C.base, 0));
+ g.addColorStop(0.6, rgba(C.base, q.spark ? 0.6 : 0.72));
+ g.addColorStop(1, rgba(C.mist, 1));
+ x.strokeStyle = g; x.lineWidth = q.spark ? 1.3 : 1.9; x.lineCap = 'round';
+ x.beginPath(); subPath(x, P, Math.min(head, tailS), Math.max(head, tailS)); x.stroke();
+ }
+ if (q.dir > 0 ? q.s <= P.len : q.s >= 0) {
+ const B = pointAt(P, head, this.tmpB);
+ const hs = q.spark ? 14 : 22;
+ // Solid bead first so the signal still reads on white pages, then the additive glow.
+ x.fillStyle = rgba(C.base, 0.95);
+ x.beginPath(); x.arc(B.x, B.y, q.spark ? 1.7 : 2.4, 0, TAU); x.fill();
+ x.globalCompositeOperation = 'lighter';
+ x.drawImage(this.sprHead, B.x - hs / 2, B.y - hs / 2, hs, hs);
+ x.drawImage(this.sprCore, B.x - 3.5, B.y - 3.5, 7, 7);
+ x.globalCompositeOperation = 'source-over';
+ }
+ }
+ // The agent acted on an element: fire the traces closest to it.
+ target(rect) {
+ if (!this.active || this.still || !this.traces.length) return;
+ const cx = rect.left + rect.width / 2, cy = rect.top + rect.height / 2;
+ const d = [cy, this.h - cy, cx, this.w - cx];
+ const e = this.edges[d.indexOf(Math.min(...d))];
+ const along = e.alg[0] ? cx : cy;
+ this.traces
+ .filter(t => t.edge === e)
+ .sort((a, b) => Math.abs(a.along - along) - Math.abs(b.along - along))
+ .slice(0, 5)
+ .forEach((t, n) => this.add(t.path, 1, { end: t.pad, trace: t, speed: 320, tail: 80, wait: n * 0.06, gen: 3 }));
+ }
}
+ /* aurora: a soft band hugs the frame, built from lobes in five purples that
+ drift around the perimeter at different speeds, so the glow keeps
+ shifting instead of pulsing uniformly. A crisp rim carries two comets
+ that orbit in opposite directions and flare when they meet. */
+ class Aurora extends Effect {
+ constructor() {
+ super();
+ this.glow = new Layer('webbrain-agent-effect', 0.5); // soft light: half resolution is enough
+ this.rim = new Layer('webbrain-agent-effect-rim', 1);
+ this.layers = [this.glow, this.rim];
+ const st = [[0, 1], [0.3, 0.7], [0.65, 0.22], [1, 0]];
+ this.spr = {
+ base: sprite(C.base, 128, st), soft: sprite(C.soft, 128, st), pale: sprite(C.pale, 128, st),
+ mist: sprite(C.mist, 128, st), deep: sprite(C.deep, 128, st),
+ };
+ this.sprHead = sprite(C.soft, 64, [[0, 1], [0.2, 0.6], [0.5, 0.15], [1, 0]]);
+ this.sprCore = sprite(C.core, 32, [[0, 1], [0.4, 0.6], [1, 0]]);
+ this.lobes = []; this.comets = []; this.edgeGeo = []; this.P = 1; this.fadeIn = 0;
+ this.pt = { x: 0, y: 0 }; this.pt2 = { x: 0, y: 0 };
+ }
+ onShow() { this.fadeIn = 0; }
+ layout(w, h) {
+ const P = this.P = 2 * (w + h);
+ // each edge as a segment of the perimeter parameter s (clockwise from top-left)
+ this.edgeGeo = [
+ { a: 0, b: w, ox: 0, oy: 0, tx: 1, ty: 0, horiz: true },
+ { a: w, b: w + h, ox: w, oy: 0, tx: 0, ty: 1, horiz: false },
+ { a: w + h, b: 2 * w + h, ox: w, oy: h, tx: -1, ty: 0, horiz: true },
+ { a: 2 * w + h, b: P, ox: 0, oy: h, tx: 0, ty: -1, horiz: false },
+ ];
+ const n = clamp(Math.round(P / 220), 12, 34);
+ const colors = ['base', 'base', 'base', 'deep', 'deep', 'soft', 'soft', 'pale', 'mist'];
+ const thick = clamp(Math.min(w, h) * 0.085, 48, 96);
+ this.lobes = [];
+ for (let k = 0; k < n; k++) {
+ this.lobes.push({
+ s: ((k + rand(-0.3, 0.3)) / n) * P,
+ v: rand(22, 64) * (Math.random() < 0.5 ? -1 : 1),
+ len: rand(240, 520), th: thick * rand(0.7, 1.25), color: pick(colors),
+ a: rand(0.42, 0.78), ph: rand(0, TAU), fr: rand(0.12, 0.32),
+ });
+ }
+ this.comets = [
+ { s: rand(0, P), v: P / 7.5, tail: 220 },
+ { s: rand(0, P), v: -P / 10, tail: 170 },
+ ];
+ }
+ perim(s, inset, out) {
+ const w = this.w, h = this.h, P = this.P;
+ s = ((s % P) + P) % P;
+ if (s < w) { out.x = s; out.y = inset; }
+ else if (s < w + h) { out.x = w - inset; out.y = s - w; }
+ else if (s < 2 * w + h) { out.x = w - (s - w - h); out.y = h - inset; }
+ else { out.x = inset; out.y = h - (s - 2 * w - h); }
+ return out;
+ }
+ perimPath(ctx, s0, s1, inset) {
+ const P = this.P, w = this.w, h = this.h;
+ const corners = [w, w + h, 2 * w + h, P];
+ let s = s0;
+ let p = this.perim(s, inset, this.pt2);
+ ctx.moveTo(p.x, p.y);
+ for (let guard = 0; s < s1 - 1e-6 && guard < 8; guard++) {
+ const m = ((s % P) + P) % P;
+ let next = P;
+ for (const c of corners) if (c > m + 1e-6) { next = c; break; }
+ s += Math.min(s1 - s, next - m);
+ p = this.perim(s, inset, this.pt2);
+ ctx.lineTo(p.x, p.y);
+ }
+ }
+ sAt(x, y) {
+ const w = this.w, h = this.h;
+ const d = [y, w - x, h - y, x];
+ const e = d.indexOf(Math.min(...d));
+ return e === 0 ? x : e === 1 ? w + y : e === 2 ? w + h + (w - x) : 2 * w + h + (h - y);
+ }
+ step(dt) {
+ this.fadeIn = Math.min(1, this.fadeIn + dt / 0.9);
+ for (let k = this.lobes.length - 1; k >= 0; k--) {
+ const L = this.lobes[k];
+ L.s += L.v * dt;
+ if (L.life !== undefined) { L.life -= dt; if (L.life <= 0) this.lobes.splice(k, 1); }
+ }
+ for (const c of this.comets) c.s += c.v * dt;
+ }
+ draw() {
+ const w = this.w, h = this.h;
+ if (!w) return;
+ const t = this.t, still = this.still, P = this.P;
+ const I = still ? 1 : (0.84 + 0.16 * Math.sin(t * TAU / 4.8)) * easeOutCubic(this.fadeIn);
+ const g = this.glow.ctx;
+ g.clearRect(0, 0, w, h);
+ vignette(g, w, h, 0.16 * I, 30); // a continuous floor so the frame never has gaps
+ for (const L of this.lobes) {
+ const env = L.life === undefined ? 1 : Math.min(1, (L.max - L.life) / 0.18) * clamp(L.life / L.max, 0, 1);
+ const breath = still ? 0.8 : 0.62 + 0.38 * Math.sin(t * L.fr * TAU + L.ph);
+ const alpha = clamp(L.a * breath * I * env, 0, 1);
+ if (alpha < 0.004) continue;
+ const th = L.th * (still ? 1 : 0.86 + 0.14 * Math.sin(t * 0.6 + L.ph * 1.7));
+ const half = L.len / 2, spr = this.spr[L.color];
+ const c = ((L.s % P) + P) % P;
+ g.globalAlpha = alpha;
+ // one edge-aligned ellipse per edge it touches; half of it sits off-screen
+ for (const E of this.edgeGeo) {
+ let cc = c;
+ if (cc < E.a - half) cc += P; else if (cc > E.b + half) cc -= P;
+ if (cc + half < E.a || cc - half > E.b) continue;
+ const local = cc - E.a;
+ const px = E.ox + E.tx * local, py = E.oy + E.ty * local;
+ if (E.horiz) g.drawImage(spr, px - half, py - th, half * 2, th * 2);
+ else g.drawImage(spr, px - th, py - half, th * 2, half * 2);
+ }
+ }
+ g.globalAlpha = 1;
+
+ const r = this.rim.ctx;
+ r.clearRect(0, 0, w, h);
+ r.lineWidth = 1.5;
+ r.strokeStyle = rgba(C.base, 0.55 * I);
+ r.strokeRect(0.75, 0.75, w - 1.5, h - 1.5);
+ if (still) return;
+ r.lineCap = 'butt';
+ for (const c of this.comets) {
+ const dir = Math.sign(c.v), N = 22;
+ for (let k = 0; k < N; k++) {
+ const s0 = c.s - dir * (k / N) * c.tail, s1 = c.s - dir * ((k + 1) / N) * c.tail;
+ const f = 1 - k / N;
+ r.strokeStyle = rgba(k < 2 ? C.pale : C.base, f * f * 0.95 * I);
+ r.lineWidth = 1.2 + 2.6 * f;
+ r.beginPath(); this.perimPath(r, Math.min(s0, s1), Math.max(s0, s1), 1.2); r.stroke();
+ }
+ const hp = this.perim(c.s, 1.2, this.pt);
+ r.fillStyle = rgba(C.base, 0.9 * I);
+ r.beginPath(); r.arc(hp.x, hp.y, 2.8, 0, TAU); r.fill();
+ r.globalCompositeOperation = 'lighter';
+ r.globalAlpha = I;
+ r.drawImage(this.sprHead, hp.x - 22, hp.y - 22, 44, 44);
+ r.drawImage(this.sprCore, hp.x - 4, hp.y - 4, 8, 8);
+ r.globalAlpha = 1;
+ r.globalCompositeOperation = 'source-over';
+ }
+ const [c1, c2] = this.comets;
+ let diff = (((c2.s - c1.s) % P) + P) % P;
+ if (diff > P / 2) diff -= P;
+ const dist = Math.abs(diff);
+ if (dist < 170) {
+ const f = 1 - dist / 170;
+ const m = this.perim(c1.s + diff / 2, 0, this.pt);
+ const size = 70 + 90 * f;
+ r.globalCompositeOperation = 'lighter';
+ r.globalAlpha = f * f * 0.9 * I;
+ r.drawImage(this.sprHead, m.x - size / 2, m.y - size / 2, size, size);
+ r.globalAlpha = 1;
+ r.globalCompositeOperation = 'source-over';
+ }
+ }
+ // The agent acted on an element: brighten the frame nearest to it.
+ target(rect) {
+ if (!this.active || this.still) return;
+ const s = this.sAt(rect.left + rect.width / 2, rect.top + rect.height / 2);
+ this.lobes.push({ s, v: 0, len: 360, th: 120, color: 'soft', a: 0.6, ph: 0, fr: 0, life: 1.6, max: 1.6 });
+ this.lobes.push({ s, v: 0, len: 200, th: 80, color: 'base', a: 0.7, ph: 0, fr: 0, life: 1.6, max: 1.6 });
+ }
+ }
+
+ /* scan: viewfinder brackets land in the corners; a thin beam sweeps the
+ page (down, rest, up, rest) and a fixed dot matrix lights up behind it,
+ stronger near the edges than over the content. */
+ class Scan extends Effect {
+ constructor() {
+ super();
+ this.layer = new Layer('webbrain-agent-effect', 1);
+ this.layers = [this.layer];
+ this.sprEdge = sprite(C.soft, 64, [[0, 1], [0.2, 0.55], [0.5, 0.14], [1, 0]]);
+ this.row = document.createElement('canvas');
+ this.locks = [];
+ this.sp = 14;
+ }
+ onShow() { this.locks.length = 0; }
+ layout(w, h) {
+ const L = this.layer;
+ this.arm = clamp(Math.min(w, h) * 0.042, 20, 40);
+ this.sweep = clamp(h / 330, 2.2, 3.6);
+ this.rest = 1.05;
+ this.trail = clamp(h * 0.17, 70, 150);
+ const sx = L.el.width / w, sy = L.el.height / h;
+ const row = this.row;
+ row.width = L.el.width;
+ row.height = Math.max(1, Math.ceil(4 * sy));
+ const x = row.getContext('2d');
+ x.setTransform(sx, 0, 0, row.height / 4, 0, 0);
+ for (let px = this.sp / 2; px < w; px += this.sp) {
+ const u = px / w, d = Math.min(u, 1 - u) * 2;
+ x.fillStyle = rgba(C.base, lerp(0.95, 0.22, Math.pow(d, 0.6)));
+ x.beginPath(); x.arc(px, 2, 1.1, 0, TAU); x.fill();
+ }
+ this.beamGrad = L.ctx.createLinearGradient(0, 0, w, 0);
+ for (const [o, a] of [[0, 0.9], [0.14, 0.5], [0.5, 0.28], [0.86, 0.5], [1, 0.9]]) this.beamGrad.addColorStop(o, rgba(C.base, a));
+ }
+ step(dt) {
+ for (let k = this.locks.length - 1; k >= 0; k--) {
+ this.locks[k].t += dt;
+ if (this.locks[k].t > 1.7) this.locks.splice(k, 1);
+ }
+ }
+ draw() {
+ const L = this.layer, x = L.ctx, w = L.w, h = L.h;
+ if (!w) return;
+ x.clearRect(0, 0, w, h);
+ const still = this.still, t = this.t;
+ const breath = still ? 0.5 : 0.5 + 0.5 * Math.sin(t * TAU / 3.4);
+ const fade = still ? 1 : easeOutCubic(clamp(t / 0.6, 0, 1));
+ vignette(x, w, h, (0.08 + 0.04 * breath) * fade, 24);
+ let snap = 0;
+ if (!still) {
+ const cyc = this.sweep + this.rest;
+ const tt = Math.max(0, t - 0.35); // brackets land first
+ const n = Math.floor(tt / cyc), local = tt - n * cyc, down = n % 2 === 0;
+ const k = clamp(local / this.sweep, 0, 1), e = easeInOutSine(k);
+ const y = down ? lerp(-6, h + 6, e) : lerp(h + 6, -6, e);
+ const vis = local < this.sweep ? clamp(Math.min(k / 0.07, (1 - k) / 0.07), 0, 1) * fade : 0;
+ if (t > 0.35 && vis > 0) this.drawBeam(x, w, y, down ? -1 : 1, vis);
+ const since = local - this.sweep;
+ if (t > 0.35 && since >= 0) { const s = Math.max(0, 1 - since / 0.6); snap = s * s; }
+ }
+ this.drawBrackets(x, w, h, breath, snap, fade);
+ for (const lk of this.locks) this.drawLock(x, lk);
+ }
+ drawBeam(x, w, y, dir, vis) {
+ const tr = this.trail, y2 = y + dir * tr;
+ const g = x.createLinearGradient(0, y, 0, y2);
+ g.addColorStop(0, rgba(C.base, 0.11 * vis));
+ g.addColorStop(0.35, rgba(C.base, 0.045 * vis));
+ g.addColorStop(1, rgba(C.base, 0));
+ x.fillStyle = g;
+ x.fillRect(0, Math.min(y, y2), w, tr);
+ const sp = this.sp, lo = Math.min(y, y2), hi = Math.max(y, y2);
+ for (let ry = Math.ceil(lo / sp) * sp; ry <= hi; ry += sp) {
+ const a = Math.pow(1 - Math.abs(ry - y) / tr, 2.2) * 0.75 * vis;
+ if (a < 0.01) continue;
+ x.globalAlpha = a;
+ x.drawImage(this.row, 0, ry - 2, w, 4);
+ }
+ x.globalAlpha = vis;
+ x.fillStyle = this.beamGrad;
+ x.fillRect(0, y - 0.75, w, 1.5);
+ x.globalCompositeOperation = 'lighter';
+ x.drawImage(this.sprEdge, -24, y - 24, 48, 48);
+ x.drawImage(this.sprEdge, w - 24, y - 24, 48, 48);
+ x.globalCompositeOperation = 'source-over';
+ x.fillStyle = rgba(C.base, 0.95);
+ x.fillRect(0, y - 1.5, 16, 3);
+ x.fillRect(w - 16, y - 1.5, 16, 3);
+ x.globalAlpha = 1;
+ }
+ drawBrackets(x, w, h, breath, snap, fade) {
+ const land = this.still ? 1 : easeOutBack(clamp(this.t / 0.55, 0, 1));
+ const m = lerp(48, 12, land) + 2 * breath - 4 * snap;
+ const a = this.arm * (0.9 + 0.1 * land) + 8 * snap, r = 7;
+ x.save();
+ x.globalAlpha = clamp(fade * 1.2, 0, 1);
+ x.lineCap = 'round'; x.lineJoin = 'round';
+ x.beginPath();
+ x.moveTo(m, m + a); x.lineTo(m, m + r); x.arcTo(m, m, m + r, m, r); x.lineTo(m + a, m);
+ x.moveTo(w - m - a, m); x.lineTo(w - m - r, m); x.arcTo(w - m, m, w - m, m + r, r); x.lineTo(w - m, m + a);
+ x.moveTo(w - m, h - m - a); x.lineTo(w - m, h - m - r); x.arcTo(w - m, h - m, w - m - r, h - m, r); x.lineTo(w - m - a, h - m);
+ x.moveTo(m + a, h - m); x.lineTo(m + r, h - m); x.arcTo(m, h - m, m, h - m - r, r); x.lineTo(m, h - m - a);
+ // Halo from wide translucent strokes. shadowBlur would rasterize a
+ // viewport-sized shadow layer here (the path spans all four corners).
+ x.strokeStyle = rgba(C.base, 0.07 + 0.08 * snap); x.lineWidth = 12; x.stroke();
+ x.strokeStyle = rgba(C.base, 0.14 + 0.12 * snap); x.lineWidth = 6.5; x.stroke();
+ x.strokeStyle = rgba(C.base, 0.85 + 0.15 * snap); x.lineWidth = 2.6; x.stroke();
+ x.restore();
+ }
+ drawLock(x, lk) {
+ const k = easeOutCubic(clamp(lk.t / 0.35, 0, 1));
+ const fade = lk.t < 1.2 ? 1 : Math.max(0, 1 - (lk.t - 1.2) / 0.45);
+ const R = lk.rect, pad = lerp(26, 8, k);
+ const l = R.left - pad, tp = R.top - pad, rr = R.left + R.width + pad, b = R.top + R.height + pad;
+ const a = clamp(Math.min(rr - l, b - tp) * 0.28, 7, 16);
+ x.save();
+ x.globalAlpha = k * fade;
+ x.lineWidth = 2; x.lineCap = 'round'; x.lineJoin = 'round';
+ x.strokeStyle = rgba(C.base, 0.95);
+ x.beginPath();
+ x.moveTo(l, tp + a); x.lineTo(l, tp); x.lineTo(l + a, tp);
+ x.moveTo(rr - a, tp); x.lineTo(rr, tp); x.lineTo(rr, tp + a);
+ x.moveTo(rr, b - a); x.lineTo(rr, b); x.lineTo(rr - a, b);
+ x.moveTo(l + a, b); x.lineTo(l, b); x.lineTo(l, b - a);
+ x.stroke();
+ x.restore();
+ }
+ // The agent acted on an element: the viewfinder locks onto it.
+ target(rect) {
+ if (!this.active || this.still) return;
+ this.locks.push({ rect: { left: rect.left, top: rect.top, width: rect.width, height: rect.height }, t: 0 });
+ }
+ }
+
+ /* gears: a large driver wheel sits just outside each corner and drives two
+ trains of smaller cogs along the edges. Meshing is real: one module for
+ all wheels, centre distance = sum of pitch radii, tooth phases aligned so
+ teeth sit in gaps, angular speed ∝ 1/teeth with alternating direction.
+ Wheel bodies vary (spokes, lightening holes, solid) and some wheels carry
+ a pinion on the same axle. When the agent acts, the nearest train revs. */
+ class Gears extends Effect {
+ constructor() {
+ super();
+ this.layer = new Layer('webbrain-agent-effect', 1);
+ this.layers = [this.layer];
+ this.sprGlow = sprite(C.soft, 64, [[0, 0.9], [0.3, 0.42], [0.7, 0.08], [1, 0]]);
+ this.gears = []; this.clusters = []; this.bands = null; this.rx = 1; this.ry = 1;
+ this.minFrame = 1 / 30; // slow rotation reads smooth at 30 fps and halves raster work
+ }
+ onShow() { for (const c of this.clusters) { c.kick = 0; c.k = 0; } }
+ gearSprite(N, m, style, ratio) {
+ const r = N * m / 2, ro = r + m, rr = r - 1.25 * m, half = ro + 3;
+ const S = Math.ceil(half * 2 * ratio);
+ const c = document.createElement('canvas');
+ c.width = c.height = S;
+ const x = c.getContext('2d');
+ x.setTransform(ratio, 0, 0, ratio, S / 2, S / 2);
+ const p = TAU / N, twR = 0.56 * p, twT = 0.3 * p;
+ x.beginPath();
+ for (let k = 0; k < N; k++) {
+ const a = k * p, a0 = a - twR / 2, a1 = a - twT / 2, a2 = a + twT / 2, a3 = a + twR / 2;
+ if (k === 0) x.moveTo(rr * Math.cos(a0), rr * Math.sin(a0));
+ else x.lineTo(rr * Math.cos(a0), rr * Math.sin(a0));
+ x.lineTo(ro * Math.cos(a1), ro * Math.sin(a1));
+ x.arc(0, 0, ro, a1, a2);
+ x.lineTo(rr * Math.cos(a3), rr * Math.sin(a3));
+ x.arc(0, 0, rr, a3, a + p - twR / 2);
+ }
+ x.closePath();
+ const hub = Math.max(r * 0.2, 1.8 * m), axle = Math.max(1.6, hub * 0.38), rim = rr - 1.1 * m;
+ if (style === 'spokes' && rim - hub > 3 * m) {
+ const s = N >= 30 ? 6 : N >= 20 ? 5 : 4;
+ const hw = clamp(r * 0.07, 2, 6), inner = hub + m;
+ const ao = Math.asin(Math.min(1, hw / rim)), ai = Math.asin(Math.min(1, hw / inner));
+ for (let j = 0; j < s; j++) {
+ const b = j * TAU / s, e = (j + 1) * TAU / s;
+ if (e - ai <= b + ai) continue;
+ x.moveTo(rim * Math.cos(b + ao), rim * Math.sin(b + ao));
+ x.arc(0, 0, rim, b + ao, e - ao);
+ x.arc(0, 0, inner, e - ai, b + ai, true);
+ x.closePath();
+ }
+ } else if (style === 'holes' && rim - hub > 2.4 * m) {
+ const k = N >= 24 ? 6 : 5, rho = (hub + rim) / 2;
+ const rh = Math.min((rim - hub) * 0.34, rho * Math.sin(Math.PI / k) * 0.6);
+ for (let j = 0; j < k; j++) {
+ const a = j * TAU / k + p / 2, cx = rho * Math.cos(a), cy = rho * Math.sin(a);
+ x.moveTo(cx + rh, cy);
+ x.arc(cx, cy, rh, 0, TAU);
+ }
+ }
+ x.moveTo(axle, 0);
+ x.arc(0, 0, axle, 0, TAU);
+ x.fillStyle = rgba(C.base, style === 'solid' ? 0.08 : 0.1);
+ x.fill('evenodd');
+ x.lineJoin = 'round';
+ x.strokeStyle = rgba(C.base, 0.58);
+ x.lineWidth = 1.2;
+ x.stroke();
+ x.beginPath(); x.arc(0, 0, hub, 0, TAU);
+ x.strokeStyle = rgba(C.base, 0.42); x.lineWidth = 1; x.stroke();
+ if (style === 'solid' && rim - hub > 2 * m) {
+ x.beginPath(); x.arc(0, 0, rim, 0, TAU);
+ x.setLineDash([2.5, 3.5]); x.strokeStyle = rgba(C.base, 0.34); x.stroke(); x.setLineDash([]);
+ }
+ return c;
+ }
+ layout(w, h) {
+ const m = clamp(Math.min(w, h) * 0.0062, 3.4, 6.4);
+ const ratio = this.layer.el.width / w;
+ const gears = [], clusters = [];
+ const corners = [
+ { x: 0, y: 0, a: [1, 0], b: [0, 1] },
+ { x: w, y: 0, a: [-1, 0], b: [0, 1] },
+ { x: w, y: h, a: [-1, 0], b: [0, -1] },
+ { x: 0, y: h, a: [1, 0], b: [0, -1] },
+ ];
+ const styles = ['spokes', 'holes', 'solid', 'holes', 'spokes'];
+ const sprites = new Map(); // identical wheels share one sprite
+ const make = (N, x, y, phi, omega, cl, style, order) => {
+ const g = { N, r: N * m / 2, x, y, phi, omega, cl, style, order, flash: 0 };
+ g.half = g.r + m + 3;
+ const key = N + style;
+ if (!sprites.has(key)) sprites.set(key, this.gearSprite(N, m, style, ratio));
+ g.sprite = sprites.get(key);
+ gears.push(g);
+ return g;
+ };
+ // phase for C so that its teeth fall into P's gaps along the line of centres
+ const meshPhase = (P, Cg) => {
+ const alpha = Math.atan2(Cg.y - P.y, Cg.x - P.x);
+ const pP = TAU / P.N, pC = TAU / Cg.N;
+ let f = ((alpha - P.phi) / pP) % 1; if (f < 0) f += 1;
+ let g = (0.5 - f) % 1; if (g < 0) g += 1;
+ return alpha + Math.PI - g * pC;
+ };
+ corners.forEach((cn, ci) => {
+ clusters.push({ kick: 0, k: 0, x: cn.x, y: cn.y });
+ const toXY = (u, v, e, n) => [cn.x + e[0] * u + n[0] * v, cn.y + e[1] * u + n[1] * v];
+ const N0 = randInt(30, 42), R0 = N0 * m / 2, off = R0 * rand(0.3, 0.46);
+ const [x0, y0] = toXY(-off, -off, cn.a, cn.b);
+ const driver = make(N0, x0, y0, rand(0, TAU), 0.3 * (Math.random() < 0.5 ? 1 : -1), ci, 'spokes', 0);
+ for (const [e, n] of [[cn.a, cn.b], [cn.b, cn.a]]) {
+ const reach = (e[0] ? w : h) * 0.33;
+ let parent = driver, pu = -off, pv = -off, order = 1;
+ while (order < 10) {
+ const N = pick([9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24]);
+ const R = N * m / 2, D = parent.r + R;
+ let v = -R * rand(0.32, 0.78), dv = v - pv;
+ if (Math.abs(dv) >= D * 0.92) { v = pv + Math.sign(dv) * D * 0.6; dv = v - pv; }
+ const u = pu + Math.sqrt(D * D - dv * dv);
+ if (u - R > reach) break;
+ const [gx, gy] = toXY(u, v, e, n);
+ const g = make(N, gx, gy, 0, -parent.omega * parent.N / N, ci, N <= 11 ? 'solid' : pick(styles), order++);
+ g.phi = meshPhase(parent, g);
+ if (N >= 16 && Math.random() < 0.3) {
+ parent = make(randInt(8, 11), gx, gy, rand(0, TAU), g.omega, ci, 'solid', order); // pinion on the same axle
+ } else parent = g;
+ pu = u; pv = v;
+ }
+ }
+ });
+ this.gears = gears; this.clusters = clusters;
+
+ const W = this.layer.el.width, H = this.layer.el.height;
+ this.rx = W / w; this.ry = H / h;
+ let band = 0;
+ for (const g of gears) band = Math.max(band, Math.min(g.x, g.y, w - g.x, h - g.y) + g.half);
+ band = Math.max(band, 30) + 8;
+ const bx = Math.ceil(band * this.rx), by = Math.ceil(band * this.ry);
+ this.bands = 2 * bx >= W || 2 * by >= H
+ ? [[0, 0, W, H]]
+ : [[0, 0, W, by], [0, H - by, W, by], [0, by, bx, H - 2 * by], [W - bx, by, bx, H - 2 * by]];
+ }
+ step(dt) {
+ const up = easeOutCubic(clamp(this.t / 1.6, 0, 1));
+ for (const c of this.clusters) {
+ c.k = up * (1 + 2.6 * c.kick * c.kick);
+ c.kick = Math.max(0, c.kick - dt / 1.1);
+ }
+ for (const g of this.gears) {
+ g.phi = (g.phi + g.omega * this.clusters[g.cl].k * dt) % TAU;
+ if (g.flash > 0) g.flash = Math.max(0, g.flash - dt * 1.4);
+ }
+ }
+ draw() {
+ const L = this.layer, x = L.ctx, w = L.w, h = L.h;
+ if (!w || !this.bands) return;
+ const rx = this.rx, ry = this.ry;
+ for (const b of this.bands) x.clearRect(b[0] / rx, b[1] / ry, b[2] / rx, b[3] / ry);
+ const still = this.still, t = this.t;
+ vignette(x, w, h, 0.08 * (still ? 1 : clamp(t / 0.6, 0, 1)), 24);
+ for (const g of this.gears) {
+ const a = still ? 1 : easeOutCubic(clamp((t - g.order * 0.07) / 0.4, 0, 1));
+ if (a <= 0) continue;
+ x.save();
+ x.translate(g.x, g.y);
+ x.rotate(g.phi);
+ x.globalAlpha = a;
+ x.drawImage(g.sprite, -g.half, -g.half, g.half * 2, g.half * 2);
+ x.restore();
+ if (g.flash > 0) {
+ const s = g.r * 1.6;
+ x.globalCompositeOperation = 'lighter';
+ x.globalAlpha = g.flash * 0.6;
+ x.drawImage(this.sprGlow, g.x - s / 2, g.y - s / 2, s, s);
+ x.globalAlpha = 1;
+ x.globalCompositeOperation = 'source-over';
+ }
+ }
+ }
+ // The agent acted on an element: the nearest corner's train revs up.
+ target(rect) {
+ if (!this.active || this.still || !this.gears.length) return;
+ const cx = rect.left + rect.width / 2, cy = rect.top + rect.height / 2;
+ let best = 0, bestDist = Infinity;
+ this.clusters.forEach((c, i) => { const d = Math.hypot(c.x - cx, c.y - cy); if (d < bestDist) { bestDist = d; best = i; } });
+ this.clusters[best].kick = 1;
+ let nearest = null, nearestDist = Infinity;
+ for (const g of this.gears) {
+ if (g.cl !== best) continue;
+ const d = Math.hypot(g.x - cx, g.y - cy) - g.r;
+ if (d < nearestDist) { nearestDist = d; nearest = g; }
+ }
+ if (nearest) nearest.flash = 1;
+ }
+ }
+
+ /* classic: the original pulsing inset glow, kept as a choice. */
+ class ClassicGlow {
+ constructor() { this.el = null; this.active = false; }
+ show(root) {
+ injectStyles();
+ if (!this.el) {
+ const el = document.createElement('div');
+ el.id = 'webbrain-agent-glow-border';
+ decorations().add(el);
+ el.style.cssText = `
+ position: fixed;
+ top: 0; left: 0; right: 0; bottom: 0;
+ pointer-events: none;
+ z-index: 2147483646;
+ opacity: 0;
+ transition: opacity 0.3s ease-in-out;
+ animation: webbrain-pulse 2s ease-in-out infinite;
+ box-shadow:
+ inset 0 0 10px rgba(108, 99, 255, 0.5),
+ inset 0 0 20px rgba(108, 99, 255, 0.3),
+ inset 0 0 30px rgba(108, 99, 255, 0.1);
+ `;
+ root.appendChild(el);
+ this.el = el;
+ }
+ this.active = true;
+ this.el.style.display = '';
+ requestAnimationFrame(() => requestAnimationFrame(() => { if (this.active && this.el) this.el.style.opacity = '1'; }));
+ }
+ hide() { this.active = false; if (this.el) this.el.style.opacity = '0'; }
+ suspend() { if (this.el) this.el.style.display = 'none'; }
+ resume() { if (this.el) this.el.style.display = ''; }
+ refreshMotion() {}
+ target() {}
+ destroy() { this.el?.remove(); this.el = null; this.active = false; }
+ }
+
+ function normalizeStyle(value) {
+ return STYLES.includes(value) ? value : DEFAULT_STYLE;
+ }
+
+ function createEffect(style) {
+ const effectFor = {
+ circuit: () => new NeuralCircuit(),
+ aurora: () => new Aurora(),
+ scan: () => new Scan(),
+ gears: () => new Gears(),
+ classic: () => new ClassicGlow(),
+ };
+ const created = effectFor[normalizeStyle(style)]();
+ created.styleName = normalizeStyle(style);
+ return created;
+ }
+
+ function startEffect() {
+ const root = document.body || document.documentElement;
+ if (!root || !indicatorsActive) return;
+ if (effect && effect.styleName !== effectStyle) { effect.destroy(); effect = null; }
+ if (!effect) effect = createEffect(effectStyle);
+ effect.show(root);
+ if (suspendedForToolUse) effect.suspend();
+ }
+
+ // Settings → General → Agent activity effect, applied live while a run is on.
+ function applyStyle(value) {
+ const next = normalizeStyle(value);
+ if (next === effectStyle) return;
+ effectStyle = next;
+ if (!indicatorsActive || !effect) return;
+ const previous = effect;
+ effect = null;
+ previous.hide();
+ setTimeout(() => previous.destroy(), 520);
+ startEffect();
+ }
+
+ try {
+ Promise.resolve(chrome.storage?.local?.get({ [STYLE_STORAGE_KEY]: DEFAULT_STYLE }))
+ .then((stored) => { effectStyle = normalizeStyle(stored?.[STYLE_STORAGE_KEY]); })
+ .catch(() => {})
+ .finally(() => {
+ styleLoaded = true;
+ if (indicatorsActive && !effect) startEffect();
+ });
+ chrome.storage?.onChanged?.addListener?.((changes, area) => {
+ if (area === 'local' && changes?.[STYLE_STORAGE_KEY]) applyStyle(changes[STYLE_STORAGE_KEY].newValue);
+ });
+ } catch {
+ styleLoaded = true;
+ }
+
+ reduceMotionQuery.addEventListener?.('change', () => effect?.refreshMotion?.());
+
+ /* ------------------------------------------------------------------------
+ * Agent cursor
+ * One size (75% of the original 48×56 arrow). It glides to each target and
+ * on clicks presses once with a ripple: the only size change, so a size
+ * change always means a click. Between actions it rests on the spot and
+ * fades in and out. Position uses a CSS transition and the press, ripple and
+ * resting breath use the Web Animations API, so no style is written per
+ * frame.
+ * ---------------------------------------------------------------------- */
+
+ const CURSOR_SCALE = 0.75;
+ const CURSOR_W = 48 * CURSOR_SCALE;
+ const CURSOR_H = 56 * CURSOR_SCALE;
+ const TIP_X = 5 * CURSOR_SCALE;
+ const TIP_Y = 4 * CURSOR_SCALE;
+ const GLIDE_MS = 420;
+ const CURSOR_TRANSITION = `transform ${GLIDE_MS}ms cubic-bezier(0.22, 0.8, 0.24, 1), opacity 0.25s ease`;
+ const CURSOR_SVG = `
+ <svg width="100%" height="100%" viewBox="0 0 48 56" fill="none" xmlns="http://www.w3.org/2000/svg" style="display: block;">
+ <path d="M5 4L39 31L24 34L31 50L20 54L14 38L5 48V4Z"
+ fill="#6c63ff" stroke="white" stroke-width="3" stroke-linejoin="round"/>
+ <path d="M24 34L31 50" stroke="rgba(20, 18, 48, 0.34)" stroke-width="2" stroke-linecap="round"/>
+ </svg>
+ `;
+
+ class AgentCursor {
+ constructor() {
+ this.el = null; this.body = null; this.ripple = null;
+ this.mode = 'hidden'; // 'active' | 'resting' | 'hidden'
+ this.x = 0; this.y = 0;
+ this.breath = null; this.pressAnimation = null;
+ this.restTimer = null; this.hideTimer = null;
+ }
+ mount(root) {
+ if (this.el) return;
+ const ripple = document.createElement('div');
+ ripple.setAttribute('aria-hidden', 'true');
+ decorations().add(ripple);
+ ripple.style.cssText = `
+ position: fixed; top: 0; left: 0;
+ width: 40px; height: 40px; margin: -20px 0 0 -20px;
+ box-sizing: border-box; border-radius: 50%;
+ border: 2px solid rgba(108, 99, 255, 0.85);
+ background: rgba(108, 99, 255, 0.10);
+ pointer-events: none; z-index: 2147483647; opacity: 0;
+ `;
+ const el = document.createElement('div');
+ el.id = 'webbrain-agent-target-cursor';
+ el.setAttribute('aria-hidden', 'true');
+ decorations().add(el);
+ el.style.cssText = `
+ position: fixed; top: 0; left: 0;
+ width: ${CURSOR_W}px; height: ${CURSOR_H}px;
+ pointer-events: none; z-index: 2147483647; opacity: 0;
+ transition: ${CURSOR_TRANSITION};
+ filter:
+ drop-shadow(0 10px 20px rgba(108, 99, 255, 0.36))
+ drop-shadow(0 2px 3px rgba(20, 18, 48, 0.22));
+ will-change: transform, opacity;
+ `;
+ const body = document.createElement('div');
+ // transform-origin on the arrow tip, so the click press never moves the point
+ body.style.cssText = `width: 100%; height: 100%; transform-origin: ${TIP_X}px ${TIP_Y}px;`;
+ body.innerHTML = CURSOR_SVG;
+ el.appendChild(body);
+ root.append(ripple, el);
+ this.el = el; this.body = body; this.ripple = ripple;
+ }
+ place(x, y, instant) {
+ const transform = `translate(${(x - TIP_X).toFixed(1)}px, ${(y - TIP_Y).toFixed(1)}px)`;
+ if (instant) {
+ this.el.style.transition = 'opacity 0.25s ease';
+ this.el.style.transform = transform;
+ void this.el.offsetWidth; // commit the jump before the glide transition returns
+ this.el.style.transition = CURSOR_TRANSITION;
+ } else {
+ this.el.style.transform = transform;
+ }
+ this.x = x; this.y = y;
+ }
+ // The agent acts with the tip at (x, y).
+ aim(x, y, click) {
+ clearTimeout(this.restTimer);
+ clearTimeout(this.hideTimer);
+ const still = prefersReducedMotion();
+ const fresh = this.mode === 'hidden';
+ const moved = !fresh && Math.hypot(x - this.x, y - this.y) > 2;
+ this.place(x, y, fresh || still);
+ this.mode = 'active';
+ this.el.style.opacity = '1';
+ this.settle();
+ if (click && !still) this.press(moved ? GLIDE_MS : 0);
+ this.restTimer = setTimeout(() => this.rest(), TARGET_RING_TTL_MS);
+ }
+ // Keep up with scrolling without re-triggering the click.
+ follow(x, y) {
+ if (this.mode === 'hidden') return;
+ if (Math.abs(x - this.x) < 0.5 && Math.abs(y - this.y) < 0.5) return;
+ this.place(x, y, true);
+ }
+ rest() {
+ if (this.mode !== 'active') return;
+ this.mode = 'resting';
+ if (prefersReducedMotion() || typeof this.body.animate !== 'function') return;
+ this.breath = this.body.animate([
+ { opacity: 1, easing: 'ease-in-out' },
+ { opacity: 0.32, easing: 'ease-in-out' },
+ { opacity: 1 },
+ ], { duration: 2600, iterations: Infinity });
+ }
+ // Leave the resting breath without an opacity jump.
+ settle() {
+ if (!this.breath) return;
+ let current = 1;
+ try { current = parseFloat(getComputedStyle(this.body).opacity) || 1; } catch {}
+ this.breath.cancel();
+ this.breath = null;
+ if (current < 0.98 && typeof this.body.animate === 'function') {
+ this.body.animate([{ opacity: current }, { opacity: 1 }], { duration: 220, easing: 'ease-out' });
+ }
+ }
+ press(delay) {
+ if (typeof this.body.animate !== 'function') return;
+ this.pressAnimation?.cancel();
+ this.pressAnimation = this.body.animate([
+ { transform: 'scale(1)' },
+ { transform: 'scale(0.84)', offset: 0.45 },
+ { transform: 'scale(1)' },
+ ], { duration: 320, delay, easing: 'ease-out' });
+ const at = `translate(${this.x.toFixed(1)}px, ${this.y.toFixed(1)}px)`;
+ this.ripple.getAnimations?.().forEach(animation => animation.cancel());
+ this.ripple.animate([
+ { transform: `${at} scale(0.3)`, opacity: 0.95 },
+ { transform: `${at} scale(1.6)`, opacity: 0 },
+ ], { duration: 560, delay, easing: 'cubic-bezier(0.2, 0.7, 0.3, 1)' });
+ }
+ hide() {
+ clearTimeout(this.restTimer);
+ if (this.mode === 'hidden' || !this.el) return;
+ this.mode = 'hidden';
+ this.el.style.opacity = '0';
+ clearTimeout(this.hideTimer);
+ this.hideTimer = setTimeout(() => {
+ if (this.mode !== 'hidden') return;
+ this.breath?.cancel();
+ this.breath = null;
+ }, 300);
+ }
+ suspend() {
+ if (this.el) this.el.style.display = 'none';
+ if (this.ripple) this.ripple.style.display = 'none';
+ }
+ resume() {
+ if (this.el) this.el.style.display = '';
+ if (this.ripple) this.ripple.style.display = '';
+ }
+ destroy() {
+ clearTimeout(this.restTimer);
+ clearTimeout(this.hideTimer);
+ this.breath?.cancel();
+ this.pressAnimation?.cancel();
+ this.el?.remove();
+ this.ripple?.remove();
+ this.el = null; this.body = null; this.ripple = null;
+ this.mode = 'hidden';
+ }
+ }
+
+ /* ------------------------------------------------------------------------
+ * Stop button, target ring, lifecycle
+ * ---------------------------------------------------------------------- */
+
function createStopButton() {
const container = document.createElement('div');
container.id = 'webbrain-agent-stop-container';
- (window.__wbPageMonitorDecorations ??= new WeakSet()).add(container);
+ decorations().add(container);
container.style.cssText = `
position: fixed;
bottom: 16px;
@@ -182,7 +1581,7 @@
if (indicatorsActive) button.style.background = '#ffffff';
});
button.addEventListener('click', async () => {
- // Clear the page-owned UI immediately. The service worker may have
+ // Clear the page-owned UI immediately. The background may have
// restarted (or the run may already be gone), leaving this indicator
// with no live background state to clean it up.
hide();
@@ -197,7 +1596,7 @@
function createTargetOutline() {
const el = document.createElement('div');
el.id = 'webbrain-agent-target-outline';
- (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
+ decorations().add(el);
el.style.cssText = `
position: fixed;
pointer-events: none;
@@ -207,53 +1606,16 @@
border-radius: 10px;
background: rgba(108, 99, 255, 0.035);
transition:
- opacity 0.16s ease,
- top 0.18s ease,
- left 0.18s ease,
- width 0.18s ease,
- height 0.18s ease;
+ opacity 0.35s ease,
+ top 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
+ left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
+ width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
+ height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
animation: webbrain-target-ring 1.3s ease-in-out infinite;
`;
return el;
}
- 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">
- <path d="M5 4L39 31L24 34L31 50L20 54L14 38L5 48V4Z"
- fill="#6c63ff" stroke="white" stroke-width="3" stroke-linejoin="round"/>
- <path d="M24 34L31 50" stroke="rgba(20, 18, 48, 0.34)" stroke-width="2" stroke-linecap="round"/>
- </svg>
- `;
- el.style.cssText = `
- position: fixed;
- top: 0;
- left: 0;
- width: 48px;
- height: 56px;
- pointer-events: none;
- z-index: 2147483646;
- opacity: 0;
- filter:
- drop-shadow(0 14px 26px rgba(108, 99, 255, 0.38))
- drop-shadow(0 2px 4px rgba(20, 18, 48, 0.22));
- transition:
- opacity 0.16s ease,
- transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
- animation: webbrain-target-pop 0.18s ease-out;
- will-change: transform, opacity;
- `;
- return el;
- }
-
- function clamp(value, min, max) {
- return Math.min(Math.max(value, min), max);
- }
-
function getTargetRect() {
if (targetRectOverride) return targetRectOverride;
if (!targetElement || typeof targetElement.getBoundingClientRect !== 'function') return null;
@@ -282,28 +1644,32 @@
};
}
- function placeTargetOverlay() {
- if (!targetCursorEl || !targetOutlineEl) return;
- const rect = getTargetRect();
- if (!rect) {
- targetCursorEl.style.opacity = '0';
- targetOutlineEl.style.opacity = '0';
- return;
- }
+ function cursorTip(rect) {
+ const innerX = Math.min(Math.max(rect.rawWidth * 0.62, 14), Math.max(14, rect.rawWidth - 8));
+ const innerY = Math.min(Math.max(rect.rawHeight * 0.58, 14), Math.max(14, rect.rawHeight - 8));
+ return {
+ x: clamp(rect.left + innerX, 8, window.innerWidth - CURSOR_W),
+ y: clamp(rect.top + innerY, 8, window.innerHeight - CURSOR_H),
+ };
+ }
+ function placeTargetRing(rect) {
+ if (!targetOutlineEl) return;
targetOutlineEl.style.left = `${Math.round(rect.left)}px`;
targetOutlineEl.style.top = `${Math.round(rect.top)}px`;
targetOutlineEl.style.width = `${Math.round(rect.width)}px`;
targetOutlineEl.style.height = `${Math.round(rect.height)}px`;
targetOutlineEl.style.borderRadius = `${rect.height < 28 ? 7 : 10}px`;
- targetOutlineEl.style.opacity = '1';
+ }
- const innerX = Math.min(Math.max(rect.rawWidth * 0.62, 14), Math.max(14, rect.rawWidth - 8));
- const innerY = Math.min(Math.max(rect.rawHeight * 0.58, 14), Math.max(14, rect.rawHeight - 8));
- const tipX = clamp(rect.left + innerX, 8, window.innerWidth - 40);
- const tipY = clamp(rect.top + innerY, 8, window.innerHeight - 48);
- targetCursorEl.style.transform = `translate(${Math.round(tipX - 5)}px, ${Math.round(tipY - 4)}px)`;
- targetCursorEl.style.opacity = '1';
+ // Scroll/resize: keep the ring and the (possibly resting) cursor on the
+ // element. If it scrolled out of view the cursor stays where it was.
+ function placeTargetOverlay() {
+ const rect = getTargetRect();
+ if (!rect) return;
+ placeTargetRing(rect);
+ const tip = cursorTip(rect);
+ cursor?.follow(tip.x, tip.y);
}
function scheduleTargetUpdate() {
@@ -314,57 +1680,67 @@
});
}
- function hideTargetCursor() {
+ function clearTarget() {
targetElement = null;
targetRectOverride = null;
- if (targetTimer) {
- clearTimeout(targetTimer);
- targetTimer = null;
+ if (ringTimer) {
+ clearTimeout(ringTimer);
+ ringTimer = null;
}
if (targetRaf) {
cancelAnimationFrame(targetRaf);
targetRaf = 0;
}
- if (targetCursorEl) targetCursorEl.style.opacity = '0';
if (targetOutlineEl) targetOutlineEl.style.opacity = '0';
- setTimeout(() => {
- if (targetElement || targetRectOverride) return;
- targetCursorEl?.parentNode?.removeChild(targetCursorEl);
- targetOutlineEl?.parentNode?.removeChild(targetOutlineEl);
- targetCursorEl = null;
- targetOutlineEl = null;
- }, 180);
- }
-
- function scheduleTargetExpiry() {
- if (targetTimer) clearTimeout(targetTimer);
- targetTimer = setTimeout(hideTargetCursor, TARGET_CURSOR_TTL_MS);
+ cursor?.hide();
}
- function showTarget(el, source = 'interaction') {
- if (!el || typeof el.getBoundingClientRect !== 'function') return;
+ function pointAtTarget(source) {
injectStyles();
const root = document.body || document.documentElement;
if (!root) return;
+ const rect = getTargetRect();
+ if (!rect) return;
- targetElement = el;
- targetRectOverride = null;
- if (targetOutlineEl) {
- targetOutlineEl.style.display = '';
- } else {
+ if (!targetOutlineEl) {
targetOutlineEl = createTargetOutline();
root.appendChild(targetOutlineEl);
}
- if (targetCursorEl) {
- targetCursorEl.style.display = '';
- } else {
- targetCursorEl = createTargetCursor();
- root.appendChild(targetCursorEl);
- }
- targetCursorEl.dataset.source = String(source || 'interaction');
+ targetOutlineEl.style.display = suspendedForToolUse ? 'none' : '';
+ placeTargetRing(rect);
+ targetOutlineEl.style.opacity = '1';
+
+ if (!cursor) cursor = new AgentCursor();
+ cursor.mount(root);
+ if (suspendedForToolUse) cursor.suspend();
+ const tip = cursorTip(rect);
+ cursor.aim(tip.x, tip.y, /^click/.test(String(source || '')));
+ effect?.target?.(rect);
- placeTargetOverlay();
- scheduleTargetExpiry();
+ if (ringTimer) clearTimeout(ringTimer);
+ ringTimer = setTimeout(() => {
+ ringTimer = null;
+ if (targetOutlineEl) targetOutlineEl.style.opacity = '0';
+ // Outside a run nothing would hide a resting cursor, so it leaves with
+ // the ring and its elements are removed once faded.
+ if (!indicatorsActive) {
+ clearTarget();
+ setTimeout(() => {
+ if (indicatorsActive || targetElement || targetRectOverride) return;
+ cursor?.destroy();
+ cursor = null;
+ targetOutlineEl?.parentNode?.removeChild(targetOutlineEl);
+ targetOutlineEl = null;
+ }, 400);
+ }
+ }, TARGET_RING_TTL_MS);
+ }
+
+ function showTarget(el, source = 'interaction') {
+ if (!el || typeof el.getBoundingClientRect !== 'function') return;
+ targetElement = el;
+ targetRectOverride = null;
+ pointAtTarget(source);
}
function showTargetRect(rect, source = 'interaction') {
@@ -375,10 +1751,6 @@
const h = Math.max(1, Number(rect.h ?? rect.height ?? 1));
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(w) || !Number.isFinite(h)) return;
- injectStyles();
- const root = document.body || document.documentElement;
- if (!root) return;
-
const width = Math.max(w, 28);
const height = Math.max(h, 28);
targetElement = null;
@@ -390,39 +1762,20 @@
rawWidth: width,
rawHeight: height,
};
-
- if (targetOutlineEl) {
- targetOutlineEl.style.display = '';
- } else {
- targetOutlineEl = createTargetOutline();
- root.appendChild(targetOutlineEl);
- }
- if (targetCursorEl) {
- targetCursorEl.style.display = '';
- } else {
- targetCursorEl = createTargetCursor();
- root.appendChild(targetCursorEl);
- }
- targetCursorEl.dataset.source = String(source || 'interaction');
-
- placeTargetOverlay();
- scheduleTargetExpiry();
+ pointAtTarget(source);
}
function show() {
indicatorsActive = true;
+ suspendedForToolUse = false;
armIndicatorHeartbeat();
injectStyles();
const root = document.body || document.documentElement;
if (!root) return; // page hasn't parsed yet — extremely unlikely on document_idle
- if (borderEl) {
- borderEl.style.display = '';
- } else {
- borderEl = createBorder();
- root.appendChild(borderEl);
- }
+ // Until the saved style has loaded, the loader starts the effect.
+ if (styleLoaded) startEffect();
if (stopContainerEl) {
stopContainerEl.style.display = '';
@@ -436,7 +1789,6 @@
// second to apply the in-flight values for a clean transition.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
- if (borderEl) borderEl.style.opacity = '1';
const btn = stopContainerEl?.querySelector('#webbrain-agent-stop-button');
if (btn) {
btn.style.transform = 'translateY(0)';
@@ -450,8 +1802,8 @@
clearIndicatorHeartbeat();
if (!indicatorsActive) return;
indicatorsActive = false;
- if (borderEl) borderEl.style.opacity = '0';
- hideTargetCursor();
+ effect?.hide();
+ clearTarget();
const btn = stopContainerEl?.querySelector('#webbrain-agent-stop-button');
if (btn) {
btn.style.transform = 'translateY(80px)';
@@ -460,11 +1812,15 @@
setTimeout(() => {
// Bail if the user re-triggered show() during the fade-out.
if (indicatorsActive) return;
- borderEl?.parentNode?.removeChild(borderEl);
+ effect?.destroy();
+ effect = null;
+ cursor?.destroy();
+ cursor = null;
stopContainerEl?.parentNode?.removeChild(stopContainerEl);
- borderEl = null;
+ targetOutlineEl?.parentNode?.removeChild(targetOutlineEl);
stopContainerEl = null;
- }, 320);
+ targetOutlineEl = null;
+ }, 520);
}
function clearIndicatorHeartbeat() {
@@ -481,35 +1837,33 @@
}
/**
- * Hide both elements without tearing them down — for the brief window
- * around a screenshot capture, so the agent doesn't see its own border
- * pulsing in the screenshots it sends back to the model.
+ * Hide everything without tearing it down — for the brief window around a
+ * screenshot capture, so the agent doesn't see its own effect or cursor in
+ * the screenshots it sends back to the model.
*/
function hideForToolUse() {
- savedBorderVisible = !!(borderEl && borderEl.style.display !== 'none');
+ suspendedForToolUse = true;
savedStopVisible = !!(stopContainerEl && stopContainerEl.style.display !== 'none');
- savedTargetCursorVisible = !!(targetCursorEl && targetCursorEl.style.display !== 'none');
savedTargetOutlineVisible = !!(targetOutlineEl && targetOutlineEl.style.display !== 'none');
- if (borderEl) borderEl.style.display = 'none';
+ effect?.suspend();
+ cursor?.suspend();
if (stopContainerEl) stopContainerEl.style.display = 'none';
- if (targetCursorEl) targetCursorEl.style.display = 'none';
if (targetOutlineEl) targetOutlineEl.style.display = 'none';
}
function showAfterToolUse() {
- if (savedBorderVisible && borderEl) borderEl.style.display = '';
+ suspendedForToolUse = false;
+ effect?.resume();
+ cursor?.resume();
if (savedStopVisible && stopContainerEl) stopContainerEl.style.display = '';
- if (savedTargetCursorVisible && targetCursorEl) targetCursorEl.style.display = '';
if (savedTargetOutlineVisible && targetOutlineEl) targetOutlineEl.style.display = '';
- savedBorderVisible = false;
savedStopVisible = false;
- savedTargetCursorVisible = false;
savedTargetOutlineVisible = false;
}
window.addEventListener('scroll', scheduleTargetUpdate, true);
window.addEventListener('resize', scheduleTargetUpdate, true);
- window.__webbrainAgentIndicator = { showTarget, showTargetRect, hideTarget: hideTargetCursor };
+ window.__webbrainAgentIndicator = { showTarget, showTargetRect, hideTarget: clearTarget };
chrome.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
if (!msg || typeof msg.type !== 'string') return;
diff --git a/src/chrome/src/ui/locales/ar.js b/src/chrome/src/ui/locales/ar.js
index 1f9c542b4..3a243ada5 100644
--- a/src/chrome/src/ui/locales/ar.js
+++ b/src/chrome/src/ui/locales/ar.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "جارٍ إعادة محاولة الإجابة…",
'sp.response.incomplete_retrying': "إجابة غير مكتملة · جارٍ إعادة المحاولة…",
'sp.response.incomplete': "إجابة غير مكتملة",
+ "st.display.agent_indicator.label": "تأثير نشاط الوكيل",
+ "st.display.agent_indicator.desc": "مظهر حواف الصفحة أثناء عمل WebBrain في علامة تبويب. كل الأنماط تمرّر نقراتك إلى الصفحة ولا تظهر في لقطات الشاشة.",
+ "st.display.agent_indicator.circuit": "دائرة عصبية",
+ "st.display.agent_indicator.aurora": "شفق قطبي",
+ "st.display.agent_indicator.scan": "مسح",
+ "st.display.agent_indicator.gears": "تروس",
+ "st.display.agent_indicator.classic": "توهج كلاسيكي",
};
diff --git a/src/chrome/src/ui/locales/bn.js b/src/chrome/src/ui/locales/bn.js
index 339bbd17d..d90649ed0 100644
--- a/src/chrome/src/ui/locales/bn.js
+++ b/src/chrome/src/ui/locales/bn.js
@@ -1371,4 +1371,11 @@ export default {
'sp.activity.retrying_response': "উত্তর আবার চেষ্টা করা হচ্ছে…",
'sp.response.incomplete_retrying': "অসম্পূর্ণ উত্তর · আবার চেষ্টা করা হচ্ছে…",
'sp.response.incomplete': "অসম্পূর্ণ উত্তর",
+ "st.display.agent_indicator.label": "এজেন্ট কার্যকলাপ ইফেক্ট",
+ "st.display.agent_indicator.desc": "WebBrain কোনো ট্যাবে কাজ করার সময় পেজের কিনারা কেমন দেখাবে। প্রতিটি স্টাইল আপনার ক্লিক পেজে পৌঁছাতে দেয় এবং স্ক্রিনশটে আসে না।",
+ "st.display.agent_indicator.circuit": "নিউরাল সার্কিট",
+ "st.display.agent_indicator.aurora": "অরোরা",
+ "st.display.agent_indicator.scan": "স্ক্যান",
+ "st.display.agent_indicator.gears": "গিয়ার",
+ "st.display.agent_indicator.classic": "ক্লাসিক আভা",
};
diff --git a/src/chrome/src/ui/locales/de.js b/src/chrome/src/ui/locales/de.js
index 925da832c..40b5a0922 100644
--- a/src/chrome/src/ui/locales/de.js
+++ b/src/chrome/src/ui/locales/de.js
@@ -1344,4 +1344,11 @@ export default {
'sp.activity.retrying_response': "Antwort wird erneut versucht…",
'sp.response.incomplete_retrying': "Unvollständige Antwort · erneuter Versuch…",
'sp.response.incomplete': "Unvollständige Antwort",
+ "st.display.agent_indicator.label": "Effekt bei Agentenaktivität",
+ "st.display.agent_indicator.desc": "Legt fest, wie die Seitenränder aussehen, während WebBrain in einem Tab arbeitet. Jeder Stil lässt Ihre Klicks durch und erscheint nicht auf Screenshots.",
+ "st.display.agent_indicator.circuit": "Neuronaler Schaltkreis",
+ "st.display.agent_indicator.aurora": "Polarlicht",
+ "st.display.agent_indicator.scan": "Scan",
+ "st.display.agent_indicator.gears": "Zahnräder",
+ "st.display.agent_indicator.classic": "Klassisches Leuchten",
};
diff --git a/src/chrome/src/ui/locales/en.js b/src/chrome/src/ui/locales/en.js
index 39d885745..be0f1ca8e 100644
--- a/src/chrome/src/ui/locales/en.js
+++ b/src/chrome/src/ui/locales/en.js
@@ -1377,4 +1377,11 @@ export default {
'st.providers.webgpu_download.resume': 'Resume',
'st.providers.webgpu_download.stop': 'Stop & remove',
'st.providers.webgpu_download.activate_blocked': 'Download the selected text model before using WebGPU in standalone chat.',
+ "st.display.agent_indicator.label": "Agent activity effect",
+ "st.display.agent_indicator.desc": "How the page edges look while WebBrain works on a tab. Every style lets your clicks through and stays out of screenshots.",
+ "st.display.agent_indicator.circuit": "Neural circuit",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Scan",
+ "st.display.agent_indicator.gears": "Gears",
+ "st.display.agent_indicator.classic": "Classic glow",
};
diff --git a/src/chrome/src/ui/locales/es.js b/src/chrome/src/ui/locales/es.js
index 62db780bb..ded5ec833 100644
--- a/src/chrome/src/ui/locales/es.js
+++ b/src/chrome/src/ui/locales/es.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Reintentando respuesta…",
'sp.response.incomplete_retrying': "Respuesta incompleta · reintentando…",
'sp.response.incomplete': "Respuesta incompleta",
+ "st.display.agent_indicator.label": "Efecto de actividad del agente",
+ "st.display.agent_indicator.desc": "Cómo se ven los bordes de la página mientras WebBrain trabaja en una pestaña. Todos los estilos dejan pasar tus clics y no aparecen en las capturas de pantalla.",
+ "st.display.agent_indicator.circuit": "Circuito neuronal",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Escaneo",
+ "st.display.agent_indicator.gears": "Engranajes",
+ "st.display.agent_indicator.classic": "Brillo clásico",
};
diff --git a/src/chrome/src/ui/locales/fa.js b/src/chrome/src/ui/locales/fa.js
index 399ecf839..79b640331 100644
--- a/src/chrome/src/ui/locales/fa.js
+++ b/src/chrome/src/ui/locales/fa.js
@@ -1371,4 +1371,11 @@ export default {
'sp.activity.retrying_response': "در حال تلاش دوباره برای پاسخ…",
'sp.response.incomplete_retrying': "پاسخ ناقص · تلاش دوباره…",
'sp.response.incomplete': "پاسخ ناقص",
+ "st.display.agent_indicator.label": "جلوهٔ فعالیت عامل",
+ "st.display.agent_indicator.desc": "ظاهر لبه‌های صفحه هنگامی که WebBrain در یک زبانه کار می‌کند. همهٔ سبک‌ها کلیک‌های شما را به صفحه می‌رسانند و در عکس‌های صفحه دیده نمی‌شوند.",
+ "st.display.agent_indicator.circuit": "مدار عصبی",
+ "st.display.agent_indicator.aurora": "شفق قطبی",
+ "st.display.agent_indicator.scan": "اسکن",
+ "st.display.agent_indicator.gears": "چرخ‌دنده‌ها",
+ "st.display.agent_indicator.classic": "درخشش کلاسیک",
};
diff --git a/src/chrome/src/ui/locales/fr.js b/src/chrome/src/ui/locales/fr.js
index 38de3e4d1..9aafc654a 100644
--- a/src/chrome/src/ui/locales/fr.js
+++ b/src/chrome/src/ui/locales/fr.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Nouvelle tentative de réponse…",
'sp.response.incomplete_retrying': "Réponse incomplète · nouvelle tentative…",
'sp.response.incomplete': "Réponse incomplète",
+ "st.display.agent_indicator.label": "Effet d'activité de l'agent",
+ "st.display.agent_indicator.desc": "Apparence des bords de la page pendant que WebBrain travaille dans un onglet. Tous les styles laissent passer vos clics et n'apparaissent pas sur les captures d'écran.",
+ "st.display.agent_indicator.circuit": "Circuit neuronal",
+ "st.display.agent_indicator.aurora": "Aurore",
+ "st.display.agent_indicator.scan": "Balayage",
+ "st.display.agent_indicator.gears": "Engrenages",
+ "st.display.agent_indicator.classic": "Halo classique",
};
diff --git a/src/chrome/src/ui/locales/he.js b/src/chrome/src/ui/locales/he.js
index 57f414e2a..b4abece29 100644
--- a/src/chrome/src/ui/locales/he.js
+++ b/src/chrome/src/ui/locales/he.js
@@ -1325,4 +1325,11 @@ export default {
'sp.activity.retrying_response': "מנסה שוב להשיב…",
'sp.response.incomplete_retrying': "תשובה חלקית · מנסה שוב…",
'sp.response.incomplete': "תשובה חלקית",
+ "st.display.agent_indicator.label": "אפקט פעילות הסוכן",
+ "st.display.agent_indicator.desc": "איך נראים שולי הדף בזמן ש-WebBrain עובד בכרטיסייה. כל הסגנונות מעבירים את הלחיצות שלך לדף ואינם מופיעים בצילומי מסך.",
+ "st.display.agent_indicator.circuit": "מעגל עצבי",
+ "st.display.agent_indicator.aurora": "זוהר קוטבי",
+ "st.display.agent_indicator.scan": "סריקה",
+ "st.display.agent_indicator.gears": "גלגלי שיניים",
+ "st.display.agent_indicator.classic": "הילה קלאסית",
};
diff --git a/src/chrome/src/ui/locales/hi.js b/src/chrome/src/ui/locales/hi.js
index 1ba4480a0..c34aa2b42 100644
--- a/src/chrome/src/ui/locales/hi.js
+++ b/src/chrome/src/ui/locales/hi.js
@@ -1371,4 +1371,11 @@ export default {
'sp.activity.retrying_response': "उत्तर के लिए फिर प्रयास हो रहा है…",
'sp.response.incomplete_retrying': "अधूरा उत्तर · फिर प्रयास हो रहा है…",
'sp.response.incomplete': "अधूरा उत्तर",
+ "st.display.agent_indicator.label": "एजेंट गतिविधि प्रभाव",
+ "st.display.agent_indicator.desc": "WebBrain जब किसी टैब पर काम करता है तब पेज के किनारे कैसे दिखें। हर शैली आपके क्लिक पेज तक जाने देती है और स्क्रीनशॉट में नहीं आती।",
+ "st.display.agent_indicator.circuit": "न्यूरल सर्किट",
+ "st.display.agent_indicator.aurora": "ऑरोरा",
+ "st.display.agent_indicator.scan": "स्कैन",
+ "st.display.agent_indicator.gears": "गियर",
+ "st.display.agent_indicator.classic": "क्लासिक चमक",
};
diff --git a/src/chrome/src/ui/locales/id.js b/src/chrome/src/ui/locales/id.js
index 9e70412ef..1a7083512 100644
--- a/src/chrome/src/ui/locales/id.js
+++ b/src/chrome/src/ui/locales/id.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Mencoba ulang jawaban…",
'sp.response.incomplete_retrying': "Jawaban belum lengkap · mencoba ulang…",
'sp.response.incomplete': "Jawaban belum lengkap",
+ "st.display.agent_indicator.label": "Efek aktivitas agen",
+ "st.display.agent_indicator.desc": "Tampilan tepi halaman saat WebBrain bekerja di sebuah tab. Semua gaya meneruskan klik Anda ke halaman dan tidak muncul di tangkapan layar.",
+ "st.display.agent_indicator.circuit": "Sirkuit saraf",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Pindai",
+ "st.display.agent_indicator.gears": "Roda gigi",
+ "st.display.agent_indicator.classic": "Cahaya klasik",
};
diff --git a/src/chrome/src/ui/locales/ja.js b/src/chrome/src/ui/locales/ja.js
index 18f2e6d67..f9d4c863e 100644
--- a/src/chrome/src/ui/locales/ja.js
+++ b/src/chrome/src/ui/locales/ja.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "回答を再試行中…",
'sp.response.incomplete_retrying': "未完の回答 · 再試行中…",
'sp.response.incomplete': "未完の回答",
+ "st.display.agent_indicator.label": "エージェント動作エフェクト",
+ "st.display.agent_indicator.desc": "WebBrain がタブで作業している間のページ端の表示です。どのスタイルでもクリックはページに届き、スクリーンショットには写りません。",
+ "st.display.agent_indicator.circuit": "ニューラル回路",
+ "st.display.agent_indicator.aurora": "オーロラ",
+ "st.display.agent_indicator.scan": "スキャン",
+ "st.display.agent_indicator.gears": "歯車",
+ "st.display.agent_indicator.classic": "クラシックな光",
};
diff --git a/src/chrome/src/ui/locales/ko.js b/src/chrome/src/ui/locales/ko.js
index fb7cda149..62a3c6582 100644
--- a/src/chrome/src/ui/locales/ko.js
+++ b/src/chrome/src/ui/locales/ko.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "답변 다시 시도 중…",
'sp.response.incomplete_retrying': "미완성 답변 · 다시 시도 중…",
'sp.response.incomplete': "미완성 답변",
+ "st.display.agent_indicator.label": "에이전트 작업 효과",
+ "st.display.agent_indicator.desc": "WebBrain이 탭에서 작업하는 동안 페이지 가장자리의 모습입니다. 모든 스타일은 클릭을 페이지로 통과시키며 스크린샷에 나타나지 않습니다.",
+ "st.display.agent_indicator.circuit": "신경 회로",
+ "st.display.agent_indicator.aurora": "오로라",
+ "st.display.agent_indicator.scan": "스캔",
+ "st.display.agent_indicator.gears": "톱니바퀴",
+ "st.display.agent_indicator.classic": "클래식 글로우",
};
diff --git a/src/chrome/src/ui/locales/ms.js b/src/chrome/src/ui/locales/ms.js
index 497352787..9f76d5d1b 100644
--- a/src/chrome/src/ui/locales/ms.js
+++ b/src/chrome/src/ui/locales/ms.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Mencuba semula jawapan…",
'sp.response.incomplete_retrying': "Jawapan tidak lengkap · mencuba semula…",
'sp.response.incomplete': "Jawapan tidak lengkap",
+ "st.display.agent_indicator.label": "Kesan aktiviti ejen",
+ "st.display.agent_indicator.desc": "Rupa tepi halaman semasa WebBrain bekerja dalam tab. Semua gaya membenarkan klik anda sampai ke halaman dan tidak muncul dalam tangkapan skrin.",
+ "st.display.agent_indicator.circuit": "Litar saraf",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Imbas",
+ "st.display.agent_indicator.gears": "Gear",
+ "st.display.agent_indicator.classic": "Cahaya klasik",
};
diff --git a/src/chrome/src/ui/locales/nl.js b/src/chrome/src/ui/locales/nl.js
index 76a138324..7aa0d714a 100644
--- a/src/chrome/src/ui/locales/nl.js
+++ b/src/chrome/src/ui/locales/nl.js
@@ -1324,4 +1324,11 @@ export default {
'sp.activity.retrying_response': "Antwoord opnieuw proberen…",
'sp.response.incomplete_retrying': "Onvolledig antwoord · opnieuw proberen…",
'sp.response.incomplete': "Onvolledig antwoord",
+ "st.display.agent_indicator.label": "Effect bij agentactiviteit",
+ "st.display.agent_indicator.desc": "Hoe de paginaranden eruitzien terwijl WebBrain in een tabblad werkt. Elke stijl laat je klikken door en blijft buiten schermafbeeldingen.",
+ "st.display.agent_indicator.circuit": "Neuraal circuit",
+ "st.display.agent_indicator.aurora": "Poollicht",
+ "st.display.agent_indicator.scan": "Scan",
+ "st.display.agent_indicator.gears": "Tandwielen",
+ "st.display.agent_indicator.classic": "Klassieke gloed",
};
diff --git a/src/chrome/src/ui/locales/pl.js b/src/chrome/src/ui/locales/pl.js
index df038e784..5b0f6d536 100644
--- a/src/chrome/src/ui/locales/pl.js
+++ b/src/chrome/src/ui/locales/pl.js
@@ -1333,4 +1333,11 @@ export default {
'sp.activity.retrying_response': "Ponawianie odpowiedzi…",
'sp.response.incomplete_retrying': "Niepełna odpowiedź · ponawianie…",
'sp.response.incomplete': "Niepełna odpowiedź",
+ "st.display.agent_indicator.label": "Efekt aktywności agenta",
+ "st.display.agent_indicator.desc": "Wygląd krawędzi strony, gdy WebBrain pracuje na karcie. Każdy styl przepuszcza Twoje kliknięcia i nie pojawia się na zrzutach ekranu.",
+ "st.display.agent_indicator.circuit": "Obwód neuronowy",
+ "st.display.agent_indicator.aurora": "Zorza",
+ "st.display.agent_indicator.scan": "Skanowanie",
+ "st.display.agent_indicator.gears": "Zębatki",
+ "st.display.agent_indicator.classic": "Klasyczna poświata",
};
diff --git a/src/chrome/src/ui/locales/pt.js b/src/chrome/src/ui/locales/pt.js
index d47f5f26c..c4160ce40 100644
--- a/src/chrome/src/ui/locales/pt.js
+++ b/src/chrome/src/ui/locales/pt.js
@@ -1371,4 +1371,11 @@ export default {
'sp.activity.retrying_response': "Tentando novamente a resposta…",
'sp.response.incomplete_retrying': "Resposta incompleta · tentando novamente…",
'sp.response.incomplete': "Resposta incompleta",
+ "st.display.agent_indicator.label": "Efeito de atividade do agente",
+ "st.display.agent_indicator.desc": "Como as bordas da página ficam enquanto o WebBrain trabalha em uma guia. Todos os estilos deixam seus cliques passarem e não aparecem nas capturas de tela.",
+ "st.display.agent_indicator.circuit": "Circuito neural",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Varredura",
+ "st.display.agent_indicator.gears": "Engrenagens",
+ "st.display.agent_indicator.classic": "Brilho clássico",
};
diff --git a/src/chrome/src/ui/locales/ru.js b/src/chrome/src/ui/locales/ru.js
index f342a83d2..0cf3beb4d 100644
--- a/src/chrome/src/ui/locales/ru.js
+++ b/src/chrome/src/ui/locales/ru.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Повторная попытка ответа…",
'sp.response.incomplete_retrying': "Неполный ответ · повторная попытка…",
'sp.response.incomplete': "Неполный ответ",
+ "st.display.agent_indicator.label": "Эффект активности агента",
+ "st.display.agent_indicator.desc": "Как выглядят края страницы, пока WebBrain работает во вкладке. Все стили пропускают ваши клики и не попадают на скриншоты.",
+ "st.display.agent_indicator.circuit": "Нейронная схема",
+ "st.display.agent_indicator.aurora": "Сияние",
+ "st.display.agent_indicator.scan": "Сканирование",
+ "st.display.agent_indicator.gears": "Шестерёнки",
+ "st.display.agent_indicator.classic": "Классическое свечение",
};
diff --git a/src/chrome/src/ui/locales/th.js b/src/chrome/src/ui/locales/th.js
index 09a60f80e..59b765c0a 100644
--- a/src/chrome/src/ui/locales/th.js
+++ b/src/chrome/src/ui/locales/th.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "กำลังลองตอบอีกครั้ง…",
'sp.response.incomplete_retrying': "คำตอบยังไม่สมบูรณ์ · กำลังลองอีกครั้ง…",
'sp.response.incomplete': "คำตอบยังไม่สมบูรณ์",
+ "st.display.agent_indicator.label": "เอฟเฟกต์ขณะเอเจนต์ทำงาน",
+ "st.display.agent_indicator.desc": "ลักษณะขอบหน้าเว็บขณะที่ WebBrain ทำงานในแท็บ ทุกสไตล์ปล่อยให้การคลิกของคุณผ่านไปยังหน้าเว็บ และไม่ปรากฏในภาพหน้าจอ",
+ "st.display.agent_indicator.circuit": "วงจรประสาท",
+ "st.display.agent_indicator.aurora": "แสงออโรรา",
+ "st.display.agent_indicator.scan": "สแกน",
+ "st.display.agent_indicator.gears": "เฟือง",
+ "st.display.agent_indicator.classic": "แสงเรืองแบบคลาสสิก",
};
diff --git a/src/chrome/src/ui/locales/tl.js b/src/chrome/src/ui/locales/tl.js
index 9855c98c4..dc36dad27 100644
--- a/src/chrome/src/ui/locales/tl.js
+++ b/src/chrome/src/ui/locales/tl.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Sinusubukang muli ang sagot…",
'sp.response.incomplete_retrying': "Hindi kumpletong sagot · sinusubukang muli…",
'sp.response.incomplete': "Hindi kumpletong sagot",
+ "st.display.agent_indicator.label": "Epekto habang gumagana ang agent",
+ "st.display.agent_indicator.desc": "Ang itsura ng mga gilid ng page habang gumagana ang WebBrain sa isang tab. Lahat ng istilo ay nagpapadaan ng iyong mga click sa page at hindi lumalabas sa mga screenshot.",
+ "st.display.agent_indicator.circuit": "Neural na circuit",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Pag-scan",
+ "st.display.agent_indicator.gears": "Mga gear",
+ "st.display.agent_indicator.classic": "Klasikong liwanag",
};
diff --git a/src/chrome/src/ui/locales/tr.js b/src/chrome/src/ui/locales/tr.js
index 16cedeaa4..04dce6ddb 100644
--- a/src/chrome/src/ui/locales/tr.js
+++ b/src/chrome/src/ui/locales/tr.js
@@ -1371,4 +1371,11 @@ export default {
'st.providers.webgpu_download.resume': 'Resume',
'st.providers.webgpu_download.stop': 'Stop & remove',
'st.providers.webgpu_download.activate_blocked': 'Download the selected model before choosing WebGPU for chat.',
+ "st.display.agent_indicator.label": "Ajan çalışma efekti",
+ "st.display.agent_indicator.desc": "WebBrain bir sekmede çalışırken sayfa kenarlarının nasıl görüneceğini seçin. Tüm stiller tıklamalarınızı sayfaya geçirir ve ekran görüntülerine girmez.",
+ "st.display.agent_indicator.circuit": "Sinir devresi",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Tarama",
+ "st.display.agent_indicator.gears": "Dişliler",
+ "st.display.agent_indicator.classic": "Klasik parıltı",
};
diff --git a/src/chrome/src/ui/locales/uk.js b/src/chrome/src/ui/locales/uk.js
index 743c80cd1..535497957 100644
--- a/src/chrome/src/ui/locales/uk.js
+++ b/src/chrome/src/ui/locales/uk.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "Повторна спроба відповіді…",
'sp.response.incomplete_retrying': "Неповна відповідь · повторна спроба…",
'sp.response.incomplete': "Неповна відповідь",
+ "st.display.agent_indicator.label": "Ефект активності агента",
+ "st.display.agent_indicator.desc": "Як виглядають краї сторінки, поки WebBrain працює у вкладці. Усі стилі пропускають ваші кліки й не потрапляють на знімки екрана.",
+ "st.display.agent_indicator.circuit": "Нейронна схема",
+ "st.display.agent_indicator.aurora": "Сяйво",
+ "st.display.agent_indicator.scan": "Сканування",
+ "st.display.agent_indicator.gears": "Шестерні",
+ "st.display.agent_indicator.classic": "Класичне світіння",
};
diff --git a/src/chrome/src/ui/locales/vi.js b/src/chrome/src/ui/locales/vi.js
index 8e1b92391..cb8e83b0f 100644
--- a/src/chrome/src/ui/locales/vi.js
+++ b/src/chrome/src/ui/locales/vi.js
@@ -1371,4 +1371,11 @@ export default {
'sp.activity.retrying_response': "Đang thử lại câu trả lời…",
'sp.response.incomplete_retrying': "Câu trả lời chưa hoàn chỉnh · đang thử lại…",
'sp.response.incomplete': "Câu trả lời chưa hoàn chỉnh",
+ "st.display.agent_indicator.label": "Hiệu ứng khi tác tử hoạt động",
+ "st.display.agent_indicator.desc": "Giao diện viền trang khi WebBrain làm việc trên một thẻ. Mọi kiểu đều cho cú nhấp của bạn đi xuyên qua và không xuất hiện trong ảnh chụp màn hình.",
+ "st.display.agent_indicator.circuit": "Mạch thần kinh",
+ "st.display.agent_indicator.aurora": "Cực quang",
+ "st.display.agent_indicator.scan": "Quét",
+ "st.display.agent_indicator.gears": "Bánh răng",
+ "st.display.agent_indicator.classic": "Viền sáng cổ điển",
};
diff --git a/src/chrome/src/ui/locales/zh.js b/src/chrome/src/ui/locales/zh.js
index cfa119106..fbaee823f 100644
--- a/src/chrome/src/ui/locales/zh.js
+++ b/src/chrome/src/ui/locales/zh.js
@@ -1372,4 +1372,11 @@ export default {
'sp.activity.retrying_response': "正在重试回答…",
'sp.response.incomplete_retrying': "回答未完成 · 正在重试…",
'sp.response.incomplete': "回答未完成",
+ "st.display.agent_indicator.label": "智能体活动效果",
+ "st.display.agent_indicator.desc": "WebBrain 在标签页中工作时页面边缘的样式。所有样式都会让点击穿透到页面,且不会出现在截图中。",
+ "st.display.agent_indicator.circuit": "神经回路",
+ "st.display.agent_indicator.aurora": "极光",
+ "st.display.agent_indicator.scan": "扫描",
+ "st.display.agent_indicator.gears": "齿轮",
+ "st.display.agent_indicator.classic": "经典光晕",
};
diff --git a/src/chrome/src/ui/settings.html b/src/chrome/src/ui/settings.html
index 437893ed2..9d53a149e 100644
--- a/src/chrome/src/ui/settings.html
+++ b/src/chrome/src/ui/settings.html
@@ -64,6 +64,19 @@
<option value="dark" data-i18n="st.display.theme.dark"></option>
</select>
</div>
+ <div class="setting-row">
+ <div class="setting-info">
+ <div class="setting-label" data-i18n="st.display.agent_indicator.label"></div>
+ <div class="setting-desc" data-i18n="st.display.agent_indicator.desc"></div>
+ </div>
+ <select id="select-agent-indicator-style" data-i18n-aria-label="st.display.agent_indicator.label" style="background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:6px;padding:6px 10px;font-family:inherit;cursor:pointer;">
+ <option value="circuit" data-i18n="st.display.agent_indicator.circuit"></option>
+ <option value="aurora" data-i18n="st.display.agent_indicator.aurora"></option>
+ <option value="scan" data-i18n="st.display.agent_indicator.scan"></option>
+ <option value="gears" data-i18n="st.display.agent_indicator.gears"></option>
+ <option value="classic" data-i18n="st.display.agent_indicator.classic"></option>
+ </select>
+ </div>
<div class="setting-row">
<div class="setting-info">
<div class="setting-label" data-i18n="st.display.download_directory.label"></div>
diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.js
index c31a216bc..d3183df51 100644
--- a/src/chrome/src/ui/settings.js
+++ b/src/chrome/src/ui/settings.js
@@ -117,6 +117,9 @@ const apocalypseModeLink = document.getElementById('apocalypse-mode-link');
const apocalypseModeStatus = document.getElementById('apocalypse-mode-status');
const verboseToggle = document.getElementById('toggle-verbose');
const composerDeliveryModeSelect = document.getElementById('select-composer-delivery-mode');
+const agentIndicatorStyleSelect = document.getElementById('select-agent-indicator-style');
+// Read by content/agent-visual-indicator.js; 'circuit' is the default.
+const AGENT_INDICATOR_STYLES = ['circuit', 'aurora', 'scan', 'gears', 'classic'];
const selectionShortcutToggle = document.getElementById('toggle-selection-shortcut');
const pdfViewerToggle = document.getElementById('toggle-pdf-viewer');
const autoGroupTabsToggle = document.getElementById('toggle-auto-group-tabs');
@@ -676,7 +679,7 @@ async function init() {
chrome.storage.local.remove(['authToken', 'authEmail', 'authDefaultModel']).catch(() => {});
// Load display settings
- const stored = await chrome.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'selectionShortcutEnabled', 'pdfViewerEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'newTabEnabled', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'webMcpEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'strictSecretMode', 'strictGuards', 'leanMode', 'visionMode', 'visionQuality', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'clarifyTimeoutPolicy', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
+ const stored = await chrome.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'agentIndicatorStyle', 'selectionShortcutEnabled', 'pdfViewerEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'newTabEnabled', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'webMcpEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'strictSecretMode', 'strictGuards', 'leanMode', 'visionMode', 'visionQuality', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'clarifyTimeoutPolicy', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
if (typeof stored.providerFilter === 'string' && ['all','active','local','cloud','router'].includes(stored.providerFilter)) {
providerFilter = stored.providerFilter;
}
@@ -685,6 +688,9 @@ async function init() {
if (composerDeliveryModeSelect) {
composerDeliveryModeSelect.value = stored.composerDeliveryMode === 'steer' ? 'steer' : 'queue';
}
+ if (agentIndicatorStyleSelect) {
+ agentIndicatorStyleSelect.value = AGENT_INDICATOR_STYLES.includes(stored.agentIndicatorStyle) ? stored.agentIndicatorStyle : 'circuit';
+ }
if (selectionShortcutToggle) selectionShortcutToggle.checked = stored.selectionShortcutEnabled !== false;
if (pdfViewerToggle) pdfViewerToggle.checked = stored.pdfViewerEnabled === undefined || stored.pdfViewerEnabled === true;
if (autoGroupTabsToggle) autoGroupTabsToggle.checked = stored[AUTO_GROUP_TABS_KEY] !== false;
@@ -1430,6 +1436,11 @@ composerDeliveryModeSelect?.addEventListener('change', async () => {
await chrome.storage.local.set({ composerDeliveryMode: mode }).catch(() => {});
});
+agentIndicatorStyleSelect?.addEventListener('change', async () => {
+ const style = AGENT_INDICATOR_STYLES.includes(agentIndicatorStyleSelect.value) ? agentIndicatorStyleSelect.value : 'circuit';
+ await chrome.storage.local.set({ agentIndicatorStyle: style }).catch(() => {});
+});
+
downloadDirectoryInput?.addEventListener('input', () => {
downloadDirectoryInput.setCustomValidity('');
});
diff --git a/src/firefox/src/config-transfer.js b/src/firefox/src/config-transfer.js
index e71dd8e95..ffe34a476 100644
--- a/src/firefox/src/config-transfer.js
+++ b/src/firefox/src/config-transfer.js
@@ -27,6 +27,7 @@ export const DEFAULT_CONFIG_SETTINGS = Object.freeze({
[UI_SCALE_STORAGE_KEY]: 100,
verboseMode: false,
composerDeliveryMode: 'queue',
+ agentIndicatorStyle: 'circuit',
selectionShortcutEnabled: true,
[AUTO_GROUP_TABS_KEY]: true,
helpImproveWebBrain: true,
@@ -198,6 +199,7 @@ const NUMBER_KEYS = new Set([
]);
const STRING_KEYS = new Set([
'composerDeliveryMode',
+ 'agentIndicatorStyle',
'clarifyTimeoutPolicy',
'leanMode',
'visionMode',
@@ -262,6 +264,7 @@ function validSettingValue(key, value) {
// 'on' is Auto's name from before the option was renamed (currentSettingValue).
if (key === 'visionMode') return ['auto', 'on', 'off'].includes(value);
if (key === 'visionQuality') return ['economy', 'balanced', 'sharp'].includes(value);
+ if (key === 'agentIndicatorStyle') return ['circuit', 'aurora', 'scan', 'gears', 'classic'].includes(value);
if (key === 'decisionBaseUrl') {
if (typeof value !== 'string') return false;
try { resolveDecisionConfig({ decisionProvider: 'local', decisionBaseUrl: value }); return true; }
diff --git a/src/firefox/src/content/agent-visual-indicator.js b/src/firefox/src/content/agent-visual-indicator.js
index dacd74186..93e3280a4 100644
--- a/src/firefox/src/content/agent-visual-indicator.js
+++ b/src/firefox/src/content/agent-visual-indicator.js
@@ -1,15 +1,24 @@
/**
* WebBrain Agent Visual Indicator (content script)
*
- * Renders an animated purple inset glow around the page viewport while
- * the agent is operating on this tab, a "Stop WebBrain" floating button,
- * and a large WebBrain-purple cursor/outline on the element currently
- * being acted on. The base indicator follows Anthropic's Claude-for-Chrome
- * extension pattern, recolored for WebBrain's accent (#6c63ff).
+ * While the agent is operating on this tab it draws:
+ * - an effect around the viewport edges, chosen in Settings → General →
+ * "Agent activity effect" (storage key `agentIndicatorStyle`):
+ * circuit (default) — circuit traces grow in from the edges; signals run
+ * along them and their pads fire neighbouring pads
+ * aurora — a soft light band drifts around the frame
+ * scan — corner brackets and a slow scanning beam
+ * gears — meshing cog trains turn in the corners
+ * classic — the original pulsing inset glow
+ * - a "Stop WebBrain" floating button,
+ * - the agent cursor and a ring on the element being acted on. The cursor
+ * keeps one size: it glides to each target, presses once with a ripple on
+ * clicks, and between actions rests where it last acted, slowly fading in
+ * and out instead of disappearing.
*
* Lifecycle messages from the service worker:
*
- * WB_SHOW_AGENT_INDICATORS — agent run started → fade in border + button
+ * WB_SHOW_AGENT_INDICATORS — agent run started → fade in effect + button
* WB_HIDE_AGENT_INDICATORS — agent run ended → fade out + remove
* WB_AGENT_INDICATOR_HEARTBEAT — refresh the active-run lease without
* changing screenshot visibility
@@ -22,43 +31,61 @@
* agent.abort(tabId) the same way the sidepanel's Stop button does.
*
* Self-contained — no imports, runs in the page's content-script world.
- * z-index uses the max signed 32-bit value so the indicator sits above
- * site overlays/modals but never accidentally swallows page input
- * (border has pointer-events: none; button uses pointer-events: auto).
+ * z-index uses the max signed 32-bit range so the indicator sits above
+ * site overlays/modals but never accidentally swallows page input: every
+ * element is pointer-events: none except the Stop button. Every element is
+ * registered in window.__wbPageMonitorDecorations so the page monitor ignores
+ * it. Canvas effects animate with requestAnimationFrame and the cursor with
+ * CSS transitions and the Web Animations API, because the page monitor
+ * observes `style` attributes: a running indicator must not write DOM
+ * attributes every frame. prefers-reduced-motion gets still frames.
*/
(function () {
if (window.__webbrainAgentIndicatorInjected) return;
window.__webbrainAgentIndicatorInjected = true;
- const TARGET_CURSOR_TTL_MS = 3000;
- // The background refreshes this lease every 20 seconds. If its worker
- // disappears before the normal HIDE message, the page-owned UI cleans
- // itself up instead of leaving a permanent glow and Stop button.
+ // How long the target ring and the fully opaque cursor stay after an
+ // action before the cursor settles into its resting state.
+ const TARGET_RING_TTL_MS = 1400;
+ // The background refreshes this lease every 20 seconds. If the background
+ // stops before the normal HIDE message, the page-owned UI cleans itself up
+ // instead of leaving a permanent effect and Stop button.
const INDICATOR_HEARTBEAT_TIMEOUT_MS = 65_000;
- let borderEl = null;
+ const STYLE_STORAGE_KEY = 'agentIndicatorStyle';
+ const DEFAULT_STYLE = 'circuit';
+ const STYLES = ['circuit', 'aurora', 'scan', 'gears', 'classic'];
+
+ let effectStyle = DEFAULT_STYLE;
+ let styleLoaded = false;
+ let effect = null;
let stopContainerEl = null;
- let targetCursorEl = null;
let targetOutlineEl = null;
+ let cursor = null;
let targetElement = null;
let targetRectOverride = null;
- let targetTimer = null;
+ let ringTimer = null;
let targetRaf = 0;
let indicatorHeartbeatTimer = null;
let indicatorsActive = false;
+ let suspendedForToolUse = false;
// Saved visibility state during HIDE_FOR_TOOL_USE so SHOW_AFTER_TOOL_USE
// can restore the right thing (don't want to show indicators that
// weren't on before the screenshot).
- let savedBorderVisible = false;
let savedStopVisible = false;
- let savedTargetCursorVisible = false;
let savedTargetOutlineVisible = false;
+ const decorations = () => (window.__wbPageMonitorDecorations ??= new WeakSet());
+ const reduceMotionQuery = typeof window.matchMedia === 'function'
+ ? window.matchMedia('(prefers-reduced-motion: reduce)')
+ : { matches: false };
+ const prefersReducedMotion = () => reduceMotionQuery.matches === true;
+
function injectStyles() {
if (document.getElementById('webbrain-agent-styles')) return;
const style = document.createElement('style');
style.id = 'webbrain-agent-styles';
- (window.__wbPageMonitorDecorations ??= new WeakSet()).add(style);
+ decorations().add(style);
style.textContent = `
@keyframes webbrain-pulse {
0% {
@@ -81,11 +108,6 @@
}
}
- @keyframes webbrain-target-pop {
- 0% { opacity: 0; }
- 100% { opacity: 1; }
- }
-
@keyframes webbrain-target-ring {
0%, 100% {
box-shadow:
@@ -102,30 +124,1407 @@
(document.head || document.documentElement).appendChild(style);
}
- 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;
- pointer-events: none;
- z-index: 2147483646;
- opacity: 0;
- transition: opacity 0.3s ease-in-out;
- animation: webbrain-pulse 2s ease-in-out infinite;
- box-shadow:
- inset 0 0 10px rgba(108, 99, 255, 0.5),
- inset 0 0 20px rgba(108, 99, 255, 0.3),
- inset 0 0 30px rgba(108, 99, 255, 0.1);
- `;
- return el;
+ /* ------------------------------------------------------------------------
+ * Edge effects
+ * ---------------------------------------------------------------------- */
+
+ const TAU = Math.PI * 2;
+ // WebBrain purples (#6c63ff family) only.
+ const C = {
+ base: [108, 99, 255], // #6c63ff accent
+ soft: [141, 134, 255], // #8d86ff
+ pale: [169, 163, 255], // #a9a3ff
+ mist: [199, 195, 255], // #c7c3ff
+ deep: [90, 82, 213], // #5a52d5
+ core: [244, 242, 255], // signal highlight
+ };
+ const rgba = (c, a) => `rgba(${c[0]},${c[1]},${c[2]},${a <= 0 ? 0 : a >= 1 ? 1 : a.toFixed(4)})`;
+ const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
+ const lerp = (a, b, t) => a + (b - a) * t;
+ const rand = (a, b) => a + Math.random() * (b - a);
+ const randInt = (a, b) => Math.floor(a + Math.random() * (b - a + 1));
+ const pick = list => list[Math.floor(Math.random() * list.length)];
+ const easeOutCubic = t => 1 - Math.pow(1 - t, 3);
+ const easeInOutSine = t => -(Math.cos(Math.PI * t) - 1) / 2;
+ const easeOutBack = t => { const c1 = 1.70158, c3 = c1 + 1; return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2); };
+
+ function sprite(color, size, stops) {
+ const canvas = document.createElement('canvas');
+ canvas.width = canvas.height = size;
+ const ctx = canvas.getContext('2d');
+ const r = size / 2;
+ const grad = ctx.createRadialGradient(r, r, 0, r, r, r);
+ for (const [offset, alpha] of stops) grad.addColorStop(offset, rgba(color, alpha));
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, size, size);
+ return canvas;
+ }
+
+ // Soft inset edge light, a quieter cousin of the classic box-shadow glow.
+ function vignette(ctx, w, h, alpha, size) {
+ if (alpha <= 0.002) return;
+ const s = Math.min(size, w / 2, h / 2);
+ for (const [x, y, bw, bh, x0, y0, x1, y1] of [
+ [0, 0, w, s, 0, 0, 0, s],
+ [0, h - s, w, s, 0, h, 0, h - s],
+ [0, 0, s, h, 0, 0, s, 0],
+ [w - s, 0, s, h, w, 0, w - s, 0],
+ ]) {
+ const g = ctx.createLinearGradient(x0, y0, x1, y1);
+ g.addColorStop(0, rgba(C.base, alpha));
+ g.addColorStop(0.45, rgba(C.base, alpha * 0.32));
+ g.addColorStop(1, rgba(C.base, 0));
+ ctx.fillStyle = g;
+ ctx.fillRect(x, y, bw, bh);
+ }
+ }
+
+ function makePath(pts) {
+ const n = pts.length;
+ const xs = new Float32Array(n), ys = new Float32Array(n), cum = new Float32Array(n);
+ let len = 0;
+ for (let k = 0; k < n; k++) {
+ xs[k] = pts[k][0]; ys[k] = pts[k][1];
+ if (k) len += Math.hypot(xs[k] - xs[k - 1], ys[k] - ys[k - 1]);
+ cum[k] = len;
+ }
+ return { xs, ys, cum, len, n };
+ }
+ function pointAt(p, s, out) {
+ if (s <= 0) { out.x = p.xs[0]; out.y = p.ys[0]; return out; }
+ if (s >= p.len) { out.x = p.xs[p.n - 1]; out.y = p.ys[p.n - 1]; return out; }
+ let k = 1;
+ while (k < p.n - 1 && p.cum[k] < s) k++;
+ const seg = p.cum[k] - p.cum[k - 1] || 1;
+ const u = (s - p.cum[k - 1]) / seg;
+ out.x = p.xs[k - 1] + (p.xs[k] - p.xs[k - 1]) * u;
+ out.y = p.ys[k - 1] + (p.ys[k] - p.ys[k - 1]) * u;
+ return out;
+ }
+ const subPathPoint = { x: 0, y: 0 };
+ function subPath(ctx, p, s0, s1) {
+ s0 = clamp(s0, 0, p.len); s1 = clamp(s1, 0, p.len);
+ if (s1 - s0 < 0.01) return false;
+ pointAt(p, s0, subPathPoint); ctx.moveTo(subPathPoint.x, subPathPoint.y);
+ for (let k = 1; k < p.n - 1; k++) if (p.cum[k] > s0 && p.cum[k] < s1) ctx.lineTo(p.xs[k], p.ys[k]);
+ pointAt(p, s1, subPathPoint); ctx.lineTo(subPathPoint.x, subPathPoint.y);
+ return true;
+ }
+
+ // One full-viewport, click-through canvas. Layout properties are !important
+ // so page rules such as `canvas { max-width: 100%; height: auto }` cannot
+ // resize or reposition it.
+ class Layer {
+ constructor(id, scale = 1) {
+ this.id = id; this.scale = scale;
+ this.el = null; this.ctx = null; this.w = 0; this.h = 0;
+ }
+ mount(root) {
+ if (this.el) return;
+ const el = document.createElement('canvas');
+ el.id = this.id;
+ el.setAttribute('aria-hidden', 'true');
+ decorations().add(el);
+ el.style.cssText = [
+ 'position: fixed !important', 'top: 0 !important', 'left: 0 !important',
+ 'right: 0 !important', 'bottom: 0 !important', 'width: 100% !important', 'height: 100% !important',
+ 'max-width: none !important', 'max-height: none !important', 'margin: 0 !important',
+ 'padding: 0 !important', 'border: 0 !important', 'transform: none !important',
+ 'background: transparent !important', 'pointer-events: none !important',
+ 'z-index: 2147483646 !important', 'display: none !important',
+ 'opacity: 0', 'transition: opacity 0.45s ease',
+ ].join('; ');
+ root.appendChild(el);
+ this.el = el;
+ this.ctx = el.getContext('2d');
+ }
+ setDisplay(on) { this.el?.style.setProperty('display', on ? 'block' : 'none', 'important'); }
+ fit() {
+ const w = this.el.clientWidth, h = this.el.clientHeight;
+ if (!w || !h) return false;
+ const ratio = Math.min(window.devicePixelRatio || 1, 2) * this.scale;
+ const pw = Math.max(1, Math.round(w * ratio)), ph = Math.max(1, Math.round(h * ratio));
+ const changed = pw !== this.el.width || ph !== this.el.height || w !== this.w || h !== this.h;
+ this.w = w; this.h = h;
+ if (pw !== this.el.width) this.el.width = pw;
+ if (ph !== this.el.height) this.el.height = ph;
+ this.ctx.setTransform(pw / w, 0, 0, ph / h, 0, 0);
+ return changed;
+ }
+ clear() {
+ if (!this.ctx) return;
+ this.ctx.save();
+ this.ctx.setTransform(1, 0, 0, 1, 0, 0);
+ this.ctx.clearRect(0, 0, this.el.width, this.el.height);
+ this.ctx.restore();
+ }
+ remove() { this.el?.remove(); this.el = null; this.ctx = null; }
+ }
+
+ class Effect {
+ constructor() {
+ this.layers = [];
+ this.active = false; this.mounted = false; this.suspended = false;
+ this.raf = 0; this.t = 0; this.last = 0; this.acc = 0; this.w = 0; this.h = 0;
+ this.minFrame = 0; // seconds between drawn frames; 0 = every display frame
+ this.hideTimer = 0; this.fitRaf = 0;
+ this.onResize = () => this.requestFit();
+ }
+ get still() { return prefersReducedMotion(); }
+ mount(root) {
+ if (this.mounted) return;
+ for (const layer of this.layers) layer.mount(root);
+ this.mounted = true;
+ window.addEventListener('resize', this.onResize);
+ }
+ requestFit() {
+ if (this.fitRaf || !this.active) return;
+ this.fitRaf = requestAnimationFrame(() => { this.fitRaf = 0; this.fit(false); });
+ }
+ fit(fresh) {
+ let changed = false;
+ for (const layer of this.layers) changed = layer.fit() || changed;
+ const first = this.layers[0];
+ if (!first.w) return;
+ this.w = first.w; this.h = first.h;
+ if (changed || fresh) this.layout(first.w, first.h, fresh);
+ if (this.active && !this.raf) this.draw(0);
+ }
+ show(root) {
+ this.mount(root);
+ clearTimeout(this.hideTimer);
+ const wasActive = this.active;
+ this.active = true;
+ if (!this.suspended) for (const layer of this.layers) layer.setDisplay(true);
+ if (!wasActive) { this.t = 0; this.onShow(); this.fit(true); }
+ this.loop();
+ requestAnimationFrame(() => requestAnimationFrame(() => {
+ if (this.active) for (const layer of this.layers) if (layer.el) layer.el.style.opacity = '1';
+ }));
+ }
+ hide() {
+ if (!this.active) return;
+ this.active = false;
+ for (const layer of this.layers) if (layer.el) layer.el.style.opacity = '0';
+ clearTimeout(this.hideTimer);
+ this.hideTimer = setTimeout(() => {
+ if (this.active) return;
+ this.halt();
+ for (const layer of this.layers) { layer.clear(); layer.setDisplay(false); }
+ }, 500);
+ }
+ // Screenshot capture: hide instantly and stop drawing, then continue.
+ suspend() {
+ this.suspended = true;
+ for (const layer of this.layers) layer.setDisplay(false);
+ this.halt();
+ }
+ resume() {
+ this.suspended = false;
+ if (!this.active) return;
+ for (const layer of this.layers) layer.setDisplay(true);
+ this.fit(false);
+ this.loop();
+ }
+ loop() {
+ if (this.raf || this.suspended || !this.active) return;
+ if (this.still) { this.draw(0); return; }
+ this.last = performance.now();
+ this.acc = 0;
+ const tick = now => {
+ this.raf = requestAnimationFrame(tick);
+ this.acc += Math.max((now - this.last) / 1000, 0);
+ this.last = now;
+ if (this.acc < this.minFrame - 0.002) return;
+ const dt = Math.min(this.acc, 1 / 20);
+ this.acc = 0;
+ this.t += dt;
+ this.step(dt);
+ this.draw(dt);
+ };
+ this.raf = requestAnimationFrame(tick);
+ }
+ halt() { if (this.raf) cancelAnimationFrame(this.raf); this.raf = 0; }
+ refreshMotion() { if (!this.active) return; this.halt(); this.loop(); }
+ destroy() {
+ this.halt();
+ clearTimeout(this.hideTimer);
+ if (this.fitRaf) cancelAnimationFrame(this.fitRaf);
+ this.fitRaf = 0;
+ window.removeEventListener('resize', this.onResize);
+ for (const layer of this.layers) layer.remove();
+ this.mounted = false; this.active = false;
+ }
+ onShow() {}
+ layout() {}
+ step() {}
+ draw() {}
+ target() {}
+ }
+
+ /* circuit: traces on a grid (orthogonal and 45° runs, no crossings) grow in
+ from every edge. Signals travel them; pads flash when hit and fire
+ neighbouring pads through faint synapse links in short cascades. */
+ class NeuralCircuit extends Effect {
+ constructor() {
+ super();
+ this.layer = new Layer('webbrain-agent-effect', 1);
+ this.layers = [this.layer];
+ this.cache = document.createElement('canvas');
+ this.sprHead = sprite(C.soft, 64, [[0, 1], [0.18, 0.7], [0.45, 0.18], [1, 0]]);
+ this.sprCore = sprite(C.core, 32, [[0, 1], [0.35, 0.65], [1, 0]]);
+ this.sprFlash = sprite(C.base, 96, [[0, 0.9], [0.22, 0.45], [0.55, 0.1], [1, 0]]);
+ this.traces = []; this.pads = []; this.vias = []; this.links = []; this.pulses = []; this.edges = [];
+ this.bands = null; this.rx = 1; this.ry = 1;
+ this.spawnAcc = 0; this.intro = 0; this.introDur = 1.4; this.maxPulses = 56; this.rate = 8;
+ this.tmpA = { x: 0, y: 0 }; this.tmpB = { x: 0, y: 0 }; this.heads = [];
+ }
+ onShow() { this.intro = 0; this.pulses.length = 0; this.spawnAcc = 0; }
+ layout(w, h, fresh) {
+ const g = 8;
+ const cols = Math.max(6, Math.round(w / g)), rows = Math.max(6, Math.round(h / g));
+ const sx = w / cols, sy = h / rows;
+ const depthPx = clamp(Math.min(w, h) * 0.13, 50, 130);
+ const maxCells = Math.max(4, Math.round(depthPx / Math.max(sx, sy)));
+ this.depthPx = depthPx;
+ const W1 = cols + 1;
+ const occ = new Int32Array(W1 * (rows + 1)).fill(-1);
+ const inside = (i, j) => i >= 0 && j >= 0 && i <= cols && j <= rows;
+ const interior = (i, j) => i > 0 && j > 0 && i < cols && j < rows;
+ const clearAt = (i, j, id) => {
+ for (let dj = -1; dj <= 1; dj++) for (let di = -1; di <= 1; di++) {
+ const ii = i + di, jj = j + dj;
+ if (!inside(ii, jj)) continue;
+ const o = occ[jj * W1 + ii];
+ if (o !== -1 && o !== id) return false;
+ }
+ return true;
+ };
+ const mark = (i, j, id) => { occ[j * W1 + i] = id; };
+ const unmark = cells => { for (const [i, j] of cells) occ[j * W1 + i] = -1; };
+ const edges = [
+ { len: cols, at: k => [k, 0], inw: [0, 1], alg: [1, 0], dep: (i, j) => j },
+ { len: cols, at: k => [k, rows], inw: [0, -1], alg: [1, 0], dep: (i, j) => rows - j },
+ { len: rows, at: k => [0, k], inw: [1, 0], alg: [0, 1], dep: i => i },
+ { len: rows, at: k => [cols, k], inw: [-1, 0], alg: [0, 1], dep: i => cols - i },
+ ];
+ this.edges = edges;
+ const route = (e, i, j, plan, id, maxD) => {
+ const cells = [];
+ for (const [[dx, dy], n] of plan) {
+ let moved = 0;
+ for (let s = 0; s < n; s++) {
+ const ni = i + dx, nj = j + dy;
+ if (!interior(ni, nj) || e.dep(ni, nj) > maxD || !clearAt(ni, nj, id)) break;
+ i = ni; j = nj; mark(i, j, id); cells.push([i, j]); moved++;
+ }
+ if (moved < n) break;
+ }
+ return cells;
+ };
+
+ const raw = [];
+ let id = 0;
+ for (const e of edges) {
+ const [ix, iy] = e.inw, [ax, ay] = e.alg;
+ let k = randInt(2, 4);
+ while (k <= e.len - 2) {
+ const [i0, j0] = e.at(k);
+ if (Math.random() < 0.74 && clearAt(i0, j0, id)) {
+ mark(i0, j0, id);
+ const side = Math.random() < 0.5 ? -1 : 1;
+ const diag = [ix + side * ax, iy + side * ay];
+ const par = [side * ax, side * ay];
+ const back = [ix - side * ax, iy - side * ay];
+ const r = Math.random();
+ const plan = [[[ix, iy], randInt(2, 6)]];
+ if (r < 0.38) plan.push([diag, randInt(1, 4)], [[ix, iy], randInt(1, 6)]);
+ else if (r < 0.72) plan.push([diag, randInt(1, 3)], [par, randInt(3, 10)]);
+ else if (r < 0.88) plan.push([diag, randInt(2, 4)], [back, randInt(1, 3)], [[ix, iy], randInt(1, 3)]);
+ else plan.push([[ix, iy], randInt(2, 7)]);
+ const maxD = Math.max(3, Math.round(maxCells * rand(0.45, 1)));
+ const cells = route(e, i0, j0, plan, id, maxD);
+ if (cells.length >= 3) {
+ raw.push({ id, edge: e, side, cells: [[i0, j0], ...cells] });
+ id++;
+ k += randInt(2, 6);
+ continue;
+ }
+ unmark(cells);
+ occ[j0 * W1 + i0] = -1;
+ }
+ k += randInt(1, 3);
+ }
+ }
+ for (const tr of raw) {
+ if (tr.cells.length < 7 || Math.random() > 0.36) continue;
+ const m = randInt(2, tr.cells.length - 4);
+ const [bi, bj] = tr.cells[m];
+ const e = tr.edge, s = -tr.side;
+ const [ix, iy] = e.inw, [ax, ay] = e.alg;
+ const plan = Math.random() < 0.55
+ ? [[[ix + s * ax, iy + s * ay], randInt(2, 4)], [[ix, iy], randInt(1, 4)]]
+ : [[[ix + s * ax, iy + s * ay], 1], [[s * ax, s * ay], randInt(2, 6)]];
+ const cells = route(e, bi, bj, plan, tr.id, maxCells);
+ if (cells.length >= 3) tr.branch = { at: m, cells: [[bi, bj], ...cells] };
+ else unmark(cells);
+ }
+
+ const px = ([i, j]) => [i * sx, j * sy];
+ const simplify = cells => {
+ if (cells.length < 3) return cells.slice();
+ const out = [cells[0]];
+ for (let k = 1; k < cells.length - 1; k++) {
+ const a = cells[k - 1], b = cells[k], c = cells[k + 1];
+ if (b[0] - a[0] !== c[0] - b[0] || b[1] - a[1] !== c[1] - b[1]) out.push(b);
+ }
+ out.push(cells[cells.length - 1]);
+ return out;
+ };
+ const depthAlpha = (x, y) => lerp(0.62, 0.16, clamp(Math.min(x, y, w - x, h - y) / depthPx, 0, 1));
+ const traces = [], pads = [], vias = [], links = [];
+ for (const r of raw) {
+ const pts = simplify(r.cells).map(px);
+ pts[0] = [pts[0][0] - r.edge.inw[0] * 3, pts[0][1] - r.edge.inw[1] * 3]; // start just off-screen
+ const path = makePath(pts);
+ const end = pts[pts.length - 1];
+ const neuron = Math.random() < 0.17;
+ const tr = {
+ edge: r.edge, path, lw: Math.random() < 0.22 ? 1.6 : 1.1,
+ along: r.edge.alg[0] ? pts[0][0] : pts[0][1], x0: pts[0][0], y0: pts[0][1],
+ delay: rand(0, 0.34), grow: clamp(path.len / 230, 0.22, 0.72), booted: false, branch: null,
+ };
+ tr.pad = { x: end[0], y: end[1], r: neuron ? rand(2.7, 3.3) : rand(1.6, 2.2), neuron, flash: 0, links: [], trace: tr, branch: null, a: depthAlpha(end[0], end[1]) };
+ pads.push(tr.pad);
+ for (let k = 1; k < pts.length - 1; k++) if (Math.random() < 0.16) vias.push({ x: pts[k][0], y: pts[k][1], a: depthAlpha(pts[k][0], pts[k][1]) * 0.9 });
+ if (r.branch) {
+ let s = 3;
+ for (let k = 1; k <= r.branch.at; k++) s += Math.hypot((r.cells[k][0] - r.cells[k - 1][0]) * sx, (r.cells[k][1] - r.cells[k - 1][1]) * sy);
+ const bpts = simplify(r.branch.cells).map(px);
+ const bpath = makePath(bpts);
+ const bend = bpts[bpts.length - 1];
+ const br = { path: bpath, s, booted: false };
+ br.t0 = tr.delay + (1 - Math.cbrt(1 - clamp(s / path.len, 0, 0.999))) * tr.grow;
+ br.grow = clamp(bpath.len / 230, 0.18, 0.5);
+ br.pad = { x: bend[0], y: bend[1], r: rand(1.5, 2), neuron: false, flash: 0, links: [], trace: tr, branch: br, a: depthAlpha(bend[0], bend[1]) };
+ pads.push(br.pad);
+ tr.branch = br;
+ }
+ traces.push(tr);
+ }
+ for (let a = 0; a < pads.length; a++) {
+ const A = pads[a];
+ for (let b = a + 1; b < pads.length; b++) {
+ const B = pads[b];
+ if (A.trace === B.trace || A.links.length > 1 || B.links.length > 1) continue;
+ const dx = B.x - A.x, dy = B.y - A.y, d = Math.hypot(dx, dy);
+ if (d < 16 || d > 54 || Math.random() < 0.4) continue;
+ const bend = rand(-0.35, 0.35) * d;
+ const cx = (A.x + B.x) / 2 - (dy / d) * bend, cy = (A.y + B.y) / 2 + (dx / d) * bend;
+ const pts = [];
+ for (let q = 0; q <= 12; q++) {
+ const t = q / 12, u = 1 - t;
+ pts.push([u * u * A.x + 2 * u * t * cx + t * t * B.x, u * u * A.y + 2 * u * t * cy + t * t * B.y]);
+ }
+ const link = { a: A, b: B, path: makePath(pts), alpha: Math.min(A.a, B.a) };
+ A.links.push(link); B.links.push(link); links.push(link);
+ }
+ }
+ this.traces = traces; this.pads = pads; this.vias = vias; this.links = links;
+ this.introDur = Math.max(0.6, ...traces.map(t => Math.max(t.delay + t.grow, t.branch ? t.branch.t0 + t.branch.grow : 0))) + 0.3;
+ this.rate = (w + h) * 2 / 520;
+ this.pulses.length = 0;
+ if (!fresh) this.intro = Infinity;
+
+ const cacheCtx = this.cache.getContext('2d');
+ for (const tr of traces) { tr.gMain = this.depthGrad(this.layer.ctx, tr); tr.gCache = this.depthGrad(cacheCtx, tr); }
+ this.paintCache();
+
+ // Everything this effect draws stays within `band` of an edge, so only
+ // those four strips are cleared and composited (in whole device pixels,
+ // so the cache copies 1:1).
+ const W = this.layer.el.width, H = this.layer.el.height;
+ this.rx = W / w; this.ry = H / h;
+ const band = depthPx + 40;
+ const bx = Math.ceil(band * this.rx), by = Math.ceil(band * this.ry);
+ this.bands = 2 * bx >= W || 2 * by >= H
+ ? [[0, 0, W, H]]
+ : [[0, 0, W, by], [0, H - by, W, by], [0, by, bx, H - 2 * by], [W - bx, by, bx, H - 2 * by]];
+ }
+ depthGrad(ctx, tr) {
+ const [ix, iy] = tr.edge.inw;
+ const x0 = ix ? (ix > 0 ? 0 : this.w) : tr.x0;
+ const y0 = iy ? (iy > 0 ? 0 : this.h) : tr.y0;
+ const g = ctx.createLinearGradient(x0, y0, x0 + ix * this.depthPx, y0 + iy * this.depthPx);
+ g.addColorStop(0, rgba(C.base, 0.56));
+ g.addColorStop(0.5, rgba(C.base, 0.3));
+ g.addColorStop(1, rgba(C.base, 0.08));
+ return g;
+ }
+ paintCache() {
+ const L = this.layer, c = this.cache;
+ c.width = L.el.width; c.height = L.el.height;
+ const x = c.getContext('2d');
+ x.setTransform(L.el.width / L.w, 0, 0, L.el.height / L.h, 0, 0);
+ x.lineCap = 'round'; x.lineJoin = 'round';
+ for (const tr of this.traces) {
+ x.strokeStyle = tr.gCache; x.lineWidth = tr.lw;
+ x.beginPath(); subPath(x, tr.path, 0, tr.path.len); x.stroke();
+ if (tr.branch) { x.lineWidth = 1; x.beginPath(); subPath(x, tr.branch.path, 0, tr.branch.path.len); x.stroke(); }
+ }
+ this.paintExtras(x, 1);
+ for (const p of this.pads) this.paintPad(x, p, 1);
+ }
+ paintExtras(x, alpha) {
+ x.globalAlpha = alpha;
+ x.setLineDash([1.5, 3.5]); x.lineWidth = 1;
+ for (const lk of this.links) { x.strokeStyle = rgba(C.soft, lk.alpha * 0.6); x.beginPath(); subPath(x, lk.path, 0, lk.path.len); x.stroke(); }
+ x.setLineDash([]);
+ for (const v of this.vias) { x.strokeStyle = rgba(C.base, v.a); x.beginPath(); x.arc(v.x, v.y, 2.3, 0, TAU); x.stroke(); }
+ x.globalAlpha = 1;
+ }
+ paintPad(x, p, scale) {
+ const r = p.r * scale;
+ if (r <= 0.05) return;
+ if (p.neuron) {
+ x.globalAlpha = clamp(p.a * 0.85 * scale, 0, 1);
+ x.drawImage(this.sprFlash, p.x - 13, p.y - 13, 26, 26);
+ x.globalAlpha = 1;
+ }
+ x.fillStyle = rgba(C.base, Math.min(1, p.a * 1.5));
+ x.beginPath(); x.arc(p.x, p.y, r, 0, TAU); x.fill();
+ x.strokeStyle = rgba(C.base, p.a * 0.75); x.lineWidth = 1;
+ x.beginPath(); x.arc(p.x, p.y, r + 2.4 * scale, 0, TAU); x.stroke();
+ }
+ step(dt) {
+ if (this.intro < this.introDur) {
+ this.intro += dt;
+ for (const tr of this.traces) {
+ if (!tr.booted && this.intro >= tr.delay + tr.grow) { tr.booted = true; tr.pad.flash = Math.max(tr.pad.flash, 0.75); }
+ const br = tr.branch;
+ if (br && !br.booted && this.intro >= br.t0 + br.grow) { br.booted = true; br.pad.flash = Math.max(br.pad.flash, 0.6); }
+ }
+ }
+ if (this.intro > this.introDur * 0.75) {
+ this.spawnAcc += dt * this.rate;
+ while (this.spawnAcc >= 1) { this.spawnAcc -= 1; this.spawn(); }
+ }
+ for (let k = this.pulses.length - 1; k >= 0; k--) {
+ const q = this.pulses[k];
+ if (q.wait > 0) { q.wait -= dt; continue; }
+ const prev = q.s;
+ q.s += q.dir * q.speed * dt;
+ const br = q.trace && q.trace.branch;
+ if (br && q.dir > 0 && prev < br.s && q.s >= br.s && Math.random() < 0.55) {
+ this.add(br.path, 1, { end: br.pad, speed: q.speed * 0.92, tail: q.tail * 0.8, gen: q.gen });
+ }
+ if (!q.arrived && (q.dir > 0 ? q.s >= q.path.len : q.s <= 0)) { q.arrived = true; this.arrive(q); }
+ if (q.dir > 0 ? q.s - q.tail >= q.path.len : q.s + q.tail <= 0) this.pulses.splice(k, 1);
+ }
+ const decay = dt * 1.6;
+ for (const p of this.pads) if (p.flash > 0) p.flash = Math.max(0, p.flash - decay);
+ }
+ add(path, dir, o = {}) {
+ if (this.pulses.length >= this.maxPulses) return null;
+ const q = {
+ path, dir, s: dir > 0 ? 0 : path.len,
+ speed: o.speed ?? rand(150, 235), tail: o.tail ?? rand(36, 64),
+ end: o.end || null, spark: !!o.spark, gen: o.gen || 0, wait: o.wait || 0,
+ trace: o.trace || null, arrived: false,
+ };
+ this.pulses.push(q);
+ return q;
+ }
+ spawn() {
+ if (!this.traces.length) return;
+ const tr = pick(this.traces);
+ if (Math.random() < 0.7) this.add(tr.path, 1, { end: tr.pad, trace: tr });
+ else { tr.pad.flash = Math.max(tr.pad.flash, 0.7); this.add(tr.path, -1, {}); }
+ }
+ arrive(q) {
+ const p = q.end;
+ if (!p) return;
+ p.flash = 1;
+ if (q.spark) {
+ if (Math.random() < 0.7) this.add((p.branch || p.trace).path, -1, { gen: q.gen });
+ return;
+ }
+ if (q.gen < 3 && p.links.length && Math.random() < 0.55) {
+ const lk = pick(p.links), fwd = lk.a === p;
+ this.add(lk.path, fwd ? 1 : -1, { end: fwd ? lk.b : lk.a, spark: true, speed: rand(300, 380), tail: rand(14, 22), gen: q.gen + 1, wait: 0.06 });
+ }
+ }
+ draw() {
+ const L = this.layer, x = L.ctx, w = L.w, h = L.h;
+ if (!w || !this.bands) return;
+ const rx = this.rx, ry = this.ry;
+ for (const b of this.bands) x.clearRect(b[0] / rx, b[1] / ry, b[2] / rx, b[3] / ry);
+ const still = this.still;
+ const inIntro = !still && this.intro < this.introDur;
+ const breathe = still ? 1 : 0.8 + 0.2 * Math.sin(this.t * TAU / 3.6);
+ vignette(x, w, h, 0.12 * breathe * (inIntro ? clamp(this.intro / 0.5, 0, 1) : 1), 28);
+ if (inIntro) this.drawIntro(x);
+ else {
+ x.globalAlpha = 0.86 + 0.14 * breathe;
+ for (const b of this.bands) x.drawImage(this.cache, b[0], b[1], b[2], b[3], b[0] / rx, b[1] / ry, b[2] / rx, b[3] / ry);
+ x.globalAlpha = 1;
+ }
+ if (still) return;
+ x.globalCompositeOperation = 'lighter';
+ for (const p of this.pads) {
+ if (p.flash <= 0) continue;
+ const f = p.flash, size = 10 + 34 * f;
+ x.globalAlpha = f * 0.95;
+ x.drawImage(this.sprFlash, p.x - size / 2, p.y - size / 2, size, size);
+ }
+ x.globalAlpha = 1;
+ x.globalCompositeOperation = 'source-over';
+ for (const p of this.pads) {
+ if (p.flash <= 0) continue;
+ const f = p.flash;
+ x.strokeStyle = rgba(C.base, 0.55 * f * f); x.lineWidth = 1.2;
+ x.beginPath(); x.arc(p.x, p.y, p.r + 3 + (1 - f) * 15, 0, TAU); x.stroke();
+ x.fillStyle = rgba(C.mist, f);
+ x.beginPath(); x.arc(p.x, p.y, p.r * (1 + 0.3 * f), 0, TAU); x.fill();
+ }
+ for (const q of this.pulses) this.drawPulse(x, q);
+ }
+ drawIntro(x) {
+ const T = this.intro, heads = this.heads;
+ heads.length = 0;
+ x.lineCap = 'round'; x.lineJoin = 'round';
+ for (const tr of this.traces) {
+ const k = clamp((T - tr.delay) / tr.grow, 0, 1);
+ if (k <= 0) continue;
+ const s1 = easeOutCubic(k) * tr.path.len;
+ x.strokeStyle = tr.gMain; x.lineWidth = tr.lw;
+ x.beginPath(); subPath(x, tr.path, 0, s1); x.stroke();
+ if (k < 1) heads.push(pointAt(tr.path, s1, { x: 0, y: 0 }));
+ else this.paintPad(x, tr.pad, easeOutBack(clamp((T - tr.delay - tr.grow) / 0.3, 0, 1)));
+ const br = tr.branch;
+ if (br) {
+ const kb = clamp((T - br.t0) / br.grow, 0, 1);
+ if (kb > 0) {
+ const sb = easeOutCubic(kb) * br.path.len;
+ x.strokeStyle = tr.gMain; x.lineWidth = 1;
+ x.beginPath(); subPath(x, br.path, 0, sb); x.stroke();
+ if (kb < 1) heads.push(pointAt(br.path, sb, { x: 0, y: 0 }));
+ else this.paintPad(x, br.pad, easeOutBack(clamp((T - br.t0 - br.grow) / 0.3, 0, 1)));
+ }
+ }
+ }
+ const late = clamp((T - (this.introDur - 0.55)) / 0.45, 0, 1);
+ if (late > 0) this.paintExtras(x, late);
+ x.globalCompositeOperation = 'lighter';
+ for (const p of heads) {
+ x.drawImage(this.sprHead, p.x - 9, p.y - 9, 18, 18);
+ x.drawImage(this.sprCore, p.x - 3, p.y - 3, 6, 6);
+ }
+ x.globalCompositeOperation = 'source-over';
+ }
+ drawPulse(x, q) {
+ if (q.wait > 0) return;
+ const P = q.path;
+ const head = clamp(q.s, 0, P.len), tailS = clamp(q.s - q.dir * q.tail, 0, P.len);
+ if (Math.abs(head - tailS) > 0.5) {
+ const A = pointAt(P, tailS, this.tmpA), B = pointAt(P, head, this.tmpB);
+ const g = x.createLinearGradient(A.x, A.y, B.x, B.y);
+ g.addColorStop(0, rgba(C.base, 0));
+ g.addColorStop(0.6, rgba(C.base, q.spark ? 0.6 : 0.72));
+ g.addColorStop(1, rgba(C.mist, 1));
+ x.strokeStyle = g; x.lineWidth = q.spark ? 1.3 : 1.9; x.lineCap = 'round';
+ x.beginPath(); subPath(x, P, Math.min(head, tailS), Math.max(head, tailS)); x.stroke();
+ }
+ if (q.dir > 0 ? q.s <= P.len : q.s >= 0) {
+ const B = pointAt(P, head, this.tmpB);
+ const hs = q.spark ? 14 : 22;
+ // Solid bead first so the signal still reads on white pages, then the additive glow.
+ x.fillStyle = rgba(C.base, 0.95);
+ x.beginPath(); x.arc(B.x, B.y, q.spark ? 1.7 : 2.4, 0, TAU); x.fill();
+ x.globalCompositeOperation = 'lighter';
+ x.drawImage(this.sprHead, B.x - hs / 2, B.y - hs / 2, hs, hs);
+ x.drawImage(this.sprCore, B.x - 3.5, B.y - 3.5, 7, 7);
+ x.globalCompositeOperation = 'source-over';
+ }
+ }
+ // The agent acted on an element: fire the traces closest to it.
+ target(rect) {
+ if (!this.active || this.still || !this.traces.length) return;
+ const cx = rect.left + rect.width / 2, cy = rect.top + rect.height / 2;
+ const d = [cy, this.h - cy, cx, this.w - cx];
+ const e = this.edges[d.indexOf(Math.min(...d))];
+ const along = e.alg[0] ? cx : cy;
+ this.traces
+ .filter(t => t.edge === e)
+ .sort((a, b) => Math.abs(a.along - along) - Math.abs(b.along - along))
+ .slice(0, 5)
+ .forEach((t, n) => this.add(t.path, 1, { end: t.pad, trace: t, speed: 320, tail: 80, wait: n * 0.06, gen: 3 }));
+ }
}
+ /* aurora: a soft band hugs the frame, built from lobes in five purples that
+ drift around the perimeter at different speeds, so the glow keeps
+ shifting instead of pulsing uniformly. A crisp rim carries two comets
+ that orbit in opposite directions and flare when they meet. */
+ class Aurora extends Effect {
+ constructor() {
+ super();
+ this.glow = new Layer('webbrain-agent-effect', 0.5); // soft light: half resolution is enough
+ this.rim = new Layer('webbrain-agent-effect-rim', 1);
+ this.layers = [this.glow, this.rim];
+ const st = [[0, 1], [0.3, 0.7], [0.65, 0.22], [1, 0]];
+ this.spr = {
+ base: sprite(C.base, 128, st), soft: sprite(C.soft, 128, st), pale: sprite(C.pale, 128, st),
+ mist: sprite(C.mist, 128, st), deep: sprite(C.deep, 128, st),
+ };
+ this.sprHead = sprite(C.soft, 64, [[0, 1], [0.2, 0.6], [0.5, 0.15], [1, 0]]);
+ this.sprCore = sprite(C.core, 32, [[0, 1], [0.4, 0.6], [1, 0]]);
+ this.lobes = []; this.comets = []; this.edgeGeo = []; this.P = 1; this.fadeIn = 0;
+ this.pt = { x: 0, y: 0 }; this.pt2 = { x: 0, y: 0 };
+ }
+ onShow() { this.fadeIn = 0; }
+ layout(w, h) {
+ const P = this.P = 2 * (w + h);
+ // each edge as a segment of the perimeter parameter s (clockwise from top-left)
+ this.edgeGeo = [
+ { a: 0, b: w, ox: 0, oy: 0, tx: 1, ty: 0, horiz: true },
+ { a: w, b: w + h, ox: w, oy: 0, tx: 0, ty: 1, horiz: false },
+ { a: w + h, b: 2 * w + h, ox: w, oy: h, tx: -1, ty: 0, horiz: true },
+ { a: 2 * w + h, b: P, ox: 0, oy: h, tx: 0, ty: -1, horiz: false },
+ ];
+ const n = clamp(Math.round(P / 220), 12, 34);
+ const colors = ['base', 'base', 'base', 'deep', 'deep', 'soft', 'soft', 'pale', 'mist'];
+ const thick = clamp(Math.min(w, h) * 0.085, 48, 96);
+ this.lobes = [];
+ for (let k = 0; k < n; k++) {
+ this.lobes.push({
+ s: ((k + rand(-0.3, 0.3)) / n) * P,
+ v: rand(22, 64) * (Math.random() < 0.5 ? -1 : 1),
+ len: rand(240, 520), th: thick * rand(0.7, 1.25), color: pick(colors),
+ a: rand(0.42, 0.78), ph: rand(0, TAU), fr: rand(0.12, 0.32),
+ });
+ }
+ this.comets = [
+ { s: rand(0, P), v: P / 7.5, tail: 220 },
+ { s: rand(0, P), v: -P / 10, tail: 170 },
+ ];
+ }
+ perim(s, inset, out) {
+ const w = this.w, h = this.h, P = this.P;
+ s = ((s % P) + P) % P;
+ if (s < w) { out.x = s; out.y = inset; }
+ else if (s < w + h) { out.x = w - inset; out.y = s - w; }
+ else if (s < 2 * w + h) { out.x = w - (s - w - h); out.y = h - inset; }
+ else { out.x = inset; out.y = h - (s - 2 * w - h); }
+ return out;
+ }
+ perimPath(ctx, s0, s1, inset) {
+ const P = this.P, w = this.w, h = this.h;
+ const corners = [w, w + h, 2 * w + h, P];
+ let s = s0;
+ let p = this.perim(s, inset, this.pt2);
+ ctx.moveTo(p.x, p.y);
+ for (let guard = 0; s < s1 - 1e-6 && guard < 8; guard++) {
+ const m = ((s % P) + P) % P;
+ let next = P;
+ for (const c of corners) if (c > m + 1e-6) { next = c; break; }
+ s += Math.min(s1 - s, next - m);
+ p = this.perim(s, inset, this.pt2);
+ ctx.lineTo(p.x, p.y);
+ }
+ }
+ sAt(x, y) {
+ const w = this.w, h = this.h;
+ const d = [y, w - x, h - y, x];
+ const e = d.indexOf(Math.min(...d));
+ return e === 0 ? x : e === 1 ? w + y : e === 2 ? w + h + (w - x) : 2 * w + h + (h - y);
+ }
+ step(dt) {
+ this.fadeIn = Math.min(1, this.fadeIn + dt / 0.9);
+ for (let k = this.lobes.length - 1; k >= 0; k--) {
+ const L = this.lobes[k];
+ L.s += L.v * dt;
+ if (L.life !== undefined) { L.life -= dt; if (L.life <= 0) this.lobes.splice(k, 1); }
+ }
+ for (const c of this.comets) c.s += c.v * dt;
+ }
+ draw() {
+ const w = this.w, h = this.h;
+ if (!w) return;
+ const t = this.t, still = this.still, P = this.P;
+ const I = still ? 1 : (0.84 + 0.16 * Math.sin(t * TAU / 4.8)) * easeOutCubic(this.fadeIn);
+ const g = this.glow.ctx;
+ g.clearRect(0, 0, w, h);
+ vignette(g, w, h, 0.16 * I, 30); // a continuous floor so the frame never has gaps
+ for (const L of this.lobes) {
+ const env = L.life === undefined ? 1 : Math.min(1, (L.max - L.life) / 0.18) * clamp(L.life / L.max, 0, 1);
+ const breath = still ? 0.8 : 0.62 + 0.38 * Math.sin(t * L.fr * TAU + L.ph);
+ const alpha = clamp(L.a * breath * I * env, 0, 1);
+ if (alpha < 0.004) continue;
+ const th = L.th * (still ? 1 : 0.86 + 0.14 * Math.sin(t * 0.6 + L.ph * 1.7));
+ const half = L.len / 2, spr = this.spr[L.color];
+ const c = ((L.s % P) + P) % P;
+ g.globalAlpha = alpha;
+ // one edge-aligned ellipse per edge it touches; half of it sits off-screen
+ for (const E of this.edgeGeo) {
+ let cc = c;
+ if (cc < E.a - half) cc += P; else if (cc > E.b + half) cc -= P;
+ if (cc + half < E.a || cc - half > E.b) continue;
+ const local = cc - E.a;
+ const px = E.ox + E.tx * local, py = E.oy + E.ty * local;
+ if (E.horiz) g.drawImage(spr, px - half, py - th, half * 2, th * 2);
+ else g.drawImage(spr, px - th, py - half, th * 2, half * 2);
+ }
+ }
+ g.globalAlpha = 1;
+
+ const r = this.rim.ctx;
+ r.clearRect(0, 0, w, h);
+ r.lineWidth = 1.5;
+ r.strokeStyle = rgba(C.base, 0.55 * I);
+ r.strokeRect(0.75, 0.75, w - 1.5, h - 1.5);
+ if (still) return;
+ r.lineCap = 'butt';
+ for (const c of this.comets) {
+ const dir = Math.sign(c.v), N = 22;
+ for (let k = 0; k < N; k++) {
+ const s0 = c.s - dir * (k / N) * c.tail, s1 = c.s - dir * ((k + 1) / N) * c.tail;
+ const f = 1 - k / N;
+ r.strokeStyle = rgba(k < 2 ? C.pale : C.base, f * f * 0.95 * I);
+ r.lineWidth = 1.2 + 2.6 * f;
+ r.beginPath(); this.perimPath(r, Math.min(s0, s1), Math.max(s0, s1), 1.2); r.stroke();
+ }
+ const hp = this.perim(c.s, 1.2, this.pt);
+ r.fillStyle = rgba(C.base, 0.9 * I);
+ r.beginPath(); r.arc(hp.x, hp.y, 2.8, 0, TAU); r.fill();
+ r.globalCompositeOperation = 'lighter';
+ r.globalAlpha = I;
+ r.drawImage(this.sprHead, hp.x - 22, hp.y - 22, 44, 44);
+ r.drawImage(this.sprCore, hp.x - 4, hp.y - 4, 8, 8);
+ r.globalAlpha = 1;
+ r.globalCompositeOperation = 'source-over';
+ }
+ const [c1, c2] = this.comets;
+ let diff = (((c2.s - c1.s) % P) + P) % P;
+ if (diff > P / 2) diff -= P;
+ const dist = Math.abs(diff);
+ if (dist < 170) {
+ const f = 1 - dist / 170;
+ const m = this.perim(c1.s + diff / 2, 0, this.pt);
+ const size = 70 + 90 * f;
+ r.globalCompositeOperation = 'lighter';
+ r.globalAlpha = f * f * 0.9 * I;
+ r.drawImage(this.sprHead, m.x - size / 2, m.y - size / 2, size, size);
+ r.globalAlpha = 1;
+ r.globalCompositeOperation = 'source-over';
+ }
+ }
+ // The agent acted on an element: brighten the frame nearest to it.
+ target(rect) {
+ if (!this.active || this.still) return;
+ const s = this.sAt(rect.left + rect.width / 2, rect.top + rect.height / 2);
+ this.lobes.push({ s, v: 0, len: 360, th: 120, color: 'soft', a: 0.6, ph: 0, fr: 0, life: 1.6, max: 1.6 });
+ this.lobes.push({ s, v: 0, len: 200, th: 80, color: 'base', a: 0.7, ph: 0, fr: 0, life: 1.6, max: 1.6 });
+ }
+ }
+
+ /* scan: viewfinder brackets land in the corners; a thin beam sweeps the
+ page (down, rest, up, rest) and a fixed dot matrix lights up behind it,
+ stronger near the edges than over the content. */
+ class Scan extends Effect {
+ constructor() {
+ super();
+ this.layer = new Layer('webbrain-agent-effect', 1);
+ this.layers = [this.layer];
+ this.sprEdge = sprite(C.soft, 64, [[0, 1], [0.2, 0.55], [0.5, 0.14], [1, 0]]);
+ this.row = document.createElement('canvas');
+ this.locks = [];
+ this.sp = 14;
+ }
+ onShow() { this.locks.length = 0; }
+ layout(w, h) {
+ const L = this.layer;
+ this.arm = clamp(Math.min(w, h) * 0.042, 20, 40);
+ this.sweep = clamp(h / 330, 2.2, 3.6);
+ this.rest = 1.05;
+ this.trail = clamp(h * 0.17, 70, 150);
+ const sx = L.el.width / w, sy = L.el.height / h;
+ const row = this.row;
+ row.width = L.el.width;
+ row.height = Math.max(1, Math.ceil(4 * sy));
+ const x = row.getContext('2d');
+ x.setTransform(sx, 0, 0, row.height / 4, 0, 0);
+ for (let px = this.sp / 2; px < w; px += this.sp) {
+ const u = px / w, d = Math.min(u, 1 - u) * 2;
+ x.fillStyle = rgba(C.base, lerp(0.95, 0.22, Math.pow(d, 0.6)));
+ x.beginPath(); x.arc(px, 2, 1.1, 0, TAU); x.fill();
+ }
+ this.beamGrad = L.ctx.createLinearGradient(0, 0, w, 0);
+ for (const [o, a] of [[0, 0.9], [0.14, 0.5], [0.5, 0.28], [0.86, 0.5], [1, 0.9]]) this.beamGrad.addColorStop(o, rgba(C.base, a));
+ }
+ step(dt) {
+ for (let k = this.locks.length - 1; k >= 0; k--) {
+ this.locks[k].t += dt;
+ if (this.locks[k].t > 1.7) this.locks.splice(k, 1);
+ }
+ }
+ draw() {
+ const L = this.layer, x = L.ctx, w = L.w, h = L.h;
+ if (!w) return;
+ x.clearRect(0, 0, w, h);
+ const still = this.still, t = this.t;
+ const breath = still ? 0.5 : 0.5 + 0.5 * Math.sin(t * TAU / 3.4);
+ const fade = still ? 1 : easeOutCubic(clamp(t / 0.6, 0, 1));
+ vignette(x, w, h, (0.08 + 0.04 * breath) * fade, 24);
+ let snap = 0;
+ if (!still) {
+ const cyc = this.sweep + this.rest;
+ const tt = Math.max(0, t - 0.35); // brackets land first
+ const n = Math.floor(tt / cyc), local = tt - n * cyc, down = n % 2 === 0;
+ const k = clamp(local / this.sweep, 0, 1), e = easeInOutSine(k);
+ const y = down ? lerp(-6, h + 6, e) : lerp(h + 6, -6, e);
+ const vis = local < this.sweep ? clamp(Math.min(k / 0.07, (1 - k) / 0.07), 0, 1) * fade : 0;
+ if (t > 0.35 && vis > 0) this.drawBeam(x, w, y, down ? -1 : 1, vis);
+ const since = local - this.sweep;
+ if (t > 0.35 && since >= 0) { const s = Math.max(0, 1 - since / 0.6); snap = s * s; }
+ }
+ this.drawBrackets(x, w, h, breath, snap, fade);
+ for (const lk of this.locks) this.drawLock(x, lk);
+ }
+ drawBeam(x, w, y, dir, vis) {
+ const tr = this.trail, y2 = y + dir * tr;
+ const g = x.createLinearGradient(0, y, 0, y2);
+ g.addColorStop(0, rgba(C.base, 0.11 * vis));
+ g.addColorStop(0.35, rgba(C.base, 0.045 * vis));
+ g.addColorStop(1, rgba(C.base, 0));
+ x.fillStyle = g;
+ x.fillRect(0, Math.min(y, y2), w, tr);
+ const sp = this.sp, lo = Math.min(y, y2), hi = Math.max(y, y2);
+ for (let ry = Math.ceil(lo / sp) * sp; ry <= hi; ry += sp) {
+ const a = Math.pow(1 - Math.abs(ry - y) / tr, 2.2) * 0.75 * vis;
+ if (a < 0.01) continue;
+ x.globalAlpha = a;
+ x.drawImage(this.row, 0, ry - 2, w, 4);
+ }
+ x.globalAlpha = vis;
+ x.fillStyle = this.beamGrad;
+ x.fillRect(0, y - 0.75, w, 1.5);
+ x.globalCompositeOperation = 'lighter';
+ x.drawImage(this.sprEdge, -24, y - 24, 48, 48);
+ x.drawImage(this.sprEdge, w - 24, y - 24, 48, 48);
+ x.globalCompositeOperation = 'source-over';
+ x.fillStyle = rgba(C.base, 0.95);
+ x.fillRect(0, y - 1.5, 16, 3);
+ x.fillRect(w - 16, y - 1.5, 16, 3);
+ x.globalAlpha = 1;
+ }
+ drawBrackets(x, w, h, breath, snap, fade) {
+ const land = this.still ? 1 : easeOutBack(clamp(this.t / 0.55, 0, 1));
+ const m = lerp(48, 12, land) + 2 * breath - 4 * snap;
+ const a = this.arm * (0.9 + 0.1 * land) + 8 * snap, r = 7;
+ x.save();
+ x.globalAlpha = clamp(fade * 1.2, 0, 1);
+ x.lineCap = 'round'; x.lineJoin = 'round';
+ x.beginPath();
+ x.moveTo(m, m + a); x.lineTo(m, m + r); x.arcTo(m, m, m + r, m, r); x.lineTo(m + a, m);
+ x.moveTo(w - m - a, m); x.lineTo(w - m - r, m); x.arcTo(w - m, m, w - m, m + r, r); x.lineTo(w - m, m + a);
+ x.moveTo(w - m, h - m - a); x.lineTo(w - m, h - m - r); x.arcTo(w - m, h - m, w - m - r, h - m, r); x.lineTo(w - m - a, h - m);
+ x.moveTo(m + a, h - m); x.lineTo(m + r, h - m); x.arcTo(m, h - m, m, h - m - r, r); x.lineTo(m, h - m - a);
+ // Halo from wide translucent strokes. shadowBlur would rasterize a
+ // viewport-sized shadow layer here (the path spans all four corners).
+ x.strokeStyle = rgba(C.base, 0.07 + 0.08 * snap); x.lineWidth = 12; x.stroke();
+ x.strokeStyle = rgba(C.base, 0.14 + 0.12 * snap); x.lineWidth = 6.5; x.stroke();
+ x.strokeStyle = rgba(C.base, 0.85 + 0.15 * snap); x.lineWidth = 2.6; x.stroke();
+ x.restore();
+ }
+ drawLock(x, lk) {
+ const k = easeOutCubic(clamp(lk.t / 0.35, 0, 1));
+ const fade = lk.t < 1.2 ? 1 : Math.max(0, 1 - (lk.t - 1.2) / 0.45);
+ const R = lk.rect, pad = lerp(26, 8, k);
+ const l = R.left - pad, tp = R.top - pad, rr = R.left + R.width + pad, b = R.top + R.height + pad;
+ const a = clamp(Math.min(rr - l, b - tp) * 0.28, 7, 16);
+ x.save();
+ x.globalAlpha = k * fade;
+ x.lineWidth = 2; x.lineCap = 'round'; x.lineJoin = 'round';
+ x.strokeStyle = rgba(C.base, 0.95);
+ x.beginPath();
+ x.moveTo(l, tp + a); x.lineTo(l, tp); x.lineTo(l + a, tp);
+ x.moveTo(rr - a, tp); x.lineTo(rr, tp); x.lineTo(rr, tp + a);
+ x.moveTo(rr, b - a); x.lineTo(rr, b); x.lineTo(rr - a, b);
+ x.moveTo(l + a, b); x.lineTo(l, b); x.lineTo(l, b - a);
+ x.stroke();
+ x.restore();
+ }
+ // The agent acted on an element: the viewfinder locks onto it.
+ target(rect) {
+ if (!this.active || this.still) return;
+ this.locks.push({ rect: { left: rect.left, top: rect.top, width: rect.width, height: rect.height }, t: 0 });
+ }
+ }
+
+ /* gears: a large driver wheel sits just outside each corner and drives two
+ trains of smaller cogs along the edges. Meshing is real: one module for
+ all wheels, centre distance = sum of pitch radii, tooth phases aligned so
+ teeth sit in gaps, angular speed ∝ 1/teeth with alternating direction.
+ Wheel bodies vary (spokes, lightening holes, solid) and some wheels carry
+ a pinion on the same axle. When the agent acts, the nearest train revs. */
+ class Gears extends Effect {
+ constructor() {
+ super();
+ this.layer = new Layer('webbrain-agent-effect', 1);
+ this.layers = [this.layer];
+ this.sprGlow = sprite(C.soft, 64, [[0, 0.9], [0.3, 0.42], [0.7, 0.08], [1, 0]]);
+ this.gears = []; this.clusters = []; this.bands = null; this.rx = 1; this.ry = 1;
+ this.minFrame = 1 / 30; // slow rotation reads smooth at 30 fps and halves raster work
+ }
+ onShow() { for (const c of this.clusters) { c.kick = 0; c.k = 0; } }
+ gearSprite(N, m, style, ratio) {
+ const r = N * m / 2, ro = r + m, rr = r - 1.25 * m, half = ro + 3;
+ const S = Math.ceil(half * 2 * ratio);
+ const c = document.createElement('canvas');
+ c.width = c.height = S;
+ const x = c.getContext('2d');
+ x.setTransform(ratio, 0, 0, ratio, S / 2, S / 2);
+ const p = TAU / N, twR = 0.56 * p, twT = 0.3 * p;
+ x.beginPath();
+ for (let k = 0; k < N; k++) {
+ const a = k * p, a0 = a - twR / 2, a1 = a - twT / 2, a2 = a + twT / 2, a3 = a + twR / 2;
+ if (k === 0) x.moveTo(rr * Math.cos(a0), rr * Math.sin(a0));
+ else x.lineTo(rr * Math.cos(a0), rr * Math.sin(a0));
+ x.lineTo(ro * Math.cos(a1), ro * Math.sin(a1));
+ x.arc(0, 0, ro, a1, a2);
+ x.lineTo(rr * Math.cos(a3), rr * Math.sin(a3));
+ x.arc(0, 0, rr, a3, a + p - twR / 2);
+ }
+ x.closePath();
+ const hub = Math.max(r * 0.2, 1.8 * m), axle = Math.max(1.6, hub * 0.38), rim = rr - 1.1 * m;
+ if (style === 'spokes' && rim - hub > 3 * m) {
+ const s = N >= 30 ? 6 : N >= 20 ? 5 : 4;
+ const hw = clamp(r * 0.07, 2, 6), inner = hub + m;
+ const ao = Math.asin(Math.min(1, hw / rim)), ai = Math.asin(Math.min(1, hw / inner));
+ for (let j = 0; j < s; j++) {
+ const b = j * TAU / s, e = (j + 1) * TAU / s;
+ if (e - ai <= b + ai) continue;
+ x.moveTo(rim * Math.cos(b + ao), rim * Math.sin(b + ao));
+ x.arc(0, 0, rim, b + ao, e - ao);
+ x.arc(0, 0, inner, e - ai, b + ai, true);
+ x.closePath();
+ }
+ } else if (style === 'holes' && rim - hub > 2.4 * m) {
+ const k = N >= 24 ? 6 : 5, rho = (hub + rim) / 2;
+ const rh = Math.min((rim - hub) * 0.34, rho * Math.sin(Math.PI / k) * 0.6);
+ for (let j = 0; j < k; j++) {
+ const a = j * TAU / k + p / 2, cx = rho * Math.cos(a), cy = rho * Math.sin(a);
+ x.moveTo(cx + rh, cy);
+ x.arc(cx, cy, rh, 0, TAU);
+ }
+ }
+ x.moveTo(axle, 0);
+ x.arc(0, 0, axle, 0, TAU);
+ x.fillStyle = rgba(C.base, style === 'solid' ? 0.08 : 0.1);
+ x.fill('evenodd');
+ x.lineJoin = 'round';
+ x.strokeStyle = rgba(C.base, 0.58);
+ x.lineWidth = 1.2;
+ x.stroke();
+ x.beginPath(); x.arc(0, 0, hub, 0, TAU);
+ x.strokeStyle = rgba(C.base, 0.42); x.lineWidth = 1; x.stroke();
+ if (style === 'solid' && rim - hub > 2 * m) {
+ x.beginPath(); x.arc(0, 0, rim, 0, TAU);
+ x.setLineDash([2.5, 3.5]); x.strokeStyle = rgba(C.base, 0.34); x.stroke(); x.setLineDash([]);
+ }
+ return c;
+ }
+ layout(w, h) {
+ const m = clamp(Math.min(w, h) * 0.0062, 3.4, 6.4);
+ const ratio = this.layer.el.width / w;
+ const gears = [], clusters = [];
+ const corners = [
+ { x: 0, y: 0, a: [1, 0], b: [0, 1] },
+ { x: w, y: 0, a: [-1, 0], b: [0, 1] },
+ { x: w, y: h, a: [-1, 0], b: [0, -1] },
+ { x: 0, y: h, a: [1, 0], b: [0, -1] },
+ ];
+ const styles = ['spokes', 'holes', 'solid', 'holes', 'spokes'];
+ const sprites = new Map(); // identical wheels share one sprite
+ const make = (N, x, y, phi, omega, cl, style, order) => {
+ const g = { N, r: N * m / 2, x, y, phi, omega, cl, style, order, flash: 0 };
+ g.half = g.r + m + 3;
+ const key = N + style;
+ if (!sprites.has(key)) sprites.set(key, this.gearSprite(N, m, style, ratio));
+ g.sprite = sprites.get(key);
+ gears.push(g);
+ return g;
+ };
+ // phase for C so that its teeth fall into P's gaps along the line of centres
+ const meshPhase = (P, Cg) => {
+ const alpha = Math.atan2(Cg.y - P.y, Cg.x - P.x);
+ const pP = TAU / P.N, pC = TAU / Cg.N;
+ let f = ((alpha - P.phi) / pP) % 1; if (f < 0) f += 1;
+ let g = (0.5 - f) % 1; if (g < 0) g += 1;
+ return alpha + Math.PI - g * pC;
+ };
+ corners.forEach((cn, ci) => {
+ clusters.push({ kick: 0, k: 0, x: cn.x, y: cn.y });
+ const toXY = (u, v, e, n) => [cn.x + e[0] * u + n[0] * v, cn.y + e[1] * u + n[1] * v];
+ const N0 = randInt(30, 42), R0 = N0 * m / 2, off = R0 * rand(0.3, 0.46);
+ const [x0, y0] = toXY(-off, -off, cn.a, cn.b);
+ const driver = make(N0, x0, y0, rand(0, TAU), 0.3 * (Math.random() < 0.5 ? 1 : -1), ci, 'spokes', 0);
+ for (const [e, n] of [[cn.a, cn.b], [cn.b, cn.a]]) {
+ const reach = (e[0] ? w : h) * 0.33;
+ let parent = driver, pu = -off, pv = -off, order = 1;
+ while (order < 10) {
+ const N = pick([9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24]);
+ const R = N * m / 2, D = parent.r + R;
+ let v = -R * rand(0.32, 0.78), dv = v - pv;
+ if (Math.abs(dv) >= D * 0.92) { v = pv + Math.sign(dv) * D * 0.6; dv = v - pv; }
+ const u = pu + Math.sqrt(D * D - dv * dv);
+ if (u - R > reach) break;
+ const [gx, gy] = toXY(u, v, e, n);
+ const g = make(N, gx, gy, 0, -parent.omega * parent.N / N, ci, N <= 11 ? 'solid' : pick(styles), order++);
+ g.phi = meshPhase(parent, g);
+ if (N >= 16 && Math.random() < 0.3) {
+ parent = make(randInt(8, 11), gx, gy, rand(0, TAU), g.omega, ci, 'solid', order); // pinion on the same axle
+ } else parent = g;
+ pu = u; pv = v;
+ }
+ }
+ });
+ this.gears = gears; this.clusters = clusters;
+
+ const W = this.layer.el.width, H = this.layer.el.height;
+ this.rx = W / w; this.ry = H / h;
+ let band = 0;
+ for (const g of gears) band = Math.max(band, Math.min(g.x, g.y, w - g.x, h - g.y) + g.half);
+ band = Math.max(band, 30) + 8;
+ const bx = Math.ceil(band * this.rx), by = Math.ceil(band * this.ry);
+ this.bands = 2 * bx >= W || 2 * by >= H
+ ? [[0, 0, W, H]]
+ : [[0, 0, W, by], [0, H - by, W, by], [0, by, bx, H - 2 * by], [W - bx, by, bx, H - 2 * by]];
+ }
+ step(dt) {
+ const up = easeOutCubic(clamp(this.t / 1.6, 0, 1));
+ for (const c of this.clusters) {
+ c.k = up * (1 + 2.6 * c.kick * c.kick);
+ c.kick = Math.max(0, c.kick - dt / 1.1);
+ }
+ for (const g of this.gears) {
+ g.phi = (g.phi + g.omega * this.clusters[g.cl].k * dt) % TAU;
+ if (g.flash > 0) g.flash = Math.max(0, g.flash - dt * 1.4);
+ }
+ }
+ draw() {
+ const L = this.layer, x = L.ctx, w = L.w, h = L.h;
+ if (!w || !this.bands) return;
+ const rx = this.rx, ry = this.ry;
+ for (const b of this.bands) x.clearRect(b[0] / rx, b[1] / ry, b[2] / rx, b[3] / ry);
+ const still = this.still, t = this.t;
+ vignette(x, w, h, 0.08 * (still ? 1 : clamp(t / 0.6, 0, 1)), 24);
+ for (const g of this.gears) {
+ const a = still ? 1 : easeOutCubic(clamp((t - g.order * 0.07) / 0.4, 0, 1));
+ if (a <= 0) continue;
+ x.save();
+ x.translate(g.x, g.y);
+ x.rotate(g.phi);
+ x.globalAlpha = a;
+ x.drawImage(g.sprite, -g.half, -g.half, g.half * 2, g.half * 2);
+ x.restore();
+ if (g.flash > 0) {
+ const s = g.r * 1.6;
+ x.globalCompositeOperation = 'lighter';
+ x.globalAlpha = g.flash * 0.6;
+ x.drawImage(this.sprGlow, g.x - s / 2, g.y - s / 2, s, s);
+ x.globalAlpha = 1;
+ x.globalCompositeOperation = 'source-over';
+ }
+ }
+ }
+ // The agent acted on an element: the nearest corner's train revs up.
+ target(rect) {
+ if (!this.active || this.still || !this.gears.length) return;
+ const cx = rect.left + rect.width / 2, cy = rect.top + rect.height / 2;
+ let best = 0, bestDist = Infinity;
+ this.clusters.forEach((c, i) => { const d = Math.hypot(c.x - cx, c.y - cy); if (d < bestDist) { bestDist = d; best = i; } });
+ this.clusters[best].kick = 1;
+ let nearest = null, nearestDist = Infinity;
+ for (const g of this.gears) {
+ if (g.cl !== best) continue;
+ const d = Math.hypot(g.x - cx, g.y - cy) - g.r;
+ if (d < nearestDist) { nearestDist = d; nearest = g; }
+ }
+ if (nearest) nearest.flash = 1;
+ }
+ }
+
+ /* classic: the original pulsing inset glow, kept as a choice. */
+ class ClassicGlow {
+ constructor() { this.el = null; this.active = false; }
+ show(root) {
+ injectStyles();
+ if (!this.el) {
+ const el = document.createElement('div');
+ el.id = 'webbrain-agent-glow-border';
+ decorations().add(el);
+ el.style.cssText = `
+ position: fixed;
+ top: 0; left: 0; right: 0; bottom: 0;
+ pointer-events: none;
+ z-index: 2147483646;
+ opacity: 0;
+ transition: opacity 0.3s ease-in-out;
+ animation: webbrain-pulse 2s ease-in-out infinite;
+ box-shadow:
+ inset 0 0 10px rgba(108, 99, 255, 0.5),
+ inset 0 0 20px rgba(108, 99, 255, 0.3),
+ inset 0 0 30px rgba(108, 99, 255, 0.1);
+ `;
+ root.appendChild(el);
+ this.el = el;
+ }
+ this.active = true;
+ this.el.style.display = '';
+ requestAnimationFrame(() => requestAnimationFrame(() => { if (this.active && this.el) this.el.style.opacity = '1'; }));
+ }
+ hide() { this.active = false; if (this.el) this.el.style.opacity = '0'; }
+ suspend() { if (this.el) this.el.style.display = 'none'; }
+ resume() { if (this.el) this.el.style.display = ''; }
+ refreshMotion() {}
+ target() {}
+ destroy() { this.el?.remove(); this.el = null; this.active = false; }
+ }
+
+ function normalizeStyle(value) {
+ return STYLES.includes(value) ? value : DEFAULT_STYLE;
+ }
+
+ function createEffect(style) {
+ const effectFor = {
+ circuit: () => new NeuralCircuit(),
+ aurora: () => new Aurora(),
+ scan: () => new Scan(),
+ gears: () => new Gears(),
+ classic: () => new ClassicGlow(),
+ };
+ const created = effectFor[normalizeStyle(style)]();
+ created.styleName = normalizeStyle(style);
+ return created;
+ }
+
+ function startEffect() {
+ const root = document.body || document.documentElement;
+ if (!root || !indicatorsActive) return;
+ if (effect && effect.styleName !== effectStyle) { effect.destroy(); effect = null; }
+ if (!effect) effect = createEffect(effectStyle);
+ effect.show(root);
+ if (suspendedForToolUse) effect.suspend();
+ }
+
+ // Settings → General → Agent activity effect, applied live while a run is on.
+ function applyStyle(value) {
+ const next = normalizeStyle(value);
+ if (next === effectStyle) return;
+ effectStyle = next;
+ if (!indicatorsActive || !effect) return;
+ const previous = effect;
+ effect = null;
+ previous.hide();
+ setTimeout(() => previous.destroy(), 520);
+ startEffect();
+ }
+
+ try {
+ Promise.resolve(browser.storage?.local?.get({ [STYLE_STORAGE_KEY]: DEFAULT_STYLE }))
+ .then((stored) => { effectStyle = normalizeStyle(stored?.[STYLE_STORAGE_KEY]); })
+ .catch(() => {})
+ .finally(() => {
+ styleLoaded = true;
+ if (indicatorsActive && !effect) startEffect();
+ });
+ browser.storage?.onChanged?.addListener?.((changes, area) => {
+ if (area === 'local' && changes?.[STYLE_STORAGE_KEY]) applyStyle(changes[STYLE_STORAGE_KEY].newValue);
+ });
+ } catch {
+ styleLoaded = true;
+ }
+
+ reduceMotionQuery.addEventListener?.('change', () => effect?.refreshMotion?.());
+
+ /* ------------------------------------------------------------------------
+ * Agent cursor
+ * One size (75% of the original 48×56 arrow). It glides to each target and
+ * on clicks presses once with a ripple: the only size change, so a size
+ * change always means a click. Between actions it rests on the spot and
+ * fades in and out. Position uses a CSS transition and the press, ripple and
+ * resting breath use the Web Animations API, so no style is written per
+ * frame.
+ * ---------------------------------------------------------------------- */
+
+ const CURSOR_SCALE = 0.75;
+ const CURSOR_W = 48 * CURSOR_SCALE;
+ const CURSOR_H = 56 * CURSOR_SCALE;
+ const TIP_X = 5 * CURSOR_SCALE;
+ const TIP_Y = 4 * CURSOR_SCALE;
+ const GLIDE_MS = 420;
+ const CURSOR_TRANSITION = `transform ${GLIDE_MS}ms cubic-bezier(0.22, 0.8, 0.24, 1), opacity 0.25s ease`;
+ const CURSOR_SVG = `
+ <svg width="100%" height="100%" viewBox="0 0 48 56" fill="none" xmlns="http://www.w3.org/2000/svg" style="display: block;">
+ <path d="M5 4L39 31L24 34L31 50L20 54L14 38L5 48V4Z"
+ fill="#6c63ff" stroke="white" stroke-width="3" stroke-linejoin="round"/>
+ <path d="M24 34L31 50" stroke="rgba(20, 18, 48, 0.34)" stroke-width="2" stroke-linecap="round"/>
+ </svg>
+ `;
+
+ class AgentCursor {
+ constructor() {
+ this.el = null; this.body = null; this.ripple = null;
+ this.mode = 'hidden'; // 'active' | 'resting' | 'hidden'
+ this.x = 0; this.y = 0;
+ this.breath = null; this.pressAnimation = null;
+ this.restTimer = null; this.hideTimer = null;
+ }
+ mount(root) {
+ if (this.el) return;
+ const ripple = document.createElement('div');
+ ripple.setAttribute('aria-hidden', 'true');
+ decorations().add(ripple);
+ ripple.style.cssText = `
+ position: fixed; top: 0; left: 0;
+ width: 40px; height: 40px; margin: -20px 0 0 -20px;
+ box-sizing: border-box; border-radius: 50%;
+ border: 2px solid rgba(108, 99, 255, 0.85);
+ background: rgba(108, 99, 255, 0.10);
+ pointer-events: none; z-index: 2147483647; opacity: 0;
+ `;
+ const el = document.createElement('div');
+ el.id = 'webbrain-agent-target-cursor';
+ el.setAttribute('aria-hidden', 'true');
+ decorations().add(el);
+ el.style.cssText = `
+ position: fixed; top: 0; left: 0;
+ width: ${CURSOR_W}px; height: ${CURSOR_H}px;
+ pointer-events: none; z-index: 2147483647; opacity: 0;
+ transition: ${CURSOR_TRANSITION};
+ filter:
+ drop-shadow(0 10px 20px rgba(108, 99, 255, 0.36))
+ drop-shadow(0 2px 3px rgba(20, 18, 48, 0.22));
+ will-change: transform, opacity;
+ `;
+ const body = document.createElement('div');
+ // transform-origin on the arrow tip, so the click press never moves the point
+ body.style.cssText = `width: 100%; height: 100%; transform-origin: ${TIP_X}px ${TIP_Y}px;`;
+ body.innerHTML = CURSOR_SVG;
+ el.appendChild(body);
+ root.append(ripple, el);
+ this.el = el; this.body = body; this.ripple = ripple;
+ }
+ place(x, y, instant) {
+ const transform = `translate(${(x - TIP_X).toFixed(1)}px, ${(y - TIP_Y).toFixed(1)}px)`;
+ if (instant) {
+ this.el.style.transition = 'opacity 0.25s ease';
+ this.el.style.transform = transform;
+ void this.el.offsetWidth; // commit the jump before the glide transition returns
+ this.el.style.transition = CURSOR_TRANSITION;
+ } else {
+ this.el.style.transform = transform;
+ }
+ this.x = x; this.y = y;
+ }
+ // The agent acts with the tip at (x, y).
+ aim(x, y, click) {
+ clearTimeout(this.restTimer);
+ clearTimeout(this.hideTimer);
+ const still = prefersReducedMotion();
+ const fresh = this.mode === 'hidden';
+ const moved = !fresh && Math.hypot(x - this.x, y - this.y) > 2;
+ this.place(x, y, fresh || still);
+ this.mode = 'active';
+ this.el.style.opacity = '1';
+ this.settle();
+ if (click && !still) this.press(moved ? GLIDE_MS : 0);
+ this.restTimer = setTimeout(() => this.rest(), TARGET_RING_TTL_MS);
+ }
+ // Keep up with scrolling without re-triggering the click.
+ follow(x, y) {
+ if (this.mode === 'hidden') return;
+ if (Math.abs(x - this.x) < 0.5 && Math.abs(y - this.y) < 0.5) return;
+ this.place(x, y, true);
+ }
+ rest() {
+ if (this.mode !== 'active') return;
+ this.mode = 'resting';
+ if (prefersReducedMotion() || typeof this.body.animate !== 'function') return;
+ this.breath = this.body.animate([
+ { opacity: 1, easing: 'ease-in-out' },
+ { opacity: 0.32, easing: 'ease-in-out' },
+ { opacity: 1 },
+ ], { duration: 2600, iterations: Infinity });
+ }
+ // Leave the resting breath without an opacity jump.
+ settle() {
+ if (!this.breath) return;
+ let current = 1;
+ try { current = parseFloat(getComputedStyle(this.body).opacity) || 1; } catch {}
+ this.breath.cancel();
+ this.breath = null;
+ if (current < 0.98 && typeof this.body.animate === 'function') {
+ this.body.animate([{ opacity: current }, { opacity: 1 }], { duration: 220, easing: 'ease-out' });
+ }
+ }
+ press(delay) {
+ if (typeof this.body.animate !== 'function') return;
+ this.pressAnimation?.cancel();
+ this.pressAnimation = this.body.animate([
+ { transform: 'scale(1)' },
+ { transform: 'scale(0.84)', offset: 0.45 },
+ { transform: 'scale(1)' },
+ ], { duration: 320, delay, easing: 'ease-out' });
+ const at = `translate(${this.x.toFixed(1)}px, ${this.y.toFixed(1)}px)`;
+ this.ripple.getAnimations?.().forEach(animation => animation.cancel());
+ this.ripple.animate([
+ { transform: `${at} scale(0.3)`, opacity: 0.95 },
+ { transform: `${at} scale(1.6)`, opacity: 0 },
+ ], { duration: 560, delay, easing: 'cubic-bezier(0.2, 0.7, 0.3, 1)' });
+ }
+ hide() {
+ clearTimeout(this.restTimer);
+ if (this.mode === 'hidden' || !this.el) return;
+ this.mode = 'hidden';
+ this.el.style.opacity = '0';
+ clearTimeout(this.hideTimer);
+ this.hideTimer = setTimeout(() => {
+ if (this.mode !== 'hidden') return;
+ this.breath?.cancel();
+ this.breath = null;
+ }, 300);
+ }
+ suspend() {
+ if (this.el) this.el.style.display = 'none';
+ if (this.ripple) this.ripple.style.display = 'none';
+ }
+ resume() {
+ if (this.el) this.el.style.display = '';
+ if (this.ripple) this.ripple.style.display = '';
+ }
+ destroy() {
+ clearTimeout(this.restTimer);
+ clearTimeout(this.hideTimer);
+ this.breath?.cancel();
+ this.pressAnimation?.cancel();
+ this.el?.remove();
+ this.ripple?.remove();
+ this.el = null; this.body = null; this.ripple = null;
+ this.mode = 'hidden';
+ }
+ }
+
+ /* ------------------------------------------------------------------------
+ * Stop button, target ring, lifecycle
+ * ---------------------------------------------------------------------- */
+
function createStopButton() {
const container = document.createElement('div');
container.id = 'webbrain-agent-stop-container';
- (window.__wbPageMonitorDecorations ??= new WeakSet()).add(container);
+ decorations().add(container);
container.style.cssText = `
position: fixed;
bottom: 16px;
@@ -197,7 +1596,7 @@
function createTargetOutline() {
const el = document.createElement('div');
el.id = 'webbrain-agent-target-outline';
- (window.__wbPageMonitorDecorations ??= new WeakSet()).add(el);
+ decorations().add(el);
el.style.cssText = `
position: fixed;
pointer-events: none;
@@ -207,53 +1606,16 @@
border-radius: 10px;
background: rgba(108, 99, 255, 0.035);
transition:
- opacity 0.16s ease,
- top 0.18s ease,
- left 0.18s ease,
- width 0.18s ease,
- height 0.18s ease;
+ opacity 0.35s ease,
+ top 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
+ left 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
+ width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
+ height 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
animation: webbrain-target-ring 1.3s ease-in-out infinite;
`;
return el;
}
- 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">
- <path d="M5 4L39 31L24 34L31 50L20 54L14 38L5 48V4Z"
- fill="#6c63ff" stroke="white" stroke-width="3" stroke-linejoin="round"/>
- <path d="M24 34L31 50" stroke="rgba(20, 18, 48, 0.34)" stroke-width="2" stroke-linecap="round"/>
- </svg>
- `;
- el.style.cssText = `
- position: fixed;
- top: 0;
- left: 0;
- width: 48px;
- height: 56px;
- pointer-events: none;
- z-index: 2147483646;
- opacity: 0;
- filter:
- drop-shadow(0 14px 26px rgba(108, 99, 255, 0.38))
- drop-shadow(0 2px 4px rgba(20, 18, 48, 0.22));
- transition:
- opacity 0.16s ease,
- transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
- animation: webbrain-target-pop 0.18s ease-out;
- will-change: transform, opacity;
- `;
- return el;
- }
-
- function clamp(value, min, max) {
- return Math.min(Math.max(value, min), max);
- }
-
function getTargetRect() {
if (targetRectOverride) return targetRectOverride;
if (!targetElement || typeof targetElement.getBoundingClientRect !== 'function') return null;
@@ -282,28 +1644,32 @@
};
}
- function placeTargetOverlay() {
- if (!targetCursorEl || !targetOutlineEl) return;
- const rect = getTargetRect();
- if (!rect) {
- targetCursorEl.style.opacity = '0';
- targetOutlineEl.style.opacity = '0';
- return;
- }
+ function cursorTip(rect) {
+ const innerX = Math.min(Math.max(rect.rawWidth * 0.62, 14), Math.max(14, rect.rawWidth - 8));
+ const innerY = Math.min(Math.max(rect.rawHeight * 0.58, 14), Math.max(14, rect.rawHeight - 8));
+ return {
+ x: clamp(rect.left + innerX, 8, window.innerWidth - CURSOR_W),
+ y: clamp(rect.top + innerY, 8, window.innerHeight - CURSOR_H),
+ };
+ }
+ function placeTargetRing(rect) {
+ if (!targetOutlineEl) return;
targetOutlineEl.style.left = `${Math.round(rect.left)}px`;
targetOutlineEl.style.top = `${Math.round(rect.top)}px`;
targetOutlineEl.style.width = `${Math.round(rect.width)}px`;
targetOutlineEl.style.height = `${Math.round(rect.height)}px`;
targetOutlineEl.style.borderRadius = `${rect.height < 28 ? 7 : 10}px`;
- targetOutlineEl.style.opacity = '1';
+ }
- const innerX = Math.min(Math.max(rect.rawWidth * 0.62, 14), Math.max(14, rect.rawWidth - 8));
- const innerY = Math.min(Math.max(rect.rawHeight * 0.58, 14), Math.max(14, rect.rawHeight - 8));
- const tipX = clamp(rect.left + innerX, 8, window.innerWidth - 40);
- const tipY = clamp(rect.top + innerY, 8, window.innerHeight - 48);
- targetCursorEl.style.transform = `translate(${Math.round(tipX - 5)}px, ${Math.round(tipY - 4)}px)`;
- targetCursorEl.style.opacity = '1';
+ // Scroll/resize: keep the ring and the (possibly resting) cursor on the
+ // element. If it scrolled out of view the cursor stays where it was.
+ function placeTargetOverlay() {
+ const rect = getTargetRect();
+ if (!rect) return;
+ placeTargetRing(rect);
+ const tip = cursorTip(rect);
+ cursor?.follow(tip.x, tip.y);
}
function scheduleTargetUpdate() {
@@ -314,57 +1680,67 @@
});
}
- function hideTargetCursor() {
+ function clearTarget() {
targetElement = null;
targetRectOverride = null;
- if (targetTimer) {
- clearTimeout(targetTimer);
- targetTimer = null;
+ if (ringTimer) {
+ clearTimeout(ringTimer);
+ ringTimer = null;
}
if (targetRaf) {
cancelAnimationFrame(targetRaf);
targetRaf = 0;
}
- if (targetCursorEl) targetCursorEl.style.opacity = '0';
if (targetOutlineEl) targetOutlineEl.style.opacity = '0';
- setTimeout(() => {
- if (targetElement || targetRectOverride) return;
- targetCursorEl?.parentNode?.removeChild(targetCursorEl);
- targetOutlineEl?.parentNode?.removeChild(targetOutlineEl);
- targetCursorEl = null;
- targetOutlineEl = null;
- }, 180);
- }
-
- function scheduleTargetExpiry() {
- if (targetTimer) clearTimeout(targetTimer);
- targetTimer = setTimeout(hideTargetCursor, TARGET_CURSOR_TTL_MS);
+ cursor?.hide();
}
- function showTarget(el, source = 'interaction') {
- if (!el || typeof el.getBoundingClientRect !== 'function') return;
+ function pointAtTarget(source) {
injectStyles();
const root = document.body || document.documentElement;
if (!root) return;
+ const rect = getTargetRect();
+ if (!rect) return;
- targetElement = el;
- targetRectOverride = null;
- if (targetOutlineEl) {
- targetOutlineEl.style.display = '';
- } else {
+ if (!targetOutlineEl) {
targetOutlineEl = createTargetOutline();
root.appendChild(targetOutlineEl);
}
- if (targetCursorEl) {
- targetCursorEl.style.display = '';
- } else {
- targetCursorEl = createTargetCursor();
- root.appendChild(targetCursorEl);
- }
- targetCursorEl.dataset.source = String(source || 'interaction');
+ targetOutlineEl.style.display = suspendedForToolUse ? 'none' : '';
+ placeTargetRing(rect);
+ targetOutlineEl.style.opacity = '1';
+
+ if (!cursor) cursor = new AgentCursor();
+ cursor.mount(root);
+ if (suspendedForToolUse) cursor.suspend();
+ const tip = cursorTip(rect);
+ cursor.aim(tip.x, tip.y, /^click/.test(String(source || '')));
+ effect?.target?.(rect);
- placeTargetOverlay();
- scheduleTargetExpiry();
+ if (ringTimer) clearTimeout(ringTimer);
+ ringTimer = setTimeout(() => {
+ ringTimer = null;
+ if (targetOutlineEl) targetOutlineEl.style.opacity = '0';
+ // Outside a run nothing would hide a resting cursor, so it leaves with
+ // the ring and its elements are removed once faded.
+ if (!indicatorsActive) {
+ clearTarget();
+ setTimeout(() => {
+ if (indicatorsActive || targetElement || targetRectOverride) return;
+ cursor?.destroy();
+ cursor = null;
+ targetOutlineEl?.parentNode?.removeChild(targetOutlineEl);
+ targetOutlineEl = null;
+ }, 400);
+ }
+ }, TARGET_RING_TTL_MS);
+ }
+
+ function showTarget(el, source = 'interaction') {
+ if (!el || typeof el.getBoundingClientRect !== 'function') return;
+ targetElement = el;
+ targetRectOverride = null;
+ pointAtTarget(source);
}
function showTargetRect(rect, source = 'interaction') {
@@ -375,10 +1751,6 @@
const h = Math.max(1, Number(rect.h ?? rect.height ?? 1));
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(w) || !Number.isFinite(h)) return;
- injectStyles();
- const root = document.body || document.documentElement;
- if (!root) return;
-
const width = Math.max(w, 28);
const height = Math.max(h, 28);
targetElement = null;
@@ -390,39 +1762,20 @@
rawWidth: width,
rawHeight: height,
};
-
- if (targetOutlineEl) {
- targetOutlineEl.style.display = '';
- } else {
- targetOutlineEl = createTargetOutline();
- root.appendChild(targetOutlineEl);
- }
- if (targetCursorEl) {
- targetCursorEl.style.display = '';
- } else {
- targetCursorEl = createTargetCursor();
- root.appendChild(targetCursorEl);
- }
- targetCursorEl.dataset.source = String(source || 'interaction');
-
- placeTargetOverlay();
- scheduleTargetExpiry();
+ pointAtTarget(source);
}
function show() {
indicatorsActive = true;
+ suspendedForToolUse = false;
armIndicatorHeartbeat();
injectStyles();
const root = document.body || document.documentElement;
if (!root) return; // page hasn't parsed yet — extremely unlikely on document_idle
- if (borderEl) {
- borderEl.style.display = '';
- } else {
- borderEl = createBorder();
- root.appendChild(borderEl);
- }
+ // Until the saved style has loaded, the loader starts the effect.
+ if (styleLoaded) startEffect();
if (stopContainerEl) {
stopContainerEl.style.display = '';
@@ -436,7 +1789,6 @@
// second to apply the in-flight values for a clean transition.
requestAnimationFrame(() => {
requestAnimationFrame(() => {
- if (borderEl) borderEl.style.opacity = '1';
const btn = stopContainerEl?.querySelector('#webbrain-agent-stop-button');
if (btn) {
btn.style.transform = 'translateY(0)';
@@ -450,8 +1802,8 @@
clearIndicatorHeartbeat();
if (!indicatorsActive) return;
indicatorsActive = false;
- if (borderEl) borderEl.style.opacity = '0';
- hideTargetCursor();
+ effect?.hide();
+ clearTarget();
const btn = stopContainerEl?.querySelector('#webbrain-agent-stop-button');
if (btn) {
btn.style.transform = 'translateY(80px)';
@@ -460,11 +1812,15 @@
setTimeout(() => {
// Bail if the user re-triggered show() during the fade-out.
if (indicatorsActive) return;
- borderEl?.parentNode?.removeChild(borderEl);
+ effect?.destroy();
+ effect = null;
+ cursor?.destroy();
+ cursor = null;
stopContainerEl?.parentNode?.removeChild(stopContainerEl);
- borderEl = null;
+ targetOutlineEl?.parentNode?.removeChild(targetOutlineEl);
stopContainerEl = null;
- }, 320);
+ targetOutlineEl = null;
+ }, 520);
}
function clearIndicatorHeartbeat() {
@@ -481,35 +1837,33 @@
}
/**
- * Hide both elements without tearing them down — for the brief window
- * around a screenshot capture, so the agent doesn't see its own border
- * pulsing in the screenshots it sends back to the model.
+ * Hide everything without tearing it down — for the brief window around a
+ * screenshot capture, so the agent doesn't see its own effect or cursor in
+ * the screenshots it sends back to the model.
*/
function hideForToolUse() {
- savedBorderVisible = !!(borderEl && borderEl.style.display !== 'none');
+ suspendedForToolUse = true;
savedStopVisible = !!(stopContainerEl && stopContainerEl.style.display !== 'none');
- savedTargetCursorVisible = !!(targetCursorEl && targetCursorEl.style.display !== 'none');
savedTargetOutlineVisible = !!(targetOutlineEl && targetOutlineEl.style.display !== 'none');
- if (borderEl) borderEl.style.display = 'none';
+ effect?.suspend();
+ cursor?.suspend();
if (stopContainerEl) stopContainerEl.style.display = 'none';
- if (targetCursorEl) targetCursorEl.style.display = 'none';
if (targetOutlineEl) targetOutlineEl.style.display = 'none';
}
function showAfterToolUse() {
- if (savedBorderVisible && borderEl) borderEl.style.display = '';
+ suspendedForToolUse = false;
+ effect?.resume();
+ cursor?.resume();
if (savedStopVisible && stopContainerEl) stopContainerEl.style.display = '';
- if (savedTargetCursorVisible && targetCursorEl) targetCursorEl.style.display = '';
if (savedTargetOutlineVisible && targetOutlineEl) targetOutlineEl.style.display = '';
- savedBorderVisible = false;
savedStopVisible = false;
- savedTargetCursorVisible = false;
savedTargetOutlineVisible = false;
}
window.addEventListener('scroll', scheduleTargetUpdate, true);
window.addEventListener('resize', scheduleTargetUpdate, true);
- window.__webbrainAgentIndicator = { showTarget, showTargetRect, hideTarget: hideTargetCursor };
+ window.__webbrainAgentIndicator = { showTarget, showTargetRect, hideTarget: clearTarget };
browser.runtime.onMessage.addListener((msg, _sender, sendResponse) => {
if (!msg || typeof msg.type !== 'string') return;
diff --git a/src/firefox/src/ui/locales/ar.js b/src/firefox/src/ui/locales/ar.js
index 7ba747643..77c19d072 100644
--- a/src/firefox/src/ui/locales/ar.js
+++ b/src/firefox/src/ui/locales/ar.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "جارٍ إعادة محاولة الإجابة…",
'sp.response.incomplete_retrying': "إجابة غير مكتملة · جارٍ إعادة المحاولة…",
'sp.response.incomplete': "إجابة غير مكتملة",
+ "st.display.agent_indicator.label": "تأثير نشاط الوكيل",
+ "st.display.agent_indicator.desc": "مظهر حواف الصفحة أثناء عمل WebBrain في علامة تبويب. كل الأنماط تمرّر نقراتك إلى الصفحة ولا تظهر في لقطات الشاشة.",
+ "st.display.agent_indicator.circuit": "دائرة عصبية",
+ "st.display.agent_indicator.aurora": "شفق قطبي",
+ "st.display.agent_indicator.scan": "مسح",
+ "st.display.agent_indicator.gears": "تروس",
+ "st.display.agent_indicator.classic": "توهج كلاسيكي",
};
diff --git a/src/firefox/src/ui/locales/bn.js b/src/firefox/src/ui/locales/bn.js
index 6cb61a4f7..12bac1fdf 100644
--- a/src/firefox/src/ui/locales/bn.js
+++ b/src/firefox/src/ui/locales/bn.js
@@ -1327,4 +1327,11 @@ export default {
'sp.activity.retrying_response': "উত্তর আবার চেষ্টা করা হচ্ছে…",
'sp.response.incomplete_retrying': "অসম্পূর্ণ উত্তর · আবার চেষ্টা করা হচ্ছে…",
'sp.response.incomplete': "অসম্পূর্ণ উত্তর",
+ "st.display.agent_indicator.label": "এজেন্ট কার্যকলাপ ইফেক্ট",
+ "st.display.agent_indicator.desc": "WebBrain কোনো ট্যাবে কাজ করার সময় পেজের কিনারা কেমন দেখাবে। প্রতিটি স্টাইল আপনার ক্লিক পেজে পৌঁছাতে দেয় এবং স্ক্রিনশটে আসে না।",
+ "st.display.agent_indicator.circuit": "নিউরাল সার্কিট",
+ "st.display.agent_indicator.aurora": "অরোরা",
+ "st.display.agent_indicator.scan": "স্ক্যান",
+ "st.display.agent_indicator.gears": "গিয়ার",
+ "st.display.agent_indicator.classic": "ক্লাসিক আভা",
};
diff --git a/src/firefox/src/ui/locales/de.js b/src/firefox/src/ui/locales/de.js
index 3cf6cf9a3..bed3a6110 100644
--- a/src/firefox/src/ui/locales/de.js
+++ b/src/firefox/src/ui/locales/de.js
@@ -1300,4 +1300,11 @@ export default {
'sp.activity.retrying_response': "Antwort wird erneut versucht…",
'sp.response.incomplete_retrying': "Unvollständige Antwort · erneuter Versuch…",
'sp.response.incomplete': "Unvollständige Antwort",
+ "st.display.agent_indicator.label": "Effekt bei Agentenaktivität",
+ "st.display.agent_indicator.desc": "Legt fest, wie die Seitenränder aussehen, während WebBrain in einem Tab arbeitet. Jeder Stil lässt Ihre Klicks durch und erscheint nicht auf Screenshots.",
+ "st.display.agent_indicator.circuit": "Neuronaler Schaltkreis",
+ "st.display.agent_indicator.aurora": "Polarlicht",
+ "st.display.agent_indicator.scan": "Scan",
+ "st.display.agent_indicator.gears": "Zahnräder",
+ "st.display.agent_indicator.classic": "Klassisches Leuchten",
};
diff --git a/src/firefox/src/ui/locales/en.js b/src/firefox/src/ui/locales/en.js
index 3031ec611..ddc5d5689 100644
--- a/src/firefox/src/ui/locales/en.js
+++ b/src/firefox/src/ui/locales/en.js
@@ -1331,4 +1331,11 @@ export default {
'st.sync.consent.legacy': 'Turn on encrypted sync? WebBrain will transmit an end-to-end encrypted copy of your memories, profile autofill, and API-key provider settings to WebBrain Compass. Chat history and OAuth sign-ins are not synced.',
'st.sync.consent.denied': 'Encrypted sync permission was not granted.',
'st.providers.webgpu_note.body': '{modelLink} runs entirely in Chrome with no API endpoint. Download it in Providers > WebGPU or Apocalypse Mode, then use the nuclear control in standalone chat.',
+ "st.display.agent_indicator.label": "Agent activity effect",
+ "st.display.agent_indicator.desc": "How the page edges look while WebBrain works on a tab. Every style lets your clicks through and stays out of screenshots.",
+ "st.display.agent_indicator.circuit": "Neural circuit",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Scan",
+ "st.display.agent_indicator.gears": "Gears",
+ "st.display.agent_indicator.classic": "Classic glow",
};
diff --git a/src/firefox/src/ui/locales/es.js b/src/firefox/src/ui/locales/es.js
index 057cbd3f2..0a105e775 100644
--- a/src/firefox/src/ui/locales/es.js
+++ b/src/firefox/src/ui/locales/es.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Reintentando respuesta…",
'sp.response.incomplete_retrying': "Respuesta incompleta · reintentando…",
'sp.response.incomplete': "Respuesta incompleta",
+ "st.display.agent_indicator.label": "Efecto de actividad del agente",
+ "st.display.agent_indicator.desc": "Cómo se ven los bordes de la página mientras WebBrain trabaja en una pestaña. Todos los estilos dejan pasar tus clics y no aparecen en las capturas de pantalla.",
+ "st.display.agent_indicator.circuit": "Circuito neuronal",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Escaneo",
+ "st.display.agent_indicator.gears": "Engranajes",
+ "st.display.agent_indicator.classic": "Brillo clásico",
};
diff --git a/src/firefox/src/ui/locales/fa.js b/src/firefox/src/ui/locales/fa.js
index 32f4c5c51..33f5fac85 100644
--- a/src/firefox/src/ui/locales/fa.js
+++ b/src/firefox/src/ui/locales/fa.js
@@ -1327,4 +1327,11 @@ export default {
'sp.activity.retrying_response': "در حال تلاش دوباره برای پاسخ…",
'sp.response.incomplete_retrying': "پاسخ ناقص · تلاش دوباره…",
'sp.response.incomplete': "پاسخ ناقص",
+ "st.display.agent_indicator.label": "جلوهٔ فعالیت عامل",
+ "st.display.agent_indicator.desc": "ظاهر لبه‌های صفحه هنگامی که WebBrain در یک زبانه کار می‌کند. همهٔ سبک‌ها کلیک‌های شما را به صفحه می‌رسانند و در عکس‌های صفحه دیده نمی‌شوند.",
+ "st.display.agent_indicator.circuit": "مدار عصبی",
+ "st.display.agent_indicator.aurora": "شفق قطبی",
+ "st.display.agent_indicator.scan": "اسکن",
+ "st.display.agent_indicator.gears": "چرخ‌دنده‌ها",
+ "st.display.agent_indicator.classic": "درخشش کلاسیک",
};
diff --git a/src/firefox/src/ui/locales/fr.js b/src/firefox/src/ui/locales/fr.js
index 202b4de58..852789c5c 100644
--- a/src/firefox/src/ui/locales/fr.js
+++ b/src/firefox/src/ui/locales/fr.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Nouvelle tentative de réponse…",
'sp.response.incomplete_retrying': "Réponse incomplète · nouvelle tentative…",
'sp.response.incomplete': "Réponse incomplète",
+ "st.display.agent_indicator.label": "Effet d'activité de l'agent",
+ "st.display.agent_indicator.desc": "Apparence des bords de la page pendant que WebBrain travaille dans un onglet. Tous les styles laissent passer vos clics et n'apparaissent pas sur les captures d'écran.",
+ "st.display.agent_indicator.circuit": "Circuit neuronal",
+ "st.display.agent_indicator.aurora": "Aurore",
+ "st.display.agent_indicator.scan": "Balayage",
+ "st.display.agent_indicator.gears": "Engrenages",
+ "st.display.agent_indicator.classic": "Halo classique",
};
diff --git a/src/firefox/src/ui/locales/he.js b/src/firefox/src/ui/locales/he.js
index 3e9ffbcb9..a13dc6b74 100644
--- a/src/firefox/src/ui/locales/he.js
+++ b/src/firefox/src/ui/locales/he.js
@@ -1259,4 +1259,11 @@ export default {
'sp.activity.retrying_response': "מנסה שוב להשיב…",
'sp.response.incomplete_retrying': "תשובה חלקית · מנסה שוב…",
'sp.response.incomplete': "תשובה חלקית",
+ "st.display.agent_indicator.label": "אפקט פעילות הסוכן",
+ "st.display.agent_indicator.desc": "איך נראים שולי הדף בזמן ש-WebBrain עובד בכרטיסייה. כל הסגנונות מעבירים את הלחיצות שלך לדף ואינם מופיעים בצילומי מסך.",
+ "st.display.agent_indicator.circuit": "מעגל עצבי",
+ "st.display.agent_indicator.aurora": "זוהר קוטבי",
+ "st.display.agent_indicator.scan": "סריקה",
+ "st.display.agent_indicator.gears": "גלגלי שיניים",
+ "st.display.agent_indicator.classic": "הילה קלאסית",
};
diff --git a/src/firefox/src/ui/locales/hi.js b/src/firefox/src/ui/locales/hi.js
index 113f5d08b..2acb9be2e 100644
--- a/src/firefox/src/ui/locales/hi.js
+++ b/src/firefox/src/ui/locales/hi.js
@@ -1327,4 +1327,11 @@ export default {
'sp.activity.retrying_response': "उत्तर के लिए फिर प्रयास हो रहा है…",
'sp.response.incomplete_retrying': "अधूरा उत्तर · फिर प्रयास हो रहा है…",
'sp.response.incomplete': "अधूरा उत्तर",
+ "st.display.agent_indicator.label": "एजेंट गतिविधि प्रभाव",
+ "st.display.agent_indicator.desc": "WebBrain जब किसी टैब पर काम करता है तब पेज के किनारे कैसे दिखें। हर शैली आपके क्लिक पेज तक जाने देती है और स्क्रीनशॉट में नहीं आती।",
+ "st.display.agent_indicator.circuit": "न्यूरल सर्किट",
+ "st.display.agent_indicator.aurora": "ऑरोरा",
+ "st.display.agent_indicator.scan": "स्कैन",
+ "st.display.agent_indicator.gears": "गियर",
+ "st.display.agent_indicator.classic": "क्लासिक चमक",
};
diff --git a/src/firefox/src/ui/locales/id.js b/src/firefox/src/ui/locales/id.js
index 4497cdfbb..55fcdc2be 100644
--- a/src/firefox/src/ui/locales/id.js
+++ b/src/firefox/src/ui/locales/id.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Mencoba ulang jawaban…",
'sp.response.incomplete_retrying': "Jawaban belum lengkap · mencoba ulang…",
'sp.response.incomplete': "Jawaban belum lengkap",
+ "st.display.agent_indicator.label": "Efek aktivitas agen",
+ "st.display.agent_indicator.desc": "Tampilan tepi halaman saat WebBrain bekerja di sebuah tab. Semua gaya meneruskan klik Anda ke halaman dan tidak muncul di tangkapan layar.",
+ "st.display.agent_indicator.circuit": "Sirkuit saraf",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Pindai",
+ "st.display.agent_indicator.gears": "Roda gigi",
+ "st.display.agent_indicator.classic": "Cahaya klasik",
};
diff --git a/src/firefox/src/ui/locales/ja.js b/src/firefox/src/ui/locales/ja.js
index 409d5553e..7ecf35c2d 100644
--- a/src/firefox/src/ui/locales/ja.js
+++ b/src/firefox/src/ui/locales/ja.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "回答を再試行中…",
'sp.response.incomplete_retrying': "未完の回答 · 再試行中…",
'sp.response.incomplete': "未完の回答",
+ "st.display.agent_indicator.label": "エージェント動作エフェクト",
+ "st.display.agent_indicator.desc": "WebBrain がタブで作業している間のページ端の表示です。どのスタイルでもクリックはページに届き、スクリーンショットには写りません。",
+ "st.display.agent_indicator.circuit": "ニューラル回路",
+ "st.display.agent_indicator.aurora": "オーロラ",
+ "st.display.agent_indicator.scan": "スキャン",
+ "st.display.agent_indicator.gears": "歯車",
+ "st.display.agent_indicator.classic": "クラシックな光",
};
diff --git a/src/firefox/src/ui/locales/ko.js b/src/firefox/src/ui/locales/ko.js
index 935e72070..156de0773 100644
--- a/src/firefox/src/ui/locales/ko.js
+++ b/src/firefox/src/ui/locales/ko.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "답변 다시 시도 중…",
'sp.response.incomplete_retrying': "미완성 답변 · 다시 시도 중…",
'sp.response.incomplete': "미완성 답변",
+ "st.display.agent_indicator.label": "에이전트 작업 효과",
+ "st.display.agent_indicator.desc": "WebBrain이 탭에서 작업하는 동안 페이지 가장자리의 모습입니다. 모든 스타일은 클릭을 페이지로 통과시키며 스크린샷에 나타나지 않습니다.",
+ "st.display.agent_indicator.circuit": "신경 회로",
+ "st.display.agent_indicator.aurora": "오로라",
+ "st.display.agent_indicator.scan": "스캔",
+ "st.display.agent_indicator.gears": "톱니바퀴",
+ "st.display.agent_indicator.classic": "클래식 글로우",
};
diff --git a/src/firefox/src/ui/locales/ms.js b/src/firefox/src/ui/locales/ms.js
index 9c9da29fb..09a46b907 100644
--- a/src/firefox/src/ui/locales/ms.js
+++ b/src/firefox/src/ui/locales/ms.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Mencuba semula jawapan…",
'sp.response.incomplete_retrying': "Jawapan tidak lengkap · mencuba semula…",
'sp.response.incomplete': "Jawapan tidak lengkap",
+ "st.display.agent_indicator.label": "Kesan aktiviti ejen",
+ "st.display.agent_indicator.desc": "Rupa tepi halaman semasa WebBrain bekerja dalam tab. Semua gaya membenarkan klik anda sampai ke halaman dan tidak muncul dalam tangkapan skrin.",
+ "st.display.agent_indicator.circuit": "Litar saraf",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Imbas",
+ "st.display.agent_indicator.gears": "Gear",
+ "st.display.agent_indicator.classic": "Cahaya klasik",
};
diff --git a/src/firefox/src/ui/locales/nl.js b/src/firefox/src/ui/locales/nl.js
index 3c99fc0ed..b7a6809dd 100644
--- a/src/firefox/src/ui/locales/nl.js
+++ b/src/firefox/src/ui/locales/nl.js
@@ -1280,4 +1280,11 @@ export default {
'sp.activity.retrying_response': "Antwoord opnieuw proberen…",
'sp.response.incomplete_retrying': "Onvolledig antwoord · opnieuw proberen…",
'sp.response.incomplete': "Onvolledig antwoord",
+ "st.display.agent_indicator.label": "Effect bij agentactiviteit",
+ "st.display.agent_indicator.desc": "Hoe de paginaranden eruitzien terwijl WebBrain in een tabblad werkt. Elke stijl laat je klikken door en blijft buiten schermafbeeldingen.",
+ "st.display.agent_indicator.circuit": "Neuraal circuit",
+ "st.display.agent_indicator.aurora": "Poollicht",
+ "st.display.agent_indicator.scan": "Scan",
+ "st.display.agent_indicator.gears": "Tandwielen",
+ "st.display.agent_indicator.classic": "Klassieke gloed",
};
diff --git a/src/firefox/src/ui/locales/pl.js b/src/firefox/src/ui/locales/pl.js
index 609cc12e4..08b0626a4 100644
--- a/src/firefox/src/ui/locales/pl.js
+++ b/src/firefox/src/ui/locales/pl.js
@@ -1267,4 +1267,11 @@ export default {
'sp.activity.retrying_response': "Ponawianie odpowiedzi…",
'sp.response.incomplete_retrying': "Niepełna odpowiedź · ponawianie…",
'sp.response.incomplete': "Niepełna odpowiedź",
+ "st.display.agent_indicator.label": "Efekt aktywności agenta",
+ "st.display.agent_indicator.desc": "Wygląd krawędzi strony, gdy WebBrain pracuje na karcie. Każdy styl przepuszcza Twoje kliknięcia i nie pojawia się na zrzutach ekranu.",
+ "st.display.agent_indicator.circuit": "Obwód neuronowy",
+ "st.display.agent_indicator.aurora": "Zorza",
+ "st.display.agent_indicator.scan": "Skanowanie",
+ "st.display.agent_indicator.gears": "Zębatki",
+ "st.display.agent_indicator.classic": "Klasyczna poświata",
};
diff --git a/src/firefox/src/ui/locales/pt.js b/src/firefox/src/ui/locales/pt.js
index 5d8d96480..0001c020a 100644
--- a/src/firefox/src/ui/locales/pt.js
+++ b/src/firefox/src/ui/locales/pt.js
@@ -1327,4 +1327,11 @@ export default {
'sp.activity.retrying_response': "Tentando novamente a resposta…",
'sp.response.incomplete_retrying': "Resposta incompleta · tentando novamente…",
'sp.response.incomplete': "Resposta incompleta",
+ "st.display.agent_indicator.label": "Efeito de atividade do agente",
+ "st.display.agent_indicator.desc": "Como as bordas da página ficam enquanto o WebBrain trabalha em uma guia. Todos os estilos deixam seus cliques passarem e não aparecem nas capturas de tela.",
+ "st.display.agent_indicator.circuit": "Circuito neural",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Varredura",
+ "st.display.agent_indicator.gears": "Engrenagens",
+ "st.display.agent_indicator.classic": "Brilho clássico",
};
diff --git a/src/firefox/src/ui/locales/ru.js b/src/firefox/src/ui/locales/ru.js
index 774610ff3..0d1fb2bb4 100644
--- a/src/firefox/src/ui/locales/ru.js
+++ b/src/firefox/src/ui/locales/ru.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Повторная попытка ответа…",
'sp.response.incomplete_retrying': "Неполный ответ · повторная попытка…",
'sp.response.incomplete': "Неполный ответ",
+ "st.display.agent_indicator.label": "Эффект активности агента",
+ "st.display.agent_indicator.desc": "Как выглядят края страницы, пока WebBrain работает во вкладке. Все стили пропускают ваши клики и не попадают на скриншоты.",
+ "st.display.agent_indicator.circuit": "Нейронная схема",
+ "st.display.agent_indicator.aurora": "Сияние",
+ "st.display.agent_indicator.scan": "Сканирование",
+ "st.display.agent_indicator.gears": "Шестерёнки",
+ "st.display.agent_indicator.classic": "Классическое свечение",
};
diff --git a/src/firefox/src/ui/locales/th.js b/src/firefox/src/ui/locales/th.js
index 730ccd122..dc208d87e 100644
--- a/src/firefox/src/ui/locales/th.js
+++ b/src/firefox/src/ui/locales/th.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "กำลังลองตอบอีกครั้ง…",
'sp.response.incomplete_retrying': "คำตอบยังไม่สมบูรณ์ · กำลังลองอีกครั้ง…",
'sp.response.incomplete': "คำตอบยังไม่สมบูรณ์",
+ "st.display.agent_indicator.label": "เอฟเฟกต์ขณะเอเจนต์ทำงาน",
+ "st.display.agent_indicator.desc": "ลักษณะขอบหน้าเว็บขณะที่ WebBrain ทำงานในแท็บ ทุกสไตล์ปล่อยให้การคลิกของคุณผ่านไปยังหน้าเว็บ และไม่ปรากฏในภาพหน้าจอ",
+ "st.display.agent_indicator.circuit": "วงจรประสาท",
+ "st.display.agent_indicator.aurora": "แสงออโรรา",
+ "st.display.agent_indicator.scan": "สแกน",
+ "st.display.agent_indicator.gears": "เฟือง",
+ "st.display.agent_indicator.classic": "แสงเรืองแบบคลาสสิก",
};
diff --git a/src/firefox/src/ui/locales/tl.js b/src/firefox/src/ui/locales/tl.js
index ddeec62ae..5cd405e93 100644
--- a/src/firefox/src/ui/locales/tl.js
+++ b/src/firefox/src/ui/locales/tl.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Sinusubukang muli ang sagot…",
'sp.response.incomplete_retrying': "Hindi kumpletong sagot · sinusubukang muli…",
'sp.response.incomplete': "Hindi kumpletong sagot",
+ "st.display.agent_indicator.label": "Epekto habang gumagana ang agent",
+ "st.display.agent_indicator.desc": "Ang itsura ng mga gilid ng page habang gumagana ang WebBrain sa isang tab. Lahat ng istilo ay nagpapadaan ng iyong mga click sa page at hindi lumalabas sa mga screenshot.",
+ "st.display.agent_indicator.circuit": "Neural na circuit",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Pag-scan",
+ "st.display.agent_indicator.gears": "Mga gear",
+ "st.display.agent_indicator.classic": "Klasikong liwanag",
};
diff --git a/src/firefox/src/ui/locales/tr.js b/src/firefox/src/ui/locales/tr.js
index a3beaab5b..04fa3beb1 100644
--- a/src/firefox/src/ui/locales/tr.js
+++ b/src/firefox/src/ui/locales/tr.js
@@ -1305,4 +1305,11 @@ export default {
"st.sync.consent.legacy": "Şifreli senkronizasyon açılsın mı? WebBrain, anılarınızın, profil otomatik doldurmanızın ve API anahtarı sağlayıcı ayarlarınızın uçtan uca şifrelenmiş bir kopyasını WebBrain Compass'a iletecektir. Sohbet geçmişi ve OAuth oturum açma işlemleri senkronize edilmez.",
"st.sync.consent.denied": "Şifrelenmiş senkronizasyon izni verilmedi.",
'st.providers.webgpu_note.body': '{modelLink} runs entirely in Chrome with no API endpoint. Download it in Providers > WebGPU or Apocalypse Mode, then use the nuclear control in standalone chat.',
+ "st.display.agent_indicator.label": "Ajan çalışma efekti",
+ "st.display.agent_indicator.desc": "WebBrain bir sekmede çalışırken sayfa kenarlarının nasıl görüneceğini seçin. Tüm stiller tıklamalarınızı sayfaya geçirir ve ekran görüntülerine girmez.",
+ "st.display.agent_indicator.circuit": "Sinir devresi",
+ "st.display.agent_indicator.aurora": "Aurora",
+ "st.display.agent_indicator.scan": "Tarama",
+ "st.display.agent_indicator.gears": "Dişliler",
+ "st.display.agent_indicator.classic": "Klasik parıltı",
};
diff --git a/src/firefox/src/ui/locales/uk.js b/src/firefox/src/ui/locales/uk.js
index 9c4b3b0f9..34fe67fcc 100644
--- a/src/firefox/src/ui/locales/uk.js
+++ b/src/firefox/src/ui/locales/uk.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "Повторна спроба відповіді…",
'sp.response.incomplete_retrying': "Неповна відповідь · повторна спроба…",
'sp.response.incomplete': "Неповна відповідь",
+ "st.display.agent_indicator.label": "Ефект активності агента",
+ "st.display.agent_indicator.desc": "Як виглядають краї сторінки, поки WebBrain працює у вкладці. Усі стилі пропускають ваші кліки й не потрапляють на знімки екрана.",
+ "st.display.agent_indicator.circuit": "Нейронна схема",
+ "st.display.agent_indicator.aurora": "Сяйво",
+ "st.display.agent_indicator.scan": "Сканування",
+ "st.display.agent_indicator.gears": "Шестерні",
+ "st.display.agent_indicator.classic": "Класичне світіння",
};
diff --git a/src/firefox/src/ui/locales/vi.js b/src/firefox/src/ui/locales/vi.js
index b5a8f959c..b378c9b54 100644
--- a/src/firefox/src/ui/locales/vi.js
+++ b/src/firefox/src/ui/locales/vi.js
@@ -1327,4 +1327,11 @@ export default {
'sp.activity.retrying_response': "Đang thử lại câu trả lời…",
'sp.response.incomplete_retrying': "Câu trả lời chưa hoàn chỉnh · đang thử lại…",
'sp.response.incomplete': "Câu trả lời chưa hoàn chỉnh",
+ "st.display.agent_indicator.label": "Hiệu ứng khi tác tử hoạt động",
+ "st.display.agent_indicator.desc": "Giao diện viền trang khi WebBrain làm việc trên một thẻ. Mọi kiểu đều cho cú nhấp của bạn đi xuyên qua và không xuất hiện trong ảnh chụp màn hình.",
+ "st.display.agent_indicator.circuit": "Mạch thần kinh",
+ "st.display.agent_indicator.aurora": "Cực quang",
+ "st.display.agent_indicator.scan": "Quét",
+ "st.display.agent_indicator.gears": "Bánh răng",
+ "st.display.agent_indicator.classic": "Viền sáng cổ điển",
};
diff --git a/src/firefox/src/ui/locales/zh.js b/src/firefox/src/ui/locales/zh.js
index e06767ffa..083056e11 100644
--- a/src/firefox/src/ui/locales/zh.js
+++ b/src/firefox/src/ui/locales/zh.js
@@ -1306,4 +1306,11 @@ export default {
'sp.activity.retrying_response': "正在重试回答…",
'sp.response.incomplete_retrying': "回答未完成 · 正在重试…",
'sp.response.incomplete': "回答未完成",
+ "st.display.agent_indicator.label": "智能体活动效果",
+ "st.display.agent_indicator.desc": "WebBrain 在标签页中工作时页面边缘的样式。所有样式都会让点击穿透到页面,且不会出现在截图中。",
+ "st.display.agent_indicator.circuit": "神经回路",
+ "st.display.agent_indicator.aurora": "极光",
+ "st.display.agent_indicator.scan": "扫描",
+ "st.display.agent_indicator.gears": "齿轮",
+ "st.display.agent_indicator.classic": "经典光晕",
};
diff --git a/src/firefox/src/ui/settings.html b/src/firefox/src/ui/settings.html
index 6e9b0366c..003815684 100644
--- a/src/firefox/src/ui/settings.html
+++ b/src/firefox/src/ui/settings.html
@@ -64,6 +64,19 @@
<option value="dark" data-i18n="st.display.theme.dark"></option>
</select>
</div>
+ <div class="setting-row">
+ <div class="setting-info">
+ <div class="setting-label" data-i18n="st.display.agent_indicator.label"></div>
+ <div class="setting-desc" data-i18n="st.display.agent_indicator.desc"></div>
+ </div>
+ <select id="select-agent-indicator-style" data-i18n-aria-label="st.display.agent_indicator.label" style="background:var(--bg);color:var(--text);border:1px solid var(--border);border-radius:6px;padding:6px 10px;font-family:inherit;cursor:pointer;">
+ <option value="circuit" data-i18n="st.display.agent_indicator.circuit"></option>
+ <option value="aurora" data-i18n="st.display.agent_indicator.aurora"></option>
+ <option value="scan" data-i18n="st.display.agent_indicator.scan"></option>
+ <option value="gears" data-i18n="st.display.agent_indicator.gears"></option>
+ <option value="classic" data-i18n="st.display.agent_indicator.classic"></option>
+ </select>
+ </div>
<div class="setting-row">
<div class="setting-info">
<div class="setting-label" data-i18n="st.display.download_directory.label"></div>
diff --git a/src/firefox/src/ui/settings.js b/src/firefox/src/ui/settings.js
index e9c042b13..50b9f0b0d 100644
--- a/src/firefox/src/ui/settings.js
+++ b/src/firefox/src/ui/settings.js
@@ -96,6 +96,9 @@ const apocalypseModeLink = document.getElementById('apocalypse-mode-link');
const apocalypseModeStatus = document.getElementById('apocalypse-mode-status');
const verboseToggle = document.getElementById('toggle-verbose');
const composerDeliveryModeSelect = document.getElementById('select-composer-delivery-mode');
+const agentIndicatorStyleSelect = document.getElementById('select-agent-indicator-style');
+// Read by content/agent-visual-indicator.js; 'circuit' is the default.
+const AGENT_INDICATOR_STYLES = ['circuit', 'aurora', 'scan', 'gears', 'classic'];
const selectionShortcutToggle = document.getElementById('toggle-selection-shortcut');
const autoGroupTabsToggle = document.getElementById('toggle-auto-group-tabs');
const helpImproveToggle = document.getElementById('toggle-help-improve');
@@ -608,7 +611,7 @@ async function init() {
browser.storage.local.remove(['authToken', 'authEmail', 'authDefaultModel']).catch(() => {});
// Load display settings
- const stored = await browser.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'selectionShortcutEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'strictSecretMode', 'strictGuards', 'leanMode', 'visionMode', 'visionQuality', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'clarifyTimeoutPolicy', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
+ const stored = await browser.storage.local.get([...DECISION_SETTINGS_KEYS, 'verboseMode', 'composerDeliveryMode', 'agentIndicatorStyle', 'selectionShortcutEnabled', AUTO_GROUP_TABS_KEY, 'helpImproveWebBrain', 'screenshotFallback', 'maxAgentSteps', 'autoScreenshot', 'useSiteAdapters', 'researchEscalationEnabled', 'researchEscalationEngine', 'voiceInputEnabled', 'alwaysAllowApiMutations', 'apiMutationObserverEnabled', 'openaiAskStreamingEnabled', 'planBeforeActMode', 'planBeforeAct', 'planReviewMode', 'planReviewConfidenceThreshold', DOWNLOAD_DIRECTORY_STORAGE_KEY, 'notifySound', 'completionConfetti', 'completionFlashTab', 'tracingEnabled', 'feedbackDiagnosticsEnabled', 'strictSecretMode', 'strictGuards', 'leanMode', 'visionMode', 'visionQuality', 'agentAllowLocalNetwork', 'scheduledTasksEnabled', 'scheduledRequireConsequentialConfirmation', 'systemOneEnabled', 'systemOneWatchEnabled', 'systemOneCompletionEnabled', 'systemOneFastClassifications', 'systemOneFastBrowser', 'systemOneWatchThreshold', 'systemOneCompletionThreshold', 'typesafeApiKey', 'providerFilter', 'requestTimeoutMs', 'clarifyTimeoutSec', 'clarifyTimeoutSemanticsV2', 'clarifyTimeoutPolicy', 'costAllowanceSessionUsd', 'costAllowanceTotalUsd', 'meteredProviderCostSpentUsd', 'screenshotRedaction', 'imageDetail', 'maxScreenshotsPerTurn', 'maxImageDimension']);
if (typeof stored.providerFilter === 'string' && ['all','active','local','cloud','router'].includes(stored.providerFilter)) {
providerFilter = stored.providerFilter;
}
@@ -617,6 +620,9 @@ async function init() {
if (composerDeliveryModeSelect) {
composerDeliveryModeSelect.value = stored.composerDeliveryMode === 'steer' ? 'steer' : 'queue';
}
+ if (agentIndicatorStyleSelect) {
+ agentIndicatorStyleSelect.value = AGENT_INDICATOR_STYLES.includes(stored.agentIndicatorStyle) ? stored.agentIndicatorStyle : 'circuit';
+ }
if (selectionShortcutToggle) selectionShortcutToggle.checked = stored.selectionShortcutEnabled !== false;
if (autoGroupTabsToggle) autoGroupTabsToggle.checked = stored[AUTO_GROUP_TABS_KEY] !== false;
if (helpImproveToggle) helpImproveToggle.checked = stored.helpImproveWebBrain !== false; // on by default
@@ -1347,6 +1353,11 @@ composerDeliveryModeSelect?.addEventListener('change', async () => {
await browser.storage.local.set({ composerDeliveryMode: mode }).catch(() => {});
});
+agentIndicatorStyleSelect?.addEventListener('change', async () => {
+ const style = AGENT_INDICATOR_STYLES.includes(agentIndicatorStyleSelect.value) ? agentIndicatorStyleSelect.value : 'circuit';
+ await browser.storage.local.set({ agentIndicatorStyle: style }).catch(() => {});
+});
+
downloadDirectoryInput?.addEventListener('input', () => {
downloadDirectoryInput.setCustomValidity('');
});
diff --git a/test/page-monitor-ui.mjs b/test/page-monitor-ui.mjs
index ce6c02dd5..b235f8e36 100644
--- a/test/page-monitor-ui.mjs
+++ b/test/page-monitor-ui.mjs
@@ -2255,6 +2255,59 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
} finally { await browser.close(); }
});
+ test(`${build}: agent cursor, target ring and every activity effect stay out of page feedback`, async () => {
+ const { browser, page } = await fixture(engine, build);
+ try {
+ // The settings select writes `agentIndicatorStyle`; the indicator applies it live.
+ await page.evaluate(() => {
+ window.storageListeners = [];
+ chrome.storage = {
+ local: { get: async defaults => ({ ...defaults, agentIndicatorStyle: 'scan' }) },
+ onChanged: { addListener: fn => storageListeners.push(fn) },
+ };
+ });
+ 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(300);
+ // Glide, press and ripple, then the resting breath (opacity only, via Web Animations).
+ await page.evaluate(() => window.__webbrainAgentIndicator.showTarget(document.getElementById('agent'), 'click_ax'));
+ await page.waitForTimeout(500);
+ await page.evaluate(() => window.__webbrainAgentIndicator.showTarget(document.getElementById('field'), 'type_text'));
+ await page.waitForTimeout(2200);
+ const resting = await page.evaluate(() => {
+ const cursor = document.getElementById('webbrain-agent-target-cursor');
+ const effect = document.getElementById('webbrain-agent-effect');
+ return {
+ cursorPointerEvents: getComputedStyle(cursor).pointerEvents,
+ cursorShown: getComputedStyle(cursor).opacity === '1',
+ breathing: cursor.firstElementChild.getAnimations().some(animation => animation.effect.getComputedTiming().iterations === Infinity),
+ effectPointerEvents: getComputedStyle(effect).pointerEvents,
+ effectDisplay: getComputedStyle(effect).display,
+ };
+ });
+ assert.deepEqual(resting, {
+ cursorPointerEvents: 'none', cursorShown: true, breathing: true, effectPointerEvents: 'none', effectDisplay: 'block',
+ });
+ for (const style of ['aurora', 'gears', 'classic', 'circuit']) {
+ await page.evaluate(style => storageListeners.forEach(fn => fn({ agentIndicatorStyle: { newValue: style } }, 'local')), style);
+ await page.evaluate(() => window.__webbrainAgentIndicator.showTarget(document.getElementById('select'), 'click_coordinates'));
+ await page.waitForTimeout(650);
+ }
+ assert.equal(await page.evaluate(() => document.querySelectorAll('#webbrain-agent-effect').length), 1, 'the previous effect is removed after a switch');
+ assert.equal((await page.evaluate(() => feedback)).length, 0, JSON.stringify(await page.evaluate(() => feedback)));
+ // Screenshot capture hides every part, and nothing intercepts real input.
+ await page.evaluate(() => messageListeners.forEach(listener => listener({ type: 'WB_HIDE_FOR_TOOL_USE' }, {}, () => {})));
+ assert.deepEqual(await page.evaluate(() => ['webbrain-agent-effect', 'webbrain-agent-target-cursor', 'webbrain-agent-stop-container']
+ .map(id => getComputedStyle(document.getElementById(id)).display)), ['none', 'none', 'none']);
+ await page.evaluate(() => messageListeners.forEach(listener => listener({ type: 'WB_SHOW_AFTER_TOOL_USE' }, {}, () => {})));
+ await page.locator('#human').click();
+ assert.ok((await page.evaluate(() => feedback)).some(event => event.kind === 'click' && 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 {
diff --git a/test/run.js b/test/run.js
index 62cf7d479..fd3600915 100644
--- a/test/run.js
+++ b/test/run.js
@@ -119964,6 +119964,38 @@ test('Chrome click_ax timeout after mouse press unwinds without completing the c
}
});
+test('agent activity effect is a General setting, portable, and read live by the page indicator', () => {
+ for (const [label, prefix, configTransfer, runtimeApi] of [
+ ['chrome', 'src/chrome', ConfigTransferCh, 'chrome'],
+ ['firefox', 'src/firefox', ConfigTransferFx, 'browser'],
+ ]) {
+ const settingsHtml = fs.readFileSync(path.join(ROOT, prefix, 'src/ui/settings.html'), 'utf8');
+ const settingsJs = fs.readFileSync(path.join(ROOT, prefix, 'src/ui/settings.js'), 'utf8');
+ const indicator = fs.readFileSync(path.join(ROOT, prefix, 'src/content/agent-visual-indicator.js'), 'utf8');
+
+ const select = settingsPanelHtml(settingsHtml, 'display').match(/<select id="select-agent-indicator-style"[\s\S]*?<\/select>/)?.[0];
+ assert.ok(select, `${label}: the effect choice belongs to Settings → General`);
+ assert.deepEqual([...select.matchAll(/<option value="([a-z]+)"/g)].map(match => match[1]),
+ ['circuit', 'aurora', 'scan', 'gears', 'classic'], `${label}: effect options changed`);
+ assert.match(settingsJs, new RegExp(`${runtimeApi}\\.storage\\.local\\.set\\(\\{ agentIndicatorStyle: style \\}\\)`), `${label}: the select must save agentIndicatorStyle`);
+ assert.match(indicator, /const STYLE_STORAGE_KEY = 'agentIndicatorStyle';/, `${label}: the indicator reads another key`);
+ assert.match(indicator, /const DEFAULT_STYLE = 'circuit';/, `${label}: Neural circuit should be the default effect`);
+ assert.match(indicator, new RegExp(`${runtimeApi}\\.storage\\?\\.onChanged`), `${label}: a new choice should apply to a running task`);
+ // The cursor animates through CSS transitions and Web Animations: the page
+ // monitor observes style attributes, so nothing may write them per frame.
+ const cursorClass = indicator.slice(indicator.indexOf('class AgentCursor'), indicator.indexOf('function createStopButton'));
+ assert.ok(cursorClass.length > 0, `${label}: AgentCursor missing`);
+ assert.doesNotMatch(cursorClass, /requestAnimationFrame/, `${label}: the cursor must not run a per-frame style loop`);
+
+ assert.equal(configTransfer.DEFAULT_CONFIG_SETTINGS.agentIndicatorStyle, 'circuit', `${label}: portable default changed`);
+ assert.ok(configTransfer.CONFIG_STORAGE_KEYS.includes('agentIndicatorStyle'), `${label}: config export/import omitted the effect`);
+ const exported = JSON.stringify(configTransfer.createConfigExport({ agentIndicatorStyle: 'gears' }));
+ assert.equal(configTransfer.parseConfigImport(exported).settings.agentIndicatorStyle, 'gears', `${label}: a chosen effect should survive export and import`);
+ const unknown = JSON.stringify({ ...JSON.parse(exported), settings: { ...JSON.parse(exported).settings, agentIndicatorStyle: 'sparkles' } });
+ assert.throws(() => configTransfer.parseConfigImport(unknown), /agentIndicatorStyle/, `${label}: an unknown effect should be rejected on import`);
+ }
+});
+
test('page Stop WebBrain clears stale indicators without stopping recordings', () => {
for (const [label, prefix, runtimeApi] of [
['chrome', 'src/chrome', 'chrome'],