Skip to content

[FEATURE]: web: file preview has no download action, binary files cannot be saved #60180

Open

Description

@xiaoqinxing
  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

The web app (opencode pair → browser) file preview is view-only: there is no download action in the preview header, the file tree, or any tab menu. Files the agent generated on the server cannot be saved from the browser.

  • Text files: select-all + copy is the only way out.
  • Binary files (zip, pdf, docx, images, fonts, …): the preview shows the binary placeholder and there is no route to the bytes at all.
  • The only built-in download I could find is view.download in the legacy artifact toolbar (packages/gui-plugins/src/file/artifact-toolbar.tsx), and it only renders while props.text !== undefined. The V2 file preview (packages/session-ui/src/v2/components/session-review-file-preview-v2.tsx) exposes no toolbar actions, so in current V2 there is no download entry point at all.
  • API side: the server.fs group only has read, list, find (plus experimental write / watch). 2.1.2's /openapi.json and current dev (packages/server/src/handlers/fs.ts) both have no download route.

This matters most for remote / paired sessions: the person in the browser often has no shell on the server, so "just scp it" is not available.

Proposed solution

Add a download action (button and/or context-menu item) to the file preview and file tree that streams the raw bytes from fs.read:

  1. Server: add GET /api/fs/download/* (or a download flag on fs.read) returning Content-Disposition: attachment; filename="…", with RFC 5987 encoding for non-ASCII names. serveFile already streams with Range support, so large files should not be buffered in the app.
  2. App: a Download item in the file preview header and in the file tree row menu that navigates to that URL. Using a navigation, not fetch + blob, keeps memory flat for large generated artifacts.
  3. Keep it available when the preview falls back to the binary placeholder — that is the case that is impossible today.

Prior art

I am happy to rebase and re-submit #39879 against current dev, or to open a smaller PR that adds only the download endpoint plus the preview header item, whichever is preferred.

Workaround used today

A userscript that re-fetches /api/fs/read/<path>?location[directory]=<dir> and saves the blob through a[download]. It works, but no user should need one for a basic "save this generated file" action.

Environment

  • opencode 2.1.2, Linux x64; the same gap exists in current dev.
  • Web app accessed over opencode pair in a desktop browser.

Activity

  1. opencodejr commented on Oct 29, 2026

    @opencodejr
    Contributor

    Thanks for the detailed write-up, @xiaoqinxing! You're asking for a Download action in the web app's file preview and file tree, backed by a server route that streams the raw bytes as an attachment, and for it to work when the preview shows the binary placeholder too. Today generated files can't be saved from the browser, which hurts most in remote or paired sessions with no shell access.

    The current V2 preview and the fs API don't offer this, so it's a new feature rather than a bug. The maintainers will consider it, and your offer of a PR (either rebasing #39879 or the smaller endpoint-plus-header version) is noted.

    Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions