Skip to content

Make Quarto Posit Workbench aware - #14869

Merged
cderv merged 1 commit into
mainfrom
feature/pwb-localhost
Sep 9, 2026
Merged

cderv merged 1 commit into
mainfrom
feature/pwb-localhost

Conversation

@melissa-barca

Copy link
Copy Markdown
Collaborator

Description

Clicking a link inside a Quarto preview in Positron on Posit Workbench opened the page in a new browser tab instead of navigating inside the Viewer pane. Links are now classified against the origin the browser is on, so internal links stay in the pane.

Quarto's own preview server infers its origin from the request and sees localhost, while the browser is on the Workbench host. Comparing those two classified every internal link as external, on any deployment that serves a preview through a proxy. Comparing parsed origins also resolves relative hrefs, which the previous prefix comparison always treated as external.

Verified in Positron on a Posit Workbench deployment: a dashboard tab click stays in the Viewer pane, a relative in-document link stays in the pane, the toolbar "Open in Browser" still opens the system browser, and a genuinely external link still opens the system browser.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR
AI-assisted PR
  • AI tool used: Claude Code
  • Codebase grounding: local clone
  • Human review: I have reviewed, tested, and verified the AI-generated content before submitting.

Fixes #14865

handleExternalLinks compared anchor hrefs against the origin the preview
server inferred from the request. Behind a proxy the browser is on a
different origin, so internal links were classified as external and the
embedder opened them in a new browser tab.

Compare parsed origins for equality against window.location.origin,
still accepting the server-provided origin. Parsing also resolves
relative hrefs, which a prefix test always treated as external.

Fixes #14865
@posit-snyk-bot

posit-snyk-bot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@cscheid

cscheid commented Sep 8, 2026

Copy link
Copy Markdown
Member

quarto-preview is a fraught bit of our codebase, so we especially appreciate the PR. This looks good to me. It would be even better if we knew for sure that we have an e2e test that exercises quarto preview in the common case. (@cderv will know for sure).

@cderv cderv left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No, we don't have an automated e2e test that exercises quarto preview. Nothing in tests/ starts the preview server, and the Playwright suite serves pre-rendered files, so quarto-preview.js is never loaded there. Expanding Playwright to cover it is tracked in #10696.
We only have manual testing through /quarto-preview-test and tests/docs/manual/preview cases.

I verified this one by hand instead, with a viewer-like iframe host page and a reverse proxy on a second origin, so the browser origin differs from the one the preview server infers. On main an internal link click posts openExternal to the parent, with this PR it stays in the pane, and a genuinely external link still posts openExternal. On a plain localhost preview both behave identically, so the common local case is unchanged.

@cderv
cderv merged commit f594174 into main Sep 9, 2026
69 checks passed
@cderv
cderv deleted the feature/pwb-localhost branch September 9, 2026 09:54
cderv added a commit that referenced this pull request Sep 9, 2026
Verifying #14869 needed a way to exercise the code in
src/webui/quarto-preview/src/frame/ that only runs inside an embedded
viewer (RStudio Viewer, VS Code Simple Browser, Posit Workbench). A
plain top-level preview never reaches it, and quarto-cli has no e2e
test that starts `quarto preview` at all.

- Reference for the `quarto-preview-test` skill covering the iframe +
  postMessage host page pattern, a throwaway reverse proxy for
  reproducing a proxied deployment's browser/server origin mismatch,
  the server's first-request client-injection detection, and the
  precondition assertion needed before trusting a click result
- Test workflows skip `.claude/**`-only changes, since agent config
  cannot affect build or test outcomes

Related to #14869, #10696.
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.

Quarto doesn't recognize same-origin links on Posit Workbench

4 participants