Skip to content

Open source CapCut alternative.

TypeScript

feat(site): preview exports plain, reveal in Finder, and delete them

David Led318610d5f2b
diff --git a/site/src/cut/components/PlatformPreview.tsx b/site/src/cut/components/PlatformPreview.tsx
index a205aed2..07e6c31b 100644
--- a/site/src/cut/components/PlatformPreview.tsx
+++ b/site/src/cut/components/PlatformPreview.tsx
@@ -7,6 +7,7 @@ import {
Camera,
Check,
Copy,
+ FolderOpen,
Heart,
MessageCircle,
MoreHorizontal,
@@ -21,6 +22,7 @@ import {
X,
} from "lucide-react";
import { Button } from "@/components/ui/button";
+import { revealExport } from "@/cut/lib/exportClient";
import { CAPTION_LIMIT, normalizeTags } from "@/cut/lib/publish";
import { useEditor } from "@/cut/lib/store";
import { cn } from "@/lib/utils";
@@ -31,9 +33,10 @@ export interface ExportItem {
mtime: number;
}
-type Platform = "tiktok" | "instagram" | "youtube";
+type Platform = "original" | "tiktok" | "instagram" | "youtube";
const PLATFORMS: { id: Platform; label: string }[] = [
+ { id: "original", label: "Original" },
{ id: "tiktok", label: "TikTok" },
{ id: "instagram", label: "Instagram" },
{ id: "youtube", label: "YouTube" },
@@ -54,7 +57,7 @@ export function PlatformPreviewDialog({
}) {
const publish = useEditor((s) => s.publish);
const setPublish = useEditor((s) => s.setPublish);
- const [platform, setPlatform] = useState<Platform>("tiktok");
+ const [platform, setPlatform] = useState<Platform>("original");
const [muted, setMuted] = useState(true);
const [copied, setCopied] = useState(false);
const videoRef = useRef<HTMLVideoElement>(null);
@@ -91,9 +94,15 @@ export function PlatformPreviewDialog({
<div className="flex w-[300px] shrink-0 flex-col gap-3.5 overflow-y-auto border-r border-border p-4">
<div>
<div className="text-sm font-semibold tracking-tight">Post preview</div>
- <div className="mt-0.5 truncate font-mono text-[10.5px] text-muted-foreground">
- {item.file}
- </div>
+ <button
+ type="button"
+ onClick={() => void revealExport(projectId, item.file).catch(() => {})}
+ title="Show in Finder"
+ 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" />
+ <span className="truncate">{item.file}</span>
+ </button>
</div>
<div className="flex flex-col gap-1.5">
@@ -207,16 +216,25 @@ export function PlatformPreviewDialog({
<video
ref={videoRef}
src={url}
- className="absolute inset-0 size-full object-cover"
+ className={cn(
+ "absolute inset-0 size-full",
+ // "Original" shows the true exported frame, uncropped; the
+ // platform mocks fill the phone the way each app would.
+ platform === "original" ? "object-contain" : "object-cover"
+ )}
autoPlay
loop
muted={muted}
playsInline
onClick={() => setMuted((m) => !m)}
/>
- {/* legibility gradients */}
- <div className="pointer-events-none absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent" />
- <div className="pointer-events-none absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-black/70 via-black/25 to-transparent" />
+ {/* legibility gradients — only under platform chrome */}
+ {platform !== "original" && (
+ <>
+ <div className="pointer-events-none absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent" />
+ <div className="pointer-events-none absolute inset-x-0 bottom-0 h-44 bg-gradient-to-t from-black/70 via-black/25 to-transparent" />
+ </>
+ )}
<button
className="absolute top-3.5 left-3.5 z-20 grid size-7 place-items-center rounded-full bg-black/40 text-white"
diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsx
index 7340aa2f..bb31043b 100644
--- a/site/src/cut/components/SidePanel.tsx
+++ b/site/src/cut/components/SidePanel.tsx
@@ -1,7 +1,7 @@
"use client";
import { useEffect, useRef, useState } from "react";
-import { Captions, Check, Circle, ClipboardList, Copy, Film, FolderOpen, FolderPlus, Loader2, Mic, Music, Play, Plus, Trash2, Upload, Video } from "lucide-react";
+import { Captions, Check, Circle, ClipboardList, Copy, Film, FolderOpen, FolderPlus, Loader2, Mic, Music, Plus, Trash2, Upload, Video } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
AlertDialog,
@@ -21,6 +21,7 @@ import {
} from "@/components/ui/dropdown-menu";
import { apiFetch, apiUrl } from "@/cut/lib/api";
import { clearAssetDrag, setAssetDragData } from "@/cut/lib/assetDrag";
+import { deleteExport, revealExport } from "@/cut/lib/exportClient";
import {
addLibraryAssetToProject,
deleteFromLibrary,
@@ -160,6 +161,7 @@ function MediaPanel({
const inputRef = useRef<HTMLInputElement>(null);
const [exports, setExports] = useState<ExportItem[]>([]);
const [preview, setPreview] = useState<ExportItem | null>(null);
+ const [deletingExport, setDeletingExport] = useState<ExportItem | null>(null);
// Refresh the list on open and every time the export dialog closes.
useEffect(() => {
@@ -174,6 +176,19 @@ function MediaPanel({
};
}, [projectId, exportOpen]);
+ const removeExport = async () => {
+ const it = deletingExport;
+ if (!it) return;
+ setDeletingExport(null);
+ try {
+ await deleteExport(projectId, it.file);
+ setExports((prev) => prev.filter((e) => e.file !== it.file));
+ if (preview?.file === it.file) setPreview(null);
+ } catch {
+ // Leave the list as-is on failure; it mirrors what's on disk.
+ }
+ };
+
return (
<>
<PanelHead title="Media" />
@@ -219,41 +234,62 @@ function MediaPanel({
{exports.length > 0 && (
<div className="mt-5 px-3.5">
- <div className="mb-2 text-[11px] font-semibold tracking-wider text-muted-foreground uppercase">
- Exports
- </div>
+ <div className="mb-2 text-[13px] font-semibold tracking-tight">Exports</div>
<div className="flex flex-col gap-1.5">
{exports.map((it) => (
- <button
+ <div
key={it.file}
- className="export-row flex w-full items-center gap-2.5 rounded-lg border border-border p-1.5 text-left transition-colors hover:border-input hover:bg-muted/50"
- title="Preview as a post"
- onClick={() => setPreview(it)}
+ className="export-row group flex w-full items-center gap-2.5 rounded-lg border border-border p-1.5 transition-colors hover:border-input hover:bg-muted/50"
>
- <video
- muted
- playsInline
- preload="metadata"
- src={`${apiUrl(`/api/cut/projects/${projectId}/exports/${encodeURIComponent(it.file)}`)}#t=0.1`}
- className="h-11 w-[25px] shrink-0 rounded-[4px] bg-black object-cover"
- />
- <span className="min-w-0 flex-1">
- <span className="block truncate text-[11.5px] font-medium">
- {new Date(it.mtime).toLocaleString([], {
- month: "short",
- day: "numeric",
- hour: "numeric",
- minute: "2-digit",
- })}
- </span>
- <span className="block text-[10.5px] text-muted-foreground">
- {(it.size / (1024 * 1024)).toFixed(1)} MB · MP4
+ <button
+ type="button"
+ className="flex min-w-0 flex-1 items-center gap-2.5 text-left"
+ title="Preview as a post"
+ onClick={() => setPreview(it)}
+ >
+ <video
+ muted
+ playsInline
+ preload="metadata"
+ src={`${apiUrl(`/api/cut/projects/${projectId}/exports/${encodeURIComponent(it.file)}`)}#t=0.1`}
+ className="h-11 w-[25px] shrink-0 rounded-[4px] bg-black object-cover"
+ />
+ <span className="min-w-0 flex-1">
+ <span className="block truncate text-[11.5px] font-medium">
+ {new Date(it.mtime).toLocaleString([], {
+ month: "short",
+ day: "numeric",
+ hour: "numeric",
+ minute: "2-digit",
+ })}
+ </span>
+ <span className="block text-[10.5px] text-muted-foreground">
+ {(it.size / (1024 * 1024)).toFixed(1)} MB · MP4
+ </span>
</span>
- </span>
- <span className="mr-1 flex items-center gap-1 rounded-md bg-muted px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground">
- <Play className="size-2.5" /> Play
- </span>
- </button>
+ </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>
+ <Button
+ variant="ghost"
+ size="icon-xs"
+ aria-label="Delete export"
+ title="Delete export"
+ className="text-muted-foreground hover:text-destructive"
+ onClick={() => setDeletingExport(it)}
+ >
+ <Trash2 />
+ </Button>
+ </div>
+ </div>
))}
</div>
</div>
@@ -266,6 +302,30 @@ function MediaPanel({
onClose={() => setPreview(null)}
/>
)}
+
+ <AlertDialog open={!!deletingExport} onOpenChange={(o) => !o && setDeletingExport(null)}>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Delete this export?</AlertDialogTitle>
+ <AlertDialogDescription>
+ The rendered file leaves the project’s exports folder. Your cut is untouched — you
+ can export it again anytime.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ className="bg-destructive/10 text-destructive hover:bg-destructive/20"
+ onClick={(e) => {
+ e.preventDefault();
+ void removeExport();
+ }}
+ >
+ Delete
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</>
);
}
diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.ts
index cef42113..de3cd037 100644
--- a/site/src/cut/server/ai/catalog.ts
+++ b/site/src/cut/server/ai/catalog.ts
@@ -279,7 +279,7 @@ Caption style is fixed: bold white SF, translucent plate, bottom-center (y≈0.8
"publish-and-export": `# Publish & export
Publish tab fields (set_publish): caption (TikTok limit 4,000 chars INCLUDING tags/emoji; hook in the first line), tags (3–5 focused tags recommended; stored space-separated, rendered as #tags), soundTitle (TikTok lets you rename the sound once after posting), handle (shown as @handle in platform previews).
-Export (open_export): presets Best 1080p CRF19, Quick share 1080p, Draft 720p — H.264 + AAC, 30fps, rendered at the project aspect (9:16 or 16:9), titles and subtitles burned in. Files land in the project's exports/ folder and appear in the Media tab's Exports section, where each can be previewed in TikTok/Instagram/YouTube chrome with the publish metadata rendered in place.`,
+Export (open_export): presets Original (matches the sharpest source clip along the aspect, 1080p floor, 4K cap), Best 1080p CRF19, Quick share 1080p, Draft 720p — H.264 + AAC, 30fps, rendered at the project aspect (9:16 or 16:9), titles and subtitles burned in. Files land in the project's exports/ folder and appear in the Media tab's Exports section, where each can be previewed plain or in TikTok/Instagram/YouTube chrome with the publish metadata rendered in place, revealed in Finder, or deleted.`,
};
/** System prompt shared by all providers. */
diff --git a/site/src/cut/server/http/projects.ts b/site/src/cut/server/http/projects.ts
index 891c257c..6ecc2fa2 100644
--- a/site/src/cut/server/http/projects.ts
+++ b/site/src/cut/server/http/projects.ts
@@ -1,7 +1,9 @@
+import { execFile } from "node:child_process";
import type { ProjectDoc } from "@/cut/lib/types";
import { makeFreezeFrame } from "../frames";
import {
createProject,
+ deleteExport,
deleteProject,
exportPath,
listExports,
@@ -13,6 +15,7 @@ import {
} from "../projects";
import { serveFileRange } from "../serveFile";
import { createTranscribeJob, getTranscribeJob, type TranscribeSpec } from "../transcribe";
+import { exists } from "../util";
const err = (message: string, status: number) => Response.json({ error: message }, { status });
const caught = (e: unknown, fallback: string, status = 500) =>
@@ -123,6 +126,35 @@ export const projectsApi = {
return serveFileRange(p, req, { contentType: "video/mp4" });
},
+ /** Reveal a rendered export in Finder (Cut runs on the user's own Mac). */
+ async revealExport(_req: Request, { id, file }: { id: string; file: string }) {
+ let p: string;
+ try {
+ p = exportPath(id, decodeURIComponent(file));
+ } catch {
+ return err("Bad request.", 400);
+ }
+ if (!(await exists(p))) return err("Export not found.", 404);
+ try {
+ await new Promise<void>((resolve, reject) =>
+ execFile("open", ["-R", p], (e) => (e ? reject(e) : resolve()))
+ );
+ return Response.json({ ok: true });
+ } catch (e) {
+ return caught(e, "Could not reveal the file.");
+ }
+ },
+
+ /** Delete a rendered export from the project folder. */
+ async removeExport(_req: Request, { id, file }: { id: string; file: string }) {
+ try {
+ await deleteExport(id, decodeURIComponent(file));
+ return Response.json({ ok: true });
+ } catch (e) {
+ return caught(e, "Could not delete the export.");
+ }
+ },
+
/** Start a background transcription of the current cut. */
async transcribeStart(req: Request, { id }: { id: string }) {
try {
diff --git a/site/src/cut/server/http/routes.ts b/site/src/cut/server/http/routes.ts
index 4ae878d4..d4e46077 100644
--- a/site/src/cut/server/http/routes.ts
+++ b/site/src/cut/server/http/routes.ts
@@ -29,6 +29,8 @@ export const CUT_ROUTES: CutRoute[] = [
{ method: "GET", path: "/api/cut/projects/:id/media/:file", handler: (req, p) => projectsApi.serveMedia(req, { id: p.id, file: p.file }) },
{ method: "GET", path: "/api/cut/projects/:id/exports", handler: (req, p) => projectsApi.listExports(req, { id: p.id }) },
{ method: "GET", path: "/api/cut/projects/:id/exports/:file", handler: (req, p) => projectsApi.serveExport(req, { id: p.id, file: p.file }) },
+ { method: "DELETE", path: "/api/cut/projects/:id/exports/:file", handler: (req, p) => projectsApi.removeExport(req, { id: p.id, file: p.file }) },
+ { method: "POST", path: "/api/cut/projects/:id/exports/:file/reveal", handler: (req, p) => projectsApi.revealExport(req, { id: p.id, file: p.file }) },
{ method: "POST", path: "/api/cut/projects/:id/transcribe", handler: (req, p) => projectsApi.transcribeStart(req, { id: p.id }) },
{ method: "GET", path: "/api/cut/projects/:id/transcribe", handler: (req, p) => projectsApi.transcribePoll(req, { id: p.id }) },
{ method: "POST", path: "/api/cut/projects/:id/freeze", handler: (req, p) => projectsApi.freeze(req, { id: p.id }) },
diff --git a/site/src/cut/server/projects.ts b/site/src/cut/server/projects.ts
index d463868c..33d1d07a 100644
--- a/site/src/cut/server/projects.ts
+++ b/site/src/cut/server/projects.ts
@@ -51,6 +51,11 @@ export async function listExports(id: string) {
.sort((a, b) => b.mtime - a.mtime);
}
+/** Remove one rendered export from the project folder. */
+export async function deleteExport(id: string, fileName: string) {
+ await rm(exportPath(id, fileName), { force: true });
+}
+
const docPath = (id: string) => path.join(projectDir(id), "project.json");
export async function readProject(id: string): Promise<ProjectDoc | null> {