Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

Add link and local publishing with an account-scoped shared library

webadderallc4e354d0df90
diff --git a/.env.example b/.env.example
index 45d02d2a..6125a102 100644
--- a/.env.example
+++ b/.env.example
@@ -1,3 +1,7 @@
# Public client configuration. Never put a Supabase service-role key here.
VITE_SUPABASE_URL=https://YOUR_PROJECT_REF.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_YOUR_KEY
+
+# Leave blank until the hosted recording service is deployed and verified.
+# Development defaults to localhost:8787; packaged builds require an explicit URL.
+VITE_CLOUD_SHARE_ENDPOINT=
diff --git a/electron/electron-env.d.ts b/electron/electron-env.d.ts
index 70e8f5f1..13ec73ab 100644
--- a/electron/electron-env.d.ts
+++ b/electron/electron-env.d.ts
@@ -952,6 +952,23 @@ interface Window {
canceled?: boolean;
error?: string;
}>;
+ cloudShareManage: (input: {
+ endpoint: string;
+ token: string;
+ action: "list" | "delete";
+ shareCode?: string;
+ }) => Promise<{
+ success: boolean;
+ error?: string;
+ videos?: Array<{
+ code: string;
+ createdAt?: string;
+ title: string;
+ size: number;
+ ready: boolean;
+ url: string;
+ }>;
+ }>;
cloudShareCancel: (uploadId: string) => Promise<{ success: boolean }>;
onCloudShareProgress: (
callback: (progress: {
diff --git a/electron/ipc/recording/shareThumbnail.test.ts b/electron/ipc/recording/shareThumbnail.test.ts
new file mode 100644
index 00000000..825809ce
--- /dev/null
+++ b/electron/ipc/recording/shareThumbnail.test.ts
@@ -0,0 +1,68 @@
+import { execFile } from "node:child_process";
+import { mkdtemp, rm } from "node:fs/promises";
+import { tmpdir } from "node:os";
+import path from "node:path";
+import { promisify } from "node:util";
+import { describe, expect, it, vi } from "vitest";
+import ffmpeg from "ffmpeg-static";
+
+vi.mock("../ffmpeg/binary", () => ({ getFfmpegBinaryPath: () => ffmpeg }));
+import { createShareThumbnail } from "./shareThumbnail";
+const run = promisify(execFile);
+
+describe("shared recording preview", () => {
+ it("extracts the first frame, preserving aspect ratio and bounding its size", async () => {
+ const dir = await mkdtemp(path.join(tmpdir(), "recordly-poster-test-"));
+ try {
+ const video = path.join(dir, "red-then-blue.mp4");
+ await run(ffmpeg!, [
+ "-hide_banner",
+ "-loglevel",
+ "error",
+ "-f",
+ "lavfi",
+ "-i",
+ "color=red:s=1280x720:d=0.1:r=30",
+ "-f",
+ "lavfi",
+ "-i",
+ "color=blue:s=1280x720:d=0.1:r=30",
+ "-filter_complex",
+ "[0:v][1:v]concat=n=2:v=1:a=0",
+ "-c:v",
+ "libx264",
+ "-pix_fmt",
+ "yuv420p",
+ video,
+ ]);
+ const poster = await createShareThumbnail(video, new AbortController().signal);
+ expect(poster.subarray(0, 2)).toEqual(Buffer.from([0xff, 0xd8]));
+ const decoded = await new Promise<Buffer>((resolve, reject) => {
+ const child = execFile(
+ ffmpeg!,
+ [
+ "-hide_banner",
+ "-loglevel",
+ "error",
+ "-i",
+ "pipe:0",
+ "-f",
+ "rawvideo",
+ "-pix_fmt",
+ "rgb24",
+ "pipe:1",
+ ],
+ { encoding: "buffer", maxBuffer: 1024 * 1024 },
+ (error, stdout) => (error ? reject(error) : resolve(stdout)),
+ );
+ child.stdin!.end(poster);
+ });
+ expect(decoded.length).toBe(640 * 360 * 3);
+ expect(decoded[0]).toBeGreaterThan(220);
+ expect(decoded[1]).toBeLessThan(30);
+ expect(decoded[2]).toBeLessThan(30);
+ } finally {
+ await rm(dir, { recursive: true, force: true });
+ }
+ }, 20000);
+});
diff --git a/electron/ipc/recording/shareThumbnail.ts b/electron/ipc/recording/shareThumbnail.ts
new file mode 100644
index 00000000..48183fff
--- /dev/null
+++ b/electron/ipc/recording/shareThumbnail.ts
@@ -0,0 +1,37 @@
+import { execFile } from "node:child_process";
+import { promisify } from "node:util";
+import { getFfmpegBinaryPath } from "../ffmpeg/binary";
+
+const run = promisify(execFile);
+
+/** The caller must validate the local export path before decoding it. */
+export async function createShareThumbnail(filePath: string, signal: AbortSignal): Promise<Buffer> {
+ const { stdout } = await run(
+ getFfmpegBinaryPath(),
+ [
+ "-hide_banner",
+ "-loglevel",
+ "error",
+ "-nostdin",
+ "-threads",
+ "1",
+ "-i",
+ filePath,
+ "-frames:v",
+ "1",
+ "-an",
+ "-vf",
+ "scale=640:640:force_original_aspect_ratio=decrease",
+ "-q:v",
+ "4",
+ "-f",
+ "image2pipe",
+ "-c:v",
+ "mjpeg",
+ "pipe:1",
+ ],
+ { encoding: "buffer", maxBuffer: 1024 * 1024, timeout: 15000, windowsHide: true, signal },
+ );
+ if (!stdout.length) throw new Error("Video has no preview frame");
+ return stdout;
+}
diff --git a/electron/ipc/register/cloudShare.test.ts b/electron/ipc/register/cloudShare.test.ts
index bfaa1198..a874b151 100644
--- a/electron/ipc/register/cloudShare.test.ts
+++ b/electron/ipc/register/cloudShare.test.ts
@@ -29,6 +29,14 @@ describe("cloud share contract", () => {
});
it("rejects insecure and untrusted remote endpoints", () => {
+ expect(() =>
+ normalizeCloudEndpoint("https://untrusted.example.test/api/upload"),
+ ).toThrow("only allowed through the Recordly service");
+ expect(() =>
+ normalizeCloudEndpoint(
+ "https://videos.recordly.dev.attacker.example/api/upload",
+ ),
+ ).toThrow("only allowed through the Recordly service");
expect(() => normalizeCloudEndpoint("http://share.example.com/api/shares")).toThrow(
"only allowed through the Recordly service",
);
diff --git a/electron/ipc/register/cloudShare.ts b/electron/ipc/register/cloudShare.ts
index a46afcbf..32c13471 100644
--- a/electron/ipc/register/cloudShare.ts
+++ b/electron/ipc/register/cloudShare.ts
@@ -1,3 +1,4 @@
+import { createShareThumbnail } from "../recording/shareThumbnail";
import { createReadStream } from "node:fs";
import fs from "node:fs/promises";
import path from "node:path";
@@ -249,6 +250,76 @@ async function uploadMultipart(options: {
}
export function registerCloudShareHandlers() {
+ ipcMain.handle(
+ "cloud-share-manage",
+ async (
+ _event,
+ input: { endpoint?: unknown; token?: unknown; action?: unknown; shareCode?: unknown },
+ ) => {
+ try {
+ const endpoint = normalizeCloudEndpoint(input?.endpoint);
+ if (
+ typeof input.token !== "string" ||
+ !input.token ||
+ Buffer.byteLength(input.token) > MAX_AUTH_TOKEN_BYTES
+ )
+ throw new Error("Sign in to manage shared recordings.");
+ if (input.action !== "list" && input.action !== "delete")
+ throw new Error("Invalid recording action.");
+ if (
+ input.action === "delete" &&
+ (typeof input.shareCode !== "string" ||
+ !/^[a-z0-9]{1,128}$/.test(input.shareCode))
+ )
+ throw new Error("Invalid recording ID.");
+ const response = await fetch(
+ new URL(
+ input.action === "list" ? "/api/videos" : `/api/delete/${input.shareCode}`,
+ endpoint,
+ ),
+ {
+ method: input.action === "list" ? "GET" : "DELETE",
+ headers: { authorization: `Bearer ${input.token}` },
+ redirect: "error",
+ signal: AbortSignal.timeout(30000),
+ },
+ );
+ if (!response.ok)
+ throw new Error(
+ await responseError(response, "Could not manage shared recordings"),
+ );
+ if (input.action === "delete") return { success: true };
+ const data = (await readJsonResponse(response)) as { videos?: unknown };
+ if (!Array.isArray(data.videos)) throw new Error("Invalid recordings response.");
+ return {
+ success: true,
+ videos: data.videos.slice(0, 100).map((video: Record<string, unknown>) => {
+ if (
+ typeof video.share_code !== "string" ||
+ !/^[a-z0-9]{1,128}$/.test(video.share_code) ||
+ typeof video.title !== "string"
+ )
+ throw new Error("Invalid recording response.");
+ return {
+ code: video.share_code,
+ title: video.title,
+ size: Number(video.file_size) || 0,
+ createdAt:
+ typeof video.created_at === "string" ? video.created_at : undefined,
+ ready: video.upload_completed === 1,
+ url: new URL(`/s/${video.share_code}`, endpoint).href,
+ };
+ }),
+ };
+ } catch (error) {
+ return {
+ success: false,
+ error: error instanceof Error ? error.message : String(error),
+ };
+ }
+ },
+ );
+
ipcMain.handle(
"cloud-share-upload",
async (
@@ -415,6 +486,37 @@ export function registerCloudShareHandlers() {
);
}
}
+ if (ticket.shareCode) {
+ try {
+ const thumbnail = await createShareThumbnail(
+ resolvedPath,
+ controller.signal,
+ );
+ const response = await fetch(
+ new URL(`/api/upload-thumbnail/${ticket.shareCode}`, endpointOrigin),
+ {
+ method: "PUT",
+ headers: {
+ authorization: `Bearer ${token}`,
+ "content-type": "image/jpeg",
+ "content-length": String(thumbnail.length),
+ },
+ body: new Uint8Array(thumbnail),
+ redirect: "error",
+ signal: controller.signal,
+ },
+ );
+ if (!response.ok)
+ throw new Error(`Thumbnail upload failed (${response.status})`);
+ } catch {
+ // The recording is already published. Older/missing posters use the
+ // video's first frame in the library instead of failing the share.
+ console.warn(
+ "Shared video poster unavailable; using video preview fallback.",
+ );
+ }
+ }
+
return { success: true, uploadId, shareUrl: ticket.shareUrl };
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
diff --git a/electron/preload.ts b/electron/preload.ts
index 468ef2e9..2ef032e0 100644
--- a/electron/preload.ts
+++ b/electron/preload.ts
@@ -1022,6 +1022,12 @@ contextBridge.exposeInMainWorld("electronAPI", {
notes?: string;
uploadId?: string;
}) => ipcRenderer.invoke("cloud-share-upload", input),
+ cloudShareManage: (input: {
+ endpoint: string;
+ token: string;
+ action: "list" | "delete";
+ shareCode?: string;
+ }) => ipcRenderer.invoke("cloud-share-manage", input),
cloudShareCancel: (uploadId: string) => ipcRenderer.invoke("cloud-share-cancel", uploadId),
onCloudShareProgress: (
callback: (progress: {
diff --git a/src/components/video-editor/ExportSettingsMenu.tsx b/src/components/video-editor/ExportSettingsMenu.tsx
index 3c4fc65f..de569507 100644
--- a/src/components/video-editor/ExportSettingsMenu.tsx
+++ b/src/components/video-editor/ExportSettingsMenu.tsx
@@ -41,6 +41,9 @@ interface ExportSettingsMenuProps {
gifOutputDimensions: { width: number; height: number };
onExport?: () => void;
className?: string;
+ hideHeading?: boolean;
+ hideAction?: boolean;
+ linkMode?: boolean;
}
function Choices<T extends string | number>({
@@ -119,43 +122,50 @@ export function ExportSettingsMenu({
gifOutputDimensions,
onExport,
className,
+ hideHeading = false,
+ hideAction = false,
+ linkMode = false,
}: ExportSettingsMenuProps) {
const tSettings = useScopedT("settings");
const isLegacyModel = exportPipelineModel === "legacy";
return (
<Card className={className}>
- <Card.Header>
- <Card.Title>{tSettings("export.title", "Export")}</Card.Title>
- </Card.Header>
+ {!hideHeading && (
+ <Card.Header>
+ <Card.Title>{tSettings("export.title", "Export")}</Card.Title>
+ </Card.Header>
+ )}
<Card.Content className="gap-4">
- <Choices
- label={tSettings("export.format", "Format")}
- value={exportFormat}
- onChange={onExportFormatChange}
- options={[
- {
- value: "mp4",
- textValue: tSettings("export.mp4"),
- label: (
- <span className="flex items-center gap-2">
- <Film />
- {tSettings("export.mp4")}
- </span>
- ),
- },
- {
- value: "gif",
- textValue: tSettings("export.gif"),
- label: (
- <span className="flex items-center gap-2">
- <Image />
- {tSettings("export.gif")}
- </span>
- ),
- },
- ]}
- />
+ {!linkMode && (
+ <Choices
+ label={tSettings("export.format", "Format")}
+ value={exportFormat}
+ onChange={onExportFormatChange}
+ options={[
+ {
+ value: "mp4",
+ textValue: tSettings("export.mp4"),
+ label: (
+ <span className="flex items-center gap-2">
+ <Film />
+ {tSettings("export.mp4")}
+ </span>
+ ),
+ },
+ {
+ value: "gif",
+ textValue: tSettings("export.gif"),
+ label: (
+ <span className="flex items-center gap-2">
+ <Image />
+ {tSettings("export.gif")}
+ </span>
+ ),
+ },
+ ]}
+ />
+ )}
{exportFormat === "mp4" ? (
<>
<Choices
@@ -256,14 +266,16 @@ export function ExportSettingsMenu({
</>
)}
</Card.Content>
- <Card.Footer>
- <Button size="lg" onClick={onExport} className="w-full">
- <Download />
- {tSettings("export.exportVideo", undefined, {
- format: exportFormat === "gif" ? "GIF" : "Video",
- })}
- </Button>
- </Card.Footer>
+ {!hideAction && (
+ <Card.Footer>
+ <Button size="lg" onClick={onExport} className="w-full">
+ <Download />
+ {tSettings("export.exportVideo", undefined, {
+ format: exportFormat === "gif" ? "GIF" : "Video",
+ })}
+ </Button>
+ </Card.Footer>
+ )}
</Card>
);
}
diff --git a/src/components/video-editor/cloud/CloudShareButton.tsx b/src/components/video-editor/cloud/CloudShareButton.tsx
index abe52a00..c44f1d1b 100644
--- a/src/components/video-editor/cloud/CloudShareButton.tsx
+++ b/src/components/video-editor/cloud/CloudShareButton.tsx
@@ -1,6 +1,8 @@
+import { checkShareCapacity, RECORDING_LIMIT_MESSAGE } from "./shareCapacity";
+import { SharedRecordings } from "./SharedRecordings";
import { saveProjectShareLink } from "./projectShareLinks";
import { useI18n } from "@/contexts/I18nContext";
-import { Check, CloudArrowUp, Copy, ShareNetwork } from "@/components/ui/icons";
+import { Check } from "@/components/ui/icons";
import { useCallback, useEffect, useRef, useState } from "react";
import { toast } from "@/components/ui/toast";
import { Button } from "@/components/ui/button";
@@ -11,21 +13,25 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
-import { Input } from "@/components/ui/input";
+import { Export, LinkSimple } from "@phosphor-icons/react";
import { Label } from "@/components/ui/label";
-const DEFAULT_CLOUD_ENDPOINT = "http://localhost:8787/api/upload";
+import { CLOUD_SHARE_ENDPOINT as DEFAULT_CLOUD_ENDPOINT } from "./endpoint";
type Props = {
- projectPath?: string | null;
+ projectPath?: string | null;
filePath?: string;
projectTitle: string;
prepareFile?: () => Promise<string | undefined>;
+ preparationProgress?: number;
onCancelPrepare?: () => void;
open?: boolean;
onOpenChange?: (open: boolean) => void;
hideTrigger?: boolean;
authToken?: string;
+ inline?: boolean;
+ onBusyChange?: (busy: boolean) => void;
+ onRequestSignIn?: () => void;
};
export function CloudShareButton({
@@ -33,11 +39,15 @@ export function CloudShareButton({
filePath,
projectTitle,
prepareFile,
+ preparationProgress = 0,
onCancelPrepare,
open: controlledOpen,
onOpenChange,
hideTrigger = false,
authToken,
+ inline = false,
+ onBusyChange,
+ onRequestSignIn,
}: Props) {
const { t } = useI18n();
const [internalOpen, setInternalOpen] = useState(false);
@@ -52,6 +62,29 @@ export function CloudShareButton({
const [uploadId, setUploadId] = useState<string>();
const [progress, setProgress] = useState(0);
const [uploading, setUploading] = useState(false);
+ const [capacityAvailable, setCapacityAvailable] = useState<boolean | null>(null);
+ const [checkingCapacity, setCheckingCapacity] = useState(false);
+ useEffect(() => {
+ if (!authToken || !DEFAULT_CLOUD_ENDPOINT) return;
+ let active = true;
+ setCheckingCapacity(true);
+ void checkShareCapacity(DEFAULT_CLOUD_ENDPOINT, authToken)
+ .then((available) => {
+ if (active) setCapacityAvailable(available);
+ })
+ .catch(() => {
+ if (active) setCapacityAvailable(null);
+ })
+ .finally(() => {
+ if (active) setCheckingCapacity(false);
+ });
+ return () => {
+ active = false;
+ };
+ }, [authToken]);
+ useEffect(() => {
+ onBusyChange?.(uploading);
+ }, [uploading, onBusyChange]);
const [phase, setPhase] = useState<"idle" | "preparing" | "uploading">("idle");
const [error, setError] = useState<string>();
const [shareUrl, setShareUrl] = useState<string>();
@@ -59,6 +92,14 @@ export function CloudShareButton({
const [notes, setNotes] = useState("");
const preparedFileRef = useRef<string | undefined>(undefined);
const cancelRequestedRef = useRef(false);
+ const activeUploadId = useRef<string | undefined>(undefined);
+ useEffect(() => {
+ if (phase === "preparing" && Number.isFinite(preparationProgress)) {
+ setProgress((current) =>
+ Math.max(current, Math.min(70, Math.round(preparationProgress * 0.7))),
+ );
+ }
+ }, [phase, preparationProgress]);
const discardPreparedFile = useCallback(() => {
const preparedPath = preparedFileRef.current;
@@ -70,11 +111,13 @@ export function CloudShareButton({
useEffect(() => {
return window.electronAPI.onCloudShareProgress((next) => {
- setUploadId(next.uploadId);
- setProgress(
- next.totalBytes > 0
- ? Math.min(100, Math.round((next.uploadedBytes / next.totalBytes) * 100))
- : 0,
+ if (next.uploadId !== activeUploadId.current) return;
+ if (next.totalBytes <= 0 || !Number.isFinite(next.uploadedBytes)) return;
+ setProgress((current) =>
+ Math.max(
+ current,
+ Math.min(99, 70 + Math.round((next.uploadedBytes / next.totalBytes) * 29)),
+ ),
);
});
}, []);
@@ -96,12 +139,19 @@ export function CloudShareButton({
const handleUpload = useCallback(async () => {
setUploading(true);
setProgress(0);
- setPhase("preparing");
+ setPhase("idle");
cancelRequestedRef.current = false;
setError(undefined);
setShareUrl(undefined);
try {
+ if (!DEFAULT_CLOUD_ENDPOINT)
+ throw new Error("Cloud sharing is not available in this build yet.");
if (!authToken) throw new Error(t("editor.cloud.signInRequired"));
+ const available = await checkShareCapacity(DEFAULT_CLOUD_ENDPOINT, authToken);
+ setCapacityAvailable(available);
+ if (!available) throw new Error(RECORDING_LIMIT_MESSAGE);
+ if (cancelRequestedRef.current) return;
+ setPhase("preparing");
let resolvedFilePath = filePath ?? preparedFileRef.current;
if (!resolvedFilePath) {
resolvedFilePath = await prepareFile?.();
@@ -115,6 +165,8 @@ export function CloudShareButton({
}
const nextUploadId = crypto.randomUUID();
setUploadId(nextUploadId);
+ activeUploadId.current = nextUploadId;
+ setProgress(70);
setPhase("uploading");
const result = await window.electronAPI.cloudShareUpload({
filePath: resolvedFilePath,
@@ -130,7 +182,13 @@ export function CloudShareButton({
}
setProgress(100);
setShareUrl(result.shareUrl);
- if (projectPath) { try { saveProjectShareLink(projectPath, result.shareUrl); } catch { toast.error("Share created, but its link could not be saved locally"); } }
+ if (projectPath) {
+ try {
+ saveProjectShareLink(projectPath, result.shareUrl);
+ } catch {
+ toast.error("Share created, but its link could not be saved locally");
+ }
+ }
toast.success(t("editor.cloud.linkCreated"));
} catch (cause) {
setError(cause instanceof Error ? cause.message : String(cause));
@@ -138,6 +196,7 @@ export function CloudShareButton({
setUploading(false);
setPhase("idle");
setUploadId(undefined);
+ activeUploadId.current = undefined;
}
}, [projectPath, authToken, filePath, notes, prepareFile, projectTitle, t]);
@@ -159,6 +218,83 @@ export function CloudShareButton({
}
}, [shareUrl, t]);
+ const form = (
+ <>
+ {shareUrl ? (
+ <Button type="button" size="lg" onClick={copyShareUrl} className="w-full">
+ {copied ? <Check className="h-4 w-4" /> : <LinkSimple className="h-4 w-4" />}
+ {copied ? t("editor.cloud.copied") : "Copy link"}
+ </Button>
+ ) : (
+ <div className="space-y-4">
+ {!uploading && (
+ <div className="space-y-2">
+ <Label htmlFor="cloud-share-notes">{t("editor.cloud.notes")}</Label>
+ <textarea
+ id="cloud-share-notes"
+ placeholder={t("editor.cloud.notesPlaceholder")}
+ value={notes}
+ onChange={(event) => setNotes(event.target.value.slice(0, 2000))}
+ disabled={uploading}
+ className="block h-20 w-full resize-none rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring"
+ />
+ {!inline && (
+ <p className="text-right text-[11px] text-muted-foreground">
+ {notes.length}/2000
+ </p>
+ )}
+ </div>
+ )}
+ {uploading ? (
+ <div className="space-y-2">
+ <div className="h-2 overflow-hidden rounded-full bg-foreground/10">
+ <div
+ className="h-full bg-[#2563EB] transition-all"
+ style={{ width: `${progress}%` }}
+ />
+ </div>
+ <p className="text-xs text-muted-foreground">Uploading · {progress}%</p>
+ </div>
+ ) : null}
+ {error || capacityAvailable === false ? (
+ <p className="text-sm text-destructive">
+ {error || RECORDING_LIMIT_MESSAGE}
+ </p>
+ ) : null}
+ <div className="flex justify-end gap-2">
+ {uploading ? (
+ <Button
+ type="button"
+ variant="outline"
+ onClick={() => void handleCancel()}
+ >
+ {t("common.actions.cancel")}
+ </Button>
+ ) : (
+ <Button
+ type="button"
+ size="lg"
+ className="w-full"
+ disabled={
+ Boolean(authToken) &&
+ (checkingCapacity || capacityAvailable === false)
+ }
+ onClick={() => {
+ if (!authToken && onRequestSignIn) onRequestSignIn();
+ else void handleUpload();
+ }}
+ >
+ <Export className="h-4 w-4" />
+ {authToken ? "Share" : "Sign in to share"}
+ </Button>
+ )}
+ </div>
+ </div>
+ )}
+ </>
+ );
+ if (inline) return <div>{form}</div>;
+
return (
<>
{hideTrigger ? null : (
@@ -170,7 +306,7 @@ export function CloudShareButton({
className="inline-flex h-11 flex-1 items-center justify-center gap-2 rounded-lg border-foreground/10 bg-foreground/5 px-3 text-foreground hover:bg-foreground/10 disabled:opacity-40"
title={t("editor.cloud.createLinkTitle")}
>
- <ShareNetwork className="h-4 w-4" />
+ <Export className="h-4 w-4" />
<span className="text-sm font-semibold tracking-tight">
{t("editor.cloud.createLink")}
</span>
@@ -181,86 +317,20 @@ export function CloudShareButton({
<DialogHeader>
<DialogTitle>{t("editor.cloud.heading")}</DialogTitle>
<DialogDescription>{t("editor.cloud.description")}</DialogDescription>
+ <p className="text-xs text-muted-foreground">
+ Free-plan links expire after 14 days.
+ </p>
</DialogHeader>
- {shareUrl ? (
- <div className="space-y-4">
- <div className="flex items-center gap-2 rounded-lg border border-emerald-500/20 bg-emerald-500/10 p-3 text-sm text-emerald-400">
- <Check className="h-5 w-5 shrink-0" />
- {t("editor.cloud.ready")}
- </div>
- <div className="flex gap-2">
- <Input value={shareUrl} readOnly className="min-w-0" />
- <Button type="button" onClick={copyShareUrl} className="shrink-0">
- {copied ? (
- <Check className="h-4 w-4" />
- ) : (
- <Copy className="h-4 w-4" />
- )}
- {copied ? t("editor.cloud.copied") : t("editor.cloud.copy")}
- </Button>
- </div>
- <Button
- type="button"
- variant="outline"
- onClick={() => void window.electronAPI.openExternalUrl(shareUrl)}
- className="w-full"
- >
- {t("editor.cloud.openPage")}
- </Button>
- </div>
- ) : (
- <div className="space-y-4">
- <div className="space-y-2">
- <Label htmlFor="cloud-share-notes">{t("editor.cloud.notes")}</Label>
- <textarea
- id="cloud-share-notes"
- placeholder={t("editor.cloud.notesPlaceholder")}
- value={notes}
- onChange={(event) =>
- setNotes(event.target.value.slice(0, 2000))
- }
- disabled={uploading}
- className="min-h-24 w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring"
- />
- <p className="text-right text-[11px] text-muted-foreground">
- {notes.length}/2000
- </p>
- </div>
- {uploading ? (
- <div className="space-y-2">
- <div className="h-2 overflow-hidden rounded-full bg-foreground/10">
- <div
- className="h-full bg-[#2563EB] transition-all"
- style={{ width: `${progress}%` }}
- />
- </div>
- <p className="text-xs text-muted-foreground">
- {phase === "preparing"
- ? t("editor.cloud.preparing")
- : t("editor.cloud.uploading", undefined, { progress })}
- </p>
- </div>
- ) : null}
- {error ? <p className="text-sm text-destructive">{error}</p> : null}
- <div className="flex justify-end gap-2">
- {uploading ? (
- <Button
- type="button"
- variant="outline"
- onClick={() => void handleCancel()}
- >
- {t("common.actions.cancel")}
- </Button>
- ) : (
- <Button type="button" onClick={() => void handleUpload()}>
- <CloudArrowUp className="h-4 w-4" />
- {t("editor.cloud.publish")}
- </Button>
- )}
- </div>
- </div>
+ {!uploading && authToken && DEFAULT_CLOUD_ENDPOINT && (
+ <SharedRecordings
+ token={authToken}
+ endpoint={DEFAULT_CLOUD_ENDPOINT}
+ refreshKey={shareUrl}
+ />
)}
+
+ {form}
</DialogContent>
</Dialog>
</>
diff --git a/src/components/video-editor/cloud/SharedRecordings.tsx b/src/components/video-editor/cloud/SharedRecordings.tsx
new file mode 100644
index 00000000..27d1e1e8
--- /dev/null
+++ b/src/components/video-editor/cloud/SharedRecordings.tsx
@@ -0,0 +1,317 @@
+import { LibrarySkeleton } from "../dashboard/LibrarySkeleton";
+import { ProjectCard } from "../dashboard/ProjectCard";
+import { DashboardToolbar } from "../dashboard/DashboardToolbar";
+import { DashboardFilters } from "../dashboard/DashboardFilters";
+import { DashboardAnnouncements } from "../dashboard/DashboardAnnouncements";
+import { Fragment, useCallback, useEffect, useRef, useState } from "react";
+import { Alert, Button } from "@heroui/react";
+import { ArrowClockwise, ArrowSquareOut, Trash } from "@/components/ui/icons";
+
+type Recording = {
+ code: string;
+ title: string;
+ size: number;
+ ready: boolean;
+ url: string;
+ createdAt?: string;
+};
+
+export function SharedRecordings({
+ token,
+ endpoint,
+ refreshKey,
+ standalone = false,
+ accountLabel,
+}: {
+ token: string;
+ endpoint: string;
+ refreshKey?: string;
+ standalone?: boolean;
+ accountLabel?: string;
+}) {
+ const [query, setQuery] = useState("");
+ const [period, setPeriod] = useState("all");
+ const [sort, setSort] = useState("recent");
+ const [selected, setSelected] = useState<string[]>([]);
+ const [selecting, setSelecting] = useState(false);
+ const [expanded, setExpanded] = useState(standalone);
+ const [recordings, setRecordings] = useState<Recording[]>([]);
+ const [loading, setLoading] = useState(false);
+ const [deleting, setDeleting] = useState<string>();
+ const [error, setError] = useState<string>();
+ const loadGeneration = useRef(0);
+ const load = useCallback(async () => {
+ const generation = ++loadGeneration.current;
+ setLoading(true);
+ setRecordings([]);
+ setError(undefined);
+ try {
+ const result = await window.electronAPI.cloudShareManage({
+ token,
+ endpoint,
+ action: "list",
+ });
+ if (generation !== loadGeneration.current) return;
+ if (!result.success)
+ throw new Error(result.error || "Could not load shared recordings.");
+ setRecordings(result.videos || []);
+ } catch (cause) {
+ if (generation === loadGeneration.current)
+ setError(cause instanceof Error ? cause.message : String(cause));
+ } finally {
+ if (generation === loadGeneration.current) setLoading(false);
+ }
+ }, [token, endpoint]);
+ // biome-ignore lint/correctness/useExhaustiveDependencies: A new share URL must refresh this library.
+ useEffect(() => {
+ if (expanded) void load();
+ return () => { loadGeneration.current += 1; };
+ }, [expanded, load, refreshKey]);
+ const remove = async (code: string) => {
+ setDeleting(code);
+ setError(undefined);
+ try {
+ const result = await window.electronAPI.cloudShareManage({
+ token,
+ endpoint,
+ action: "delete",
+ shareCode: code,
+ });
+ if (!result.success) throw new Error(result.error || "Could not delete recording.");
+ setRecordings((current) => current.filter((recording) => recording.code !== code));
+ } catch (cause) {
+ setError(cause instanceof Error ? cause.message : String(cause));
+ } finally {
+ setDeleting(undefined);
+ }
+ };
+ if (standalone) {
+ const entries = recordings
+ .map((recording) => ({
+ path: recording.code,
+ name: recording.title,
+ updatedAt: recording.createdAt
+ ? Date.parse(
+ recording.createdAt.includes("T")
+ ? recording.createdAt
+ : recording.createdAt.replace(" ", "T") + "Z",
+ )
+ : 0,
+ thumbnailPath: recording.ready
+ ? new URL(`/thumb/${recording.code}`, endpoint).href
+ : null,
+ isCurrent: false,
+ isInProjectsDirectory: false,
+ recording,
+ }))
+ .filter(
+ (entry) =>
+ entry.name.toLowerCase().includes(query.toLowerCase()) &&
+ (period === "all" ||
+ entry.updatedAt >= Date.now() - (period === "week" ? 7 : 30) * 86400000),
+ )
+ .sort((a, b) =>
+ sort === "name" ? a.name.localeCompare(b.name) : b.updatedAt - a.updatedAt,
+ );
+ const run = async (action: () => Promise<unknown>) => {
+ try {
+ await action();
+ } catch (cause) {
+ setError(cause instanceof Error ? cause.message : String(cause));
+ }
+ };
+ return (
+ <div className="-mx-7 lg:-mx-10">
+ <DashboardAnnouncements />
+ <DashboardToolbar
+ query={query}
+ setQuery={setQuery}
+ isRaw={false}
+ onImportFile={load}
+ run={run}
+ busy={loading || Boolean(deleting)}
+ actionLabel="Refresh"
+ />
+ <DashboardFilters
+ hideSelection
+ isRaw={false}
+ period={period}
+ setPeriod={setPeriod}
+ sort={sort}
+ setSort={setSort}
+ selecting={selecting}
+ setSelecting={setSelecting}
+ selected={selected}
+ setSelected={setSelected}
+ visible={entries}
+ busy={loading || Boolean(deleting)}
+ deleteEntries={async () => undefined}
+ />
+ <div className="px-7 lg:px-10">
+ {error && (
+ <p role="alert" className="mb-4 text-sm text-danger">
+ {error}
+ </p>
+ )}
+ {loading ? (
+ <LibrarySkeleton />
+ ) : entries.length ? (
+ <ul
+ aria-label="Shared projects"
+ className="grid grid-cols-[repeat(auto-fill,minmax(min(100%,280px),1fr))] gap-x-7 gap-y-10 lg:gap-x-9"
+ >
+ {entries.map((entry) => (
+ <Fragment key={entry.path}>
+ <ProjectCard
+ entry={entry}
+ webUrl={entry.recording.url}
+ webReady={entry.recording.ready}
+ accountLabel={accountLabel}
+ busy={Boolean(deleting)}
+ selecting={false}
+ selected={[]}
+ toggleSelected={() => undefined}
+ openEntry={() =>
+ void run(async () => {
+ const result =
+ await window.electronAPI.openExternalUrl(
+ entry.recording.url,
+ );
+ if (!result.success)
+ throw new Error(
+ result.error || "Could not open link.",
+ );
+ })
+ }
+ run={run}
+ onShareProject={async () => undefined}
+ onRenameProject={async (path) => path}
+ folders={[]}
+ save={() => undefined}
+ assignFolder={() => undefined}
+ onDelete={() => void remove(entry.path)}
+ />
+ </Fragment>
+ ))}
+ </ul>
+ ) : (
+ <div className="flex h-64 flex-col items-center justify-center gap-3 text-sm text-muted-foreground">
+ <span aria-hidden="true" className="text-4xl">
+ 🦗
+ </span>
+ <p>
+ {query || period !== "all"
+ ? "No matching projects"
+ : "It's looking empty in here..."}
+ </p>
+ </div>
+ )}
+ </div>
+ </div>
+ );
+ }
+
+ return (
+ <section className="space-y-3 border-b border-foreground/10 pb-4">
+ <div className="flex items-center justify-between gap-2">
+ {standalone ? (
+ <h2 className="text-lg font-semibold">Shared recordings</h2>
+ ) : (
+ <Button
+ variant="ghost"
+ size="sm"
+ onPress={() => setExpanded((value) => !value)}
+ aria-expanded={expanded}
+ >
+ {expanded ? "Hide shared recordings" : "Manage shared recordings"}
+ </Button>
+ )}
+ {expanded && (
+ <Button
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ aria-label="Refresh recordings"
+ isDisabled={loading || Boolean(deleting)}
+ onPress={() => void load()}
+ >
+ <ArrowClockwise className="size-4" />
+ </Button>
+ )}
+ </div>
+ {expanded && (
+ <>
+ <p className="text-xs text-muted">
+ {loading
+ ? "Loading recordings…"
+ : `${recordings.length} of 5 recordings · 1 GB each · Free links expire after 14 days`}
+ </p>
+ {loading ? (
+ <LibrarySkeleton />
+ ) : (
+ <ul
+ className={
+ standalone ? "space-y-2" : "max-h-64 space-y-2 overflow-y-auto"
+ }
+ >
+ {recordings.map((recording) => (
+ <li
+ key={recording.code}
+ className="rounded-lg border border-foreground/10 p-3"
+ >
+ <div className="flex items-center gap-3">
+ <div className="min-w-0 flex-1">
+ <p className="truncate text-sm font-medium">
+ {recording.title}
+ </p>
+ <p className="text-xs text-muted">
+ {(recording.size / 1024 / 1024).toFixed(1)} MB
+ {!recording.ready && " · Incomplete upload"}
+ </p>
+ </div>
+ {recording.ready && (
+ <Button
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ aria-label={`Open ${recording.title}`}
+ onPress={() =>
+ void window.electronAPI.openExternalUrl(
+ recording.url,
+ )
+ }
+ >
+ <ArrowSquareOut className="size-4" />
+ </Button>
+ )}
+ <Button
+ variant="ghost"
+ size="sm"
+ isIconOnly
+ aria-label={`Delete ${recording.title}`}
+ isDisabled={Boolean(deleting)}
+ className="text-danger"
+ onPress={() => void remove(recording.code)}
+ >
+ <Trash className="size-4" />
+ </Button>
+ </div>
+ </li>
+ ))}
+ {!recordings.length && !error && (
+ <li className="text-sm text-muted">No shared recordings yet.</li>
+ )}
+ </ul>
+ )}
+ {error && (
+ <Alert status="danger">
+ <Alert.Content>
+ <Alert.Description>{error}</Alert.Description>
+ </Alert.Content>
+ </Alert>
+ )}
+ </>
+ )}
+ </section>
+ );
+}
diff --git a/src/components/video-editor/cloud/endpoint.ts b/src/components/video-editor/cloud/endpoint.ts
new file mode 100644
index 00000000..d8f419ba
--- /dev/null
+++ b/src/components/video-editor/cloud/endpoint.ts
@@ -0,0 +1,3 @@
+export const CLOUD_SHARE_ENDPOINT =
+ import.meta.env.VITE_CLOUD_SHARE_ENDPOINT?.trim() ||
+ (import.meta.env.DEV ? "http://localhost:8787/api/upload" : "");
diff --git a/src/components/video-editor/cloud/shareCapacity.test.ts b/src/components/video-editor/cloud/shareCapacity.test.ts
new file mode 100644
index 00000000..e31b836c
--- /dev/null
+++ b/src/components/video-editor/cloud/shareCapacity.test.ts
@@ -0,0 +1,31 @@
+import { afterEach, expect, it, vi } from "vitest";
+import { checkShareCapacity } from "./shareCapacity";
+afterEach(() => vi.unstubAllGlobals());
+function mockList(result: unknown) {
+ const manage = vi.fn().mockResolvedValue(result);
+ vi.stubGlobal("window", { electronAPI: { cloudShareManage: manage } });
+ return manage;
+}
+it("blocks five recordings, including incomplete uploads", async () => {
+ mockList({ success: true, videos: Array.from({ length: 5 }, (_, i) => ({ ready: i < 4 })) });
+ expect(await checkShareCapacity("https://example.test/api/upload", "token")).toBe(false);
+});
+it("allows another share after a slot is freed", async () => {
+ const manage = mockList({ success: true, videos: Array(4).fill({ ready: true }) });
+ expect(await checkShareCapacity("https://example.test/api/upload", "token")).toBe(true);
+ expect(manage).toHaveBeenCalledWith({
+ endpoint: "https://example.test/api/upload",
+ token: "token",
+ action: "list",
+ });
+});
+it("fails closed when the server cannot verify capacity", async () => {
+ mockList({ success: false, error: "Offline" });
+ await expect(checkShareCapacity("https://example.test/api/upload", "token")).rejects.toThrow(
+ "Offline",
+ );
+ mockList({ success: true });
+ await expect(checkShareCapacity("https://example.test/api/upload", "token")).rejects.toThrow(
+ "Could not check",
+ );
+});
diff --git a/src/components/video-editor/cloud/shareCapacity.ts b/src/components/video-editor/cloud/shareCapacity.ts
new file mode 100644
index 00000000..03bfdb4d
--- /dev/null
+++ b/src/components/video-editor/cloud/shareCapacity.ts
@@ -0,0 +1,12 @@
+export const FREE_RECORDING_LIMIT = 5;
+export const RECORDING_LIMIT_MESSAGE =
+ "You have 5 cloud recordings. Delete one from Shared before sharing another.";
+
+export async function checkShareCapacity(endpoint: string, token: string): Promise<boolean> {
+ const result = await window.electronAPI.cloudShareManage({ endpoint, token, action: "list" });
+ if (!result.success || !Array.isArray(result.videos)) {
+ throw new Error(result.error || "Could not check cloud storage. Try again.");
+ }
+ // Pending uploads occupy slots too, matching the backend's atomic quota check.
+ return result.videos.length < FREE_RECORDING_LIMIT;
+}
diff --git a/src/components/video-editor/dashboard/DashboardFilters.tsx b/src/components/video-editor/dashboard/DashboardFilters.tsx
index 00efd102..0da8fa85 100644
--- a/src/components/video-editor/dashboard/DashboardFilters.tsx
+++ b/src/components/video-editor/dashboard/DashboardFilters.tsx
@@ -19,6 +19,7 @@ export function DashboardFilters({
visible,
busy,
deleteEntries,
+ hideSelection = false,
}: Pick<
DashboardModel & DashboardProps,
| "isRaw"
@@ -33,7 +34,7 @@ export function DashboardFilters({
| "visible"
| "busy"
| "deleteEntries"
->) {
+> & { hideSelection?: boolean }) {
return (
<>
<div className="flex items-center gap-3 px-7 pb-7 lg:px-10">
@@ -54,21 +55,23 @@ export function DashboardFilters({
{label}
</Button>
))}
- <Button
- variant="ghost"
- size="icon"
- className="size-7 min-w-7 text-danger"
- aria-label={
- isRaw ? "Select raw files to remove" : "Select projects to delete"
- }
- aria-pressed={selecting}
- onClick={() => {
- setSelecting(!selecting);
- setSelected([]);
- }}
- >
- <Trash weight="fill" className="size-4" />
- </Button>
+ {!hideSelection && (
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7 min-w-7 text-danger"
+ aria-label={
+ isRaw ? "Select raw files to remove" : "Select projects to delete"
+ }
+ aria-pressed={selecting}
+ onClick={() => {
+ setSelecting(!selecting);
+ setSelected([]);
+ }}
+ >
+ <Trash weight="fill" className="size-4" />
+ </Button>
+ )}
</div>
<div className="ml-auto">
<Dropdown>
diff --git a/src/components/video-editor/dashboard/DashboardGrid.tsx b/src/components/video-editor/dashboard/DashboardGrid.tsx
index 7e86c4e3..76751b36 100644
--- a/src/components/video-editor/dashboard/DashboardGrid.tsx
+++ b/src/components/video-editor/dashboard/DashboardGrid.tsx
@@ -1,4 +1,6 @@
import { LibrarySkeleton } from "./LibrarySkeleton";
+import { SharedRecordings } from "../cloud/SharedRecordings";
+import { CLOUD_SHARE_ENDPOINT } from "../cloud/endpoint";
import { RecordNewButton } from "./RecordNewButton";
import { RawPreview } from "./RawRecordings";
import { Cloud, ImageSquare } from "@/components/ui/icons";
@@ -15,7 +17,6 @@ import type { DashboardModel } from "./useDashboardModel";
export function DashboardGrid({
onImportFile,
loading,
- deleteEntries,
isRaw,
rawPreview,
setRawPreview,
@@ -25,6 +26,7 @@ export function DashboardGrid({
error,
section,
accountLabel,
+ authToken,
onSignIn,
onShareProject,
visible,
@@ -41,10 +43,10 @@ export function DashboardGrid({
hasActiveFilters,
setQuery,
run,
+ deleteEntries,
}: Pick<
DashboardProps & DashboardModel,
| "loading"
- | "deleteEntries"
| "onImportFile"
| "isRaw"
| "rawPreview"
@@ -55,6 +57,7 @@ export function DashboardGrid({
| "error"
| "section"
| "accountLabel"
+ | "authToken"
| "onSignIn"
| "onShareProject"
| "visible"
@@ -70,6 +73,7 @@ export function DashboardGrid({
| "query"
| "hasActiveFilters"
| "setQuery"
+ | "deleteEntries"
| "run"
>) {
return (
@@ -83,17 +87,31 @@ export function DashboardGrid({
{section === "settings" ? (
<DashboardSettings onImportFile={onImportFile} />
) : section === "shared" ? (
- <div className="flex h-64 flex-col items-center justify-center gap-3 text-sm text-muted-foreground">
- <Cloud weight="fill" className="size-8 opacity-40" />
- <p>
- {accountLabel
- ? "Shared videos are managed in your cloud library."
- : "Sign in to manage shared videos."}
- </p>
- <Button variant="secondary" onClick={onSignIn}>
- {accountLabel ? "Account" : "Sign in"}
- </Button>
- </div>
+ authToken && CLOUD_SHARE_ENDPOINT ? (
+ <div>
+ <SharedRecordings
+ key={authToken}
+ token={authToken}
+ endpoint={CLOUD_SHARE_ENDPOINT}
+ accountLabel={accountLabel}
+ standalone
+ />
+ </div>
+ ) : (
+ <div className="flex h-64 flex-col items-center justify-center gap-3 text-sm text-muted-foreground">
+ <Cloud weight="fill" className="size-8 opacity-40" />
+ <p>
+ {authToken
+ ? "Cloud sharing is not available in this build yet."
+ : "Sign in to manage shared videos."}
+ </p>
+ {!authToken && (
+ <Button variant="secondary" onClick={onSignIn}>
+ Sign in
+ </Button>
+ )}
+ </div>
+ )
) : (isRaw ? rawLoading : loading) ? (
<LibrarySkeleton />
) : visible.length ? (
diff --git a/src/components/video-editor/dashboard/DashboardToolbar.tsx b/src/components/video-editor/dashboard/DashboardToolbar.tsx
index 907a55c1..d7d13c2a 100644
--- a/src/components/video-editor/dashboard/DashboardToolbar.tsx
+++ b/src/components/video-editor/dashboard/DashboardToolbar.tsx
@@ -1,4 +1,4 @@
-import { MagnifyingGlass, UploadSimple } from "@/components/ui/icons";
+import { MagnifyingGlass, UploadSimple, ArrowClockwise } from "@/components/ui/icons";
import { type CSSProperties } from "react";
import { Button } from "@/components/ui/button";
@@ -15,10 +15,11 @@ export function DashboardToolbar({
setQuery,
run,
busy,
+ actionLabel = "Import",
}: Pick<
DashboardProps & DashboardModel,
"onImportFile" | "query" | "setQuery" | "run" | "busy" | "isRaw"
->) {
+> & { actionLabel?: string }) {
return (
<>
<header
@@ -45,8 +46,12 @@ export function DashboardToolbar({
onClick={() => void run(onImportFile)}
className="h-10 shrink-0 gap-2 text-[13px]"
>
- <UploadSimple className="size-4" />
- Import
+ {actionLabel === "Refresh" ? (
+ <ArrowClockwise className="size-4" />
+ ) : (
+ <UploadSimple className="size-4" />
+ )}
+ {actionLabel}
</Button>
</div>
</header>
diff --git a/src/components/video-editor/dashboard/ProjectCard.tsx b/src/components/video-editor/dashboard/ProjectCard.tsx
index a0c8a70d..51c0ecb9 100644
--- a/src/components/video-editor/dashboard/ProjectCard.tsx
+++ b/src/components/video-editor/dashboard/ProjectCard.tsx
@@ -1,3 +1,4 @@
+import { Globe } from "@phosphor-icons/react";
import { ProjectFolderChips } from "./ProjectFolderChips";
import { RawThumbnail } from "./RawRecordings";
import { AccountAvatar } from "@/components/ui/account-avatar";
@@ -25,9 +26,11 @@ type Props = Pick<
| "folders"
| "save"
| "assignFolder"
-> & { entry: ProjectLibraryEntry; onDelete?: () => void };
+> & { entry: ProjectLibraryEntry; webUrl?: string; webReady?: boolean; onDelete?: () => void };
export function ProjectCard({
accountLabel,
+ webUrl,
+ webReady = true,
onDelete,
entry,
busy,
@@ -74,7 +77,7 @@ export function ProjectCard({
<li className="group min-w-0">
<Button
variant="ghost"
- disabled={busy}
+ disabled={busy || (Boolean(webUrl) && !webReady)}
aria-label={entry.name}
onPointerEnter={(event) => {
if (event.pointerType === "mouse") setHovering(true);
@@ -96,8 +99,13 @@ export function ProjectCard({
key={`${entry.thumbnailPath}-${entry.updatedAt}`}
revision={entry.updatedAt}
path={entry.thumbnailPath}
- projectPath={entry.path}
- previewActive={hovering && !selecting && !busy}
+ videoSource={
+ webUrl && webReady
+ ? new URL(`/v/${entry.path}`, webUrl).href
+ : undefined
+ }
+ projectPath={webUrl ? undefined : entry.path}
+ previewActive={!webUrl && hovering && !selecting && !busy}
/>
)}
{selecting && (
@@ -151,61 +159,73 @@ export function ProjectCard({
day: "numeric",
})}
</p>
- <ProjectFolderChips
- folders={assignedFolders}
- name={entry.name}
- onRemove={(id) => assignFolder(entry.path, id)}
- />
- <Dropdown>
- <Button
- variant="ghost"
- size="sm"
- aria-label={`Add folder to ${entry.name}`}
- className="h-6 min-w-0 shrink-0 gap-1.5 rounded-full px-2.5 text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100"
- >
- <Plus className="size-3" />
- Add folder
- </Button>
- <Dropdown.Popover>
- <Dropdown.Menu aria-label="Assign project folder">
- {folders.map((item) => (
- <Dropdown.Item
- key={item.id}
- id={item.id}
- textValue={item.name}
- onAction={() => assignFolder(entry.path, item.id)}
- >
- <FolderSimple
- weight="fill"
- style={{ color: item.color }}
- />
- {item.name}
- {item.paths.includes(entry.path) && (
- <Check className="size-3" />
+ {webUrl && (
+ <Globe
+ aria-label="Web project"
+ className="size-3.5 text-muted-foreground"
+ />
+ )}
+ {webUrl && !webReady && (
+ <span className="text-xs text-muted-foreground">Incomplete upload</span>
+ )}
+ {!webUrl && (
+ <>
+ <ProjectFolderChips
+ folders={assignedFolders}
+ name={entry.name}
+ onRemove={(id) => assignFolder(entry.path, id)}
+ />
+ <Dropdown>
+ <Button
+ variant="ghost"
+ size="sm"
+ aria-label={`Add folder to ${entry.name}`}
+ className="h-6 min-w-0 shrink-0 gap-1.5 rounded-full px-2.5 text-[11px] text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus:opacity-100"
+ >
+ <Plus className="size-3" />
+ Add folder
+ </Button>
+ <Dropdown.Popover>
+ <Dropdown.Menu aria-label="Assign project folder">
+ {folders.map((item) => (
+ <Dropdown.Item
+ key={item.id}
+ id={item.id}
+ textValue={item.name}
+ onAction={() =>
+ assignFolder(entry.path, item.id)
+ }
+ >
+ <FolderSimple
+ weight="fill"
+ style={{ color: item.color }}
+ />
+ {item.name}
+ {item.paths.includes(entry.path) && (
+ <Check className="size-3" />
+ )}
+ </Dropdown.Item>
+ ))}
+ {folder && (
+ <Dropdown.Item
+ id="remove"
+ onAction={() =>
+ assignFolder(entry.path, "none")
+ }
+ >
+ Remove from all folders
+ </Dropdown.Item>
)}
- </Dropdown.Item>
- ))}
- {folder && (
- <Dropdown.Item
- id="remove"
- onAction={() => assignFolder(entry.path, "none")}
- >
- Remove from all folders
- </Dropdown.Item>
- )}
- {!folders.length && (
- <Dropdown.Item id="empty" isDisabled>
- Create a folder in the sidebar
- </Dropdown.Item>
- )}
- {onDelete && (
- <Dropdown.Item id="delete" variant="danger" className="text-danger" isDisabled={busy} onAction={onDelete}>
- {entry.rawSource ? "Remove from library" : "Delete project"}
- </Dropdown.Item>
- )}
- </Dropdown.Menu>
- </Dropdown.Popover>
- </Dropdown>
+ {!folders.length && (
+ <Dropdown.Item id="empty" isDisabled>
+ Create a folder in the sidebar
+ </Dropdown.Item>
+ )}
+ </Dropdown.Menu>
+ </Dropdown.Popover>
+ </Dropdown>
+ </>
+ )}
</div>
</div>
<Dropdown>
@@ -219,48 +239,74 @@ export function ProjectCard({
</Button>
<Dropdown.Popover>
<Dropdown.Menu aria-label="Project options">
- <Dropdown.Item id="open" onAction={() => openEntry(entry)}>
- {entry.rawSource ? "Preview file" : "Open project"}
- </Dropdown.Item>
<Dropdown.Item
- id="rename"
- onAction={() => {
- setName(entry.name);
- requestAnimationFrame(() => requestAnimationFrame(() => setEditing(true)));
- }}
+ id="open"
+ isDisabled={Boolean(webUrl) && !webReady}
+ onAction={() => openEntry(entry)}
>
- Rename
+ {webUrl
+ ? "Open link"
+ : entry.rawSource
+ ? "Preview file"
+ : "Open project"}
</Dropdown.Item>
- {!entry.rawSource && (
- <Dropdown.Item
- id="share"
- onAction={() =>
- void run(async () => {
- if (shareUrl)
- await window.electronAPI.openExternalUrl(shareUrl);
- else await onShareProject(entry.path);
- })
- }
- >
- {shareUrl ? "View in web" : "Share"}
- </Dropdown.Item>
+ {!webUrl && (
+ <>
+ <Dropdown.Item
+ id="rename"
+ onAction={() => {
+ setName(entry.name);
+ requestAnimationFrame(() => requestAnimationFrame(() => setEditing(true)));
+ }}
+ >
+ Rename
+ </Dropdown.Item>
+ {!entry.rawSource && (
+ <Dropdown.Item
+ id="share"
+ onAction={() =>
+ void run(async () => {
+ if (shareUrl)
+ await window.electronAPI.openExternalUrl(
+ shareUrl,
+ );
+ else await onShareProject(entry.path);
+ })
+ }
+ >
+ {shareUrl ? "View in web" : "Share"}
+ </Dropdown.Item>
+ )}
+ <Dropdown.Item
+ aria-label={
+ entry.rawSource
+ ? `Show ${entry.name} in folder`
+ : undefined
+ }
+ id="reveal"
+ onAction={() =>
+ void run(async () => {
+ await window.electronAPI.revealInFolder(entry.path);
+ })
+ }
+ >
+ Show in folder
+ </Dropdown.Item>
+ </>
)}
- <Dropdown.Item
- aria-label={
- entry.rawSource ? `Show ${entry.name} in folder` : undefined
- }
- id="reveal"
- onAction={() =>
- void run(async () => {
- await window.electronAPI.revealInFolder(entry.path);
- })
- }
- >
- Show in folder
- </Dropdown.Item>
{onDelete && (
- <Dropdown.Item id="delete" variant="danger" className="text-danger" isDisabled={busy} onAction={onDelete}>
- {entry.rawSource ? "Remove from library" : "Delete project"}
+ <Dropdown.Item
+ id="delete"
+ variant="danger"
+ className="text-danger"
+ isDisabled={busy}
+ onAction={onDelete}
+ >
+ {webUrl
+ ? "Delete recording"
+ : entry.rawSource
+ ? "Remove from library"
+ : "Delete project"}
</Dropdown.Item>
)}
</Dropdown.Menu>
diff --git a/src/components/video-editor/dashboard/ProjectThumbnail.tsx b/src/components/video-editor/dashboard/ProjectThumbnail.tsx
index 83083017..364ef3eb 100644
--- a/src/components/video-editor/dashboard/ProjectThumbnail.tsx
+++ b/src/components/video-editor/dashboard/ProjectThumbnail.tsx
@@ -9,14 +9,17 @@ export function ProjectThumbnail({
projectPath,
previewActive = false,
revision = 0,
+ videoSource,
}: {
path: string | null;
projectPath?: string;
previewActive?: boolean;
revision?: number;
+ videoSource?: string;
}) {
const [loadedSource, setLoadedSource] = useState<string | null>(null);
const [failedSource, setFailedSource] = useState<string | null>(null);
+ const [visible, setVisible] = useState(false);
const [preview, setPreview] = useState<ProjectPreviewData | null>(null);
const host = useRef<HTMLDivElement>(null);
const finish = useCallback(() => setPreview(null), []);
@@ -50,6 +53,15 @@ export function ProjectThumbnail({
setPreview(null);
};
}, [previewActive, projectPath, revision]);
+ useEffect(() => {
+ if (!videoSource || !host.current) return;
+ const observer = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting), {
+ rootMargin: "100px",
+ });
+ observer.observe(host.current);
+ return () => observer.disconnect();
+ }, [videoSource]);
+
const sourceKey = `${path}:${revision}`;
return (
<div
@@ -73,6 +85,16 @@ export function ProjectThumbnail({
onLoad={() => setLoadedSource(sourceKey)}
className="h-full w-full object-cover"
/>
+ ) : videoSource && visible ? (
+ <video
+ src={videoSource}
+ preload="metadata"
+ muted
+ playsInline
+ tabIndex={-1}
+ aria-hidden="true"
+ className="pointer-events-none h-full w-full object-cover"
+ />
) : (
<ImageSquare weight="fill" className="size-8 text-muted-foreground/20" />
)}
diff --git a/src/components/video-editor/dashboard/types.ts b/src/components/video-editor/dashboard/types.ts
index 0348c59a..b2f3b4d5 100644
--- a/src/components/video-editor/dashboard/types.ts
+++ b/src/components/video-editor/dashboard/types.ts
@@ -12,4 +12,5 @@ export type DashboardProps = {
onRenameProject: (path: string, name: string) => Promise<string>;
onShareProject: (path: string) => Promise<void>;
accountLabel?: string;
+ authToken?: string;
};
diff --git a/src/components/video-editor/export/useExportDialogActions.ts b/src/components/video-editor/export/useExportDialogActions.ts
index 813286c0..bfebc537 100644
--- a/src/components/video-editor/export/useExportDialogActions.ts
+++ b/src/components/video-editor/export/useExportDialogActions.ts
@@ -1,7 +1,7 @@
import { type RefObject, useCallback } from "react";
import { toast } from "@/components/ui/toast";
import type { ExportFormat, ExportSettings } from "@/lib/exporter";
-import { resolveExportStartSettings } from "../exportStartSettings";
+import { resolveExportStartSettings, resolveShareExportSettings } from "../exportStartSettings";
import type { VideoPlaybackRef } from "../VideoPlayback";
import type { useExportSession } from "./useExportSession";
import type { useExportSettings } from "./useExportSettings";
@@ -97,8 +97,8 @@ export function useExportDialogActions({
const resolvedSettings = resolveCurrentSettings("mp4");
if (!resolvedSettings) return undefined;
session.setExportError(null);
- session.setShowExportDropdown(false);
- return handleExport(resolvedSettings, { destination: "share" });
+ session.setShowExportDropdown(true);
+ return handleExport(resolveShareExportSettings(resolvedSettings), { destination: "share" });
}, [resolveCurrentSettings, session, handleExport]);
const handleCancelExport = useCallback(() => {
diff --git a/src/components/video-editor/export/useExportRunner.ts b/src/components/video-editor/export/useExportRunner.ts
index 7978bf81..21a2e2bd 100644
--- a/src/components/video-editor/export/useExportRunner.ts
+++ b/src/components/video-editor/export/useExportRunner.ts
@@ -563,7 +563,8 @@ export function useExportRunner(input: ExportRunnerInput) {
} else if (!exportWasCancelled()) {
setIsExporting(false);
exporterRef.current = null;
- setShowExportDropdown(keepExportDialogOpen);
+ if (options?.destination !== "share")
+ setShowExportDropdown(keepExportDialogOpen);
remountPreview();
}
}
diff --git a/src/components/video-editor/exportStartSettings.test.ts b/src/components/video-editor/exportStartSettings.test.ts
index 567807da..723b33d4 100644
--- a/src/components/video-editor/exportStartSettings.test.ts
+++ b/src/components/video-editor/exportStartSettings.test.ts
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
-import { resolveExportStartSettings } from "./exportStartSettings";
+import { resolveExportStartSettings, resolveShareExportSettings } from "./exportStartSettings";
const baseOptions = {
sourceWidth: 1920,
@@ -75,3 +75,24 @@ describe("resolveExportStartSettings", () => {
});
});
});
+
+it("locks sharing to fast 30 fps source quality without changing Local settings", () => {
+ const local = resolveExportStartSettings({
+ ...baseOptions,
+ mp4FrameRate: 60,
+ exportEncodingMode: "quality",
+ });
+ expect(resolveShareExportSettings(local)).toMatchObject({
+ format: "mp4",
+ quality: "source",
+ encodingMode: "fast",
+ mp4FrameRate: 30,
+ includeCaptionSidecar: false,
+ });
+ expect(local).toMatchObject({
+ encodingMode: "quality",
+ mp4FrameRate: 60,
+ quality: "good",
+ includeCaptionSidecar: true,
+ });
+});
diff --git a/src/components/video-editor/exportStartSettings.ts b/src/components/video-editor/exportStartSettings.ts
index dc0aeab7..0c7341af 100644
--- a/src/components/video-editor/exportStartSettings.ts
+++ b/src/components/video-editor/exportStartSettings.ts
@@ -64,3 +64,15 @@ export function resolveExportStartSettings({
: undefined,
};
}
+
+export function resolveShareExportSettings(settings: ExportSettings): ExportSettings {
+ return {
+ ...settings,
+ format: "mp4",
+ quality: "source",
+ encodingMode: "fast",
+ mp4FrameRate: 30,
+ includeCaptionSidecar: false,
+ gifConfig: undefined,
+ };
+}
diff --git a/src/components/video-editor/layout/EditorDialogs.tsx b/src/components/video-editor/layout/EditorDialogs.tsx
index b29c0bf2..b8673071 100644
--- a/src/components/video-editor/layout/EditorDialogs.tsx
+++ b/src/components/video-editor/layout/EditorDialogs.tsx
@@ -45,6 +45,7 @@ interface EditorDialogsProps {
onRenameProject: (path: string, name: string) => Promise<string>;
onShareProject: (path: string) => Promise<void>;
accountLabel?: string;
+ authToken?: string;
handleImportMediaOrProject: () => Promise<void>;
handleOpenProjectFromLibrary: (projectPath: string) => Promise<unknown>;
nativeCaptureUnavailableModalOpen: boolean;
@@ -75,6 +76,7 @@ export function EditorDialogs({
onRenameProject,
onShareProject,
accountLabel,
+ authToken,
handleImportMediaOrProject,
handleOpenProjectFromLibrary,
nativeCaptureUnavailableModalOpen,
@@ -194,6 +196,7 @@ export function EditorDialogs({
onRenameProject={onRenameProject}
onShareProject={onShareProject}
accountLabel={accountLabel}
+ authToken={authToken}
onImportFile={handleImportMediaOrProject}
onOpenProject={handleOpenProjectFromLibrary}
/>
diff --git a/src/components/video-editor/layout/EditorExportMenu.tsx b/src/components/video-editor/layout/EditorExportMenu.tsx
index 4dea1caf..39edb7e9 100644
--- a/src/components/video-editor/layout/EditorExportMenu.tsx
+++ b/src/components/video-editor/layout/EditorExportMenu.tsx
@@ -1,9 +1,10 @@
-import { useEffect, useState } from "react";
-import { CloudArrowUp } from "@/components/ui/icons";
+import { LinkSimple, HardDrive, Export } from "@phosphor-icons/react";
+import { useEffect, useLayoutEffect, useRef, useState } from "react";
import { CloudShareButton } from "../cloud/CloudShareButton";
-import { Card } from "@heroui/react";
+import { Card, TagGroup, Tag } from "@heroui/react";
+import { motion, useReducedMotion } from "motion/react";
import { ProgressBar } from "@heroui/react";
-import { DownloadSimple as Download } from "@/components/ui/icons";
+
import { toast } from "@/components/ui/toast";
import { Button } from "@/components/ui/button";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
@@ -15,7 +16,7 @@ import type { useExportSettings } from "../export/useExportSettings";
import type { useExportStatusViewModel } from "../export/useExportStatusViewModel";
type Props = {
- projectPath?: string | null;
+ projectPath?: string | null;
t: ReturnType<typeof useI18n>["t"];
exportSettings: ReturnType<typeof useExportSettings>;
exportSession: ReturnType<typeof useExportSession>;
@@ -40,10 +41,33 @@ type Props = {
};
export function EditorExportMenu(props: Props) {
- const [shareOpen, setShareOpen] = useState(false);
+ const { publishDestination: destination, setPublishDestination: setDestination } =
+ props.exportSettings;
+ const [shareBusy, setShareBusy] = useState(false);
+ const reducedMotion = useReducedMotion();
+ const handledShareRequest = useRef(0);
+ const contentRef = useRef<HTMLDivElement>(null);
+ const [contentHeight, setContentHeight] = useState<number>();
+ useLayoutEffect(() => {
+ if (!props.exportSession.showExportDropdown) return;
+ const content = contentRef.current;
+ if (!content) return;
+ // The popover scales in on entry. Its bounding rect includes that scale,
+ // so measuring it would lock the wrapper to a height smaller than its content.
+ const measure = () => setContentHeight(content.offsetHeight);
+ measure();
+ const observer = new ResizeObserver(measure);
+ observer.observe(content);
+ return () => observer.disconnect();
+ }, [props.exportSession.showExportDropdown]);
useEffect(() => {
- if (props.shareRequestNonce > 0) setShareOpen(true);
- }, [props.shareRequestNonce]);
+ if (props.shareRequestNonce > handledShareRequest.current) {
+ handledShareRequest.current = props.shareRequestNonce;
+ setDestination("link");
+ props.handleOpenExportDropdown();
+ }
+ }, [props.shareRequestNonce, props.handleOpenExportDropdown, setDestination]);
+
const {
t,
exportSettings,
@@ -105,13 +129,48 @@ export function EditorExportMenu(props: Props) {
nativeSkipLabel: exportNativeSkipLabel,
} = exportStatus;
+ const settingsForm = (
+ <ExportSettingsMenu
+ exportFormat={destination === "link" ? "mp4" : exportFormat}
+ onExportFormatChange={setExportFormat}
+ exportEncodingMode={exportEncodingMode}
+ onExportEncodingModeChange={setExportEncodingMode}
+ mp4FrameRate={mp4FrameRate}
+ onMp4FrameRateChange={setMp4FrameRate}
+ exportPipelineModel={exportPipelineModel}
+ experimentalNvidiaCudaExport={experimentalNvidiaCudaExport && nvidiaCudaExportAvailable}
+ onExperimentalNvidiaCudaExportChange={setExperimentalNvidiaCudaExport}
+ nvidiaCudaExportAvailable={nvidiaCudaExportAvailable}
+ exportQuality={exportQuality}
+ onExportQualityChange={setExportQuality}
+ gifFrameRate={gifFrameRate}
+ onGifFrameRateChange={setGifFrameRate}
+ gifLoop={gifLoop}
+ onGifLoopChange={setGifLoop}
+ gifSizePreset={gifSizePreset}
+ onGifSizePresetChange={setGifSizePreset}
+ showCaptionSidecarOption={hasCaptionsForSidecar && exportFormat === "mp4"}
+ includeCaptionSidecar={includeCaptionSidecar}
+ onIncludeCaptionSidecarChange={setIncludeCaptionSidecar}
+ mp4OutputDimensions={mp4OutputDimensions}
+ gifOutputDimensions={gifOutputDimensions}
+ onExport={handleStartExportFromDropdown}
+ hideHeading
+ hideAction={destination === "link"}
+ linkMode={destination === "link"}
+ className="rounded-none bg-transparent px-5 pb-5 pt-0 shadow-none"
+ />
+ );
+
return (
<>
<Popover
open={showExportDropdown}
onOpenChange={(open) => {
- if (open) handleOpenExportDropdown();
- else setShowExportDropdown(false);
+ if (shareBusy) return;
+ if (open) {
+ handleOpenExportDropdown();
+ } else setShowExportDropdown(false);
}}
modal={true}
>
@@ -120,256 +179,271 @@ export function EditorExportMenu(props: Props) {
type="button"
className="inline-flex h-9 min-w-[104px] items-center justify-center gap-2 px-4.5"
>
- <Download className="h-4 w-4" />
- <span className="text-sm font-semibold tracking-tight">
- {t("common.actions.export", "Export")}
- </span>
+ <Export className="h-4 w-4" />
+ <span className="text-sm font-semibold tracking-tight">Publish</span>
</Button>
</PopoverTrigger>
<PopoverContent
- aria-label="Export"
+ aria-label="Publish"
align="end"
sideOffset={10}
- className="w-[360px] p-0"
+ className="w-[360px] max-h-none overflow-hidden p-0"
+ isKeyboardDismissDisabled={shareBusy}
+ shouldCloseOnInteractOutside={() => !shareBusy}
>
- {isExporting ? (
- <Card className="rounded-none bg-transparent p-5 text-foreground shadow-none">
- <div className="mb-3 flex items-center justify-between gap-3">
- <div>
- <p className="text-sm font-semibold text-foreground">
- {t("editor.exportStatus.exporting", "Exporting")}
- </p>
- <p className="text-xs text-muted-foreground">
- {t(
- "editor.exportStatus.renderingFile",
- "Rendering your file.",
- )}
- </p>
- {isLightningExportInProgress && exportMessage ? (
- <p className="mt-1 text-[11px] leading-relaxed text-muted-foreground/70">
- {exportMessage}
- </p>
- ) : null}
- {isLegacyExportInProgress ? (
- <p className="mt-1 text-[11px] text-muted-foreground/70">
- Export too slow? Cancel and try Lightning export!
- </p>
- ) : null}
- </div>
- <Button
- type="button"
- variant="outline"
- onClick={handleCancelExport}
- className="h-8 px-3 text-xs"
- >
- {t("common.actions.cancel")}
- </Button>
- </div>
- <ProgressBar
- aria-label={t("editor.exportStatus.exporting", "Exporting")}
- isIndeterminate={
- isExportPreparing ||
- isExportSaving ||
- isExportFinalSaveIndeterminate
- }
- value={Math.min(
- isRenderingAudio
- ? (exportProgress?.audioProgress ?? 0) * 100
- : (exportFinalizingProgress ??
- exportProgress?.percentage ??
- 8),
- 100,
- )}
- >
- <ProgressBar.Track>
- <ProgressBar.Fill />
- </ProgressBar.Track>
- </ProgressBar>
- <p className="mt-2 text-xs text-muted-foreground">
- {exportPercentLabel}
- </p>
- {isRenderingAudio ? (
- <p className="mt-1 text-[11px] text-muted-foreground/70">
- {t(
- "editor.export.processingAudioEdits",
- "Processing audio with speed/overlay edits",
- )}
- </p>
- ) : exportRenderSpeedLabel ? (
- <p className="mt-1 text-[11px] text-muted-foreground/70">
- {exportRenderSpeedLabel}
- </p>
- ) : null}
- {exportRuntimeLabel ? (
- <p className="mt-1 text-[11px] text-muted-foreground/70">
- Path: {exportRuntimeLabel}
- </p>
- ) : null}
- {exportNativeSkipLabel ? (
- <p className="mt-1 text-[11px] text-amber-500/80">
- {exportNativeSkipLabel}
- </p>
- ) : null}
- </Card>
- ) : exportError ? (
- <Card className="rounded-none bg-transparent p-5 text-foreground shadow-none">
- <p className="text-sm font-semibold text-foreground">
- {t("editor.exportStatus.issue", "Export issue")}
- </p>
- {exportRuntimeLabel ? (
- <p className="mt-1 text-[11px] text-muted-foreground/70">
- Path: {exportRuntimeLabel}
- </p>
- ) : null}
- <p className="mt-1 select-text whitespace-pre-wrap break-words text-xs leading-relaxed text-muted-foreground">
- {exportError}
- </p>
- <div className="mt-4 flex gap-2">
- <Button
- type="button"
- variant="outline"
- className="h-8 text-xs"
- onClick={async () => {
- try {
- await navigator.clipboard.writeText(exportError);
- toast.success(
- t(
- "editor.exportStatus.errorCopied",
- "Error copied",
- ),
- );
- } catch {
- toast.error(
- t(
- "editor.exportStatus.errorCopyFailed",
- "Couldn't copy. Select the error text and copy it manually.",
- ),
- );
- }
+ <motion.div
+ initial={false}
+ animate={{ height: contentHeight ?? "auto" }}
+ transition={{ duration: reducedMotion ? 0 : 0.22, ease: "easeInOut" }}
+ className="overflow-hidden"
+ >
+ <div ref={contentRef}>
+ <div className="p-5 space-y-3">
+ <h2 className="text-sm font-semibold">Publish</h2>
+ <TagGroup
+ aria-label="Publish destination"
+ selectionMode="single"
+ disallowEmptySelection
+ selectedKeys={[destination]}
+ onSelectionChange={(keys) => {
+ if (
+ keys !== "all" &&
+ keys.size > 0 &&
+ !isExporting &&
+ !shareBusy
+ )
+ setDestination(keys.has("link") ? "link" : "local");
}}
>
- {t("editor.exportStatus.copyError", "Copy error")}
- </Button>
- {hasPendingExportSave ? (
- <Button
- type="button"
- onClick={handleRetrySaveExport}
- className="h-8 flex-1 text-xs"
- >
- {t("editor.actions.saveAgain", "Save Again")}
- </Button>
- ) : null}
- <Button
- type="button"
- variant="outline"
- onClick={handleExportDropdownClose}
- className="h-8 flex-1 text-xs"
- >
- {t("common.actions.close", "Close")}
- </Button>
+ <TagGroup.List className="flex gap-2">
+ <Tag
+ id="link"
+ isDisabled={isExporting || shareBusy}
+ className="h-24 flex-1 flex-col justify-center gap-2 rounded-xl border border-foreground/10"
+ >
+ <LinkSimple className="size-6" />
+ Link
+ </Tag>
+ <Tag
+ id="local"
+ isDisabled={isExporting || shareBusy}
+ className="h-24 flex-1 flex-col justify-center gap-2 rounded-xl border border-foreground/10"
+ >
+ <HardDrive className="size-6" />
+ Local
+ </Tag>
+ </TagGroup.List>
+ </TagGroup>
</div>
- </Card>
- ) : exportedFilePath ? (
- <Card className="rounded-none bg-transparent p-5 text-foreground shadow-none">
- <p className="text-sm font-semibold text-foreground">
- {t("editor.exportStatus.complete", "Export complete")}
- </p>
- <p className="mt-1 text-xs text-muted-foreground">
- {t(
- "editor.exportStatus.savedSuccessfully",
- "Your file was saved successfully.",
+ <div>
+ {destination === "link" ? (
+ <div className="px-5 pb-5">
+ <CloudShareButton
+ inline
+ projectPath={props.projectPath}
+ projectTitle={props.projectTitle}
+ prepareFile={props.prepareExportForShare}
+ onCancelPrepare={handleCancelExport}
+ preparationProgress={exportProgress?.percentage ?? 0}
+ authToken={props.authToken}
+ onBusyChange={setShareBusy}
+ onRequestSignIn={() => {
+ setShowExportDropdown(false);
+ props.onRequestShareSignIn();
+ }}
+ />
+ </div>
+ ) : isExporting ? (
+ <Card className="rounded-none bg-transparent p-5 text-foreground shadow-none">
+ <div className="mb-3 flex items-center justify-between gap-3">
+ <div>
+ <p className="text-sm font-semibold text-foreground">
+ {t(
+ "editor.exportStatus.exporting",
+ "Exporting",
+ )}
+ </p>
+ <p className="text-xs text-muted-foreground">
+ {t(
+ "editor.exportStatus.renderingFile",
+ "Rendering your file.",
+ )}
+ </p>
+ {isLightningExportInProgress && exportMessage ? (
+ <p className="mt-1 text-[11px] leading-relaxed text-muted-foreground/70">
+ {exportMessage}
+ </p>
+ ) : null}
+ {isLegacyExportInProgress ? (
+ <p className="mt-1 text-[11px] text-muted-foreground/70">
+ Export too slow? Cancel and try Lightning
+ export!
+ </p>
+ ) : null}
+ </div>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={handleCancelExport}
+ className="h-8 px-3 text-xs"
+ >
+ {t("common.actions.cancel")}
+ </Button>
+ </div>
+ <ProgressBar
+ aria-label={t(
+ "editor.exportStatus.exporting",
+ "Exporting",
+ )}
+ isIndeterminate={
+ isExportPreparing ||
+ isExportSaving ||
+ isExportFinalSaveIndeterminate
+ }
+ value={Math.min(
+ isRenderingAudio
+ ? (exportProgress?.audioProgress ?? 0) * 100
+ : (exportFinalizingProgress ??
+ exportProgress?.percentage ??
+ 8),
+ 100,
+ )}
+ >
+ <ProgressBar.Track>
+ <ProgressBar.Fill />
+ </ProgressBar.Track>
+ </ProgressBar>
+ <p className="mt-2 text-xs text-muted-foreground">
+ {exportPercentLabel}
+ </p>
+ {isRenderingAudio ? (
+ <p className="mt-1 text-[11px] text-muted-foreground/70">
+ {t(
+ "editor.export.processingAudioEdits",
+ "Processing audio with speed/overlay edits",
+ )}
+ </p>
+ ) : exportRenderSpeedLabel ? (
+ <p className="mt-1 text-[11px] text-muted-foreground/70">
+ {exportRenderSpeedLabel}
+ </p>
+ ) : null}
+ {exportRuntimeLabel ? (
+ <p className="mt-1 text-[11px] text-muted-foreground/70">
+ Path: {exportRuntimeLabel}
+ </p>
+ ) : null}
+ {exportNativeSkipLabel ? (
+ <p className="mt-1 text-[11px] text-amber-500/80">
+ {exportNativeSkipLabel}
+ </p>
+ ) : null}
+ </Card>
+ ) : exportError ? (
+ <Card className="rounded-none bg-transparent p-5 text-foreground shadow-none">
+ <p className="text-sm font-semibold text-foreground">
+ {t("editor.exportStatus.issue", "Export issue")}
+ </p>
+ {exportRuntimeLabel ? (
+ <p className="mt-1 text-[11px] text-muted-foreground/70">
+ Path: {exportRuntimeLabel}
+ </p>
+ ) : null}
+ <p className="mt-1 select-text whitespace-pre-wrap break-words text-xs leading-relaxed text-muted-foreground">
+ {exportError}
+ </p>
+ <div className="mt-4 flex gap-2">
+ <Button
+ type="button"
+ variant="outline"
+ className="h-8 text-xs"
+ onClick={async () => {
+ try {
+ await navigator.clipboard.writeText(
+ exportError,
+ );
+ toast.success(
+ t(
+ "editor.exportStatus.errorCopied",
+ "Error copied",
+ ),
+ );
+ } catch {
+ toast.error(
+ t(
+ "editor.exportStatus.errorCopyFailed",
+ "Couldn't copy. Select the error text and copy it manually.",
+ ),
+ );
+ }
+ }}
+ >
+ {t("editor.exportStatus.copyError", "Copy error")}
+ </Button>
+ {hasPendingExportSave ? (
+ <Button
+ type="button"
+ onClick={handleRetrySaveExport}
+ className="h-8 flex-1 text-xs"
+ >
+ {t("editor.actions.saveAgain", "Save Again")}
+ </Button>
+ ) : null}
+ <Button
+ type="button"
+ variant="outline"
+ onClick={handleExportDropdownClose}
+ className="h-8 flex-1 text-xs"
+ >
+ {t("common.actions.close", "Close")}
+ </Button>
+ </div>
+ </Card>
+ ) : exportedFilePath ? (
+ <Card className="rounded-none bg-transparent p-5 text-foreground shadow-none">
+ <p className="text-sm font-semibold text-foreground">
+ {t("editor.exportStatus.complete", "Export complete")}
+ </p>
+ <p className="mt-1 text-xs text-muted-foreground">
+ {t(
+ "editor.exportStatus.savedSuccessfully",
+ "Your file was saved successfully.",
+ )}
+ </p>
+ {exportRuntimeLabel ? (
+ <p className="mt-1 text-[11px] text-muted-foreground/70">
+ Path: {exportRuntimeLabel}
+ </p>
+ ) : null}
+ <p className="mt-3 truncate text-xs text-muted-foreground/70">
+ {exportedFilePath.split(/[\\/]/).pop()}
+ </p>
+ <div className="mt-4 flex gap-2">
+ <Button
+ type="button"
+ onClick={revealExportedFile}
+ className="h-8 flex-1 text-xs"
+ >
+ {t("editor.actions.showInFolder", "Show In Folder")}
+ </Button>
+ <Button
+ type="button"
+ variant="outline"
+ onClick={handleExportDropdownClose}
+ className="h-8 flex-1 text-xs"
+ >
+ {t("editor.cloud.done")}
+ </Button>
+ </div>
+ </Card>
+ ) : (
+ <>{settingsForm}</>
)}
- </p>
- {exportRuntimeLabel ? (
- <p className="mt-1 text-[11px] text-muted-foreground/70">
- Path: {exportRuntimeLabel}
- </p>
- ) : null}
- <p className="mt-3 truncate text-xs text-muted-foreground/70">
- {exportedFilePath.split(/[\\/]/).pop()}
- </p>
- <div className="mt-4 flex gap-2">
- <Button
- type="button"
- onClick={revealExportedFile}
- className="h-8 flex-1 text-xs"
- >
- {t("editor.actions.showInFolder", "Show In Folder")}
- </Button>
- <Button
- type="button"
- variant="outline"
- onClick={handleExportDropdownClose}
- className="h-8 flex-1 text-xs"
- >
- {t("editor.cloud.done")}
- </Button>
- </div>
- </Card>
- ) : (
- <>
- <ExportSettingsMenu
- exportFormat={exportFormat}
- onExportFormatChange={setExportFormat}
- exportEncodingMode={exportEncodingMode}
- onExportEncodingModeChange={setExportEncodingMode}
- mp4FrameRate={mp4FrameRate}
- onMp4FrameRateChange={setMp4FrameRate}
- exportPipelineModel={exportPipelineModel}
- experimentalNvidiaCudaExport={
- experimentalNvidiaCudaExport && nvidiaCudaExportAvailable
- }
- onExperimentalNvidiaCudaExportChange={
- setExperimentalNvidiaCudaExport
- }
- nvidiaCudaExportAvailable={nvidiaCudaExportAvailable}
- exportQuality={exportQuality}
- onExportQualityChange={setExportQuality}
- gifFrameRate={gifFrameRate}
- onGifFrameRateChange={setGifFrameRate}
- gifLoop={gifLoop}
- onGifLoopChange={setGifLoop}
- gifSizePreset={gifSizePreset}
- onGifSizePresetChange={setGifSizePreset}
- showCaptionSidecarOption={
- hasCaptionsForSidecar && exportFormat === "mp4"
- }
- includeCaptionSidecar={includeCaptionSidecar}
- onIncludeCaptionSidecarChange={setIncludeCaptionSidecar}
- mp4OutputDimensions={mp4OutputDimensions}
- gifOutputDimensions={gifOutputDimensions}
- onExport={handleStartExportFromDropdown}
- className="rounded-none bg-transparent p-5 shadow-none"
- />
- <div className="px-5 pb-5">
- <Button
- variant="secondary"
- className="w-full"
- onClick={() => {
- setShowExportDropdown(false);
- props.onRequestShareSignIn();
- }}
- >
- <CloudArrowUp className="size-4" />
- {t("editor.cloud.createShareLink")}
- </Button>
</div>
- </>
- )}
+ </div>
+ </motion.div>
</PopoverContent>
</Popover>
- {shareOpen && (
- <CloudShareButton
- projectPath={props.projectPath}
- hideTrigger
- open={shareOpen}
- onOpenChange={setShareOpen}
- projectTitle={props.projectTitle}
- prepareFile={props.prepareExportForShare}
- onCancelPrepare={handleCancelExport}
- authToken={props.authToken}
- />
- )}
</>
);
}
diff --git a/src/components/video-editor/layout/EditorShell.tsx b/src/components/video-editor/layout/EditorShell.tsx
index 25a8c7cb..8a98833b 100644
--- a/src/components/video-editor/layout/EditorShell.tsx
+++ b/src/components/video-editor/layout/EditorShell.tsx
@@ -181,6 +181,7 @@ export function EditorShell(props: Props) {
else setShareRequestNonce((value) => value + 1);
}}
accountLabel={auth.user?.email}
+ authToken={auth.accessToken}
handleImportMediaOrProject={openActions.handleImportMediaOrProject}
handleOpenProjectFromLibrary={openActions.handleOpenProjectFromLibrary}
nativeCaptureUnavailableModalOpen={ui.nativeCaptureUnavailableModalOpen}
diff --git a/tests/ui/publish-cloud.spec.ts b/tests/ui/publish-cloud.spec.ts
new file mode 100644
index 00000000..8883e42c
--- /dev/null
+++ b/tests/ui/publish-cloud.spec.ts
@@ -0,0 +1,37 @@
+import { expect, test } from "@playwright/test";
+
+test("publish preserves local destination and stays open throughout sharing", async ({ page }) => {
+ await page.goto("/tests/ui/publish.html");
+ await page.getByRole("button", { name: "Publish", exact: true }).click();
+ await page.getByRole("row", { name: "Local", exact: true }).click();
+ await expect(page.getByRole("button", { name: "Export Video", exact: true })).toBeVisible();
+ await page.reload();
+ await page.getByRole("button", { name: "Publish", exact: true }).click();
+ await expect(page.getByRole("row", { name: "Local", exact: true })).toHaveAttribute("aria-selected", "true");
+ await page.getByRole("row", { name: "Link", exact: true }).click();
+ await page.getByRole("button", { name: "Share", exact: true }).click();
+ await expect(page.getByText(/Uploading ·/)).toBeVisible();
+ await page.keyboard.press("Escape");
+ await expect(page.getByText(/Uploading ·/)).toBeVisible();
+ await expect(page.getByRole("row", { name: "Local", exact: true })).toHaveAttribute("aria-disabled", "true");
+ await expect(page.getByRole("button", { name: "Copy link", exact: true })).toBeVisible({ timeout: 20000 });
+});
+
+test("a full cloud quota prevents starting preparation", async ({ page }) => {
+ await page.goto("/tests/ui/publish.html?full");
+ await page.getByRole("button", { name: "Publish", exact: true }).click();
+ await expect(page.getByText("You have 5 cloud recordings. Delete one from Shared before sharing another.")).toBeVisible();
+ await expect(page.getByRole("button", { name: "Share", exact: true })).toBeDisabled();
+});
+
+test("shared cards open ready links and delete incomplete uploads", async ({ page }) => {
+ await page.goto("/tests/ui/shared-recordings.html");
+ await page.getByRole("button", { name: "Product walkthrough", exact: true }).click();
+ await expect(page.getByRole("status")).toHaveText("Opened https://example.test/s/demo1");
+ await expect(page.getByRole("button", { name: "An interrupted upload", exact: true })).toBeDisabled();
+ await page.getByRole("button", { name: "Options for An interrupted upload", exact: true }).click();
+ await page.getByRole("menuitem", { name: "Delete recording", exact: true }).click();
+ await expect(page.getByRole("button", { name: "An interrupted upload", exact: true })).toHaveCount(0);
+ await page.getByRole("textbox", { name: "Search projects" }).fill("missing");
+ await expect(page.getByText("No matching projects", { exact: true })).toBeVisible();
+});
diff --git a/tests/ui/publish.html b/tests/ui/publish.html
new file mode 100644
index 00000000..dc7b7aae
--- /dev/null
+++ b/tests/ui/publish.html
@@ -0,0 +1 @@
+<!doctype html><html><head><meta charset="UTF-8"/><title>Publish preview</title></head><body><div id="root"></div><script type="module" src="./publish.tsx"></script></body></html>
\ No newline at end of file
diff --git a/tests/ui/publish.tsx b/tests/ui/publish.tsx
new file mode 100644
index 00000000..35d34c2e
--- /dev/null
+++ b/tests/ui/publish.tsx
@@ -0,0 +1,77 @@
+import { useState, type ComponentProps } from "react";
+import { createRoot } from "react-dom/client";
+import { I18nProvider, useI18n } from "@/contexts/I18nContext";
+import { EditorExportMenu } from "@/components/video-editor/layout/EditorExportMenu";
+import "@/index.css";
+import { loadEditorPreferences } from "@/components/video-editor/editorPreferences";
+import { useExportSettings } from "@/components/video-editor/export/useExportSettings";
+const noop = () => undefined;
+let reportUpload:
+ | ((event: { uploadId: string; uploadedBytes: number; totalBytes: number }) => void)
+ | undefined;
+window.electronAPI = {
+ cloudShareManage: async () => ({
+ success: true,
+ videos: new URLSearchParams(location.search).has("full")
+ ? Array(5).fill({ ready: true })
+ : [],
+ }),
+ onCloudShareProgress: (callback: typeof reportUpload) => {
+ reportUpload = callback;
+ return () => {
+ reportUpload = undefined;
+ };
+ },
+ discardExportedTemp: async () => ({}),
+ cloudShareUpload: async ({ uploadId }: { uploadId: string }) => {
+ await new Promise((resolve) => setTimeout(resolve, 800));
+ reportUpload?.({ uploadId, uploadedBytes: 50, totalBytes: 100 });
+ await new Promise((resolve) => setTimeout(resolve, 12000));
+ return { success: true, shareUrl: "https://example.test/s/preview" };
+ },
+ cloudShareCancel: async () => ({ success: true }),
+} as unknown as typeof window.electronAPI;
+function Preview() {
+ const [open, setOpen] = useState(false);
+ const [percentage, setPercentage] = useState(0);
+ const { t } = useI18n();
+ const [preferences] = useState(loadEditorPreferences);
+ const exportSettings = useExportSettings(preferences, [], []);
+ const props = {
+ t,
+ projectTitle: "Preview",
+ authToken: "fixture",
+ shareRequestNonce: 0,
+ exportSettings,
+ exportSession: {
+ showExportDropdown: open,
+ setShowExportDropdown: setOpen,
+ exportProgress: { percentage },
+ },
+ exportDimensions: { gifOutputDimensions: { width: 800, height: 450 } },
+ exportStatus: {},
+ handleOpenExportDropdown: () => setOpen(true),
+ handleExportDropdownClose: () => setOpen(false),
+ handleCancelExport: noop,
+ handleStartExportFromDropdown: noop,
+ prepareExportForShare: async () => {
+ setPercentage(0);
+ await new Promise((resolve) => setTimeout(resolve, 800));
+ setPercentage(50);
+ await new Promise((resolve) => setTimeout(resolve, 800));
+ setPercentage(100);
+ return "synthetic-preview.mp4";
+ },
+ onRequestShareSignIn: noop,
+ } as unknown as ComponentProps<typeof EditorExportMenu>;
+ return (
+ <div className="flex justify-end p-12">
+ <EditorExportMenu {...props} />
+ </div>
+ );
+}
+createRoot(document.getElementById("root")!).render(
+ <I18nProvider>
+ <Preview />
+ </I18nProvider>,
+);
diff --git a/tests/ui/shared-recordings.html b/tests/ui/shared-recordings.html
new file mode 100644
index 00000000..cd8cd895
--- /dev/null
+++ b/tests/ui/shared-recordings.html
@@ -0,0 +1 @@
+<!doctype html><html><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Shared recordings preview</title></head><body><div id="root"></div><script type="module" src="./shared-recordings.tsx"></script></body></html>
diff --git a/tests/ui/shared-recordings.tsx b/tests/ui/shared-recordings.tsx
new file mode 100644
index 00000000..6b6bb31d
--- /dev/null
+++ b/tests/ui/shared-recordings.tsx
@@ -0,0 +1,45 @@
+import { createRoot } from "react-dom/client";
+import { SharedRecordings } from "@/components/video-editor/cloud/SharedRecordings";
+import "@/index.css";
+
+// Local fixture: no account, recording, network request, or real deletion.
+let recordings = [
+ {
+ code: "demo1",
+ title: "Product walkthrough",
+ createdAt: new Date().toISOString(),
+ size: 42 * 1024 * 1024,
+ ready: true,
+ url: "https://example.test/s/demo1",
+ },
+ {
+ code: "demo2",
+ title: "An interrupted upload",
+ createdAt: new Date().toISOString(),
+ size: 120 * 1024 * 1024,
+ ready: false,
+ url: "https://example.test/s/demo2",
+ },
+];
+window.electronAPI = {
+ openExternalUrl: async (url: string) => {
+ document.getElementById("fixture-result")!.textContent = `Opened ${url}`;
+ return { success: true };
+ },
+ cloudShareManage: async (input: { action: string; shareCode?: string }) => {
+ if (input.action === "delete")
+ recordings = recordings.filter((video) => video.code !== input.shareCode);
+ return { success: true, videos: recordings };
+ },
+} as unknown as typeof window.electronAPI;
+createRoot(document.getElementById("root")!).render(
+ <main className="dashboard-surface mx-auto mt-3 max-w-6xl rounded-2xl bg-background px-7 pb-10 lg:px-10">
+ <SharedRecordings
+ token="fixture"
+ endpoint="https://example.test/api/upload"
+ standalone
+ accountLabel="Demo creator"
+ />
+ <p id="fixture-result" role="status" />
+ </main>,
+);