Skip to content

Studio: let browser use read, click and edit files in the browser panel - #16644

Merged
shimmyshimmer merged 7 commits into
mainfrom
studio-browser-use-files
Nov 4, 2026
Merged

shimmyshimmer merged 7 commits into
mainfrom
studio-browser-use-files

Conversation

@shimmyshimmer

@shimmyshimmer shimmyshimmer commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

What changes

With Browser use on, the model could only work on web pages. Files open in the browser panel (an HTML page or React component made in the chat, a PDF, an image, code or text) were off limits, so "click the button on the page you just made, then fix the heading" could not be done.

Now:

  • HTML and React files: browser_snapshot, browser_find, browser_click, browser_type, browser_select, browser_scroll, browser_press_key, browser_move_mouse and browser_drag work inside the file's preview, the same as on a web page.
  • browser_read_file (new): reads the source of HTML, React, Markdown, code, text, SVG and CSV files, or the extracted text of a PDF or document, as numbered lines with paging.
  • browser_edit_file (new): replaces exact text, or rewrites the whole file, for HTML, React, Markdown, code, text, SVG and CSV files. The edit is added as a new version in the tab, so the preview reloads and the panel's Back button shows the earlier version. Nothing outside the panel changes. PDFs, documents and images are refused with a clear message.
  • browser_tabs (new): lists the chat's panel tabs (files by name, web pages by site only, since a title can reveal what the user is reading) and switches between them.
  • browser_screenshot on an image file returns the image itself, scaled to PNG.
  • Which tab the agent uses: a reply starts on the file the user has in front. Files with no page (PDF, text) answer snapshot and find with their text.

How it works

  • Preview frame: HTML and React previews run in the opaque-origin artifact frame, whose strict CSP has no unsafe-eval. The frame shell (routes/inference.py) now installs the page agent from an inline script, which the CSP allows. The agent is handed over on a one-time random key, and the shell captures the built-ins it uses before any canvas script runs. If the canvas can't run the script, rendering is unaffected; browser use just finds no agent there.
  • page-frame.tsx: agent replies from artifact frames are routed alongside annotation events.

Gates

  • Links in a preview are not treated as the user's links. The model can write the page, so a link it follows asks first, the same as an address it typed. Links open in a new tab, so the file tab stays where it is. A relative link (which resolves into Studio) is refused.
  • Form actions: they resolve to the frame's own address, and the frame has form-action 'none', so they are left out of the gates. Without this, every Enter in a preview would ask to "open 127.0.0.1".
  • Consequential clicks: a button labelled Delete or Buy in a preview acts only on that page, so it no longer asks. Password and payment fields stay off limits, and file inputs are still refused.
  • browser_evaluate is refused in previews. It points the model at browser_edit_file instead.

Other small changes

  • Page agent: a lone digit or letter is now kept in the text (a count of 0, a grade), while a lone symbol is still dropped as an icon. Without this the model could not see a counter change after a click.
  • browser_edit_file description: now says it is for panel files, not the sandbox's edit_file, which a small model mixed up in testing.

Verified

  • Frontend: npm run typecheck passes, and npm test passes in full (14834 tests, 0 failures). biome lint shows no new errors in the changed files. npm run build passes.
  • New frontend tests:
    • tests/browser-agent-files.test.ts: numbered paging, exact and CRLF edits, read, edit and Back on an HTML tab, the preview snapshot, a link asking first, a relative link refused, a PDF read but not edited, tabs listing and switching.
    • tests/artifact-frame-agent.test.ts: runs the shell in a VM with code generation from strings disabled. It checks that the agent installs from an inline script, leaves no key behind, and only installs from the embedder.
  • Backend: tests/test_browser_agent.py (argument bounds for the three tools, fenced file results, status badges, the shell having no eval), plus test_artifact_preview_frame_csp.py, test_middleware.py, test_mcp_apps.py and test_nudge_tool_calls_wiring.py all pass.
  • Live run: an isolated Studio built from this branch, with Qwen3-4B-Instruct-2507 GGUF on an Apple Silicon Mac. The model wrote a counter page, opened it in the panel, and then with Browser use on:
    • three browser_click calls took the count from 0 to 3;
    • browser_read_file and browser_edit_file changed the heading from Counter to Clicks, and Back returned to the original.

Three browser_click calls in the counter page's preview (the agent's cursor is on the button), count now 3:

Agent clicks in an HTML file's preview

After browser_edit_file, the heading reads Clicks and the panel's Back button is enabled:

Agent edits the HTML file

Not covered here

  • browser_screenshot of an HTML preview, PDF or text file: the capture path for these needs the desktop app, which was not run.
  • Image editing and PDF editing are not supported. The tools say so.
  • PDFs opened from a web link (rather than as a file tab) still say the browser tools can't read them.

shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
shimmyshimmer added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T12:23:14.821787Z 32c5edc 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 chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a87641eb6

ℹ️ 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".

Comment on lines +1240 to +1242
const now = findTab(tab.id);
if (!now || currentEntry(now) !== entry) return { ok: false, error: "the tab changed while the file was being edited; read it again." };
useBrowserStore.getState().editFile(tab.id, new Blob([edited.text], { type: blob.type || entry.contentType }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor cancellation before applying a file edit

If the user stops the agent or the run is cancelled while fileContent() or blob.text() is pending, this function still modifies the file afterward. Unlike the element-action path, editFile() receives no run context and never checks its abort signal before committing the mutation; runBrowserAction() only changes the reported result to STOPPED after the edit has already happened. Pass the cancellation signal through and check it immediately before updating the store so a stopped action cannot overwrite the panel file.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 32c5edc: editFile now takes the action's signal and returns stopped before committing the edit, with a test that stops mid-read.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex security review

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 32c5edced7

ℹ️ 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".

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Nov 4, 2026
@shimmyshimmer
shimmyshimmer merged commit 71c643e into main Nov 4, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-browser-use-files branch November 4, 2026 13:19
danielhanchen added a commit that referenced this pull request Nov 4, 2026
…ompts in every locale (#16677)

## Summary

`Frontend build + bundle sanity` runs `npm run i18n:check:strict`, and
that step fails on main for every PR. For example #16671, which only
touches the glass wallpaper:

```
=== nl ===
Missing keys (will fall back to en): 9
  - browser.agent.step.tabs
  - browser.agent.step.readFile
  - browser.agent.step.editFile
  - browser.askBeforeProgramDownloadsSetting
  - browser.askBeforeProgramDownloadsSettingDescription
  - browser.downloadSiteAllowAll
  - browser.downloadPrompt.once
  - browser.downloadPrompt.site
  - browser.downloadPrompt.all
Missing keys above. Add them to every overlay, or run without --strict to accept the English fallback.
```

The same 9 keys are missing from all 24 overlays. Two PRs added them to
`en.ts` only:

- #16644 (`71c643e02a`) added the browser agent's `tabs`, `readFile` and
`editFile` steps.
- #16658 (`eec7711a42`) added the program download setting, "Allow
programs too", and the three `downloadPrompt` choices.

Both features are fine. They only skipped the overlay step the strict
gate asks for, so non-English users currently see these strings in
English.

## Change

`studio/frontend/src/i18n/locales/*.ts`, every overlay except `en.ts`.
Each one gets the 9 keys, placed where `en.ts` has them:

- the three agent steps after `drag` in `browser.agent.step`;
- the two program download settings after
`askBeforeDownloadingSettingDescription`;
- `downloadSiteAllowAll` after `downloadSiteAllow`;
- `once`, `site` and `all` after `remember` in `browser.downloadPrompt`.

The wording follows each locale's existing neighbours. Agent steps use
the same form as that locale's other steps, for example "Zieht" / "Liest
die Datei" in German, "Arrastrando" / "Leyendo el archivo" in Spanish,
and "正在拖动" / "正在读取文件" in Simplified Chinese. The download strings reuse
that locale's terms for "download", "always allow" and "site". `{host}`
is kept in every `site` string. `es-419` uses the same text as `es`. No
English string and no other key changes.

## Testing

- `npm run i18n:check:strict`: main fails with 9 missing keys in each of
the 24 overlays. This branch passes, `Missing keys (will fall back to
en): 0` for every locale, "All locale overlays pass parity."
- Removing `browser.downloadPrompt.site` from `nl.ts` again makes the
strict check fail and name that key, so the gate still catches a missing
key.
- `tests/lazy-locale-loading.test.ts` and
`tests/locale-detection.test.ts`: 35 passed.
- `tsc --noEmit -p tsconfig.app.json` reports nothing in `src/i18n`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant