Repository navigation
Studio: in-app browser panel for chat - #12347
Conversation
- Run page fetches in their own pool, off the event loop, and cancel them when the panel aborts the load, so browsing can't stall chat streaming. - Only honor tab opens, external links and shortcuts from a page when its frame has focus and the user just interacted, rate limited to one per second. - Drop http: and ws: from the shell's connect-src and add treat-as-public-address, so pages can't reach local services. - Refuse favicons that point at Studio. - Cache loaded pages per history entry for instant back and forward, cap history at 50, and keep only the 4 most recent tabs mounted. - Memoize the panel and tabs, skip no-op tab updates, and watch only <head> for title changes. - Set the side panel width on the header, fade and notice instead of the content root, so resizing doesn't restyle the whole thread.
- Open local HTML files in the same frame as the attachment preview, so network access stays off until the user allows it. - Allow only https in the shell's fetch directives and add upgrade-insecure-requests. WebKit has no local network protection, so http images, scripts, styles, media and frames could reach local services directly.
…cache - Load pages into a srcdoc child of the shell, then set frame-src 'none' on the shell. The child keeps its own policy, so embeds still load, but can no longer navigate itself. This does not depend on the Navigation API, which WebKit and Chrome don't fire here, and closes the gap where the desktop app's frame-src allows every loopback port. - Parse frame messages field by field and bound titles, URLs and bodies, so a malformed message can't crash the chat. - Give the page cache a 32 MB total and 8 MB per-page byte budget, and drop a tab's pages when it closes.
- Opened files get a file menu (full name, Open in new chat or tab), Request edits, a zoom menu and download. - Page menu: find in page, copy link, zoom, device toolbar, downloads, history, clear browsing data and browser settings. - History and Downloads pages with search and per-row removal. - Settings: show full URL, manage history and downloads, clear data. - Browser button uses the internet icon, hides in a new chat and while the panel is open. - Code, text and plain file icons use the foreground color; only docs stay blue. - Washes follow the contrast setting and the tab height follows the UI scale.
- Favicons from pages load through the guarded fetch and show as blob URLs, so a page cannot point Studio at a local or LAN address. - Provider sign-in URLs always open in the system browser, since the browser panel keeps no cookies.
6eb9b51 to
5327f9a
Compare
- New Browser section under Shortcuts, with the browser icon: links and files, address bar, and browsing data. - Browser rows leave the Chat section; the panel's Browser settings item, settings search, the command palette and the desktop Settings menu point at the new section.
- Breadcrumb back to Settings and Browser settings, large title, and a search pill with a time range filter (all time, today, 7 or 30 days). - Days are collapsible cards; rows show the site favicon (loaded through the guarded fetch once on screen), title, host, time and a menu to open the page or remove it. - Rows can be selected and removed together; Clear browsing data sits above the list.
unpdf sets globalThis.pdfjsWorker to its own PDF.js build, which the viewer's PDF.js then adopts and fails on (API 5.4.296 vs worker 5.6.205). Give each document its own worker so that lookup never happens. Same change as #12346.
…link menus, canvas tools - Full view: floating chat over the browser, minimize, move chat to the left/right pane (Shift+Cmd+F) - File toolbar floats over the document; new tab page, menus and icons restyled - Request edits: annotate mode with a comment-bubble cursor, click or drag an area to mark it, comment, and send all marks to the chat as one annotations attachment - Image viewer for chat images (gallery, zoom, download, open source page) - Right-click menus for web links, sandbox file links, created-file rows and attachments; sandbox files can be opened in the default app or revealed in the file manager - Canvas parity for file tabs: Preview/Source, Run again, Console with error badge, Fix with the model, Copy, Wrap lines, Open in Canvas
…urity fixes Desktop app: web pages now load in a native child webview per tab instead of the proxy and sandboxed iframe, so Cloudflare challenges, logins and web apps work. Navigation is limited to public http(s) hosts (plus a WebKit content rule list on macOS for subresources), the views get no IPC, use their own data store, turn popups into tabs and quarantine downloads. Also fixes the tab strip being covered by the macOS titlebar drag region. Web UI: bot-check refusals are detected and explained, HTML responses are capped, favicons use a smaller cap, pushState reports are coalesced, and history writes are batched and capped. Chat performance: link context menus mount lazily, web links skip file-scope subscriptions, a descendant :has() on the thread is replaced, PDF.js shares one worker, and the image viewer drops its backdrop blur. Security: SVG and HTML never open from blob URLs on Studio's origin, redirect unwrapping only follows web targets, bidi controls are stripped from the address, and "Open in default app" opens a staged copy so a swapped symlink can't redirect it.
…, annotate HTML source - Send includes the annotation still being typed instead of dropping it. - Save Link As puts the page's base URL back, so relative links resolve. - Request edits on an HTML preview switches to its source; the framed preview can't be selected from the parent.
Pages in the desktop app's native webviews now connect through a loopback proxy (browser_proxy.rs) that resolves each host itself, refuses private or loopback answers and connects to the address it checked. That covers every request (images, fetch, sockets), not just navigations, on every platform, and stops hostnames and DNS rebinding from reaching local services. - macOS 14+: set on the pages' data store, with the Network calls looked up at run time so older macOS still launches. macOS 13 and earlier keep the content rule list. - Windows: WebView2 --proxy-server with <-loopback> so loopback isn't bypassed. Linux: WebKitGTK proxy settings on the pages' own context. Also fixes a crash: polling the page address called wry's url(), which panics on macOS while WebKit has no URL (a failed load).
…, site info icons - Find in page uses Studio's own find bar: the page is matched in its frame (case-insensitive, visible text, same highlights as the chat's) and counted back. The bar gets chat / browser page buttons while a page is open; Cmd+F searches whichever has focus. The browser's own find bar and window.find are gone. - Print: a copy of the page as it is now goes to a separate print frame (/api/browser/print) whose sandbox allows the dialog and whose CSP runs only its own script. - Take a screenshot (Chromium): this tab's capture cropped to the page, added to the chat's composer or saved. - Site info: a slimmer padlock sized and aligned with the other rows, no dividers around it, and a certificate icon. The chat header's new tab button shows the globe again.
|
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". |
…er settings tab - The find bar leads with a search icon; the chat / browser page scope buttons are plain icons, the one being searched lit and the other dimmed, with a divider before close. The chat one is the plain bubble Settings uses for Chat. The bar widens by their room while they show. - The Browser settings tab shows the globe instead of a window.
|
@codex review |
|
Codex Review: Didn't find any major issues. You're on a roll. 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". |
…dier web screenshots Desktop app (src-tauri/src/browser_capture.rs): - Take a screenshot needs no screen-share prompt. A page in a native view is captured by its engine (WebKit's snapshot on macOS, Chromium's Page.captureScreenshot on Windows); files, internal pages and proxied frames are captured from the app's webview, cropped to the page area (macOS, Windows, and WebKitGTK on Linux). The menu item always shows in the desktop app. - Print works for native pages: WebKit's print sheet on macOS, titled after the page, from a copy of the shared print info (wry's print() zeroes the shared margins, so pages print to the edge and so does everything after); Edge's print preview on Windows via ShowPrintUI, which a page can't replace the way it can window.print(). - Print stays off for framed pages in the macOS app, whose webview drops print() from frames, rather than reporting success. - Native capture and print wait for the view to come back after the menu that asked hides it. Web build: - The region capture waits for frames and the page to keep one size (the sharing bar settled) instead of a fixed 350 ms, waits for closing menus to leave the page, and stops quietly when sharing ends. Toasts, tooltips and the file toolbar are hidden for the shot. - With the device toolbar on, the shot is the device's width only.
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? 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". |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
…ute tabs Tab right-click menu: Pin to sidebar, New tab to the right, Reload (the two-arrow refresh icon), Duplicate (a copy with its history, beside it), Fork (into a new or temporary chat), Copy URL, Open in external browser, Rename, Mute tab, Close, Close other tabs, Close tabs to the right. - Pinned pages (pinned-pages-store, per account like bookmarks) show in the sidebar's Pinned section after its chats and folders: the site's icon and title, a one-click unpin, and the same menu as the tab (3-dot and right-click). Clicking one shows its tab, or opens one at the pinned address; from outside a chat it goes to one first. - Rename edits the name in place, in the tab or the sidebar row; it is kept as the tab navigates, and empty gives back the page's title. A pinned tab and its row share the name. - Mute: a muted tab shows a speaker to unmute it. Framed pages mute their media (on the page or not) and suspend Web Audio, and a muted tab's next page loads muted. In the desktop app, Windows mutes the WebView2 view; macOS mutes each page's media as it commits and loads. - The tab menu (tab-menu.tsx) is shared by the tab strip and the sidebar row. - Strings in every locale.
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ 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". |
… pruned muted view reopens muted Duplicate tab copied each history entry into a new object, so the resubmit guard (keyed by entry) no longer knew a copied POST had been sent: the copy posted the form again unasked. Copied POST entries are now marked sent, so the copy asks first. browser_view_close also forgot a tab's mute, and it is how the panel prunes views past four, so a muted tab came back with sound while showing muted; the mute now stays until the tab is unmuted.
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 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". |
| frame.tabIndex = -1; | ||
| // Kept on screen at a pixel: a frame with no size may never lay out its images. | ||
| frame.style.cssText = "position:fixed;right:0;bottom:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none"; | ||
| frame.src = apiUrl("/api/browser/print"); |
| { | ||
| type: "unsloth:browser-html", | ||
| html, | ||
| url, | ||
| base, | ||
| refresh: refresh ?? null, | ||
| zoom: zoomRef.current, | ||
| muted: mutedRef.current, | ||
| }, |
Summary
Adds a browser panel to the right of chat. Attached documents open in it as tabs, and it works as a regular browser too: type a URL or a search, follow links, go back and forward, and open new tabs.
Depends on #12346 for PDFs to render once a PDF has been extracted in the same session.
What it does
target="_blank"orwindow.openfrom a click opening a new tab. PDFs and other non-HTML links open in the file viewer.Performance
<head>.Settings
New Browser section in Settings, below Shortcuts. The panel's Browser settings item, settings search, the command palette and the desktop Settings menu all open it.
How pages load
POST /api/browser/fetchfetches through the existing_fetch_url_raw, so the SSRF guard applies (private and loopback addresses are refused). HTML comes back as JSON with its final URL and base. Anything else is returned as is, with the final URL in a header.GET /api/browser/frameis a static shell served withsandbox allow-scripts allow-forms(noallow-same-origin),form-action 'none'andtreat-as-public-address. Pages run in an opaque origin and cannot reach Studio's cookies, storage or API. Fetch directives allow onlyhttps:(andwss:for sockets) withupgrade-insecure-requests, so pages cannot reach localhttpservices through requests or subresources (WebKit has no local network protection).srcdocchild with a<base>and a small script that turns link clicks, form submits,window.openand history pushes into messages, relayed to the panel, which fetches the next page through the proxy. The panel only accepts messages from its own frame and validates every field.frame-src 'none'on itself. The child keeps its own policy, so embeds still load, but the page can no longer navigate its own frame, including to loopback ports the desktop app's CSP allows. This does not rely on the Navigation API.<meta>CSP and base tags are stripped. Short meta refreshes are followed through the proxy, long ones dropped._fetch_url_rawgainedpost_data(for form POSTs, kept only on 307/308) andmeta_out(final URL and charset).X-Frame-Optionsmiddleware, and the two browser headers are exposed through CORS.http,httpsandmailto.Testing
npm run typecheckis clean andnpm testpasses, apart from the existing More menu test that also fails onmain.pytestpasses, including the newtests/test_browser_routes.py(shell CSP and isolation, page preparation, charset decoding, raw passthrough, form POST, refused fetches as 502, the dedicated fetch pool and cancel on disconnect).target="_blank"link opens a tab, Cmd/Ctrl+L from a page focuses the address bar, pages cannot reach loopback, back and forward come from the cache, reload refetches, old tabs unload, PDFs and search load, find in page selects and reports misses, zoom applies to the page, the device toolbar narrows it, history records visits, the file menu and Request edits work, downloads are recorded, and a new chat shows no browser button. Focus and activation gating also checked in WebKit.Review fixes
Tag stripping on fetched pages (
<base>,<meta>,<head>) was quadratic on unclosed tags. One hostile page held the GIL:/api/healthstalled 12.9 s while it loaded (7 ms after the fix), so chat froze too. Matching is now linear.Split drag: the page area keeps its start width while the handle is dragged and lays out once on release. Chromium at 4x CPU throttle, Wikipedia in the panel: frames over 50 ms during a drag went from 25 to 2, long-task time from about 3.4 s to 0.5 s.
Desktop native views: only the newest bounds are sent during a resize (no backlog), show/hide only on a tab switch, views close when the panel closes (no background audio or scripts), and a reopened view returns to the page it had reached.
browser_view_showis async (a sync command creating a webview deadlocks on Windows).A child webview breaks Tauri's
WebviewWindowextractor andget_webview_window, so file dialogs, clipboard, native intents and tray restore failed once a page was open. Commands now take the callingWebview; window lookups useget_window.Linux desktop uses the proxied frame: Tauri packs Linux child webviews into the window's GtkBox, which ignores their bounds.
Back/Forward on macOS come from WebKit's own history (no Navigation API before Safari 26.2).
Open in default app checks where the opened file really is (a sandbox folder swapped for a link could stage an outside file), and requires the installation owner.
Bot checks: a Cloudflare/Akamai
Serverheader only counts on a 403, so rate limits and outages are not reported as bot checks; "Open in browser" is the primary action on a bot check.Reopening a file that changed since it opened shows the new bytes. Pages in native views can open at most one tab per second.
Web annotations: a page's title or address cannot close the annotation block the model reads, a marked password field never copies its value, a long address no longer drops the chip's title and link, and marks stay open if the composer refuses them.
Links and forms go through the proxy only after the page's own handlers leave them alone (router links and fetch-based forms stay in the page), and
requestSubmit()keeps native validation. Checked in Chromium, Firefox and WebKit: 15 failing cases before, none after.Reload drops only the current page from the cache, so Back keeps earlier pages and form results.
/api/browseris under the request body cap, revealing one sandbox file needs the installation owner, and a failed fetch logs only the host.Windows pages keep SmartScreen on (their WebView2 arguments had dropped it with wry's defaults); the app's own webview is unchanged.
Inline
onclick="return false"/onsubmit="return false"handlers now cancel the proxy navigation, aspreventDefaultdoes.Non-UTF-8 text files (
text/csv; charset=iso-8859-1and similar) are transcoded to UTF-8 instead of showing garbled.Sent attachment tabs are keyed by message, so two messages with the same file name open separate tabs. Send in the annotate bar shows for a first comment and cannot stage twice.
Remote chat images whose host refuses CORS still open in the image viewer. A failed native support probe fails a data clear instead of skipping it, so an account switch never keeps the previous account's cookies.
A native view refuses an address too long for the bar to show, so the bar never keeps an older page's address. Tab menu Reload reloads native views through the native path.
Legacy charset labels and unlabelled pages decode as windows-1252, as browsers do, and unquoted meta refreshes are followed.
An account switch clears native site data before anything else is purged, so a failed clear leaves the signed-in account whole. Reopened files are compared in 1 MiB slices rather than byte by byte on the UI thread.
Scheme-less IP and IDN links in answers open as web links, not chat files; Studio-URL detection resolves addresses before comparing origins; concurrent native downloads differing only by case get separate names on Windows and macOS.
A fitted image refits when the viewer resizes. The sandbox open tests stub
os.startfile, so Windows runs never launch an app.Duplicate on a tab showing a form's result asks before posting it again, as Back does, instead of resending the form. A muted tab stays muted in the desktop app when its native view is closed to make room for others and reopened.
Screenshots
Before (main) vs after (this PR): the browser button opens the panel beside the chat, here on example.com, with the address bar's bookmark star and its site panel open (connection status, clear browsing data, browser settings).
The tab's right-click menu (pin to sidebar, new tab to the right, duplicate, fork into a chat, copy URL, rename, mute, close) and the page pinned to the sidebar's Pinned section: