Skip to content

[backport] Fix preview browse URL for single-file documents#14301

Merged
cderv merged 6 commits intov1.9from
backport/issue-14298
Apr 3, 2026
Merged

[backport] Fix preview browse URL for single-file documents#14301
cderv merged 6 commits intov1.9from
backport/issue-14298

Conversation

@cderv
Copy link
Copy Markdown
Collaborator

@cderv cderv commented Apr 2, 2026

Important

Backport of #14300

quarto preview hello.qmd prints Browse at http://localhost:PORT/hello.html instead of http://localhost:PORT/, and GET / returns 404. This breaks Posit Workbench Proxied Servers pane.

PR #13804 made project always non-null via singleFileProjectContext(). Two code paths branch on project being truthy: the URL path computation (prints filename) and the handler selection (uses wrong default file). Fix guards both with project.isSingleFile.

Verified locally: v1.8.27 serves root URL correctly, v1.9.36 returns 404, fix restores v1.8 behavior. Also ran T17/T18 manual preview tests directly on this branch — both pass (GET / and GET /plain.html return 200). Added missing plain.qmd test fixture that was not part of the original backport.

Fixes #14298

cderv added 2 commits April 2, 2026 12:30
PR #13804 made project always non-null via singleFileProjectContext(),
causing the initialPath computation to always take the project branch.
This produced URLs like http://localhost:PORT/hello.html instead of
http://localhost:PORT/ for standalone files, breaking Posit Workbench
proxy access.

Guard with project.isSingleFile so single-file previews use root path.
Extract computation into previewInitialPath() for testability.

Fixes #14298

[backport] Fix preview browse URL for single-file documents (#14298)
Extend createMockProjectContext() with options object supporting
isSingleFile and config parameters. Use it in preview-initial-path
tests instead of a duplicate mock function.
@cderv cderv force-pushed the backport/issue-14298 branch from 0e5cfb1 to b3582f0 Compare April 2, 2026 10:30
cderv added 3 commits April 2, 2026 15:07
The handler selection at line 251 had the same project-truthiness bug
as the URL path computation: single-file projects used
projectHtmlFileRequestHandler (defaultFile="index.html") instead of
htmlFileRequestHandler (defaultFile=basename of output). This caused
GET / to return 404 for single-file previews since v1.9.

Add isSingleFile guard to handler selection. Also fix test cleanup
by letting createMockProjectContext own temp dir creation.
T17: Verify GET / returns 200 for single-file preview
T18: Verify GET /filename.html also works
T19: Verify project preview paths still work with isSingleFile guard
The skill now supports three invocation modes:
- By test ID: /quarto-preview-test T17 T18
- By topic: /quarto-preview-test root URL (fuzzy match + confirm)
- No args: ad-hoc preview testing workflow

Also add tests/docs/manual/README.md documenting all manual test suites.
@cscheid
Copy link
Copy Markdown
Collaborator

cscheid commented Apr 2, 2026

Thanks! (We would really benefit from a broader effort to have the hosted teams bring us tests against their expected behavior..)

@cderv
Copy link
Copy Markdown
Collaborator Author

cderv commented Apr 2, 2026

Yes for sure. I have now added a skill to have help from claude testing preview.

So manual regression tests we can run when we are touching preview code base. This will help.

This expected behavior is now registered.

It seems they have automatic tests though as this is how they discovered. We should probably see if we can run those tests again all our pre-release !

Required by T9/T17/T18 in the manual preview test matrix.
This fixture exists on main but was not part of the backport.
@cderv cderv merged commit 448eea6 into v1.9 Apr 3, 2026
44 checks passed
@cderv cderv deleted the backport/issue-14298 branch April 3, 2026 13:03
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.

2 participants