Skip to content

Studio: Always allow for browser scripts, globally or per site - #16707

Merged
danielhanchen merged 6 commits into
unslothai:mainfrom
debojyoti-dev:fix/browser-script-always-allow-16705
Nov 14, 2026
Merged

danielhanchen merged 6 commits into
unslothai:mainfrom
debojyoti-dev:fix/browser-script-always-allow-16705

Conversation

@debojyoti-dev

@debojyoti-dev debojyoti-dev commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #16705

What changes

The issue asks for a hands-off option for browser_evaluate, since Run scripts currently offers only "Ask every time" or "Never". #13529 left out Allow on purpose, so this keeps "Ask every time" as the default and makes the hands-off choices explicit:

  • Settings > Browser > Run scripts now offers Ask every time (default), Always allow and Never. Picking Always allow (or setting the Default row's Scripts rule to Always allow, which also covers every site) first opens an "Allow all scripts?" confirmation; Cancel keeps the current setting. With Always allow the row's description switches to a warning that models run scripts on any page without asking and that a script can read and change anything on the page.
  • Agent permissions gain a Scripts rule, on the default row and per site: Requires approval (default) or Always allow. With Run scripts on Ask every time, a script on a site whose rule is Always allow (or a subdomain of it) runs without the prompt; every other site still asks. The most specific site rule wins, as for the other columns, and a page with no host (about:blank) always asks.
  • Never still removes browser_evaluate from the turn and the executor still refuses it, whatever the site rules say.
  • Full access does not cover scripts: only Run scripts or a site's own Scripts rule skips that prompt, as before.
  • Stored values are still checked on load: scriptAccess reads allow and never as saved and anything else as ask; a site rule saved before this change (no scripts) or with an unknown value reads as Requires approval.
  • The "auto-allow read-only scripts" idea from the issue is left out: a script's source can't reliably prove it has no side effects.
  • Two new strings (scriptsColumn, scriptsAllowDescription) in all 25 locale files.

Tests

  • tests/browser-agent-gate.test.ts: scriptRunsWithoutAsking across Always allow / Ask / Never, site and subdomain rules, a narrower subdomain rule winning, a lookalike host, about:blank; checkedPermissions for the new scripts field; browser_evaluate stays in the turn under Always allow.
  • tests/browser-sync-across-windows.test.ts: scriptAccess: "allow" written by another window is kept and saved; an unknown value reads as ask.
  • Existing rule literals in browser-agent-steps.test.ts and browser-settings.test.ts gain the new field.

Verification (Windows 11, Ryzen 5 5600H)

  • npm run typecheck, npm run i18n:check:strict: clean.
  • npm test: 14915 pass, 0 fail.
  • Real Settings dialog in headless Chromium (vite + the smoke-settings.html harness): Run scripts lists the three options and saves allow; the warning description appears; the default row and a newly added site show a Scripts rule; the site's Always allow is saved; both survive a reload; a hand-written scriptAccess: "yes" reads as Ask every time; no page errors.

Not tested here: a model actually calling browser_evaluate end to end in the browser panel (needs a loaded tool-calling model); the skip path is covered by the scriptRunsWithoutAsking unit tests. Desktop (Tauri) build not tried.

Screenshots

Settings > Browser, main (7bf13f21c) on the left, this PR (2525437054) on the right, two separate Studio installs.

The Default permissions row gains a Scripts rule (Requires approval by default).

Settings > Browser, permissions table

Run scripts menu: Ask every time / Never before, Ask every time / Always allow / Never after.

Run scripts options

Picking Always allow asks for confirmation first. Cancel leaves Run scripts on Ask every time.

Allow all scripts confirmation

After confirming, the row's description switches to the warning that models run scripts on any page without asking.

Run scripts set to Always allow

Settings > Browser > Run scripts gains "Always allow" next to "Ask every
time" and "Never", with a description that warns scripts then run on any
page without asking. Agent permissions gain a Scripts rule (default and
per site: Requires approval / Always allow), so scripts on trusted sites
skip the prompt while other sites still ask. Never still refuses scripts
everywhere, Full access still does not cover scripts, and a stored value
that isn't ask/allow/never still reads as ask.

Fixes unslothai#16705
@danielhanchen danielhanchen added >3000# affects UI# edge case# new-feature# security# Moves a security boundary: sandbox, allowlist, permission or network guard labels Nov 5, 2026
@danielhanchen danielhanchen self-assigned this Nov 13, 2026
# Conflicts:
#	studio/frontend/src/features/browser/agent/executor.ts
… Always allow and site Scripts rules; tighten comments
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T08:35:12.776676Z 2525437 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 59c3dcb1b8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 13, 2026
danielhanchen added a commit that referenced this pull request Nov 13, 2026
…iffusers is missing (#17685)

## Summary

`(Python 3.13, a-f)` fails on main and on every PR based on it since
#17595 (seen on the staging runs for #15275 and #16707): 25 tests in
`studio/backend/tests/test_diffusion_vae_canvas.py`, for example

```
tests/test_diffusion_vae_canvas.py:126: in test_constant_grid_matches_the_overlap_add_and_stock_does_not
tests/test_diffusion_vae_canvas.py:25: in _image_vae_cls
core/inference/diffusion_minimax_h3_image.py:211: in vae_class
core/inference/diffusion_minimax_h3_image.py:178: in _load_vendored
E   ModuleNotFoundError: No module named 'diffusers'
```

`vae_class()` returns diffusers' `AutoencoderKLMiniMaxH3Image` or,
failing that, the vendored copy in
`studio/backend/vendor/diffusers_minimax_h3_image/`. The vendored file
builds on diffusers' own base classes (`from
diffusers.configuration_utils import ConfigMixin`,
`diffusers.models.attention`, ...), so without diffusers both paths
fail. The Studio backend CI shards do not install diffusers.

The product code is fine: Studio only reaches this VAE when diffusers is
installed. Only the test assumed diffusers was there. One test in the
file already guards on it (`pytest.importorskip("diffusers")` at line
439).

Reproduced on main with `diffusers` blocked: 25 failed, 3 passed, 2
skipped.

## Change

`_image_vae_cls()`, the helper every VAE-building test goes through,
calls `pytest.importorskip("diffusers")` first. The tests that do not
build the VAE (the bad-output probe and the graph race bookkeeping)
still run without diffusers. Test-only change.

## Testing

- `diffusers` blocked: 3 passed, 27 skipped. main: 25 failed.
- With diffusers installed: 30 passed, same as main.
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 2525437054

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 14, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 14, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 14, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 14, 2026
@danielhanchen
danielhanchen merged commit 6dbcbfe into unslothai:main Nov 14, 2026
danielhanchen added a commit that referenced this pull request Nov 16, 2026
…cripts rule (#17959)

Fixes #17837

## Problem

When the browser agent wants to run a script on a page, the prompt only
offers Deny and Allow. #16707 added hands-off options for scripts, but
only in Settings > Browser (Run scripts: Always allow, or a per-site
Scripts rule under Agent permissions). Nothing on the prompt leads
there. A user who keeps answering the prompt keeps getting it on every
script, so a task left running on a trusted site stalls until someone
comes back to click Allow again. The "Always allow" answers people give
on other prompts (opening a site, sign-ins, risky buttons) never cover
scripts, which reads as if Always allow is ignored.

## What changes

- The script prompt now also shows **Always allow**, next to Deny and
Allow. Clicking it runs the script and saves a Scripts rule of Always
allow for the page's own host (`www.` dropped, as the Settings site list
does), so later scripts on that site run without asking. Other sites
still ask.
- The saved rule is the same one a user could set by hand in Settings >
Browser > Agent permissions, and can be changed or removed there.
- If the site already has its own rule, only its Scripts value changes.
- Otherwise a new rule for the host keeps whatever applied there before
(Actions, Downloads, Unlabelled clicks from a broader site rule or the
defaults) and opens the site without asking, like a site added in
Settings.
- Always allow on a script prompt stays disabled until the script has
been scrolled to the end, as Allow already is.
- No button when the page has no host (about:blank) or the site list is
full (200 rules); those prompts look and work as before.
- Nothing else moves: Run scripts "Never" still removes the tool and the
executor still refuses it, Full access still does not cover scripts, and
every other prompt type keeps its per-chat Always allow exactly as
before.

Clicking Always allow again is never needed (the next script on that
site is not asked), and saving the same rule twice gives the same stored
value.

## Tests

- `tests/browser-agent-script-allow.test.ts`: drives the real executor.
The script prompt offers Always allow; answering it runs the script,
stores `scripts: "allow"` on the existing site rule while keeping its
other fields (`downloads: "block"` survives); the next script on that
site runs without a prompt; a script on another site still asks and does
not run. Fails on main (the prompt offers no Always allow there).
- `tests/browser-agent-gate.test.ts`: `scriptSiteRule` saves the page's
own host rather than a broader matching rule, keeps the broader rule's
fields, updates an existing rule in place, returns null for about:blank
and for a full list while still updating a site already on it.

Local: `npm run typecheck` clean, `npm test` 16407 tests, 16406 pass, 1
skipped, 0 failures.

## Screenshots

Base (`501ad46cb`, merge base) vs this PR, each from its own checkout:
the real executor and agent bar in a Vite harness, with only the page
answered by a stub (as in the node tests). A script on
`shop.example.com` is asked, answered, then a second script on the same
site is sent.

The script prompt gains Always allow.

![Script prompt before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17959/pr17959_prompt_q-bdcc31cdb2db.png)

Settings > Browser after answering. Before: Allow saves nothing and the
second script asks again. After: Always allow adds `shop.example.com`
with Scripts set to Always allow, and the second script runs without a
prompt.

![Agent permissions before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/17959/pr17959_settings_q-655e4cb243d7.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects UI# edge case# new-feature# security# Moves a security boundary: sandbox, allowlist, permission or network guard >3000#

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add an "Always allow" option for browser script execution

2 participants