Skip to content

Studio: open the Unsloth docs and Next.js sites in the browser panel - #14279

Merged
shimmyshimmer merged 5 commits into
unslothai:mainfrom
NilayYadav:docs-sites-load-in-browser
Oct 20, 2026
Merged

shimmyshimmer merged 5 commits into
unslothai:mainfrom
NilayYadav:docs-sites-load-in-browser

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

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.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T23:09:10.933021Z 462a3e3 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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, {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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) });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 19, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@danielhanchen danielhanchen added security# Moves a security boundary: sandbox, allowlist, permission or network guard edge case# labels Oct 20, 2026
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Review + reproduction evidence

Pinned review: 462a3e3b0. 1 finding, fixed in 462a3e3; 1 low-priority follow-up: URL.parse and URL.canParse still see the frame's own address.

I reproduced opening https://docs.unsloth.ai/ in the browser panel and clicking a docs link on the merge base 2429c7a (Linux, Chromium and Firefox, 1440x900):

  • Before (run): the panel shows the site's own "This page couldn't load / Reload / Back" screen; the page logs "Failed to construct 'URL': Invalid URL" (Firefox: "URL constructor: srcdoc is not a valid URL."). platform.claude.com/docs fails the same way. test_paths_resolved_against_the_shells_location_land_on_the_page and test_a_clicked_link_the_page_loads_in_full_is_followed fail.
  • PR head (run): Unsloth Docs renders, "Fine-tuning Guide" opens unsloth.ai/docs/get-started/fine-tuning-llms-guide in the panel with no blocked-navigation notice, Back returns to unsloth.ai/docs, and a double click makes one navigation. platform.claude.com/docs renders its docs home page. 39 checks pass.

PR 14279 before/after

  • example.com links, Wikipedia # links and local HTML files behave identically before and after.
  • Fixed in 462a3e3: after one unmatched blocked navigation the notice flag stopped every later link on that page from being followed; it is now checked after the click follow, with a test that fails without it.

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 (URL.parse / URL.canParse) is optional.

@shimmyshimmer

Copy link
Copy Markdown
Member

@codex security review

@shimmyshimmer
shimmyshimmer merged commit eb0a983 into unslothai:main Oct 20, 2026
wasimysaid added a commit that referenced this pull request Oct 20, 2026
## 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
```
shimmyshimmer added a commit that referenced this pull request Oct 20, 2026
## 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.

![Unsloth Docs suggested and
opened](https://raw.githubusercontent.com/shimmyshimmer/unsloth-staging-4/pr-media/pr/14324/browser_docs_pr_q-247bd1fc0cb8.png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

edge case# security# Moves a security boundary: sandbox, allowlist, permission or network guard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants