Skip to content

Open source CapCut alternative.

TypeScript

feat(site): elapsed clocks on long-running work

David Lee7bdf98f980f
diff --git a/site/src/cut/components/AiPanel.tsx b/site/src/cut/components/AiPanel.tsx
index 57b936e9..0e6eeb3b 100644
--- a/site/src/cut/components/AiPanel.tsx
+++ b/site/src/cut/components/AiPanel.tsx
@@ -26,7 +26,9 @@ import {
} from "lucide-react";
import Markdown from "react-markdown";
import { baseMarkdownComponents } from "./markdownComponents";
+import { LiveElapsed } from "./Elapsed";
import { SceneCard } from "./SceneCard";
+import { useElapsed } from "@/cut/hooks/useElapsed";
import { Button } from "@/components/ui/button";
import {
DropdownMenu,
@@ -562,7 +564,7 @@ function ChatSession({
<SceneCard />
{busy && (
<div className="ai-busy mt-1 flex items-center gap-1.5 text-[11.5px] text-muted-foreground">
- <CircleDashed className="size-3 animate-spin" /> Working…
+ <CircleDashed className="size-3 animate-spin" /> Working… <LiveElapsed />
</div>
)}
{error && (
@@ -829,6 +831,14 @@ function toolDuration(id: string | undefined, settled: boolean): string | null {
return t.sawRunning && t.end !== undefined ? formatDuration(t.end - t.start) : null;
}
+/** Live clock on a still-running tool chip. Its own component so the ticking
+ * re-render stays inside the chip — MessageView is memoized and only
+ * re-renders on stream chunks, which stop arriving while a tool runs. */
+function RunningToolClock({ start }: { start: number }) {
+ const elapsed = useElapsed(start);
+ return elapsed ? <span className="ml-auto tabular-nums text-[10px]">{elapsed}</span> : null;
+}
+
const MessageView = memo(function MessageView({ message }: { message: UIMessage }) {
if (message.role === "user") {
const text = message.parts.map((p) => (p.type === "text" ? p.text : "")).join("");
@@ -889,6 +899,11 @@ const MessageView = memo(function MessageView({ message }: { message: UIMessage
const failed = p.state === "output-error";
const done = p.state === "output-available";
const took = toolDuration(p.toolCallId, done || failed);
+ // A call still running shows a live clock from its observed start
+ // (settled chips show `took`; a call first seen already-done shows
+ // neither — its real start is unknown).
+ const runningSince =
+ !done && !failed && p.toolCallId ? toolTimes.get(p.toolCallId)?.start ?? null : null;
return (
<Fragment key={i}>
<details className="ai-tool group max-w-full">
@@ -904,6 +919,7 @@ const MessageView = memo(function MessageView({ message }: { message: UIMessage
{failed && <TriangleAlert className="size-3" />}
{!done && !failed && <CircleDashed className="size-3 animate-spin" />}
{took && <span className="ml-auto tabular-nums text-[10px]">{took}</span>}
+ {runningSince != null && <RunningToolClock start={runningSince} />}
</summary>
<pre className="mt-1 max-h-40 overflow-auto rounded-md bg-muted/70 p-2 font-mono text-[10px] leading-relaxed whitespace-pre-wrap">
{JSON.stringify({ input: p.input, output: p.output, error: p.errorText }, null, 2)}
diff --git a/site/src/cut/components/AudioPanel.tsx b/site/src/cut/components/AudioPanel.tsx
index ef9d31e4..3c80dff4 100644
--- a/site/src/cut/components/AudioPanel.tsx
+++ b/site/src/cut/components/AudioPanel.tsx
@@ -35,6 +35,7 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
+import { LiveElapsed } from "@/cut/components/Elapsed";
import { clearAssetDrag, setAssetDragData, setLibraryDragData } from "@/cut/lib/assetDrag";
import {
addLibraryAssetToProject,
@@ -270,6 +271,7 @@ function VoiceGenerator({ projectId }: { projectId: string }) {
<div className="flex items-center gap-2 text-[11px] text-muted-foreground">
<Loader2 className="size-3.5 shrink-0 animate-spin" />
{pending === 1 ? "Generating…" : `Generating ${pending}…`}
+ <LiveElapsed />
</div>
)}
</div>
@@ -561,7 +563,7 @@ function ProjectAudio({
))}
{importing && (
<div className="flex items-center gap-2 rounded-lg border border-dashed border-input px-2.5 py-2 text-[11px] text-muted-foreground">
- <Loader2 className="size-3.5 animate-spin" /> Importing…
+ <Loader2 className="size-3.5 animate-spin" /> Importing… <LiveElapsed />
</div>
)}
</div>
diff --git a/site/src/cut/components/ChatAssets.tsx b/site/src/cut/components/ChatAssets.tsx
index 7876ca57..831cb815 100644
--- a/site/src/cut/components/ChatAssets.tsx
+++ b/site/src/cut/components/ChatAssets.tsx
@@ -13,6 +13,7 @@ import {
type AssetRef,
type AssetRefKind,
} from "@/cut/lib/assetRef";
+import { useElapsed } from "@/cut/hooks/useElapsed";
import { useGenerate } from "@/cut/lib/generate";
import { lightboxItemFromRef, useLightbox } from "@/cut/lib/lightbox";
import { usePreviewAudio } from "@/cut/lib/previewAudio";
@@ -89,6 +90,7 @@ export function ToolOutputAssets({ output }: { output: unknown }) {
* render still in flight when the page closed has no card afterwards. */
export function ChatVideoJobCard({ jobId }: { jobId: string }) {
const job = useGenerate((s) => s.jobs.find((j) => j.id === jobId));
+ const elapsed = useElapsed(job?.status === "running" ? job.startedAt : null);
if (!job) return null;
if (job.status === "done") return job.assetId ? <ChatProjectAsset assetId={job.assetId} /> : null;
return (
@@ -108,7 +110,14 @@ export function ChatVideoJobCard({ jobId }: { jobId: string }) {
job.status === "error" ? "text-red-600" : "text-muted-foreground"
)}
>
- {job.status === "running" ? "Rendering…" : <HostedErrorText error={job.error} />}
+ {job.status === "running" ? (
+ <>
+ Rendering…{" "}
+ {elapsed && <span className="tabular-nums text-muted-foreground/80">{elapsed}</span>}
+ </>
+ ) : (
+ <HostedErrorText error={job.error} />
+ )}
</div>
</div>
</div>
diff --git a/site/src/cut/components/Elapsed.tsx b/site/src/cut/components/Elapsed.tsx
new file mode 100644
index 00000000..b0225018
--- /dev/null
+++ b/site/src/cut/components/Elapsed.tsx
@@ -0,0 +1,16 @@
+"use client";
+
+import { useState } from "react";
+import { useElapsed } from "../hooks/useElapsed";
+
+/** A ticking "m:ss" that starts counting when it mounts — drop it beside a
+ * long-running spinner label ("Rendering… 0:42") that renders only while the
+ * work runs. Surfaces with a real start timestamp should use the useElapsed
+ * hook instead so a remount doesn't reset the clock. */
+export function LiveElapsed({ className }: { className?: string }) {
+ const [startedAt] = useState(() => Date.now());
+ const elapsed = useElapsed(startedAt);
+ return elapsed ? (
+ <span className={className ?? "tabular-nums opacity-80"}>{elapsed}</span>
+ ) : null;
+}
diff --git a/site/src/cut/components/ExportDialog.tsx b/site/src/cut/components/ExportDialog.tsx
index 053d3186..5d74ad10 100644
--- a/site/src/cut/components/ExportDialog.tsx
+++ b/site/src/cut/components/ExportDialog.tsx
@@ -10,6 +10,7 @@ import {
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
+import { useElapsed } from "@/cut/hooks/useElapsed";
import { EXPORT_PRESETS, originalSettings, presetSettings } from "@/cut/lib/exportClient";
import { useExport } from "@/cut/lib/exportStore";
import { useEditor } from "@/cut/lib/store";
@@ -22,6 +23,8 @@ export function ExportDialog() {
const assets = useEditor((s) => s.assets);
const status = useExport((s) => s.status);
const ratio = useExport((s) => s.ratio);
+ const startedAt = useExport((s) => s.startedAt);
+ const elapsed = useElapsed(status === "running" ? startedAt : null);
const error = useExport((s) => s.error);
// "Original" leads: sized from the footage on the timeline, so it is always
// the highest option. The fixed presets follow, flipped to the aspect.
@@ -114,7 +117,9 @@ export function ExportDialog() {
/>
</div>
<div className="mt-2.5 flex justify-end text-xs text-muted-foreground">
- <span className="font-mono tabular-nums">{Math.round(ratio * 100)}%</span>
+ <span className="font-mono tabular-nums">
+ {Math.round(ratio * 100)}%{elapsed ? ` · ${elapsed}` : ""}
+ </span>
</div>
<p className="mt-3 text-center text-xs text-muted-foreground">
Rendering in the background. You can keep editing, or close this
diff --git a/site/src/cut/components/ExportStatus.tsx b/site/src/cut/components/ExportStatus.tsx
index b0acc1c7..293f0555 100644
--- a/site/src/cut/components/ExportStatus.tsx
+++ b/site/src/cut/components/ExportStatus.tsx
@@ -2,6 +2,7 @@
import { Check, FolderOpen, Loader2, X } from "lucide-react";
import { Button } from "@/components/ui/button";
+import { useElapsed } from "@/cut/hooks/useElapsed";
import { revealExport } from "@/cut/lib/exportClient";
import { useExport } from "@/cut/lib/exportStore";
import { useEditor } from "@/cut/lib/store";
@@ -10,11 +11,12 @@ import { useEditor } from "@/cut/lib/store";
* closed, so the render keeps going and the result is still one click away. */
export function ExportStatus() {
const status = useExport((s) => s.status);
- const stage = useExport((s) => s.stage);
const ratio = useExport((s) => s.ratio);
const outName = useExport((s) => s.outName);
const projectId = useExport((s) => s.projectId);
+ const startedAt = useExport((s) => s.startedAt);
const exportOpen = useEditor((s) => s.exportOpen);
+ const elapsed = useElapsed(status === "running" ? startedAt : null);
// The dialog owns the UI while it's open.
if (exportOpen || status === "idle") return null;
@@ -25,7 +27,10 @@ export function ExportStatus() {
<>
<Loader2 className="size-4 animate-spin text-primary" />
<span className="text-xs font-medium">
- Exporting… <span className="tabular-nums text-muted-foreground">{Math.round(ratio * 100)}%</span>
+ Exporting…{" "}
+ <span className="tabular-nums text-muted-foreground">
+ {Math.round(ratio * 100)}%{elapsed ? ` · ${elapsed}` : ""}
+ </span>
</span>
<Button
variant="ghost"
diff --git a/site/src/cut/components/GeneratePanel.tsx b/site/src/cut/components/GeneratePanel.tsx
index 997ebc49..e89bedda 100644
--- a/site/src/cut/components/GeneratePanel.tsx
+++ b/site/src/cut/components/GeneratePanel.tsx
@@ -12,6 +12,7 @@ import {
useRefCandidates,
useAssetDrop,
} from "@/cut/lib/assetRef";
+import { useElapsed } from "@/cut/hooks/useElapsed";
import { genPulseOverlay, useGenPulse } from "@/cut/lib/genNotify";
import { signInUrl, useGenerate, useSignedIn, type GenerateJob } from "@/cut/lib/generate";
import { useLightbox } from "@/cut/lib/lightbox";
@@ -286,6 +287,7 @@ export function GenerateVideoPanel({ projectId }: { projectId: string }) {
function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {
const asset = useEditor((s) => s.assets.find((a) => a.id === job.assetId));
const pulse = useGenPulse("video", job.assetId);
+ const elapsed = useElapsed(job.status === "running" ? job.startedAt : null);
const tileRef = useRef<HTMLDivElement>(null);
const videoRef = useRef<HTMLVideoElement>(null);
@@ -307,7 +309,16 @@ function JobRow({ job, handle }: { job: GenerateJob; handle?: string }) {
job.status === "error" ? "text-red-600" : "text-muted-foreground"
)}
>
- {job.status === "running" ? "Rendering…" : <HostedErrorText error={job.error} />}
+ {job.status === "running" ? (
+ <>
+ Rendering…{" "}
+ {elapsed && (
+ <span className="tabular-nums text-muted-foreground/80">{elapsed}</span>
+ )}
+ </>
+ ) : (
+ <HostedErrorText error={job.error} />
+ )}
</div>
</div>
{job.status !== "running" && (
diff --git a/site/src/cut/components/ImageGenPanel.tsx b/site/src/cut/components/ImageGenPanel.tsx
index 385367d5..148ab6f8 100644
--- a/site/src/cut/components/ImageGenPanel.tsx
+++ b/site/src/cut/components/ImageGenPanel.tsx
@@ -8,7 +8,8 @@ import { SectionTitle } from "@/cut/components/SectionTitle";
import { clearAssetDrag, setAssetDragData } from "@/cut/lib/assetDrag";
import { collectRefs, mentionToken, useRefCandidates, useAssetDrop } from "@/cut/lib/assetRef";
import { genPulseOverlay, useGenPulse } from "@/cut/lib/genNotify";
-import { signInUrl, useGenerate, useSignedIn } from "@/cut/lib/generate";
+import { useElapsed } from "@/cut/hooks/useElapsed";
+import { signInUrl, useGenerate, useSignedIn, type GenerateJob } from "@/cut/lib/generate";
import {
IMAGE_RESOLUTION_LABEL,
useImageGen,
@@ -184,31 +185,7 @@ export function ImageGenPanel({ projectId }: { projectId: string }) {
{jobs
.filter((j) => j.status !== "done")
.map((j) => (
- <div key={j.id} className="group flex shrink-0 items-center gap-2">
- {j.status === "running" && (
- <Loader2 className="size-3.5 shrink-0 animate-spin text-muted-foreground" />
- )}
- <div className="min-w-0 flex-1">
- <div className="truncate text-[11.5px] font-medium">{j.prompt}</div>
- <div
- className={cn(
- "text-[10.5px] leading-snug break-words",
- j.status === "error" ? "text-red-600" : "text-muted-foreground"
- )}
- >
- {j.status === "running" ? "Generating…" : <HostedErrorText error={j.error} />}
- </div>
- </div>
- {j.status === "error" && (
- <button
- title="Dismiss"
- className={cn(cardIconButton, "opacity-0 group-hover:opacity-100")}
- onClick={() => useGenerate.getState().dismiss(j.id)}
- >
- <Trash2 className="size-3.5" />
- </button>
- )}
- </div>
+ <ImageJobRow key={j.id} job={j} />
))}
{generated.length > 0 && (
@@ -329,3 +306,43 @@ function GeneratedTile({
</div>
);
}
+
+/** A generation in flight (or failed) as a compact status row with a live
+ * elapsed clock while it renders. */
+function ImageJobRow({ job }: { job: GenerateJob }) {
+ const elapsed = useElapsed(job.status === "running" ? job.startedAt : null);
+ return (
+ <div className="group flex shrink-0 items-center gap-2">
+ {job.status === "running" && (
+ <Loader2 className="size-3.5 shrink-0 animate-spin text-muted-foreground" />
+ )}
+ <div className="min-w-0 flex-1">
+ <div className="truncate text-[11.5px] font-medium">{job.prompt}</div>
+ <div
+ className={cn(
+ "text-[10.5px] leading-snug break-words",
+ job.status === "error" ? "text-red-600" : "text-muted-foreground"
+ )}
+ >
+ {job.status === "running" ? (
+ <>
+ Generating…{" "}
+ {elapsed && <span className="tabular-nums text-muted-foreground/80">{elapsed}</span>}
+ </>
+ ) : (
+ <HostedErrorText error={job.error} />
+ )}
+ </div>
+ </div>
+ {job.status === "error" && (
+ <button
+ title="Dismiss"
+ className={cn(cardIconButton, "opacity-0 group-hover:opacity-100")}
+ onClick={() => useGenerate.getState().dismiss(job.id)}
+ >
+ <Trash2 className="size-3.5" />
+ </button>
+ )}
+ </div>
+ );
+}
diff --git a/site/src/cut/components/LibraryView.tsx b/site/src/cut/components/LibraryView.tsx
index 67f1c5d3..595d57c4 100644
--- a/site/src/cut/components/LibraryView.tsx
+++ b/site/src/cut/components/LibraryView.tsx
@@ -16,6 +16,7 @@ import {
Upload,
} from "lucide-react";
import { Button } from "@/components/ui/button";
+import { LiveElapsed } from "@/cut/components/Elapsed";
import {
AlertDialog,
AlertDialogAction,
@@ -279,7 +280,9 @@ export function LibraryView() {
{uploading > 0 && (
<div className="flex aspect-square flex-col items-center justify-center gap-2 rounded-xl border border-dashed border-input text-xs text-muted-foreground">
<Loader2 className="size-4 animate-spin" />
- Uploading…
+ <span>
+ Uploading… <LiveElapsed />
+ </span>
</div>
)}
</Marquee>
@@ -322,6 +325,11 @@ export function LibraryView() {
{importing ? <Loader2 className="animate-spin" /> : <LinkIcon />} Import
</Button>
</div>
+ {importing && (
+ <p className="text-xs text-muted-foreground">
+ Downloading… <LiveElapsed />
+ </p>
+ )}
{urlError && <p className="text-xs text-destructive">{urlError}</p>}
</div>
</div>
diff --git a/site/src/cut/components/ProjectsHome.tsx b/site/src/cut/components/ProjectsHome.tsx
index 5c8451dd..5e0f2ffa 100644
--- a/site/src/cut/components/ProjectsHome.tsx
+++ b/site/src/cut/components/ProjectsHome.tsx
@@ -17,6 +17,7 @@ import {
Unplug,
} from "lucide-react";
import { Button } from "@/components/ui/button";
+import { LiveElapsed } from "@/cut/components/Elapsed";
import {
Dialog,
DialogContent,
@@ -339,8 +340,11 @@ export function ProjectsHome() {
}}
>
{importing > 0 && (
- <div className="pointer-events-none fixed right-6 bottom-6 z-50 grid size-11 place-items-center rounded-full bg-foreground/90 text-background shadow-lg">
+ <div className="pointer-events-none fixed right-6 bottom-6 z-50 flex items-center gap-2 rounded-full bg-foreground/90 px-3.5 py-2.5 text-background shadow-lg">
<Loader2 className="size-5 animate-spin" />
+ <span className="text-xs font-medium">
+ Importing… <LiveElapsed className="tabular-nums" />
+ </span>
</div>
)}
{!engineDown && projects && hasContent && (
diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsx
index 7d55297b..fd9478c5 100644
--- a/site/src/cut/components/SidePanel.tsx
+++ b/site/src/cut/components/SidePanel.tsx
@@ -3,6 +3,7 @@
import { Fragment, useEffect, useRef, useState } from "react";
import { Captions, Check, Clapperboard, ClipboardList, Copy, Film, FolderOpen, FolderPlus, Image as ImageIcon, Layers, Loader2, Music, Plus, Trash2, Upload } from "lucide-react";
import { Button } from "@/components/ui/button";
+import { LiveElapsed } from "@/cut/components/Elapsed";
import {
AlertDialog,
AlertDialogAction,
@@ -285,7 +286,9 @@ function MediaPanel({
{importing && (
<div className="flex aspect-square flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-input text-[11px] text-muted-foreground">
<Loader2 className="size-4 animate-spin" />
- Importing…
+ <span>
+ Importing… <LiveElapsed />
+ </span>
</div>
)}
</div>
diff --git a/site/src/cut/components/SubtitlesPanel.tsx b/site/src/cut/components/SubtitlesPanel.tsx
index 93748750..7a5d253e 100644
--- a/site/src/cut/components/SubtitlesPanel.tsx
+++ b/site/src/cut/components/SubtitlesPanel.tsx
@@ -14,6 +14,7 @@ import {
subtitleLaneCount,
trackLocale,
} from "@/cut/lib/subtitles";
+import { useElapsed } from "@/cut/hooks/useElapsed";
import { TIMELINE_H_MIN, useEditor } from "@/cut/lib/store";
import { PLATE_PAD_X, PLATE_PAD_Y, PLATE_RADIUS, plateFill } from "@/cut/lib/textRender";
import {
@@ -41,6 +42,13 @@ const LOCALES = [
/** Give the cue track room when it appears. */
const TIMELINE_H_WITH_SUBS = Math.max(TIMELINE_H_MIN, 276);
+/** Ticking clock beside the running transcription/translation label. */
+function SubtitleElapsed() {
+ const startedAt = useEditor((s) => s.subtitleStartedAt);
+ const elapsed = useElapsed(startedAt);
+ return elapsed ? <span className="tabular-nums text-muted-foreground">{elapsed}</span> : null;
+}
+
/** A track's short pill label: its language code (EN, KO, …). */
function laneLabel(subs: SubtitlesBlock, lane: number): string {
return trackLocale(subs, lane).split("-")[0].toUpperCase();
@@ -350,7 +358,8 @@ function EmptyState({
<div className="sub-generating flex flex-col items-center gap-3 px-6 pt-10 text-center">
<Loader2 className="size-5 animate-spin text-muted-foreground" />
<p className="text-[13px] font-medium">
- {translating ? "Translating your captions…" : "Transcribing on this Mac…"}
+ {translating ? "Translating your captions…" : "Transcribing on this Mac…"}{" "}
+ <SubtitleElapsed />
</p>
<p className="text-[11.5px] leading-relaxed text-muted-foreground">
Runs in the background — keep editing. Captions appear here when
diff --git a/site/src/cut/hooks/useElapsed.ts b/site/src/cut/hooks/useElapsed.ts
new file mode 100644
index 00000000..66625e65
--- /dev/null
+++ b/site/src/cut/hooks/useElapsed.ts
@@ -0,0 +1,22 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { formatElapsed } from "../lib/time";
+
+// Live elapsed readouts for long-running work (renders, exports, imports,
+// transcription). Every surface that spins for more than a moment shows one
+// beside its label, so the user always sees time passing.
+
+/** Ticking "m:ss" since `startedAt` (ms epoch), or null without one. The
+ * first second may read 0:00 — the clock advances only from its interval,
+ * never synchronously in render. */
+export function useElapsed(startedAt: number | null | undefined): string | null {
+ const active = startedAt != null;
+ const [now, setNow] = useState(() => Date.now());
+ useEffect(() => {
+ if (!active) return;
+ const t = setInterval(() => setNow(Date.now()), 1000);
+ return () => clearInterval(t);
+ }, [active]);
+ return active ? formatElapsed(now - startedAt) : null;
+}
diff --git a/site/src/cut/lib/exportStore.ts b/site/src/cut/lib/exportStore.ts
index 0a22f8ed..2560bba0 100644
--- a/site/src/cut/lib/exportStore.ts
+++ b/site/src/cut/lib/exportStore.ts
@@ -20,6 +20,9 @@ interface ExportState {
status: Status;
stage: string;
ratio: number;
+ /** Epoch ms when this export started (or was rejoined) — the running chip
+ * and dialog show a ticking elapsed from it. */
+ startedAt: number | null;
outName?: string;
error?: string;
projectId: string | null;
@@ -35,6 +38,7 @@ export const useExport = create<ExportState>((set, get) => ({
status: "idle",
stage: "",
ratio: 0,
+ startedAt: null,
projectId: null,
handle: null,
@@ -44,6 +48,7 @@ export const useExport = create<ExportState>((set, get) => ({
status: "running",
stage: "Preparing",
ratio: 0,
+ startedAt: Date.now(),
error: undefined,
outName: undefined,
projectId,
@@ -76,7 +81,15 @@ export const useExport = create<ExportState>((set, get) => ({
.catch(() => [])) as { id: string; status: string; progress: number; outName?: string }[];
const running = list.find((j) => j.status === "running");
if (!running) return;
- set({ status: "running", stage: "Rendering", ratio: running.progress, projectId });
+ // The true start predates the rejoin; counting from here still shows time
+ // moving, which is the point of the clock.
+ set({
+ status: "running",
+ stage: "Rendering",
+ ratio: running.progress,
+ startedAt: Date.now(),
+ projectId,
+ });
pollExport(running.id, (stage, ratio) => set({ stage, ratio }))
.then((outName) => {
downloadExport(running.id, outName);
diff --git a/site/src/cut/lib/generate.ts b/site/src/cut/lib/generate.ts
index 36151755..3560075b 100644
--- a/site/src/cut/lib/generate.ts
+++ b/site/src/cut/lib/generate.ts
@@ -28,6 +28,8 @@ export interface GenerateJob {
projectId: string;
kind: "image" | "video";
prompt: string;
+ /** Epoch ms when the render started — live cards show a ticking elapsed. */
+ startedAt: number;
status: "running" | "done" | "error";
error?: string;
/** The project asset the finished generation landed as. */
@@ -323,6 +325,7 @@ export const useGenerate = create<GenerateState>((set, get) => {
projectId,
kind: "image",
prompt,
+ startedAt: Date.now(),
status: "running",
...(opts?.chatId ? { chatId: opts.chatId } : {}),
};
@@ -397,6 +400,7 @@ export const useGenerate = create<GenerateState>((set, get) => {
projectId,
kind: "video",
prompt,
+ startedAt: Date.now(),
status: "running",
...(opts?.chatId ? { chatId: opts.chatId } : {}),
};
diff --git a/site/src/cut/lib/store.ts b/site/src/cut/lib/store.ts
index 26b1bf5c..10e2d41f 100644
--- a/site/src/cut/lib/store.ts
+++ b/site/src/cut/lib/store.ts
@@ -122,6 +122,9 @@ export interface EditorState {
subtitles: SubtitlesBlock;
subtitleStatus: SubtitleStatus;
subtitleError: string | null;
+ /** Epoch ms when the running transcription/translation started — the panel
+ * shows a ticking elapsed beside its spinner. */
+ subtitleStartedAt: number | null;
exportOpen: boolean;
/** OS file drag in flight: "media" when it carries video/audio/image (so the
* timeline is a valid target), "other" for text-only drags, null when idle. */
@@ -532,6 +535,7 @@ export const useEditor = create<EditorState>((set, get) => {
subtitleLane: 0,
subtitleStatus: "idle",
subtitleError: null,
+ subtitleStartedAt: null,
exportOpen: false,
dropActive: null,
aiOpen: typeof window !== "undefined" && localStorage.getItem("cut-ai-open") === "1",
@@ -1643,7 +1647,7 @@ export const useEditor = create<EditorState>((set, get) => {
]),
audio,
};
- set({ subtitleStatus: "running", subtitleError: null });
+ set({ subtitleStatus: "running", subtitleError: null, subtitleStartedAt: Date.now() });
try {
const cues = await runTranscription(projectId, spec);
if (cues === null) return; // switched projects mid-run
@@ -1714,7 +1718,7 @@ export const useEditor = create<EditorState>((set, get) => {
],
audio: [],
};
- set({ subtitleStatus: "running", subtitleError: null });
+ set({ subtitleStatus: "running", subtitleError: null, subtitleStartedAt: Date.now() });
try {
const cues = await runTranscription(projectId, spec);
if (cues === null) return; // switched projects mid-run
@@ -1766,7 +1770,7 @@ export const useEditor = create<EditorState>((set, get) => {
const duration = totalDuration(s.clips);
const lane = s.subtitleLane;
const epoch = laneEpoch;
- set({ subtitleStatus: "running", subtitleError: null });
+ set({ subtitleStatus: "running", subtitleError: null, subtitleStartedAt: Date.now() });
try {
const frames = await captureTimelineFrames(spans);
if (frames.length === 0) throw new Error("Could not read any frames from the cut.");
@@ -1831,6 +1835,7 @@ export const useEditor = create<EditorState>((set, get) => {
subtitles: { ...cur.subtitles, style },
subtitleStatus: "running",
subtitleError: null,
+ subtitleStartedAt: Date.now(),
}));
// Rewrite only the active track — other languages keep their text.
const cues = get().subtitles.cues.filter((c) => laneOf(c) === lane);
@@ -1887,7 +1892,7 @@ export const useEditor = create<EditorState>((set, get) => {
const locale = trackLocale(s.subtitles, lane);
const projectId = s.projectId;
const epoch = laneEpoch;
- set({ subtitleStatus: "running", subtitleError: null });
+ set({ subtitleStatus: "running", subtitleError: null, subtitleStartedAt: Date.now() });
try {
const res = await apiFetch("/api/cut/ai/captions", {
method: "POST",
diff --git a/site/src/cut/lib/time.ts b/site/src/cut/lib/time.ts
index 29c4168e..0f3fa7d7 100644
--- a/site/src/cut/lib/time.ts
+++ b/site/src/cut/lib/time.ts
@@ -1,3 +1,9 @@
+/** Elapsed wall-clock as "m:ss" — 63400ms -> "1:03". */
+export function formatElapsed(ms: number) {
+ const t = Math.max(0, Math.floor(ms / 1000));
+ return `${Math.floor(t / 60)}:${String(t % 60).padStart(2, "0")}`;
+}
+
/** 63.4 -> "1:03.4" | 8.02 -> "0:08.0" */
export function formatTime(t: number) {
const clamped = Math.max(0, t);