Skip to content

File browser opens HTML in code editor by default — no "Preview as HTML" option #296

@MidiSlave

Description

@MidiSlave

Problem

Clicking an HTML file in the Workspace file browser opens it in the code editor view (raw markup with syntax highlighting). There's no way to view the rendered HTML.

The /api/preview-file route exists and supports HTML rendering in an iframe (it's used by the Conductor complete-phase panel for mission outputs at `/tmp/dispatch-*/index.html`), but the file browser UI doesn't expose any "Preview" / "Render" / "Open in browser" affordance.

Expected behaviour

For files with renderable types (HTML, SVG, MD, images, PDF), the file browser should offer a preview action alongside / instead of the editor:

  • HTML / SVG → sandboxed iframe via /api/preview-file
  • Markdown → rendered markdown view
  • Images → thumbnail preview
  • PDF → PDF.js or similar

A simple two-button pattern works: Preview (default for renderable types) | Edit (default for code files).

Additional gap

preview-file has a hardcoded prefix allowlist (/tmp, ~/projects, ~/dispatch, ~/.hermes/projects, ~/.claude/projects, ~/.ocplatform/workspace/projects). The active workspace catalog path is not in this list — so even if the file browser did wire up the Preview button, files from the user's configured workspace would 403.

The allowlist should also include:

  • The currently-active workspace catalog path
  • Any path explicitly registered via POST /api/workspace

These are paths the user has already authorised as workspaces, so it's reasonable to allow preview within them.

Why it matters

The most common reason a user clicks an HTML file in the file browser is to see what it looks like — not to edit the source. Defaulting to the code editor inverts the expected UX.

Combined with the cross-cutting artifact rendering issue, this is the second-most common pain point for agents that produce HTML output.

Repro

  1. Configure a workspace at /srv/workspace
  2. Have the agent write an HTML file there
  3. Click the file in the Workspace file browser
  4. Get the code editor instead of a rendered view, with no obvious way to switch

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions