Resolve root relative assets in static previews#2818
Conversation
illegalcall
left a comment
There was a problem hiding this comment.
I left inline comments on the preview-origin boundary, URL generation, migration behavior, and test coverage.
|
resolve the issues pointed out @illegalcall, will double check after that |
|
Thanks for contributing to Agent Orchestrator. This PR is being picked up by the current external contributor on-call pair: If someone is already working on this, please continue as usual. For faster context or live questions, you can also join the AO Discord. Join the session here: Come by if you want to see what is being built, ask questions, or just hang around with the community. |
|
@illegalcall
|
* fix(preview): resolve root-relative static assets * fix(preview): fix lint errors * fix(preview): harden isolated asset serving * fix build errors
* fix(preview): resolve root-relative static assets * fix(preview): fix lint errors * fix(preview): harden isolated asset serving * fix build errors
Replays AgentWrapper#2818 with fork-safe OS helper integration, LAN-reachable mobile preview URLs, and released legacy path compatibility.
|
Replayed onto the xuelongmu fork in PR #206, merged as a28102b. The fork integration preserves the upstream static-preview semantics and OS-specific address handling, retains downstream run-file/cancelVerification behavior, keeps Connect Mobile preview URLs LAN-reachable, and adds compatibility for released double-escaped legacy asset paths. Exact corrected head 950b2d9 passed 12/12 CI, zero unresolved threads, clean merge-tree, and independent Sol/xhigh P0/P1/P2=0. |
Issue
AO serves workspace previews beneath
/api/v1/sessions/<id>/preview/files/....Root-relative references such as
/assets/app.css,/images/logo.svg, ES modules, andfetch("/data.json")therefore escaped the preview namespace and resolved against the daemon API root. Imported projects and production builds using root-relative assets could render without styling or fail to load runtime resources.Fix
Serve each static workspace preview from a session-specific
*.localhostorigin on the existing daemon port.The selected entry directory is mounted as the origin root, so:
dist/index.htmlserves/assets/app.cssfromdist/assets/app.css.file://preview targets remain unchanged.The existing
/preview/files/...route remains available for compatibility, and the preview poller migrates stored legacy workspace-preview URLs to the new origin.CORS now recognizes the RFC-reserved
*.localhostsubtree so browser module requests are accepted without allowing localhost lookalike domains.Files affected
backend/internal/preview/entry.gobackend/internal/preview/poller.gobackend/internal/httpd/router.gobackend/internal/httpd/controllers/sessions.gobackend/internal/httpd/cors.golocalhostsubdomain origins while rejecting suffix lookalikes.Preview, controller, poller, and CORS tests
Validation
go test ./internal/preview ./internal/httpd/controllersgo test ./internal/httpd -run 'TestCORS'go vet ./internal/preview ./internal/httpd/controllers ./internal/httpdnpm run frontend:typecheck<img>assetsfetch("/data/message.json")The repository-wide
go test ./...remains blocked by unrelated existing Windows/environment failures involving agent-auth fixtures, executable-bit assertions, CRLF expectations, missingsh, port-conflict handling, and stale generated OpenAPI output.Risks and scope
file://targets are not rewritten.*.localhostnamespace; this was manually verified in AO’s Chromium browser on Windows.