The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): let Files panel download remote backend files
xxxigm6a843f95c8e9
diff --git a/apps/desktop/src/app/right-sidebar/file-actions.tsx b/apps/desktop/src/app/right-sidebar/file-actions.tsxindex dbb2ccb65d3..e5e9443f328 100644--- a/apps/desktop/src/app/right-sidebar/file-actions.tsx+++ b/apps/desktop/src/app/right-sidebar/file-actions.tsx@@ -19,11 +19,13 @@ import {cancelInlineRename,closeFileActionDialog,copyFilePath,+ downloadRemoteFile,executeFileDelete,executeFileRename,type FileActionTarget,requestFileDelete,revealFile,+ shouldOfferRemoteFileDownload,toRelativePath} from '@/store/file-actions'import { notifyError } from '@/store/notifications'@@ -57,8 +59,10 @@ export function FileEntryContextMenu({ children, isDirectory, name, path, relaticonst { t } = useI18n()const m = t.fileMenu// Reveal / rename / delete need the local filesystem; hide them on a remote- // backend (copy-path still works everywhere).+ // backend (copy-path still works everywhere). Download uses the existing+ // gateway save bridge so a remote file can land on this machine.const localFs = !isDesktopFsRemoteMode()+ const remoteDownload = shouldOfferRemoteFileDownload(isDirectory)const target: FileActionTarget = { isDirectory, name, path }const revealLabel = pickRevealLabel(m.revealFinder, m.revealExplorer, m.revealFileManager)@@ -80,6 +84,12 @@ export function FileEntryContextMenu({ children, isDirectory, name, path, relati{m.copyRelativePath}</ContextMenuItem>)}+ {remoteDownload && (+ <>+ <ContextMenuSeparator />+ <ContextMenuItem onSelect={() => void downloadRemoteFile(path)}>{m.download}</ContextMenuItem>+ </>+ )}{localFs && (<><ContextMenuSeparator />diff --git a/apps/desktop/src/app/right-sidebar/review/file-tree.tsx b/apps/desktop/src/app/right-sidebar/review/file-tree.tsxindex 745839c523f..1ae6e21bc66 100644--- a/apps/desktop/src/app/right-sidebar/review/file-tree.tsx+++ b/apps/desktop/src/app/right-sidebar/review/file-tree.tsx@@ -20,7 +20,14 @@ import { isDesktopFsRemoteMode } from '@/lib/desktop-fs'import { displayPath } from '@/lib/display-path'import { normalizeOrLocalPreviewTarget } from '@/lib/local-preview'import { cn } from '@/lib/utils'-import { $renamingPath, copyFilePath, revealFile, toRelativePath } from '@/store/file-actions'+import {+ $renamingPath,+ copyFilePath,+ downloadRemoteFile,+ revealFile,+ shouldOfferRemoteFileDownload,+ toRelativePath+} from '@/store/file-actions'import { $sidebarWorkspaceNodeOpen, revealFileInTree, toggleWorkspaceNodeCollapsed } from '@/store/layout'import { notifyError } from '@/store/notifications'import { openPreview } from '@/store/preview'@@ -514,6 +521,12 @@ function ReviewFileContextMenu({{m.copyRelativePath}</ContextMenuItem>)}+ {shouldOfferRemoteFileDownload(false) && (+ <>+ <ContextMenuSeparator />+ <ContextMenuItem onSelect={() => void downloadRemoteFile(dragPath)}>{m.download}</ContextMenuItem>+ </>+ )}</ContextMenuContent></ContextMenu>)diff --git a/apps/desktop/src/i18n/ar.ts b/apps/desktop/src/i18n/ar.tsindex 06d7370adf8..7749e69d8d5 100644--- a/apps/desktop/src/i18n/ar.ts+++ b/apps/desktop/src/i18n/ar.ts@@ -46,6 +46,9 @@ export const ar = defineLocale({revealInSidebar: 'إظهار في شجرة الملفات',copyPath: 'نسخ المسار',copyRelativePath: 'نسخ المسار النسبي',+ download: 'تنزيل',+ downloadSaved: 'تم الحفظ',+ downloadFailed: 'فشل التنزيل',rename: 'إعادة تسمية...',delete: 'حذف',renameTitle: 'إعادة تسمية',diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.tsindex 5b9c56a8c19..962b7338c67 100644--- a/apps/desktop/src/i18n/en.ts+++ b/apps/desktop/src/i18n/en.ts@@ -52,6 +52,9 @@ export const en: Translations = {revealInSidebar: 'Reveal in filetree',copyPath: 'Copy Path',copyRelativePath: 'Copy Relative Path',+ download: 'Download',+ downloadSaved: 'Saved',+ downloadFailed: 'Download failed',rename: 'Rename…',delete: 'Delete',renameTitle: 'Rename',diff --git a/apps/desktop/src/i18n/ja.ts b/apps/desktop/src/i18n/ja.tsindex 0d55b750677..8d5872788e4 100644--- a/apps/desktop/src/i18n/ja.ts+++ b/apps/desktop/src/i18n/ja.ts@@ -52,6 +52,9 @@ export const ja = defineLocale({revealInSidebar: 'ファイルツリーで表示',copyPath: 'パスをコピー',copyRelativePath: '相対パスをコピー',+ download: 'ダウンロード',+ downloadSaved: '保存しました',+ downloadFailed: 'ダウンロードに失敗しました',rename: '名前を変更…',delete: '削除',renameTitle: '名前を変更',diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.tsindex 678e0f88e7c..ec4b3e56433 100644--- a/apps/desktop/src/i18n/types.ts+++ b/apps/desktop/src/i18n/types.ts@@ -98,6 +98,9 @@ export interface Translations {revealInSidebar: stringcopyPath: stringcopyRelativePath: string+ download: string+ downloadSaved: string+ downloadFailed: stringrename: stringdelete: stringrenameTitle: stringdiff --git a/apps/desktop/src/i18n/zh-hant.ts b/apps/desktop/src/i18n/zh-hant.tsindex 490fc298418..f2db8dd9235 100644--- a/apps/desktop/src/i18n/zh-hant.ts+++ b/apps/desktop/src/i18n/zh-hant.ts@@ -52,6 +52,9 @@ export const zhHant = defineLocale({revealInSidebar: '在檔案樹中顯示',copyPath: '複製路徑',copyRelativePath: '複製相對路徑',+ download: '下載',+ downloadSaved: '已儲存',+ downloadFailed: '下載失敗',rename: '重新命名…',delete: '刪除',renameTitle: '重新命名',diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.tsindex dd3b63af90c..a04f5a8844b 100644--- a/apps/desktop/src/i18n/zh.ts+++ b/apps/desktop/src/i18n/zh.ts@@ -52,6 +52,9 @@ export const zh: Translations = {revealInSidebar: '在文件树中显示',copyPath: '复制路径',copyRelativePath: '复制相对路径',+ download: '下载',+ downloadSaved: '已保存',+ downloadFailed: '下载失败',rename: '重命名…',delete: '删除',renameTitle: '重命名',diff --git a/apps/desktop/src/store/file-actions.ts b/apps/desktop/src/store/file-actions.tsindex 55f2b0fac3b..efd3f219eff 100644--- a/apps/desktop/src/store/file-actions.ts+++ b/apps/desktop/src/store/file-actions.ts@@ -1,15 +1,23 @@import { atom } from 'nanostores'import { translateNow } from '@/i18n'-import { copyTextToClipboard, renameDesktopPath, revealDesktopPath, trashDesktopPath } from '@/lib/desktop-fs'+import {+ copyTextToClipboard,+ isDesktopFsRemoteMode,+ renameDesktopPath,+ revealDesktopPath,+ trashDesktopPath+} from '@/lib/desktop-fs'+import { downloadGatewayMediaFile } from '@/lib/media'import { notify, notifyError } from '@/store/notifications'import { notifyWorkspaceChanged } from '@/store/workspace-events'// Shared file-row actions for BOTH trees (the file browser + the review/git-// tree): reveal, copy path, rename, delete. Rename/delete route through a single-// dialog set (driven by this atom, rendered once by `FileActionDialogs`) instead-// of one dialog per row. After a successful mutation we bump the workspace tick-// so every git-/fs-mirroring surface refreshes.+// tree): reveal, copy path, download (remote), rename, delete. Rename/delete+// route through a single dialog set (driven by this atom, rendered once by+// `FileActionDialogs`) instead of one dialog per row. After a successful+// mutation we bump the workspace tick so every git-/fs-mirroring surface+// refreshes.export interface FileActionTarget {isDirectory: boolean@@ -65,6 +73,27 @@ export async function copyFilePath(path: string): Promise<void> {}}+/** Remote Files panel can list gateway files but Reveal/Rename/Delete are local-only.+ * Download is the local-copy affordance. Folders stay out — `/api/fs/download`+ * streams a single file. */+export function shouldOfferRemoteFileDownload(isDirectory: boolean, remote = isDesktopFsRemoteMode()): boolean {+ return remote && !isDirectory+}++export async function downloadRemoteFile(path: string): Promise<void> {+ try {+ const result = await downloadGatewayMediaFile(path)++ if (result.canceled || !result.saved) {+ return+ }++ notify({ durationMs: 1500, kind: 'info', message: translateNow('fileMenu.downloadSaved') })+ } catch (error) {+ notifyError(error, translateNow('fileMenu.downloadFailed'))+ }+}+/** Strip a `relativeTo` prefix to produce a repo/cwd-relative path. */export function toRelativePath(path: string, relativeTo: string): string {const base = relativeTo.replace(/[\\/]+$/, '')