Skip to content

Studio: tighten browser use gates and fix floating browser window state - #17594

Merged
shimmyshimmer merged 3 commits into
mainfrom
studio-browser-hardening
Nov 13, 2026
Merged

shimmyshimmer merged 3 commits into
mainfrom
studio-browser-hardening

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

What changed

A review of the Studio browser, browser use and the floating browser window turned up a handful of real defects. No change to normal flows.

Browser use (model driving the browser)

  • Ordinary words in a request no longer approve a site by name. "summarize my notes" used to let the model open a made-up notes.com/?d=... without asking. Brand names ("search wikipedia") and written addresses (notes.com) still approve as before.
  • A click by ref on plain text inside a role="button" element is now gated on that control, as clicks by point already were. Before, "Place" inside a custom "Place order" button was clicked with no prompt.
  • Links from the previous page stop vouching for addresses once the tab has moved, even when the new page cannot be read (a file, an error page).

Floating browser window

  • Arrow keys on the window's handle can move it off the right edge. A key step equals the right-edge snap distance, so the window re-anchored on every press and never moved.
  • A browser floated by closing it mid-run keeps that state when you switch chats and come back, instead of returning as a full docked panel.

Page fetch

  • A script host answering with a Cache-Control: max-age of thousands of digits made the whole page fail with a 500. The value is now bounded.

Desktop (macOS)

  • The content rules that keep pages off loopback names also cover trailing-dot forms (localhost., x.localhost., x.local.).

How it was verified

  • Frontend: npm run typecheck, npm test (15749 pass, 0 fail), npm run build. New cases in browser-agent-gate, browser-floating-preview, browser-floating-layout.
  • Backend: pytest studio/backend/tests/test_browser_routes.py test_browser_agent.py test_browser_page_request.py (257 passed), with a new oversized max-age case.
  • Rust: cargo test content_rules_block_private_hosts passes with the new trailing-dot cases.
  • Live, in an isolated Studio on macOS: floated the browser, pressed ArrowLeft five times on the handle, the window moved 80px and stayed there after a window resize.

Not verified here

  • The click gate change runs inside the page; it has no DOM unit test and was not exercised with a live model (CPU-only host).
  • No Desktop build was made, so the macOS content rule change is covered by its unit test only.
  • biome check reports pre-existing formatting errors repo-wide; none are on lines this PR touches.

Found, not fixed in this PR

  • Desktop: a download the user denies or ignores keeps downloading in the background and holds one of the three app-wide download slots. Needs per-engine cancel on macOS, Windows and Linux.
  • Browser use approvals are keyed on hostname, so an approval also covers other ports on that host.

Browser use: ordinary request words no longer approve a made-up site, a click by ref on text inside a custom button is gated on that button, and a page's links stop vouching for addresses once the tab moves on.
Floating window: arrow keys can move it off the right edge, and a browser floated by a close mid-run keeps that state across a chat switch.
Page fetch: an oversized max-age no longer fails the page. Desktop: macOS content rules also block trailing-dot loopback names.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T15:13:43.691794Z 7c910ba 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: 468b876796

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

floating: saved?.floating ?? false,
floatedForAgent: false,
// A close mid-run stays a close on return: still floated for the agent, not docked open.
floatedForAgent: (saved?.floating && saved.floatedForAgent) ?? false,

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 Preserve the agent-floating flag in background chat updates

On Desktop, if the user floats the browser mid-run and switches chats, the next background browser action calls showTab() → revealIn(). The off-screen revealIn implementation replaces the saved chat state without copying floatedForAgent; openTab does the same when opening another background tab. Returning to the chat therefore restores floating: true but floatedForAgent: false, so closing the preview no longer resets the floating layout and reopening the browser incorrectly keeps it floating. Preserve the new flag in both saved-state update paths and cover a background action between switching away and returning.

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 7c910ba: both background update paths (openTab for another chat and revealIn) now carry floatedForAgent, with a test that runs a background action between switching away and returning.

@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 7c910ba116

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

Copy link
Copy Markdown
Member

Composer (macos-latest, browsers) fails tests/studio/playwright_composer_settings.py on msedge, on both attempts:

expect(editor).to_have_value("Line one\nLine two")
AssertionError: Locator expected to have Value 'Line one\nLine two'
Actual value: Line one
Lin

The driver fills Line one, presses Shift+Enter, then types Line two key by key, and the composer kept only Lin: the rest of the keystrokes went somewhere else. The same job passed on the other recent branches I checked (studio-browser-followups, studio-legacy-function-calls, studio-composer-model-picker, fix/image-vram-budget, fix/image-checkpoint-download), so it looks tied to this branch. Since this PR changes the browser use gates and the floating browser, something taking focus from the composer while it is being typed into would explain it. The full log is in the composer-macOS-browsers artifact (msedge-composer.log).

@danielhanchen

Copy link
Copy Markdown
Member

Correction to my note above: this is not specific to this branch. The same playwright_composer_settings.py failure has since shown up on two unrelated branches as well, on macOS Chrome and Edge, with the same shape: the editor keeps a prefix of what was typed (First line\nSecond instead of First line\nSecond line). Linux and Windows pass on all of them. It looks like an intermittent macOS runner issue with key-by-key typing into the composer harness, so a re-run should be enough here, and it does not need a change in this PR.

@shimmyshimmer
shimmyshimmer merged commit 0081d9e into main Nov 13, 2026
@shimmyshimmer
shimmyshimmer deleted the studio-browser-hardening branch November 13, 2026 06:54
shimmyshimmer added a commit that referenced this pull request Nov 13, 2026
… port-aware (#17596)

## What changed

Follow-ups from a review of the Studio browser and browser use. Separate
from #17594, no overlap in behaviour.

**Browser tabs survive a reload**
- Reloading the page used to close the browser panel and drop every tab.
Open tabs and each chat's panel state (open, active tab, full view,
floating) are now kept in `sessionStorage` and restored on load.
- `sessionStorage` on purpose: a reload brings the tabs back, a new
window or a fresh launch starts without a browser, and two windows do
not share one tab list.
- Only what can be loaded again is kept: new tab pages, internal pages
and GET web pages. Files (their bytes live in memory), form posts and
pages opened beside a temporary chat are dropped from a tab's history.
- A chat that was never saved gets a new key on reload, so its tabs
follow it to the new chat. A saved chat keeps its own tabs.
- Saved under an account-scoped key, and an account switch already
clears `sessionStorage`.

**Browser use approvals are port-aware**
- Approvals were keyed on hostname only, so approving `example.edu` also
covered `example.edu:8081`, and an Always allow for submit or sign-in
carried to any port. A non-default port is now its own site and asks
again. http and https on their default ports remain one site, so an
upgrade does not ask twice.
- Site patterns in Settings and the request's website policy are
unchanged.

**Browser use refuses the port Studio is really on**
- The guard that keeps the model off Studio's own address was a fixed
range (8888 to 8908). It now also refuses the port this server is bound
to, for example `-p 8000`.

## How it was verified

- Frontend: `npm run typecheck`, `npm test` (15755 pass, 0 fail), `npm
run build`. New `browser-tab-session` tests, plus port cases in
`browser-agent-gate` and `browser-agent-always-allow`.
- Backend: `pytest studio/backend/tests/test_browser_agent.py
studio/backend/tests/test_browser_routes.py` (200 passed), with a new
own-port case.
- Live, in an isolated Studio on macOS: opened the browser in a new
chat, loaded a page, reloaded the window; the panel came back open on
the same tab.

## Not verified here

- The port-aware approvals and the own-port guard are covered by unit
tests only; they were not exercised with a live model (CPU-only host).
- Tab restore was checked in web Studio, not in a Desktop build, where
pages show in native views.
- `biome check` reports pre-existing formatting errors repo-wide; none
are on lines this PR touches.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
shimmyshimmer added a commit that referenced this pull request Nov 14, 2026
…local links (#17646)

## What changed

Three additions to the Studio browser settings. Independent of #17594
and #17596.

**Import browsing history**
- Settings > Browser > Browsing data has a new Import history row, next
to the existing bookmark import.
- Accepts Safari's `History.json` (File > Export Browsing Data) and
Chrome's history from Google Takeout. Both arrive as a ZIP; unzip and
pick the JSON.
- Only http and https visits with a sane date are imported. Importing
the same file twice adds nothing, and the "Keep history for" setting and
the history limit still apply. The import works with history saving
turned off, since it is an explicit action.

**Camera and microphone site settings (Desktop app)**
- A new section sets Ask or Block for camera and for microphone, as a
default and per site. A site rule wins over the default.
- Block only: the app still never grants a page a capture device itself.
Ask is the system's own prompt, as before. The existing test that proves
no path returns Allow now runs over every rule combination.
- Rules are stored per account in the app and sent to the shell at
startup and on change. Until the first send, requests get the system
prompt.

**Links to local addresses**
- With "Open links in: Unsloth browser" on, a link to `localhost` used
to open a panel tab that cannot load, because a local page only opens in
the panel when its address is typed there. Such links now go to the
default browser, and the setting's description says so.

## How it was verified

- Frontend: `npm run typecheck`, `npm test` (15884 pass, 0 fail), `npm
run build`. New `browser-history-import` and `browser-capture-sites`
tests.
- Rust: `cargo test page_` (5 passed) and `cargo test capture` (8
passed) on macOS.
- Live, in an isolated web Studio on macOS: the Import history row is
present; importing a small Safari-format file added the one valid visit
and dropped a `javascript:` entry and one dated 1970. The camera and
microphone section is hidden outside the Desktop app, as intended.

## Not verified here

- The camera and microphone settings screen and the real block behaviour
need a running Desktop app, which was not built or driven. The Rust
change has no platform-specific code, but Windows and Linux were not
compiled.
- A site that WebView2 has already been told to allow may not reach the
handler, so Block may not apply to it until that saved answer is reset.
- The import formats follow Apple's and Google's published schemas; no
real export file was available.
- Other locales fall back to English for the new strings.
- `biome check` reports pre-existing formatting errors repo-wide; the
new files add none at error level.

Schemas:
https://developer.apple.com/documentation/safariservices/importing-data-exported-from-safari
and
https://developers.google.com/data-portability/schema-reference/chrome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants