Skip to content

Studio: fix Claude API reference pages in the browser panel - #14323

Merged
wasimysaid merged 3 commits into
unslothai:mainfrom
wasimysaid:fix/studio-claude-docs-origin
Oct 20, 2026
Merged

wasimysaid merged 3 commits into
unslothai:mainfrom
wasimysaid:fix/studio-claude-docs-origin

Conversation

@wasimysaid

Copy link
Copy Markdown
Collaborator

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:

node --experimental-strip-types --test studio/frontend/tests/browser-{url,network,page-storage,frame-message,address}.test.ts

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T08:57:00.202864Z 79c8f1a 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: 48d00bab59

ℹ️ 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".

Comment thread studio/backend/routes/browser.py Outdated
const base = args.length > 1 ? String(args[1]) : "";
if (base === "null") args = [args[0], new NativeURL(pageUrl).origin];
else if (/^about:srcdoc(?=[?#]|$)/.test(base)) args = [args[0], pageUrl];
else if (args.length === 1 && String(args[0]) === "null") args = [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 Restrict the origin rewrite to the primitive string

When a page passes a missing value as new URL(null) (for example, while validating an optional URL), coercing the argument in this guard makes it indistinguishable from the opaque-origin string and returns the current page origin even though the native constructor throws. The unconditional String also invokes custom object stringifiers once before Reflect.construct, changing their behavior; compare directly with the primitive string "null" so only window.location.origin is rewritten.

Useful? React with 👍 / 👎.

@wasimysaid

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 79c8f1a48f

ℹ️ 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".

@wasimysaid
wasimysaid merged commit c87f845 into unslothai:main Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant