Skip to content

Cloud rich file preview should use static workspace URLs instead of /download data URIs #982

@enyst

Description

@enyst

Problem

The rich file preview path for Cloud conversations still fetches file bytes through /api/file/download and converts them into data: URLs. That breaks previews that depend on relative assets, especially HTML files with sibling CSS/JS/images.

Current code path:

  • src/hooks/query/use-workspace-file-content.ts
    • local mode uses the static workspace fileserver URL from useWorkspaceSession() and renders images/PDFs/HTML-ish content from a real URL.
    • cloud mode calls AgentServerRuntimeService.downloadFile() and creates a data: URL.
  • src/api/runtime-service/agent-server-runtime-service.ts
    • cloud mode calls the runtime endpoint /api/file/download?path=... through callCloudProxy().

A data:text/html;base64,... document has no useful workspace-relative base URL, so relative references like ./style.css, ./bundle.js, or images cannot resolve to the runtime's static webserver. The result is a broken rich file view even though the runtime could serve those assets as static files.

I did not find an existing agent-canvas issue specifically tracking this. #205 is about trajectory export downloads and is unrelated.

Expected behavior

Cloud rich file previews should render from a browser-reachable static workspace URL (or an equivalent proxy URL that preserves path/base semantics), not from /api/file/download data URIs, so relative assets resolve correctly.

Possible approaches:

  • Expose/mint a Cloud-compatible static workspace session URL whose cookies/auth work in the browser.
  • Add a same-origin proxy route that serves workspace files with stable paths and forwards auth server-side.
  • For HTML previews, inject a <base href="..."> only if that can be done safely and all asset requests remain authenticated.

Acceptance criteria

  • HTML files in Cloud conversations can load sibling CSS/JS/image assets in the rich file viewer.
  • The preview path no longer depends on data: URLs for renderable rich documents that need relative assets.
  • Binary/text fallback behavior still works.
  • Regression coverage includes a Cloud-mode HTML file with at least one relative asset.

This issue was created by an AI agent (OpenHands) on behalf of the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions