Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: show the browser agent cursor where it clicks and types, with a Settings toggle (#13729)

Michael Han52a3fbefe8d8
diff --git a/studio/frontend/src/features/browser/agent/agent-store.ts b/studio/frontend/src/features/browser/agent/agent-store.ts
index 5738bc7c899..a977c97c0c4 100644
--- a/studio/frontend/src/features/browser/agent/agent-store.ts
+++ b/studio/frontend/src/features/browser/agent/agent-store.ts
@@ -48,6 +48,9 @@ type BrowserAgentState = {
setHistoryAccess: (access: HistoryAccess) => void;
scriptAccess: ScriptAccess;
setScriptAccess: (access: ScriptAccess) => void;
+ /** Draw a pointer in the page where the agent clicks, types and drags. */
+ showCursor: boolean;
+ setShowCursor: (show: boolean) => void;
/** By chat key (browser store `chat`). */
chats: Record<string, AgentChat>;
};
@@ -72,6 +75,8 @@ export const useBrowserAgentStore = create<BrowserAgentState>()(
setHistoryAccess: (historyAccess) => set({ historyAccess }),
scriptAccess: "ask",
setScriptAccess: (scriptAccess) => set({ scriptAccess }),
+ showCursor: true,
+ setShowCursor: (showCursor) => set({ showCursor }),
chats: {},
}),
{
@@ -84,6 +89,7 @@ export const useBrowserAgentStore = create<BrowserAgentState>()(
permissions: state.permissions,
historyAccess: state.historyAccess,
scriptAccess: state.scriptAccess,
+ showCursor: state.showCursor,
}),
// Checked on the way in: storage another build wrote must never read as "allow".
merge: (persisted, current) => {
@@ -94,6 +100,7 @@ export const useBrowserAgentStore = create<BrowserAgentState>()(
permissions: checkedPermissions(saved.permissions),
historyAccess: saved.historyAccess === "allow" || saved.historyAccess === "never" ? saved.historyAccess : "ask",
scriptAccess: saved.scriptAccess === "never" ? "never" : "ask",
+ showCursor: saved.showCursor !== false,
};
},
},
diff --git a/studio/frontend/src/features/browser/agent/executor.ts b/studio/frontend/src/features/browser/agent/executor.ts
index a8991976328..eb162b8a94b 100644
--- a/studio/frontend/src/features/browser/agent/executor.ts
+++ b/studio/frontend/src/features/browser/agent/executor.ts
@@ -389,7 +389,48 @@ const REF_SPAN = 100_000;
const LAST_BASE = 9_000 * REF_SPAN;
/** One command in the tab's page, installing the agent there first if this page lacks it. */
-async function pageCall(tab: BrowserTab, command: Record<string, unknown>): Promise<AgentAnswer> {
+let accentRaw = "";
+let accentColor = "";
+
+/** The theme's accent (toggles, badges; a custom Accent included) as rgb(), for the cursor's glow. */
+function cursorAccent(): string {
+ if (typeof document === "undefined") return "";
+ const raw = getComputedStyle(document.documentElement).getPropertyValue("--control-accent").trim();
+ if (raw !== accentRaw) {
+ accentRaw = raw;
+ accentColor = "";
+ // Painted, not read back from fillStyle, which keeps oklch() and color() as written.
+ const canvas = document.createElement("canvas");
+ canvas.width = 1;
+ canvas.height = 1;
+ const context = canvas.getContext("2d", { willReadFrequently: true });
+ if (context && raw) {
+ context.fillStyle = raw;
+ context.fillRect(0, 0, 1, 1);
+ const [r, g, b, a] = context.getImageData(0, 0, 1, 1).data;
+ if (a > 0) accentColor = `rgb(${r}, ${g}, ${b})`;
+ }
+ }
+ return accentColor;
+}
+
+/** Settings > Appearance > Reduce motion as `prefersReducedMotion` resolves it, read off the classes
+ * it sets on <html>: importing the settings store here would cycle through features/settings. */
+function reducedMotion(): boolean {
+ if (typeof document === "undefined") return false;
+ const html = document.documentElement.classList;
+ if (html.contains("force-reduced-motion")) return true;
+ if (html.contains("force-motion")) return false;
+ return window.matchMedia?.("(prefers-reduced-motion: reduce)").matches === true;
+}
+
+async function pageCall(tab: BrowserTab, request: Record<string, unknown>): Promise<AgentAnswer> {
+ const cursor = useBrowserAgentStore.getState().showCursor;
+ const command = {
+ ...request,
+ cursor,
+ ...(cursor ? { cursorColor: cursorAccent(), cursorStill: reducedMotion() } : {}),
+ };
const native = useNativeBrowser.getState().enabled;
const started = Date.now();
const fresh = () => {
@@ -797,12 +838,18 @@ async function perform(action: BrowserAction, context: Run): Promise<Result> {
});
if (!clicked.ok) return { ok: false, error: clicked.error };
if (clicked.navigate) {
+ const pressedAt = Date.now();
// A link: opened in this tab, under the same rules as any other address. Its href is read
// now, so it may not be one the last snapshot listed.
const gate = gateNavigation(clicked.navigate, navigationContext(action, context));
const refused = await pass(gate, context);
if (refused) return { ok: false, error: refused };
admit(clicked.navigate, gate, context);
+ // The page goes the moment the tab navigates, taking the cursor with it: let its press show first.
+ if (useBrowserAgentStore.getState().showCursor) {
+ await sleep(Math.max(0, LINK_PRESS_MS - (Date.now() - pressedAt)));
+ if (signal?.aborted) return { ok: false, error: STOPPED };
+ }
const sent = Date.now();
useBrowserStore.getState().navigate(ready.id, { url: clicked.navigate, from: here }, { replace: false });
const loaded = await waitForLoad(ready.id, signal);
@@ -858,6 +905,7 @@ type ShotView = {
doc?: string;
};
const MAX_SHOT_EDGE = 1024;
+const LINK_PRESS_MS = 350;
async function pagePoint(tab: BrowserTab, session: Session, x?: number, y?: number): Promise<{ x: number; y: number } | string | null> {
if (x === undefined || y === undefined) return null;
diff --git a/studio/frontend/src/features/browser/agent/page-agent.ts b/studio/frontend/src/features/browser/agent/page-agent.ts
index 0448c24cb50..2b889616a4a 100644
--- a/studio/frontend/src/features/browser/agent/page-agent.ts
+++ b/studio/frontend/src/features/browser/agent/page-agent.ts
@@ -82,7 +82,7 @@ export function installPageAgent(): PageAgent {
const VIEW_CHARS = 8000;
const PAGE_CHARS = 24000;
const MAX_LINKS = 400;
- const SKIP = new Set(["script", "style", "noscript", "template", "head", "meta", "link", "title"]);
+ const SKIP = new Set(["script", "style", "noscript", "template", "head", "meta", "link", "title", "unsloth-agent-cursor"]);
const ROLES = new Set([
"button",
"link",
@@ -125,7 +125,10 @@ export function installPageAgent(): PageAgent {
let scrolls = 0;
addEventListener("scroll", () => scrolls++, { capture: true, passive: true });
try {
- new MutationObserver(() => {
+ new MutationObserver((records) => {
+ // The agent's cursor going in or out (or into a dialog) is not the page changing.
+ const own = (node: Node) => node.nodeName === "UNSLOTH-AGENT-CURSOR";
+ if (records.every((r) => r.type === "childList" && [...r.addedNodes].every(own) && [...r.removedNodes].every(own))) return;
lastMutation = performance.now();
}).observe(document, { subtree: true, childList: true, attributes: true, characterData: true });
} catch {
@@ -282,6 +285,7 @@ export function installPageAgent(): PageAgent {
if (style === null) el.removeAttribute("style");
}
masked.clear();
+ cursor.mask(on);
if (!on) return { ok: true };
const fields: HTMLInputElement[] = [];
const visit = (root: Document | ShadowRoot) => {
@@ -532,6 +536,177 @@ export function installPageAgent(): PageAgent {
? { x: command.x, y: command.y }
: null;
+ // The agent's pointer (Settings > Browser). Everything it moves lives in a closed shadow root, which
+ // no MutationObserver on the document sees, so the page and the settle wait only see it inserted
+ // once; it moves by transform (compositor only) and pointer-events: none keeps it out of hit tests.
+ // CSSOM and createElementNS only: a page's CSP or Trusted Types can block <style> and innerHTML.
+ const cursor = (() => {
+ const SVG = "http://www.w3.org/2000/svg";
+ const IDLE_MS = 4000;
+ let on = false;
+ // Reduce motion: the cursor jumps and fades instead of gliding, and presses get no ring.
+ let still = false;
+ // Studio's accent as "r,g,b"; only digits parsed from rgb() ever reach a style.
+ let rgb = "59,130,246";
+ let parts: { host: HTMLElement; mover: HTMLElement; arrow: SVGSVGElement; ring: HTMLElement; rgb: string } | null = null;
+ let shown = false;
+ let masking = false;
+ let idle = 0;
+ // Only the host needs !important (page CSS can reach it); inside the closed root it would also
+ // outrank the ring's animation.
+ const styled = <E extends Element>(el: E, css: Record<string, string>, important = false): E => {
+ for (const [name, value] of Object.entries(css)) {
+ (el as unknown as HTMLElement).style.setProperty(name, value, important ? "important" : "");
+ }
+ return el;
+ };
+ // The glow is on the arrow alone: under a shared filter the ring's pulse would re-run it every frame.
+ const tint = () => {
+ if (!parts || parts.rgb === rgb) return;
+ parts.rgb = rgb;
+ parts.arrow.style.filter = `drop-shadow(0 0 3px rgba(${rgb},.95)) drop-shadow(0 0 7px rgba(${rgb},.55))`;
+ parts.ring.style.borderColor = `rgba(${rgb},.9)`;
+ };
+ const build = () => {
+ if (parts?.host.isConnected) return parts;
+ remove();
+ const host = styled(document.createElement("unsloth-agent-cursor"), {
+ all: "initial", display: "block", position: "fixed", left: "0", top: "0", width: "0", height: "0",
+ overflow: "visible", "pointer-events": "none", "z-index": "2147483647", contain: "layout style size",
+ }, true);
+ host.setAttribute("aria-hidden", "true");
+ const root = host.attachShadow({ mode: "closed" });
+ const mover = styled(document.createElement("div"), {
+ position: "absolute", left: "0", top: "0", opacity: "0", "will-change": "transform, opacity",
+ transition: "opacity 160ms ease-out",
+ });
+ const ring = styled(document.createElement("div"), {
+ position: "absolute", left: "-14px", top: "-14px", width: "28px", height: "28px", "box-sizing": "border-box",
+ "border-radius": "50%", border: "2px solid", opacity: "0",
+ });
+ // Hugeicons cursor-02, its corners rounded further by a round-joined stroke of the fill (white
+ // outline drawn wider underneath), then scaled back to size about its tip at (3, 3). The rounded
+ // tip ends up 1.25px short of (0, 0), hence the offset.
+ const arrow = styled(document.createElementNS(SVG, "svg"), {
+ position: "absolute", left: "-1.25px", top: "-1.25px", width: "24px", height: "24px", overflow: "visible",
+ });
+ arrow.setAttribute("viewBox", "0 0 24 24");
+ const shape = document.createElementNS(SVG, "g");
+ shape.setAttribute("transform", "translate(3 3) scale(.837) translate(-3 -3)");
+ for (const [color, width] of [["#fff", "6.5"], ["#0b0b0f", "3.5"]]) {
+ const path = document.createElementNS(SVG, "path");
+ path.setAttribute(
+ "d",
+ "M9.80282 4.62973L15.8364 6.99069C19.3164 8.35243 21.0564 9.03329 20.9987 10.1133C20.941 11.1934 19.1251 11.6886 15.4933 12.6791C14.412 12.974 13.8713 13.1215 13.4964 13.4963C13.1215 13.8712 12.9741 14.4119 12.6791 15.4933C11.6887 19.125 11.1934 20.9409 10.1134 20.9986C9.03335 21.0563 8.35249 19.3163 6.99075 15.8363L4.62979 9.80276C3.20411 6.15934 2.49127 4.33764 3.41448 3.41442C4.3377 2.49121 6.15941 3.20405 9.80282 4.62973Z",
+ );
+ path.setAttribute("fill", color);
+ path.setAttribute("stroke", color);
+ path.setAttribute("stroke-width", width);
+ path.setAttribute("stroke-linejoin", "round");
+ shape.append(path);
+ }
+ arrow.append(shape);
+ mover.append(ring, arrow);
+ root.append(mover);
+ parts = { host, mover, arrow, ring, rgb: "" };
+ shown = false;
+ return parts;
+ };
+ // A modal dialog, an open popover or a fullscreen element paints above every z-index (and fullscreen
+ // shows only its own subtree), so the cursor goes into the topmost one. Not the top layer itself:
+ // a popover's ::backdrop could take the user's clicks.
+ const layer = (): Element => {
+ let top: Element | null = document.fullscreenElement;
+ // Queried apart: a selector this engine doesn't know would void the other.
+ for (const selector of ["dialog:modal", ":popover-open"]) {
+ try {
+ const open = document.querySelectorAll(selector);
+ if (open.length > 0) top = open[open.length - 1];
+ } catch {
+ // Unknown selector.
+ }
+ }
+ return top && !/^(video|img|canvas|iframe|input|textarea|select)$/i.test(top.tagName) ? top : document.documentElement;
+ };
+ function remove() {
+ window.clearTimeout(idle);
+ parts?.host.remove();
+ parts = null;
+ shown = false;
+ }
+ return {
+ get on() {
+ return on;
+ },
+ /** From every command, so turning it off in Settings clears it at the next call. */
+ configure(command: Record<string, unknown>) {
+ if (typeof command.cursor === "boolean" && command.cursor !== on) {
+ on = command.cursor;
+ if (!on) remove();
+ }
+ const color = typeof command.cursorColor === "string" ? /^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.exec(command.cursorColor) : null;
+ if (color) rgb = color.slice(1).map((part) => Math.min(255, Number(part))).join(",");
+ if (typeof command.cursorStill === "boolean") still = command.cursorStill;
+ },
+ /** Glides to `at` (CSS px of the viewport); `press` adds the ring. Drag steps come every frame,
+ * so they follow closely (`glideMs`); a jump to a new target eases. */
+ show(at: Point, press: boolean, glideMs = 180) {
+ if (!on) return;
+ const c = build();
+ tint();
+ const parent = layer();
+ if (c.host.parentNode !== parent) {
+ parent.append(c.host);
+ shown = false;
+ }
+ // Appearing after a rest: at the target, not gliding in from where it faded, and without the
+ // forced layout a transition reset would need.
+ const glide = shown && !still;
+ c.mover.style.transition = glide
+ ? `transform ${glideMs}ms cubic-bezier(.2,.7,.3,1), opacity 160ms ease-out`
+ : "opacity 160ms ease-out";
+ c.mover.style.transform = `translate3d(${Math.round(at.x)}px, ${Math.round(at.y)}px, 0)`;
+ c.mover.style.opacity = masking ? "0" : "1";
+ shown = true;
+ if (press && !still && typeof c.ring.animate === "function") {
+ c.ring.animate(
+ [
+ { transform: "scale(.35)", opacity: 0.9 },
+ { transform: "scale(1.5)", opacity: 0 },
+ ],
+ { duration: 420, delay: glide ? glideMs : 0, easing: "ease-out" },
+ );
+ }
+ window.clearTimeout(idle);
+ idle = window.setTimeout(() => {
+ shown = false;
+ if (parts) parts.mover.style.opacity = "0";
+ }, IDLE_MS);
+ },
+ /** Out of the model's screenshots: it would read the pointer as part of the page. */
+ mask(hide: boolean) {
+ masking = hide;
+ if (!parts) return;
+ parts.mover.style.transition = "none";
+ parts.mover.style.opacity = !hide && shown ? "1" : "0";
+ },
+ };
+ })();
+ /** Where an action will land, taken before it runs: a click can remove its own target. Scrolled as
+ * the action itself scrolls (so its own scroll is then a no-op); a dropdown, which isn't scrolled, as it is. */
+ const aimAt = (command: Record<string, unknown>): Point | null => {
+ const op = command.op;
+ if (op !== "click" && op !== "type" && op !== "select" && op !== "pointer") return null;
+ const at = pointIn(command);
+ if (at || op === "pointer") return at;
+ const el = byRef.get(Number(String(command.ref ?? "").replace(/^r/i, "")))?.deref();
+ if (!el?.isConnected) return null;
+ if (op === "click") el.scrollIntoView({ block: "center", inline: "center" });
+ else if (op === "type") el.scrollIntoView({ block: "center" });
+ const rect = el.getBoundingClientRect();
+ return sized(rect) ? { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 } : null;
+ };
+
const elementAt = ({ x, y }: Point): Element => {
const outside = "that point is outside the visible page; take a screenshot to see what is there.";
if (x < 0 || y < 0 || x >= window.innerWidth || y >= window.innerHeight) throw new AgentError(outside);
@@ -1101,7 +1276,7 @@ export function installPageAgent(): PageAgent {
return { ok: true };
};
- const run = (command: Record<string, unknown>): Record<string, unknown> => {
+ const dispatch = (command: Record<string, unknown>): Record<string, unknown> => {
// Each page numbers its refs from where the panel says, so a ref kept from the last page
// misses rather than landing on whatever has that number here.
if (nextRef === 1 && typeof command.base === "number" && Number.isSafeInteger(command.base) && command.base > 0) {
@@ -1168,6 +1343,26 @@ export function installPageAgent(): PageAgent {
}
};
+ const run = (command: Record<string, unknown>): Record<string, unknown> => {
+ cursor.configure(command);
+ let aim: Point | null = null;
+ try {
+ aim = cursor.on ? aimAt(command) : null;
+ } catch {
+ // Only a picture: the action still runs.
+ }
+ const answer = dispatch(command);
+ if (aim && answer.ok === true) {
+ try {
+ const move = command.op === "pointer" && command.phase === "move";
+ cursor.show(aim, command.op !== "pointer" || command.phase === "down", move ? 40 : 180);
+ } catch {
+ // Only a picture: the action already happened.
+ }
+ }
+ return answer;
+ };
+
// For native views, which look it up on every call. A page that defines KEY first still wins
// there: the agent shares the page's world, so its answers are untrusted.
function view() {
diff --git a/studio/frontend/src/features/settings/settings-search.ts b/studio/frontend/src/features/settings/settings-search.ts
index 2e069128c5e..c2899553d0f 100644
--- a/studio/frontend/src/features/settings/settings-search.ts
+++ b/studio/frontend/src/features/settings/settings-search.ts
@@ -146,6 +146,7 @@ export const SETTINGS_SEARCH_INDEX: Record<SettingsTab, TranslationKey[]> = {
"browser.agentSettings.enable",
"browser.agentSettings.history",
"browser.agentSettings.scripts",
+ "browser.agentSettings.cursor",
"browser.agentSettings.permissionsTitle",
"browser.linksTitle",
"browser.openLinksSetting",
diff --git a/studio/frontend/src/features/settings/tabs/browser-agent-settings.tsx b/studio/frontend/src/features/settings/tabs/browser-agent-settings.tsx
index 0cc06dbdff2..9bd7e5cceb8 100644
--- a/studio/frontend/src/features/settings/tabs/browser-agent-settings.tsx
+++ b/studio/frontend/src/features/settings/tabs/browser-agent-settings.tsx
@@ -197,7 +197,8 @@ export function BrowserAgentSettings() {
const enabled = useBrowserAgentStore((state) => state.enabled);
const historyAccess = useBrowserAgentStore((state) => state.historyAccess);
const scriptAccess = useBrowserAgentStore((state) => state.scriptAccess);
- const { setEnabled, setHistoryAccess, setScriptAccess } = useBrowserAgentStore.getState();
+ const showCursor = useBrowserAgentStore((state) => state.showCursor);
+ const { setEnabled, setHistoryAccess, setScriptAccess, setShowCursor } = useBrowserAgentStore.getState();
return (
<>
<SettingsSection title={t("browser.agentSettings.title")}>
@@ -234,6 +235,9 @@ export function BrowserAgentSettings() {
</SelectContent>
</Select>
</SettingsRow>
+ <SettingsRow label={t("browser.agentSettings.cursor")} description={t("browser.agentSettings.cursorDescription")}>
+ <Switch aria-label={t("browser.agentSettings.cursor")} checked={showCursor} onCheckedChange={setShowCursor} />
+ </SettingsRow>
</SettingsSection>
<PermissionsTable />
</>
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index 0e06ee4f458..987aebaa277 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -61,6 +61,8 @@ export const ar = {
never: "أبدًا",
scripts: "تشغيل البرامج النصية",
scriptsDescription: "اختر ما إذا كان يمكن للنماذج تشغيل برامج نصية على الصفحات. يُعرض عليك كل برنامج نصي قبل تشغيله",
+ cursor: "إظهار المؤشر",
+ cursorDescription: "يعرض مؤشرًا حيث تنقر النماذج وتكتب وتسحب في الصفحة",
askEveryTime: "السؤال في كل مرة",
permissionsTitle: "أذونات الوكيل",
permissionsDescription: "اختر الإعدادات الافتراضية وأضف استثناءات لمواقع محددة. لا تُملأ حقول كلمات المرور والدفع أبدًا مهما كانت هذه الإعدادات.",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index f0cb158a216..fbc62e00c70 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -61,6 +61,8 @@ export const de = {
never: "Nie",
scripts: "Skripte ausführen",
scriptsDescription: "Lege fest, ob Modelle Skripte auf Seiten ausführen dürfen. Jedes Skript wird dir vorher angezeigt",
+ cursor: "Cursor anzeigen",
+ cursorDescription: "Zeigt einen Zeiger dort, wo Modelle auf der Seite klicken, tippen und ziehen",
askEveryTime: "Jedes Mal fragen",
permissionsTitle: "Agent-Berechtigungen",
permissionsDescription: "Lege Standardwerte fest und füge Ausnahmen für bestimmte Websites hinzu. Passwort- und Zahlungsfelder werden nie ausgefüllt, egal was hier steht.",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 4764435e52f..7bddb832a6b 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -58,6 +58,8 @@ export const en = {
never: "Never",
scripts: "Run scripts",
scriptsDescription: "Choose whether models can run scripts on pages. You see each script before it runs",
+ cursor: "Show cursor",
+ cursorDescription: "Show a pointer where models click, type and drag on the page",
askEveryTime: "Ask every time",
permissionsTitle: "Agent permissions",
permissionsDescription: "Choose defaults and add exceptions for specific sites. Password and payment fields are never filled, whatever these say.",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index 2ab0c1f49c3..b97653a32aa 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -61,6 +61,8 @@ export const es = {
never: "Nunca",
scripts: "Ejecutar scripts",
scriptsDescription: "Elige si los modelos pueden ejecutar scripts en las páginas. Verás cada script antes de que se ejecute",
+ cursor: "Mostrar cursor",
+ cursorDescription: "Muestra un puntero donde los modelos hacen clic, escriben y arrastran en la página",
askEveryTime: "Preguntar cada vez",
permissionsTitle: "Permisos del agente",
permissionsDescription: "Elige los valores predeterminados y añade excepciones para sitios concretos. Los campos de contraseña y de pago nunca se rellenan, digan lo que digan estos ajustes.",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index 6519ec31556..9697bf5b119 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -61,6 +61,8 @@ export const fr = {
never: "Jamais",
scripts: "Exécuter des scripts",
scriptsDescription: "Choisissez si les modèles peuvent exécuter des scripts sur les pages. Chaque script vous est montré avant de s’exécuter",
+ cursor: "Afficher le curseur",
+ cursorDescription: "Affiche un pointeur là où les modèles cliquent, saisissent et font glisser sur la page",
askEveryTime: "Demander à chaque fois",
permissionsTitle: "Autorisations de l'agent",
permissionsDescription: "Choisissez les valeurs par défaut et ajoutez des exceptions pour certains sites. Les champs de mot de passe et de paiement ne sont jamais remplis, quels que soient ces réglages.",
diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.ts
index 722b44e80b0..48b144d5aeb 100644
--- a/studio/frontend/src/i18n/locales/he.ts
+++ b/studio/frontend/src/i18n/locales/he.ts
@@ -62,6 +62,8 @@ export const he = {
never: "אף פעם",
scripts: "הרצת סקריפטים",
scriptsDescription: "בחרו אם מודלים יכולים להריץ סקריפטים בדפים. כל סקריפט מוצג לכם לפני שהוא רץ",
+ cursor: "הצגת סמן",
+ cursorDescription: "מציג סמן במקום שבו מודלים לוחצים, מקלידים וגוררים בדף",
askEveryTime: "לשאול בכל פעם",
permissionsTitle: "הרשאות הסוכן",
permissionsDescription: "בחירת ברירות מחדל והוספת חריגים לאתרים מסוימים. שדות סיסמה ותשלום לעולם אינם ממולאים, לא משנה מה מוגדר כאן.",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index 2bc957311f2..fcee5cb4195 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -61,6 +61,8 @@ export const hi = {
never: "कभी नहीं",
scripts: "स्क्रिप्ट चलाएँ",
scriptsDescription: "चुनें कि मॉडल पेजों पर स्क्रिप्ट चला सकते हैं या नहीं। हर स्क्रिप्ट चलने से पहले आपको दिखाई जाती है",
+ cursor: "कर्सर दिखाएँ",
+ cursorDescription: "पेज पर जहाँ मॉडल क्लिक, टाइप और ड्रैग करते हैं, वहाँ एक पॉइंटर दिखाएँ",
askEveryTime: "हर बार पूछें",
permissionsTitle: "एजेंट अनुमतियाँ",
permissionsDescription: "डिफ़ॉल्ट चुनें और खास साइटों के लिए अपवाद जोड़ें। पासवर्ड और भुगतान फ़ील्ड कभी नहीं भरे जाते, चाहे यहाँ कुछ भी हो।",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index 54f546b1224..4cd80cba6b0 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -60,6 +60,8 @@ export const it = {
never: "Mai",
scripts: "Esegui script",
scriptsDescription: "Scegli se i modelli possono eseguire script nelle pagine. Ogni script ti viene mostrato prima dell’esecuzione",
+ cursor: "Mostra cursore",
+ cursorDescription: "Mostra un puntatore dove i modelli fanno clic, scrivono e trascinano nella pagina",
askEveryTime: "Chiedi ogni volta",
permissionsTitle: "Autorizzazioni dell'agente",
permissionsDescription: "Scegli i valori predefiniti e aggiungi eccezioni per siti specifici. I campi di password e pagamento non vengono mai compilati, qualunque cosa indichino queste impostazioni.",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index ae7ac56037a..5bab4ba05e0 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -62,6 +62,8 @@ export const ja = {
never: "許可しない",
scripts: "スクリプトの実行",
scriptsDescription: "モデルがページ上でスクリプトを実行できるかどうかを選択します。各スクリプトは実行前に表示されます",
+ cursor: "カーソルを表示",
+ cursorDescription: "モデルがページ上でクリック、入力、ドラッグする位置にポインターを表示します",
askEveryTime: "その都度確認",
permissionsTitle: "エージェントの権限",
permissionsDescription: "既定の動作を選び、特定のサイトに例外を追加します。パスワードや支払い情報の欄は、この設定にかかわらず入力されません。",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index 8a8175f865d..819e10666a0 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -61,6 +61,8 @@ export const ko = {
never: "허용 안 함",
scripts: "스크립트 실행",
scriptsDescription: "모델이 페이지에서 스크립트를 실행할 수 있는지 선택합니다. 각 스크립트는 실행 전에 표시됩니다",
+ cursor: "커서 표시",
+ cursorDescription: "모델이 페이지에서 클릭, 입력, 드래그하는 위치에 포인터를 표시합니다",
askEveryTime: "매번 묻기",
permissionsTitle: "에이전트 권한",
permissionsDescription: "기본값을 선택하고 특정 사이트에 대한 예외를 추가합니다. 비밀번호와 결제 정보 입력란은 이 설정과 관계없이 채우지 않습니다.",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 0d102006f3a..1e858a8bca8 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -61,6 +61,8 @@ export const ptBR = {
never: "Nunca",
scripts: "Executar scripts",
scriptsDescription: "Escolha se os modelos podem executar scripts nas páginas. Cada script é mostrado a você antes de ser executado",
+ cursor: "Mostrar cursor",
+ cursorDescription: "Mostra um ponteiro onde os modelos clicam, digitam e arrastam na página",
askEveryTime: "Perguntar toda vez",
permissionsTitle: "Permissões do agente",
permissionsDescription: "Escolha os padrões e adicione exceções para sites específicos. Campos de senha e de pagamento nunca são preenchidos, seja qual for a configuração.",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index 50fbecd3674..007c0853320 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -61,6 +61,8 @@ export const ru = {
never: "Никогда",
scripts: "Запуск скриптов",
scriptsDescription: "Выберите, могут ли модели запускать скрипты на страницах. Каждый скрипт сначала показывается вам",
+ cursor: "Показывать курсор",
+ cursorDescription: "Показывает указатель там, где модели нажимают, вводят текст и перетаскивают на странице",
askEveryTime: "Спрашивать каждый раз",
permissionsTitle: "Разрешения агента",
permissionsDescription: "Выберите значения по умолчанию и добавьте исключения для отдельных сайтов. Поля паролей и платежей никогда не заполняются, что бы здесь ни было указано.",
diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.ts
index 70d72e8b3f6..03f628e1077 100644
--- a/studio/frontend/src/i18n/locales/sv.ts
+++ b/studio/frontend/src/i18n/locales/sv.ts
@@ -59,6 +59,8 @@ export const sv = {
never: "Aldrig",
scripts: "Köra skript",
scriptsDescription: "Välj om modeller får köra skript på sidor. Varje skript visas för dig innan det körs",
+ cursor: "Visa markör",
+ cursorDescription: "Visar en pekare där modeller klickar, skriver och drar på sidan",
askEveryTime: "Fråga varje gång",
permissionsTitle: "Agentbehörigheter",
permissionsDescription: "Välj standardvärden och lägg till undantag för vissa webbplatser. Lösenords- och betalningsfält fylls aldrig i, oavsett inställningarna här.",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index 9753a23f55e..5e37941459b 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -61,6 +61,8 @@ export const zhCN = {
never: "从不",
scripts: "运行脚本",
scriptsDescription: "选择模型是否可以在页面上运行脚本。每个脚本运行前都会先向你显示",
+ cursor: "显示光标",
+ cursorDescription: "在模型于页面上点击、输入和拖动的位置显示指针",
askEveryTime: "每次都询问",
permissionsTitle: "代理权限",
permissionsDescription: "选择默认设置,并为特定网站添加例外。无论这里如何设置,都不会填写密码和支付信息字段。",
diff --git a/studio/frontend/tests/browser-agent-cursor.test.ts b/studio/frontend/tests/browser-agent-cursor.test.ts
new file mode 100644
index 00000000000..178b79fc4a3
--- /dev/null
+++ b/studio/frontend/tests/browser-agent-cursor.test.ts
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import { register } from "node:module";
+import { test } from "node:test";
+
+register("./helpers/browser-executor-resolver.mjs", import.meta.url);
+const { runBrowserAction } = await import("../src/features/browser/agent/executor.ts");
+const { useBrowserAgentStore } = await import("../src/features/browser/agent/agent-store.ts");
+
+const { useBrowserStore } = await import("../src/features/browser/store.ts");
+// No page loads in node: a tab sent somewhere finishes loading on the next tick, as a quick page would.
+const realNavigate = useBrowserStore.getState().navigate;
+useBrowserStore.setState({
+ navigate: (...args: Parameters<typeof realNavigate>) => {
+ const result = realNavigate(...args);
+ setTimeout(() => useBrowserStore.getState().updateTab(args[0], { loading: false }), 0);
+ return result;
+ },
+});
+
+const globals = globalThis as Record<string, unknown>;
+const policy = { allowedDomains: [], blockedDomains: [] };
+
+const stills: unknown[] = [];
+
+async function cursorFlags(url: string): Promise<unknown[]> {
+ globals.__authFetch = async () => new Response(null, { status: 200 });
+ const flags: unknown[] = [];
+ globals.__frameAgent = async (_tabId: string, op: Record<string, unknown>) => {
+ flags.push(op.cursor);
+ stills.push(op.cursorStill);
+ if (op.op === "status") return { installed: true, result: { ok: true, quietMs: 1000, requests: 0, doc: "r1" } };
+ return { installed: true, result: { ok: true, text: "page", links: [] } };
+ };
+ const run = { runKey: "r", userText: `open ${url}` };
+ await runBrowserAction({ id: url, sessionId: "s", op: "navigate", url, direction: "down", policy }, run);
+ return flags;
+}
+
+test("the cursor is on by default and every page command carries the setting", async () => {
+ assert.equal(useBrowserAgentStore.getState().showCursor, true);
+ const flags = await cursorFlags("https://example.com/a");
+ assert.ok(flags.length > 0);
+ assert.ok(flags.every((flag) => flag === true), flags.join(", "));
+ // Reduce motion travels with the cursor; off here, where there is no document to read it from.
+ assert.ok(stills.every((still) => still === false), stills.join(", "));
+});
+
+test("turning the cursor off in Settings reaches the page on the next command", async () => {
+ useBrowserAgentStore.getState().setShowCursor(false);
+ try {
+ const flags = await cursorFlags("https://example.com/b");
+ assert.ok(flags.length > 0);
+ assert.ok(flags.every((flag) => flag === false), flags.join(", "));
+ } finally {
+ useBrowserAgentStore.getState().setShowCursor(true);
+ }
+});
+
+
+/** From the page's answer to the click until the tab is told to navigate. */
+async function linkClickHold(showCursor: boolean, from: string): Promise<number> {
+ useBrowserAgentStore.getState().setShowCursor(showCursor);
+ globals.__authFetch = async () => new Response(null, { status: 200 });
+ const link = { role: "link", name: "Docs", tag: "a", href: `${from}docs`, formMethod: "", formAction: "", formHasPassword: false, submits: false };
+ let clickedAt = 0;
+ globals.__frameAgent = async (_tabId: string, op: Record<string, unknown>) => {
+ if (op.op === "status") return { installed: true, result: { ok: true, quietMs: 1000, requests: 0, doc: "r1" } };
+ if (op.op === "describe") return { installed: true, result: { ok: true, info: link, hit: "r5", sig: "s" } };
+ if (op.op === "click") {
+ clickedAt = Date.now();
+ return { installed: true, result: { ok: true, navigate: `${from}docs` } };
+ }
+ return { installed: true, result: { ok: true, text: "page", links: [] } };
+ };
+ const run = { runKey: "r", userText: `open ${from} and click Docs` };
+ await runBrowserAction({ id: `${from}open`, sessionId: "s", op: "navigate", url: from, direction: "down", policy }, run);
+ // Nothing loads here, so the click's wait for the new page is cut off once the tab is sent on.
+ const stop = new AbortController();
+ const original = useBrowserStore.getState().navigate;
+ let navigatedAt = 0;
+ useBrowserStore.setState({
+ navigate: (...args: Parameters<typeof original>) => {
+ if (!navigatedAt && clickedAt) {
+ navigatedAt = Date.now();
+ stop.abort();
+ }
+ return original(...args);
+ },
+ });
+ try {
+ await runBrowserAction({ id: `${from}click`, sessionId: "s", op: "click", ref: "r5", direction: "down", policy }, { ...run, signal: stop.signal });
+ } finally {
+ useBrowserStore.setState({ navigate: original });
+ }
+ assert.ok(clickedAt && navigatedAt, "the link click never sent the tab on");
+ return navigatedAt - clickedAt;
+}
+
+test("a link click holds the navigation briefly so the cursor's press shows, only with the cursor on", async () => {
+ try {
+ assert.ok((await linkClickHold(true, "https://example.com/c/")) >= 300);
+ assert.ok((await linkClickHold(false, "https://example.com/d/")) < 300);
+ } finally {
+ useBrowserAgentStore.getState().setShowCursor(true);
+ }
+});