Repository navigation
Studio: open the Unsloth docs and Next.js sites in the browser panel - #14279
Conversation
[skip ci]
|
@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: cd726fbcf1
ℹ️ 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".
| // Routers resolve paths against location.href or location.origin, which throw here ("about:srcdoc", "null"). | ||
| if (cfg.url) { | ||
| const NativeURL = URL; | ||
| window.URL = new Proxy(NativeURL, { |
There was a problem hiding this comment.
Preserve URL constructor identity after proxying
On any remote page that checks constructor identity, replacing the global this way makes both URL.prototype.constructor !== URL and new URL(...).constructor !== URL: the proxy reuses NativeURL.prototype, whose constructor still points to NativeURL. Libraries that recognize or clone Web API values through this normal native invariant will therefore stop treating URL objects as URLs even when no about:srcdoc base is involved; preserve the prototype's constructor identity when installing the shim.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
instanceof, the static methods and subclassing all still work through the proxy, and nothing loaded here compares .constructor to URL, so leaving this as is.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 462a3e3b0c
ℹ️ 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 raw = (link.getAttribute("href") || "").trim(); | ||
| if (/^javascript:/i.test(raw)) return; | ||
| const modified = event.button === 1 || event.metaKey || event.ctrlKey || event.shiftKey; | ||
| if (!raw.startsWith("#")) post({ type: "linkClick", url: resolve(raw) }); |
There was a problem hiding this comment.
Disarm canceled link candidates before correlating redirects
When a page cancels an anchor click and, within three seconds, assigns location to a different same-origin URL in a WebView where the Navigation API does not intercept it (for example after an async auth or tracking callback), this records the anchor before unlessCancelled observes the cancellation. The CSP report exposes only the origin, so the later correlation accepts the page's different redirect and tells the panel to load the anchor's href instead of the URL the page requested; clear the candidate when the click is canceled, or otherwise avoid correlating a delayed canceled click without the attempted path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The cancelled click is exactly how Next.js links reach this path (preventDefault, then a full load of the same href), and the report only carries the origin, so the two cases can't be told apart here. In the rare case you describe the panel opens the link that was clicked, where before it only showed the notice.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 462a3e3b0c
ℹ️ 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".
| window.URL = new Proxy(NativeURL, { | ||
| construct(target, args, newTarget) { | ||
| const base = args.length > 1 ? String(args[1]) : ""; | ||
| if (base === "null") args = [args[0], new NativeURL(pageUrl).origin]; |
There was a problem hiding this comment.
Do not rewrite an explicit null URL base
When a proxied page calls new URL(relative, null), String(args[1]) turns the actual null into the same "null" sentinel used by location.origin, so this branch resolves the relative input against the page origin. The native constructor instead throws for a relative input with a null base, and callers can rely on that to reject an unresolved URL; this silently converts it into a same-site URL or request. Check that the uncoerced argument is the literal string "null" before applying this fallback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
An explicit null base is not something real pages pass here; the shim exists for location.origin being the string null in the sandbox, so leaving it.
Review + reproduction evidencePinned review: I reproduced opening https://docs.unsloth.ai/ in the browser panel and clicking a docs link on the merge base
Conclusion: real and fixed. The Next.js docs sites load and navigate in the panel, other pages are unchanged, and the one follow-up suggestion ( |
|
@codex security review |
## Summary
Claude API-reference pages call `new URL(window.location.origin)`. In
the browser panel’s opaque-origin srcdoc frame, that becomes `new
URL("null")` and throws `Invalid URL`, leaving the site on its
“Something went wrong” screen on direct load or navigation.
The URL proxy added in #14279 already rewrites opaque origins used as
the second argument, but misses this one-argument form. Map that form to
the current page’s origin too.
- One-line production fix; no changes to click-follow behavior, Back,
CSP, or sandbox permissions.
- Add executable regression coverage against the actual injected shim,
including explicit bases, srcdoc bases, ports, invalid inputs,
subclasses, and pages without a remote URL.
## Verification
- Before the fix: the new opaque-origin regression throws `TypeError:
Invalid URL` with input `null`.
- After the fix: 76 tests pass across `browser-url`, `browser-network`,
`browser-page-storage`, `browser-frame-message`, and `browser-address`.
- Focused TypeScript check, Python syntax parsing, and `git diff
--check` pass.
- Biome check passes with the Node-import warnings produced by its
frontend rules for this Node test file.
- Live Claude docs UI was not rerun as part of this change.
Test command:
```sh
node --experimental-strip-types --test studio/frontend/tests/browser-{url,network,page-storage,frame-message,address}.test.ts
```
## What changed The browser panel's new tab page in the web UI now suggests Unsloth Docs (`https://unsloth.ai/docs`) first, ahead of Unsloth on GitHub and Hugging Face. Until now the web UI left out both Unsloth sites because Cloudflare blocked them in the proxied view. Since #14279 the docs load there, so the docs come back; the Unsloth home page still answers the proxied view with a 403 browser check, so it stays a Desktop-only suggestion. The suggestion uses `unsloth.ai/docs`, where `docs.unsloth.ai` now redirects. The Desktop list is unchanged: it keeps `docs.unsloth.ai` beside `unsloth.ai`, since suggestions are deduplicated and hidden per host and the two would otherwise share one. ## Verification - `npm run typecheck` and `npm run build` pass; the 230 browser tests pass. Biome reports nothing new in `new-tab-page.tsx`. - Isolated Studio built from this branch (main with #14279), Playwright (Chromium), web UI browser panel: - Suggested lists Unsloth Docs, Unsloth on GitHub, Hugging Face, - clicking Unsloth Docs loads the docs at `unsloth.ai/docs`, - `unsloth.ai` itself still shows the "This site checks for a real browser" page (HTTP 403), which is why the home page is not suggested. The Desktop native browser view is not exercised from this host; its list is unchanged. Web UI browser panel: the new tab page with Unsloth Docs first, and the docs open after clicking it. 

Opening docs.unsloth.ai, gitbook.com/docs or platform.claude.com/docs in the browser panel showed the site's own "This page couldn't load" screen instead of the page. The panel shows each page in a sandboxed frame whose address is about:srcdoc, so the Next.js router these sites use fails to build its URLs ("Invalid URL") and the whole page drops to its error screen.
The page frame now resolves URLs built from the frame's own address against the page's real address, so these sites render. Their links work too. Next.js sees its own links as another site in this frame and loads them as full page loads, which the panel blocked with the "tried to go to another address" notice. Now, when a page load the panel would block goes to the same site as the link the reader just clicked, within 3 seconds of the click, the panel opens that link instead, and Back returns to the previous page. Any other blocked load still shows the notice.
Other pages and local HTML files behave as before.