Repository navigation
Studio: let browser use read, click and edit files in the browser panel - #16644
Conversation
…nd retry a call a fresh preview missed
…use off-screen file screenshots
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| 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 })); |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
Fixed in 32c5edc: editFile now takes the action's signal and returns stopped before committing the edit, with a test that stops mid-read.
|
@codex security review |
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…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`.
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:
browser_snapshot,browser_find,browser_click,browser_type,browser_select,browser_scroll,browser_press_key,browser_move_mouseandbrowser_dragwork 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_screenshoton an image file returns the image itself, scaled to PNG.How it works
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
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".browser_evaluateis refused in previews. It points the model atbrowser_edit_fileinstead.Other small changes
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_filedescription: now says it is for panel files, not the sandbox'sedit_file, which a small model mixed up in testing.Verified
npm run typecheckpasses, andnpm testpasses in full (14834 tests, 0 failures).biome lintshows no new errors in the changed files.npm run buildpasses.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.tests/test_browser_agent.py(argument bounds for the three tools, fenced file results, status badges, the shell having no eval), plustest_artifact_preview_frame_csp.py,test_middleware.py,test_mcp_apps.pyandtest_nudge_tool_calls_wiring.pyall pass.browser_clickcalls took the count from 0 to 3;browser_read_fileandbrowser_edit_filechanged the heading from Counter to Clicks, and Back returned to the original.Three
browser_clickcalls in the counter page's preview (the agent's cursor is on the button), count now 3:After
browser_edit_file, the heading reads Clicks and the panel's Back button is enabled:Not covered here
browser_screenshotof an HTML preview, PDF or text file: the capture path for these needs the desktop app, which was not run.