Repository navigation
Studio: open localhost addresses typed in the desktop browser panel - #14290
Conversation
[skip ci]
|
@codex security 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. |
[skip ci]
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4d2e5750b4
ℹ️ 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".
| if !matches!(origin, Some(url::Origin::Tuple(_, granted, granted_port)) | ||
| if *granted_port == port && granted.to_string() == host) |
There was a problem hiding this comment.
Enforce the granted scheme in local proxy routing
On Windows/Linux, if a granted http://localhost:P page issues an https://localhost:P or wss://localhost:P subresource request (or the inverse), this match discards the origin's scheme and treats the request as granted based only on host and port. Those subresources are not covered by the top-document navigation checks, so a dual-protocol or multiplexed local port is dialed directly instead of falling through to the private-host refusal, exposing an origin the user never granted; include the effective HTTP/WS scheme in the grant check.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: the local proxy only dials the exact host and port typed in the address bar, so a different scheme on that port reaches the same listener the user granted, never another service. A CONNECT tunnel also does not say whether it carries ws, wss or https, so the scheme cannot be enforced reliably at this layer. The macOS rules pin the scheme because there a default port is dropped from the URL, and that let port 80 reach 443.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81af72fe4a
ℹ️ 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".
| inner.committed.remove(&tab_id); | ||
| inner.download_starts.remove(&tab_id); | ||
| inner.placed.remove(&tab_id); | ||
| inner.local_pages.remove(&tab_id); |
There was a problem hiding this comment.
Keep local profiles until their grants are forgotten
When a local tab's native view is pruned or the browser panel unmounts, the frontend deliberately closes it with forgetLocal: false so the tab can reopen, but this unconditional removal also drops LocalPage.profile. The next create_view allocates a fresh temporary/incognito profile, so on Windows/Linux the same still-open tab loses its cookies and local storage merely by closing and reopening the panel or exceeding the view cap; this drop also occurs before the live WebView is closed below. Keep the per-tab profile until forget_local is true, separately from the short-lived proxy/view.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: local views are created incognito, which is an ephemeral web context on Linux, InPrivate on Windows and a non-persistent data store on macOS, so cookies and storage never outlive the view whether or not the folder is kept. Keeping a session across view recreation would need a persistent per-tab store, and local tabs use temporary storage on purpose.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8c8fbc7315
ℹ️ 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".
| if port.is_some_and(|port| port >= ASSIGNED_PORTS || (8888..=8908).contains(&port)) | ||
| || port == backend |
There was a problem hiding this comment.
Exclude the configured Vite port from local grants
When the desktop runs with the checked-in development configuration, Studio itself listens on localhost:5173 (studio/src-tauri/tauri.conf.json), and that Vite server forwards /api and /v1 to the otherwise-blocked backend (studio/frontend/vite.config.ts). This predicate permits port 5173, so typing that address opens Studio's own origin in a local view and makes those backend routes reachable through the allowed port; reject the configured dev-server port as another Studio-owned address.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: 5173 is Studio only under tauri dev (contributor builds; release Desktop serves the UI from the bundled backend, whose port is already refused), the address has to be typed by the user, and the backend still requires its auth token. Refusing 5173 in release builds would block Vite's default port, the most common dev server users would open here.
There was a problem hiding this comment.
Fixed in 81fa6ce, scoped to where it is real: a release build loads the app from its own scheme, so 5173 there is the user's dev server and stays openable. In a dev build (tauri::is_dev()) the configured devUrl port is now refused with the backend's, so the dev server that serves the app and forwards /api can't be opened. 3e2222e covered only the agent side of 8888-8908, not this. Test the_dev_server_the_app_is_served_from_is_never_granted added; it fails with the check removed.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81fa6ce01e
ℹ️ 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".
| rules.push(serde_json::json!({ | ||
| "trigger": { | ||
| "url-filter": format!("^{scheme_filter}://([^/@]*@)?{authority}/"), | ||
| "if-top-url": [format!("^{scheme}://([^/@]*@)?{authority}/")], |
There was a problem hiding this comment.
Preserve local access from generated local documents
On macOS 14+, if a granted app navigates its top frame to an HTML blob: URL, local_navigation_allowed keeps that document in the local view and the blob retains the granted origin, but this if-top-url pattern only matches a top URL beginning with the original http(s) scheme. The ignore rule therefore stops firing and the preceding private-host rules block the blob document's fetches or WebSockets back to the granted server, even though the same flow works on Windows/Linux; the top-frame condition needs to preserve the exact-origin exception for inherited generated documents too.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: it needs a granted app to navigate its top frame to a blob: document, which dev servers do not do in normal use, and the result fails closed (that document's requests back to the server are blocked on macOS) rather than opening anything. Widening the if-top-url pattern to generated documents would loosen the one rule that pins the exception to the typed origin.
|
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7d31a04d5a
ℹ️ 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".
| thread_local! { | ||
| // WebKit objects live on the main thread, and so does this. | ||
| static RULES: RefCell<Rules> = RefCell::new(Rules::default()); | ||
| static RULES: RefCell<std::collections::HashMap<Option<url::Origin>, Rules>> = RefCell::new(std::collections::HashMap::new()); |
There was a problem hiding this comment.
Evict unused per-origin macOS content rules
On macOS 14+, every distinct loopback origin (for example, a dev server whose port changes) leaves a Retained<WKContentRuleList> in this thread-local map, while neither tab close nor clear-data removes it. Over a long-running session the native rule objects therefore grow without bound; cap or evict this cache and remove unused identifiers from WKContentRuleListStore.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: one compiled list is kept per local origin the user typed in the session, which is a handful at most, and the lists live only for the session. That is bounded by what the user types, not a leak that grows on its own, and evicting a list still attached to a live view would need more bookkeeping than it saves.
|
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". |
Resolves the conflicts with main's redirect-link unwrapping and page permission handler: the agent's local-address gate checks the redirect target, redirect tests that relied on a port-80 loopback refusal point at Studio's own port, and the startup budget is re-measured on top of main.
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
Re-measures the startup budget on top of main's latest raise.
Fixes #14257
The desktop browser panel refused every local address, so a dev server on the same computer could not be opened beside the chat or checked by the browser agent.
Typing a local address such as
localhost:7860in the address bar now opens it in that tab, with a Local badge. Each local tab gets its own proxy that only reaches that origin, and private storage; access ends when the tab closes or leaves the address. Links, redirects, popups and the agent cannot open a new local address, and the agent uses a separate tab for public sites. Studio's own ports (8888–8908, the backend port and every port from 32768 up) are never opened. On macOS, a page whose content rules or proxy can't be set up is closed with an error instead of loading. The web app and server installs are unchanged.Trade-off: dev servers on port 32768 or above cannot be opened.
Before / after
Desktop app (Linux debug build, WebKitGTK), merge base vs this PR: typing
localhost:5173(a dev server) was refused and now opens with a Local badge; a link from that page to https://example.com is offered with an Open prompt instead of followed;localhost:8888(the app's own backend) stays refused, now naming it as Unsloth's own address.Web Studio (parity):
localhost,127.0.0.1and public sites behave the same on both sides.