Skip to content

Open source CapCut alternative.

TypeScript

fix(site): Finder affordances follow project residency, cloud exports download

David Le125e469344a4
diff --git a/site/src/cut/components/PlatformPreview.tsx b/site/src/cut/components/PlatformPreview.tsx
index 54de61b7..c9669451 100644
--- a/site/src/cut/components/PlatformPreview.tsx
+++ b/site/src/cut/components/PlatformPreview.tsx
@@ -7,6 +7,7 @@ import {
Camera,
Check,
Copy,
+ Download,
FolderOpen,
Heart,
MessageCircle,
@@ -23,7 +24,8 @@ import {
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { SectionTitle } from "@/cut/components/SectionTitle";
-import { revealExport } from "@/cut/lib/exportClient";
+import { useCutCaps } from "@/cut/lib/backend/hooks";
+import { downloadProjectExport, revealExport } from "@/cut/lib/exportClient";
import { CAPTION_LIMIT, normalizeTags } from "@/cut/lib/publish";
import { useEditor } from "@/cut/lib/store";
import { cn } from "@/lib/utils";
@@ -56,6 +58,7 @@ export function PlatformPreviewDialog({
item: ExportItem;
onClose: () => void;
}) {
+ const caps = useCutCaps();
const publish = useEditor((s) => s.publish);
const setPublish = useEditor((s) => s.setPublish);
const [platform, setPlatform] = useState<Platform>("original");
@@ -96,11 +99,19 @@ export function PlatformPreviewDialog({
<div className="text-sm font-semibold tracking-tight">Post preview</div>
<button
type="button"
- onClick={() => void revealExport(projectId, item.file).catch(() => {})}
- title="Show in Finder"
+ onClick={() =>
+ caps.revealInFinder
+ ? void revealExport(projectId, item.file).catch(() => {})
+ : downloadProjectExport(projectId, item.file)
+ }
+ title={caps.revealInFinder ? "Show in Finder" : "Download"}
className="reveal-export mt-0.5 flex w-full items-center gap-1 font-mono text-[10.5px] text-muted-foreground transition-colors hover:text-foreground"
>
- <FolderOpen className="size-3 shrink-0" />
+ {caps.revealInFinder ? (
+ <FolderOpen className="size-3 shrink-0" />
+ ) : (
+ <Download className="size-3 shrink-0" />
+ )}
<span className="truncate">{item.file}</span>
</button>
</div>
diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsx
index 46598383..465d9ed3 100644
--- a/site/src/cut/components/SidePanel.tsx
+++ b/site/src/cut/components/SidePanel.tsx
@@ -1,7 +1,7 @@
"use client";
import { Fragment, useEffect, useRef, useState } from "react";
-import { Captions, Check, Clapperboard, ClipboardList, Copy, Ellipsis, Film, FolderOpen, FolderPlus, Image as ImageIcon, Loader2, Music, Plus, Trash2, Upload } from "lucide-react";
+import { Captions, Check, Clapperboard, ClipboardList, Copy, Download, Ellipsis, Film, FolderOpen, FolderPlus, Image as ImageIcon, Loader2, Music, Plus, Trash2, Upload } from "lucide-react";
import { Button } from "@/components/ui/button";
import { LiveElapsed } from "@/cut/components/Elapsed";
import {
@@ -36,7 +36,7 @@ import {
} from "@/cut/lib/assetDrag";
import type { AssetRef } from "@/cut/lib/assetRef";
import { RefDropZone } from "./RefDropZone";
-import { deleteExport, revealExport } from "@/cut/lib/exportClient";
+import { deleteExport, downloadProjectExport, revealExport } from "@/cut/lib/exportClient";
import { useExports, useWatchExportLands } from "@/cut/lib/exportStore";
import {
addAssetToLibraryTemplate,
@@ -343,6 +343,7 @@ function MediaPanel({
onImport: (files: FileList) => void;
importing: boolean;
}) {
+ const caps = useCutCaps();
// Only user-imported media lives here; anything Cut created (recordings, AI
// generations, voiceovers, freeze frames, stock adds) is tagged with an
// `origin` and stays where it was made.
@@ -504,15 +505,27 @@ function MediaPanel({
</span>
</button>
<div className="flex shrink-0 items-center gap-0.5 pr-0.5 opacity-0 transition-opacity group-hover:opacity-100">
- <Button
- variant="ghost"
- size="icon-xs"
- aria-label="Show in Finder"
- title="Show in Finder"
- onClick={() => void revealExport(projectId, it.file).catch(() => {})}
- >
- <FolderOpen />
- </Button>
+ {caps.revealInFinder ? (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label="Show in Finder"
+ title="Show in Finder"
+ onClick={() => void revealExport(projectId, it.file).catch(() => {})}
+ >
+ <FolderOpen />
+ </Button>
+ ) : (
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label="Download export"
+ title="Download"
+ onClick={() => downloadProjectExport(projectId, it.file)}
+ >
+ <Download />
+ </Button>
+ )}
<Button
variant="ghost"
size="icon-xs"
diff --git a/site/src/cut/components/Timeline.tsx b/site/src/cut/components/Timeline.tsx
index 94d9c621..39a9cc44 100644
--- a/site/src/cut/components/Timeline.tsx
+++ b/site/src/cut/components/Timeline.tsx
@@ -23,6 +23,7 @@ import {
hasTemplateDrag,
} from "@/cut/lib/assetDrag";
import { audioClipRefs, draggingRef, hasRefDrag, type AssetRef } from "@/cut/lib/assetRef";
+import { useCutCaps } from "@/cut/lib/backend/hooks";
import {
addProjectTemplateToTimeline,
addTemplateToProject,
@@ -1798,6 +1799,7 @@ function ClipMenu({
clip: VideoClip | AudioClip;
children?: ReactNode;
}) {
+ const caps = useCutCaps();
return (
<DropdownMenu>
<DropdownMenuTrigger
@@ -1837,15 +1839,17 @@ function ClipMenu({
<DropdownMenuItem onClick={() => exportSegment(asset, clip)}>
<ArrowDownToLine /> Export segment
</DropdownMenuItem>
- <DropdownMenuItem
- onClick={() => {
- const projectId = useEditor.getState().projectId;
- if (!projectId) return;
- void revealMedia(projectId, asset.fileName).catch(() => {});
- }}
- >
- <FolderOpen /> Show in Finder
- </DropdownMenuItem>
+ {caps.revealInFinder && (
+ <DropdownMenuItem
+ onClick={() => {
+ const projectId = useEditor.getState().projectId;
+ if (!projectId) return;
+ void revealMedia(projectId, asset.fileName).catch(() => {});
+ }}
+ >
+ <FolderOpen /> Show in Finder
+ </DropdownMenuItem>
+ )}
</DropdownMenuContent>
</DropdownMenu>
);
diff --git a/site/src/cut/lib/exportClient.ts b/site/src/cut/lib/exportClient.ts
index c72d00eb..bf58b048 100644
--- a/site/src/cut/lib/exportClient.ts
+++ b/site/src/cut/lib/exportClient.ts
@@ -119,6 +119,20 @@ export async function revealExport(
);
}
+/** Download a rendered export by file name — what stands in for revealExport
+ * when the backend has no Finder (the cloud route 302s to a signed R2 URL with
+ * attachment disposition). */
+export function downloadProjectExport(projectId: string, file: string) {
+ const a = document.createElement("a");
+ a.href = getBackend().url(
+ `/api/cut/projects/${projectId}/exports/${encodeURIComponent(file)}?download=1`
+ );
+ a.download = file;
+ document.body.appendChild(a);
+ a.click();
+ a.remove();
+}
+
/** Delete a rendered export from the project folder. Throws on failure so the
* UI can stay truthful instead of optimistically dropping a file that's still
* on disk (which is why deleted exports used to reappear on the next refresh). */
diff --git a/site/src/cut/server/cloud/projects.ts b/site/src/cut/server/cloud/projects.ts
index 2d07a25d..a8e87c58 100644
--- a/site/src/cut/server/cloud/projects.ts
+++ b/site/src/cut/server/cloud/projects.ts
@@ -388,9 +388,11 @@ export const projectsCloud = {
);
},
- async serveExport(userId: string, id: string, file: string) {
+ async serveExport(userId: string, id: string, file: string, download = false) {
try {
- return redirect(await presignGet(projectExportKey(userId, id, decodeFileParam(file))));
+ const fileName = decodeFileParam(file);
+ const key = projectExportKey(userId, id, fileName);
+ return redirect(await presignGet(key, download ? fileName : undefined));
} catch (e) {
return caught(e, "Bad request.", 400);
}