GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(gui-plugins): add file download for remote server connections by drpr · Pull Request #63472 · anomalyco/opencode Conversation
|
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The title and description describe a one-line Blob cast cleanup, but this branch adds the whole feature: a new download.ts helper and a Download / Copy path context menu in the session file list and Pierre tree when no local app can open files. Please update the description to explain the feature.
How I checked: I couldn't run this in the web app, so it isn't verified. tsc -b for packages/gui-plugins passes, oxlint reports nothing on the changed files, and bun test src/file passes (192 tests). There are no new tests. I followed the file-content path in packages/app/src/workspaces/files/artifact.ts by reading the code.
Public API: unchanged. Only an internal screen prop is added to the built-in OpenInAppContextMenuV2.
Concerns, in order (details inline):
bytes for files it doesn't recognise as images, PDFs, documents and so on (zip, tar, executables), or for media over 256 MiB. For those files Download just shows "Couldn't load this file." These are the files remote users most need to save (#60180). The server already sends file reads as attachments (#62422), so downloading through the server would cover every file. It would also avoid holding the whole file in memory.downloadFile goes unhandled, so the user sees no error message.click(), which can cancel the download in some browsers.DownloadContextMenu copies most of OpenInAppContextMenuV2's trigger and hover logic.Related: #60180
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| link.href = url | ||
| link.download = name | ||
| link.click() | ||
| URL.revokeObjectURL(url) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Revoking the object URL straight after click() can cancel the download in some browsers, notably Safari and Firefox with large blobs. Revoke it after a delay, for example in a setTimeout.
This branch is hit for every binary the app doesn't recognise as an image, PDF, document and so on (zip, tar, executables): fileContentFromBytes keeps only { type: "binary", content: "", size } for them. It's also hit for media over MAX_MEDIA_BYTES. Download then shows "Couldn't load this file." for the files remote users most need to save. The server already sends file reads as attachments (#62422). Downloading through the server would cover every file, and it avoids pulling the whole file into the in-memory cache first (the forced sync above).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| // Binary: system.save takes a string, so stream or blob-download raw bytes instead. | ||
| if (content.url) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
content.url is the server's stream URL. When the server is on a different origin from the app (a common remote setup), browsers ignore the download attribute. The click then opens the image, audio or video in the current tab and navigates away from the app instead of saving it. Fetching the file into a blob, or using a URL the server marks as an attachment, avoids that.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (!resolved) return | ||
| const workspacePath = props.screen.file.resolve(resolved) | ||
|
|
||
| void downloadFile(ctx, props.screen, workspacePath).then((ok) => { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
downloadFile can reject: file.sync, ctx.system.save or the blob creation can throw. Only a resolved false shows the toast here, so a rejection is unhandled and the user gets no feedback. Add a .catch that shows the same error toast.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| /** A context menu for files on a remote server, where no local app can open them. */ | ||
| function DownloadContextMenu( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This component repeats almost all of OpenInAppContextMenuV2's trigger, hover-highlight and onOpenChange logic. Only the menu items differ. Keep one context menu that switches its items (open-in-app vs. download). Two copies of the trigger and hover handling will drift apart.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
feat: add file download for remote server connections
There was an error while loading. Please reload this page.