Repository navigation
Studio: keep browser tabs across a reload, make browser use approvals port-aware - #17596
Conversation
… port-aware Browser tabs and each chat's panel state are kept in sessionStorage, so a reload of the window brings them back; an unsaved chat's tabs follow it to its new key. Browser use approvals now tell example.edu from example.edu:8081, and the backend refuses the port this Studio is actually listening on, not only the default range.
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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: 8370503bcd
ℹ️ 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".
| export async function chatIsUnsaved(chat: string): Promise<boolean> { | ||
| if (!chat.startsWith("single:")) return false; |
There was a problem hiding this comment.
Restore tabs belonging to unsaved project chats
When tabs are opened beside an unsaved project chat, reloading still makes them inaccessible. chat-page.tsx assigns these chats a project:${view.projectId}:${projectNewThreadNonce} key and regenerates the nonce on mount, but this check rejects every project key, so claimRestored never transfers their persisted tabs or panel state to the new key. Handle unsaved project-chat keys as well, while ensuring restoration stays within the same project.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 9e867a6: a project's unsaved chat key now counts as unsaved, and its tabs are only handed to a new chat of the same project. Test covers the same project, another project and a plain chat.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. 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". |
## What changed With the browser panel open, every chat you pass through got a new empty tab, and that tab stayed in the browser's state after you left. Clicking New chat four times left three empty tabs behind for chats that may never be shown again. They are small, but nothing removed them until a reload, and they count toward the 50 tab limit on what a reload restores, so in a long running window they could push real tabs out of the saved session. Leaving a chat whose only tab is an untouched new tab now drops that tab. The chat still remembers that its panel was open (and full view), so coming back to it looks the same as before: it opens on a new tab. A tab that was renamed or pinned is kept. ## How it was verified - New test in `tests/browser-store-chats.test.ts`; it fails without the change. - `npm run typecheck`, `npm test` (15882 passed, 0 failed) and `npm run build` in `studio/frontend`. - Driven in a local web Studio with a scripted browser: after four New chat clicks the saved tab state held no leftover empty tabs (three before the change), the first chat kept its two pages, and browser Back and Forward still showed each chat its own tabs. ## Not tested here - The Desktop app was not run. The change is in the tab state both surfaces share. - The live check ran on this change applied on top of #17596 before that PR merged; on this branch only the automated checks were run.
…17668) ## Summary `Frontend build + bundle sanity` intermittently fails on PRs that do not touch the browser (seen on #17641 and #17659): ``` not ok - an unsaved chat's tabs follow it to the key a reload gives it, by either way the chat page names it location: 'studio/frontend/tests/browser-tab-session.test.ts:160:1' + actual - expected + false, + [] - true, - [ - 'https://draft.example/' - ] ``` The test came in with #17596. After a reload, the browser store asks storage whether the chat shown before the reload was saved (`chatIsUnsaved` in `tab-session.ts`), and that lookup starts with a dynamic `import()`. In the test, the import goes through the module hooks registered by `browser-store-resolver.mjs`. The test waited one `setTimeout(0)` and then asserted that the lookup had landed. On a busy runner the import can take longer than one timer tick, so the unsaved chat's tabs had not been handed over yet. The store is right: it handles the lookup landing either before or after the chat is named, and that is what the test is checking. Only the test's wait was too short. ## Change - The test stub's `__storedThreads` is now a `Set` that counts `has` calls, which is how the stub answers each lookup. `reloaded()` counts a lookup when the session it reloads from shows a `single:` chat, which is the only case where the store looks one up. - `settled()` waits until every started lookup has been answered (10 s cap, then fails with "a stored-chat lookup never answered"), then waits one more tick for the store's `.then`. No product code changes. ## Testing - Sabotage: with a 5 ms delay added to the stub's `getStoredChatThread`, main's version of the test fails with the same diff as CI. With this change it passes with a 5 ms delay and with a 60 ms one. - Without the delay: `tests/browser-tab-session.test.ts` 7 passed, 3 runs. - `tsc -p tsconfig.test.json`: no errors in the file.
…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
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
sessionStorageand restored on load.sessionStorageon 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.sessionStorage.Browser use approvals are port-aware
example.edualso coveredexample.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.Browser use refuses the port Studio is really on
-p 8000.How it was verified
npm run typecheck,npm test(15755 pass, 0 fail),npm run build. Newbrowser-tab-sessiontests, plus port cases inbrowser-agent-gateandbrowser-agent-always-allow.pytest studio/backend/tests/test_browser_agent.py studio/backend/tests/test_browser_routes.py(200 passed), with a new own-port case.Not verified here
biome checkreports pre-existing formatting errors repo-wide; none are on lines this PR touches.