Skip to content

Open source CapCut alternative.

TypeScript

feat(site): fold Library into Media and rework side-panel navigation

David Leed56d3c8cc78
diff --git a/site/src/cut/components/AiPanel.tsx b/site/src/cut/components/AiPanel.tsx
index 36e1a21d..9263a001 100644
--- a/site/src/cut/components/AiPanel.tsx
+++ b/site/src/cut/components/AiPanel.tsx
@@ -1236,7 +1236,7 @@ function MessageAssetCard({ asset }: { asset: AssetRef }) {
});
}}
>
- <FolderPlus /> Add to library
+ <FolderPlus /> Add to Library
</DropdownMenuItem>
)}
</DropdownMenuContent>
diff --git a/site/src/cut/components/AudioPanel.tsx b/site/src/cut/components/AudioPanel.tsx
index a44755dd..3abf9a30 100644
--- a/site/src/cut/components/AudioPanel.tsx
+++ b/site/src/cut/components/AudioPanel.tsx
@@ -24,6 +24,7 @@ import { Button } from "@/components/ui/button";
import { DictationControl } from "@/cut/components/MicDictation";
import { PillSelect } from "@/cut/components/PillSelect";
import { SectionTitle } from "@/cut/components/SectionTitle";
+import { SubTabs } from "@/cut/components/SubTabs";
import {
DropdownMenu,
DropdownMenuContent,
@@ -108,10 +109,17 @@ export function AudioPanel({
return (
<>
- {/* The side panel's floating close button sits on this corner; the
- right padding keeps the toggle clear of it. */}
- <div className="shrink-0 pt-4 pb-3 pr-12 pl-3.5">
- <AudioSubTabs value={sub} onChange={onSub} />
+ {/* PanelHead's height, so the side panel's floating close button lands
+ on the toggle's centerline; the right padding keeps clear of it. */}
+ <div className="flex h-12 shrink-0 items-center pr-12 pl-3.5">
+ <SubTabs
+ tabs={[
+ { id: "voice", label: "Voice" },
+ { id: "music", label: "Music" },
+ ]}
+ value={sub}
+ onChange={onSub}
+ />
</div>
<ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-5 px-3.5 pb-4">
@@ -136,39 +144,6 @@ export function AudioPanel({
);
}
-/** Voice / Music segmented toggle at the top of the Audio tab. */
-function AudioSubTabs({
- value,
- onChange,
-}: {
- value: "voice" | "music";
- onChange: (v: "voice" | "music") => void;
-}) {
- const tabs: { id: "voice" | "music"; label: string }[] = [
- { id: "voice", label: "Voice" },
- { id: "music", label: "Music" },
- ];
- return (
- <div className="flex rounded-lg bg-muted p-0.5 text-[11.5px]">
- {tabs.map((t) => (
- <button
- key={t.id}
- type="button"
- onClick={() => onChange(t.id)}
- className={cn(
- "flex-1 rounded-md px-3 py-0.5 font-medium transition-colors",
- value === t.id
- ? "bg-background text-foreground shadow-sm"
- : "text-muted-foreground hover:text-foreground"
- )}
- >
- {t.label}
- </button>
- ))}
- </div>
- );
-}
-
/** The Music generator: describe a mood, pick a length and how many takes, and
* each generated instrumental lands under "Generated music" to drag onto the
* soundtrack. Mirrors VoiceGenerator's shape — several syntheses can run at
diff --git a/site/src/cut/components/ElementsPanel.tsx b/site/src/cut/components/ElementsPanel.tsx
index e6ac64b4..33132f24 100644
--- a/site/src/cut/components/ElementsPanel.tsx
+++ b/site/src/cut/components/ElementsPanel.tsx
@@ -1,10 +1,9 @@
"use client";
-import { ChevronLeft, ChevronRight, Sparkles } from "lucide-react";
import { Tile } from "@/cut/components/PanelTile";
-import { SectionTitle } from "@/cut/components/SectionTitle";
-import { clearElementDrag, setElementDragData, type ElementDrag } from "@/cut/lib/assetDrag";
-import { PICKED_RING, useAssetPick } from "@/cut/lib/assetPick";
+import { SubTabs } from "@/cut/components/SubTabs";
+import { clearElementDrag, setElementDragData } from "@/cut/lib/assetDrag";
+import { PICKED_RING, pickGridNav, useAssetPick } from "@/cut/lib/assetPick";
import { useEditor } from "@/cut/lib/store";
import { SHAPE_LABELS, type ShapeKind } from "@/cut/lib/types";
import { useLocalPref } from "@/cut/lib/uiState";
@@ -13,107 +12,52 @@ import { CreateSticker, StickerTile, useProjectStickers } from "./Stickers";
import { ScrollArea } from "@/components/ui/scroll-area";
/**
- * The Elements tab: what you lay over the picture — the project's stickers
- * and the shapes.
- *
- * It browses in two levels. The top level is a shelf: each category shows a
- * row of what's in it and a "View all" into the category's own full grid.
- * The chips jump straight to a category, and the back arrow returns to the
- * shelf. A click picks a tile and nothing else, wherever it is; dragging one
- * onto the timeline is what places it (`assetPick.ts`).
+ * The Elements tab: what you lay over the picture. A segmented toggle at the
+ * top switches between the project's stickers and the shapes, each a grid of
+ * tiles. A click picks a tile and nothing else; dragging one onto the
+ * timeline is what places it (`assetPick.ts`).
*/
type Category = "stickers" | "shapes";
-const CATEGORIES: { id: Category; label: string }[] = [
+const CATEGORIES = [
{ id: "stickers", label: "Stickers" },
{ id: "shapes", label: "Shapes" },
-];
+] as const;
const SHAPE_KINDS = Object.keys(SHAPE_LABELS) as ShapeKind[];
-/** How many of a category the shelf shows before "View all". */
-const PEEK = 4;
-
export function ElementsPanel({ projectId }: { projectId: string }) {
const readOnly = useEditor((s) => s.readOnly);
- const [view, setView] = useLocalPref<Category | "all">(
- "cut-elements-view",
- "all",
- (v) => v === "all" || CATEGORIES.some((c) => c.id === v)
+ const [view, setView] = useLocalPref<Category>("cut-elements-view", "stickers", (v) =>
+ CATEGORIES.some((c) => c.id === v)
);
const { stickers, handleOf } = useProjectStickers();
- const stickerTiles = (limit?: number) =>
- (limit ? stickers.slice(0, limit) : stickers).map((a) => (
- <StickerTile
- key={a.id}
- asset={a}
- projectId={projectId}
- handle={handleOf(a.id)}
- readOnly={readOnly}
- />
- ));
-
return (
<>
- <div className="flex h-12 shrink-0 items-center gap-1 pr-2.5 pl-4">
- {view !== "all" && (
- <button
- type="button"
- title="All elements"
- aria-label="All elements"
- className="-ml-2 grid size-6 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
- onClick={() => setView("all")}
- >
- <ChevronLeft className="size-4" />
- </button>
- )}
- <span className="text-sm font-semibold tracking-tight">
- {view === "all" ? "Elements" : CATEGORIES.find((c) => c.id === view)?.label}
- </span>
+ {/* PanelHead's height, so the side panel's floating close button lands
+ on the toggle's centerline; the right padding keeps clear of it. */}
+ <div className="flex h-12 shrink-0 items-center pr-12 pl-3.5">
+ <SubTabs tabs={CATEGORIES} value={view} onChange={setView} />
</div>
<ScrollArea className="min-h-0 flex-1" contentClassName="flex flex-col gap-4 px-3.5 pb-4">
- <div className="flex shrink-0 flex-wrap gap-1.5">
- <Chip active={view === "all"} onClick={() => setView("all")}>
- All
- </Chip>
- {CATEGORIES.map((c) => (
- <Chip key={c.id} active={view === c.id} onClick={() => setView(c.id)}>
- {c.label}
- </Chip>
- ))}
- </div>
-
- {view === "all" && (
- <>
- <Section title="Stickers" onViewAll={() => setView("stickers")}>
- <div className="grid grid-cols-4 gap-1.5">
- {!readOnly && (
- <PeekTile title="Create a sticker" onClick={() => setView("stickers")}>
- <Sparkles className="size-4 text-muted-foreground" />
- </PeekTile>
- )}
- {stickerTiles(readOnly ? PEEK : PEEK - 1)}
- </div>
- </Section>
-
- <Section title="Shapes" onViewAll={() => setView("shapes")}>
- <div className="grid grid-cols-4 gap-1.5">
- {SHAPE_KINDS.slice(0, PEEK).map((k) => (
- <ShapePeek key={k} shape={k} />
- ))}
- </div>
- </Section>
- </>
- )}
-
{view === "stickers" && (
<>
{!readOnly && <CreateSticker projectId={projectId} />}
{stickers.length > 0 ? (
- <div className="grid shrink-0 grid-cols-2 gap-1.5">{stickerTiles()}</div>
+ <div className="grid shrink-0 grid-cols-2 gap-1.5" onKeyDown={pickGridNav}>
+ {stickers.map((a) => (
+ <StickerTile
+ key={a.id}
+ asset={a}
+ projectId={projectId}
+ handle={handleOf(a.id)}
+ readOnly={readOnly}
+ />
+ ))}
+ </div>
) : (
<p className="px-2 py-6 text-center text-xs leading-relaxed text-balance text-muted-foreground">
Stickers you make land here, cut out and ready to place.
@@ -123,7 +67,7 @@ export function ElementsPanel({ projectId }: { projectId: string }) {
)}
{view === "shapes" && (
- <div className="grid shrink-0 grid-cols-3 gap-1.5">
+ <div className="grid shrink-0 grid-cols-3 gap-1.5" onKeyDown={pickGridNav}>
{SHAPE_KINDS.map((k) => (
<ShapeTile key={k} shape={k} />
))}
@@ -134,120 +78,15 @@ export function ElementsPanel({ projectId }: { projectId: string }) {
);
}
-/** A category filter at the top of the panel; picking one opens its grid. */
-function Chip({
- active,
- onClick,
- children,
-}: {
- active: boolean;
- onClick: () => void;
- children: React.ReactNode;
-}) {
- return (
- <button
- type="button"
- aria-pressed={active}
- onClick={onClick}
- className={cn(
- "rounded-full border px-2.5 py-1 text-[11.5px] font-medium transition-colors",
- active
- ? "border-primary bg-primary text-primary-foreground"
- : "border-input text-muted-foreground hover:bg-muted hover:text-foreground"
- )}
- >
- {children}
- </button>
- );
-}
-
-/** One shelf row: the category's name, a way into it, and its peek. */
-function Section({
- title,
- onViewAll,
- children,
-}: {
- title: string;
- onViewAll: () => void;
- children: React.ReactNode;
-}) {
- return (
- <section className="flex shrink-0 flex-col gap-1.5">
- <div className="flex items-center justify-between gap-2">
- <SectionTitle>{title}</SectionTitle>
- <button
- type="button"
- className="flex items-center gap-0.5 text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground"
- onClick={onViewAll}
- >
- View all
- <ChevronRight className="size-3" />
- </button>
- </div>
- {children}
- </section>
- );
-}
-
-/** A square on a shelf row — the preview carries the meaning, so the name
- * rides the tooltip and the grid inside the category carries the label. */
-function PeekTile({
- title,
- onClick,
- picked,
- drag,
- children,
-}: {
- title: string;
- onClick: () => void;
- picked?: boolean;
- /** What this tile places when dragged onto the timeline. */
- drag?: ElementDrag;
- children: React.ReactNode;
-}) {
- return (
- <button
- type="button"
- title={title}
- aria-label={title}
- aria-pressed={picked}
- draggable={!!drag}
- onDragStart={drag ? (e) => setElementDragData(e, drag) : undefined}
- onDragEnd={drag ? clearElementDrag : undefined}
- className={cn(
- "grid aspect-square w-full place-items-center overflow-hidden rounded-lg border border-border p-1.5 transition-colors hover:bg-muted/60",
- picked && PICKED_RING
- )}
- onClick={onClick}
- >
- {children}
- </button>
- );
-}
-
-/** A shape on the shelf row and in the Shapes grid: a click picks it, a drag
- * onto the timeline places it. */
-function ShapePeek({ shape }: { shape: ShapeKind }) {
- const { picked, pick } = useAssetPick(`shape:${shape}`);
- return (
- <PeekTile
- title={`Drag ${SHAPE_LABELS[shape]} onto the timeline`}
- picked={picked}
- drag={{ kind: "shape", shape }}
- onClick={pick}
- >
- <ShapeSwatch shape={shape} className="size-6" />
- </PeekTile>
- );
-}
-
+/** A shape in the Shapes grid: a click picks it, a drag onto the timeline
+ * places it. */
function ShapeTile({ shape }: { shape: ShapeKind }) {
const { picked, pick } = useAssetPick(`shape:${shape}`);
return (
<Tile
selected={picked}
+ pickId={`shape:${shape}`}
label={SHAPE_LABELS[shape]}
- title={`Drag ${SHAPE_LABELS[shape]} onto the timeline`}
className={cn(picked && PICKED_RING)}
onClick={pick}
draggable
diff --git a/site/src/cut/components/GeneratedAssetMenu.tsx b/site/src/cut/components/GeneratedAssetMenu.tsx
index f8d80297..2bb2bfec 100644
--- a/site/src/cut/components/GeneratedAssetMenu.tsx
+++ b/site/src/cut/components/GeneratedAssetMenu.tsx
@@ -91,7 +91,7 @@ export function GeneratedAssetMenu({
})
}
>
- <FolderPlus /> Add to library
+ <FolderPlus /> Add to Library
</DropdownMenuItem>
{(after != null || onDelete) && <DropdownMenuSeparator />}
{after}
diff --git a/site/src/cut/components/PanelTile.tsx b/site/src/cut/components/PanelTile.tsx
index dd780c2b..26277acd 100644
--- a/site/src/cut/components/PanelTile.tsx
+++ b/site/src/cut/components/PanelTile.tsx
@@ -10,6 +10,7 @@ import { cn } from "@/lib/utils";
export function Tile({
ref,
selected,
+ pickId,
onClick,
onHover,
label,
@@ -23,6 +24,8 @@ export function Tile({
/** For a grid that scrolls a tile into view. */
ref?: React.Ref<HTMLButtonElement>;
selected: boolean;
+ /** The tile's id for a grid with arrow-key navigation (`pickGridNav`). */
+ pickId?: string;
onClick: () => void;
/** Pointer entering or leaving — a tile whose preview only plays on hover. */
onHover?: (inside: boolean) => void;
@@ -39,6 +42,7 @@ export function Tile({
<button
ref={ref}
type="button"
+ data-pick-id={pickId}
aria-pressed={selected}
title={title}
draggable={draggable}
@@ -49,7 +53,7 @@ export function Tile({
onFocus={() => onHover?.(true)}
onBlur={() => onHover?.(false)}
className={cn(
- "flex flex-col items-center gap-1.5 rounded-lg border border-border p-2.5 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",
+ "flex flex-col items-center gap-1.5 rounded-lg border border-border p-2.5 text-[11px] font-medium text-muted-foreground outline-none transition-colors hover:bg-muted/60 hover:text-foreground",
selected && "bg-primary/10 text-foreground ring-2 ring-[#0a84ff] ring-offset-1 ring-offset-card",
className
)}
diff --git a/site/src/cut/components/SidePanel.tsx b/site/src/cut/components/SidePanel.tsx
index 2c6eadaf..5c673132 100644
--- a/site/src/cut/components/SidePanel.tsx
+++ b/site/src/cut/components/SidePanel.tsx
@@ -16,7 +16,6 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { SectionTitle } from "@/cut/components/SectionTitle";
-import { Slider } from "@/components/ui/slider";
import {
DropdownMenu,
DropdownMenuContent,
@@ -70,7 +69,7 @@ import { activeResidency, availableResidencies, type Residency } from "@/cut/lib
import { isStylePresetTemplate } from "@/cut/lib/stylePresets";
import { retryUpload } from "@/cut/lib/importQueue";
import { isMediaFile, revealMedia } from "@/cut/lib/media";
-import { mediaUrl, TRANSITION_MAX } from "@/cut/lib/types";
+import { mediaUrl } from "@/cut/lib/types";
import { genPulseOverlay, isGenTab, useGenNotify, useGenPulse, useWatchGenTab } from "@/cut/lib/genNotify";
import { useGenerate, type GenerateJob } from "@/cut/lib/generate";
import { CAPTION_LIMIT, normalizeTags } from "@/cut/lib/publish";
@@ -96,6 +95,7 @@ import { StockVideosPanel } from "./StockVideosPanel";
import { STOCK_MUSIC } from "@/cut/lib/stockMusicManifest";
import { STOCK_VIDEOS } from "@/cut/lib/stockVideoManifest";
import { LibraryCard, ShelfBadge } from "./LibraryView";
+import { SubTabs } from "./SubTabs";
// Drag a library clip onto a folder tile to file it (side panel, single card).
const LIBRARY_MOVE_MIME = "application/x-cut-library-move";
@@ -106,7 +106,6 @@ type Tab = SidePanelTab;
const TABS: { id: Tab; label: string; icon: typeof Film }[] = [
{ id: "media", label: "Media", icon: Clapperboard },
- { id: "library", label: "Library", icon: FolderOpen },
{ id: "elements", label: "Elements", icon: Shapes },
{ id: "effects", label: "Effects", icon: Sparkles },
{ id: "transitions", label: "Transitions", icon: Blend },
@@ -156,28 +155,20 @@ export function SidePanel({
"voice",
(v) => v === "voice" || v === "music"
);
- // Rail tiles as drop targets: a Library card (asset or template) dropped on
- // Media joins the project; a Media card dropped on Library saves it there.
- // Project media (cards and timeline clips) arrives through the ref zones
- // below; these HTML5 handlers cover the library-asset and template drags.
+ // The Media rail tile as a drop target: a Library card (asset or template)
+ // dropped on it joins the project. Project media (cards and timeline clips)
+ // arrives through the ref zone below; these HTML5 handlers cover the
+ // library-asset and template drags.
const [dropTab, setDropTab] = useState<Tab | null>(null);
const acceptsDrop = (id: Tab, e: React.DragEvent) => {
const tpl = hasTemplateDrag(e) ? draggingTemplate() : null;
- if (id === "media") return hasLibraryDrag(e) || tpl?.scope === "library";
- if (id === "library") return tpl?.scope === "project";
- return false;
+ return id === "media" && (hasLibraryDrag(e) || tpl?.scope === "library");
};
- // A project asset dropped on a rail tile — from a Media card or dragged
- // straight off the timeline: Media reveals it in the panel (clears its
- // origin tag), Library saves a copy to the shared library.
- const dropRefOnTab = (id: Tab, ref: AssetRef) => {
+ // A project asset dropped on the Media tile — from a card or dragged
+ // straight off the timeline — reveals it in the panel (clears its origin tag).
+ const dropRefOnTab = (ref: AssetRef) => {
if (ref.scope !== "project") return;
- if (id === "media") {
- useEditor.getState().updateAsset(ref.id, { origin: undefined, chatId: undefined });
- } else {
- const asset = useEditor.getState().assets.find((a) => a.id === ref.id);
- if (asset) void saveAssetToLibrary(projectId, asset);
- }
+ useEditor.getState().updateAsset(ref.id, { origin: undefined, chatId: undefined });
};
// Generations that finished while their tab was closed: a blue count rides
// the rail icon, and opening the tab lets the new tiles pulse for a beat.
@@ -216,13 +207,11 @@ export function SidePanel({
// owns the asset; the matching card scrolls into view and flashes.
useRevealEffect((ref) => {
setTab(
- ref.scope === "project"
+ ref.scope === "project" || ref.scope === "library"
? "media"
- : ref.scope === "library"
- ? "library"
- : STOCK_VIDEOS.some((v) => v.id === ref.id)
- ? "video"
- : "image"
+ : STOCK_VIDEOS.some((v) => v.id === ref.id)
+ ? "video"
+ : "image"
);
});
@@ -253,18 +242,18 @@ export function SidePanel({
const unseenCount = isGenTab(id) && id !== tab ? unseen[id].length : 0;
// Full width of the rail, whatever a scrollbar has left of it, so a
// label that no longer fits ellipsises inside the tile rather than
- // running out past both edges of a centred one.
- // Side padding stays off the label: the rail is 68px and the longest
- // name needs all of it, so the tile pads the tap area vertically and
- // the label runs edge to edge.
+ // running out past both edges of a centred one. The open tab reads
+ // from its icon chip's deeper fill; no ring, so nothing to keep off
+ // the rail edges. The outline stays off — click focus otherwise
+ // draws one around the tile.
const tileClass =
- "flex w-full min-w-0 shrink-0 flex-col items-center gap-1 rounded-lg px-1 py-1.5 text-muted-foreground transition-colors hover:text-foreground";
+ "flex w-full min-w-0 shrink-0 flex-col items-center gap-1 rounded-lg px-1 py-1.5 text-muted-foreground outline-none transition-colors hover:text-foreground";
const inner = (
<>
<span
className={cn(
"relative grid size-9 place-items-center rounded-lg transition-colors",
- tab === id ? "bg-muted text-foreground" : "hover:bg-muted/60",
+ tab === id ? "bg-foreground/10 text-foreground" : "hover:bg-muted/60",
dropTab === id && "bg-primary/15 text-primary"
)}
>
@@ -299,14 +288,10 @@ export function SidePanel({
e.preventDefault();
setDropTab(null);
const tpl = draggingTemplate();
- if (id === "media") {
- if (tpl?.scope === "library") void importTemplateToProject(projectId, tpl.template);
- else {
- const lib = draggingLibrary();
- if (lib) void importLibraryAsset(projectId, lib);
- }
- } else if (tpl?.scope === "project") {
- void saveTemplate(projectId, tpl.template);
+ if (tpl?.scope === "library") void importTemplateToProject(projectId, tpl.template);
+ else {
+ const lib = draggingLibrary();
+ if (lib) void importLibraryAsset(projectId, lib);
}
clearAssetDrag();
}}
@@ -321,9 +306,9 @@ export function SidePanel({
{(id === "video" || id === "subtitles") && tabIndex > 0 && (
<div aria-hidden className="my-1 h-px w-8 shrink-0 bg-border" />
)}
- {id === "media" || id === "library" ? (
+ {id === "media" ? (
<RefDropZone
- onRef={(ref) => dropRefOnTab(id, ref)}
+ onRef={dropRefOnTab}
className="w-full shrink-0 rounded-lg"
activeClassName="bg-primary/10"
>
@@ -400,7 +385,6 @@ export function SidePanel({
{tab === "media" && (
<MediaPanel projectId={projectId} onImport={onImport} importing={importing} />
)}
- {tab === "library" && <LibraryPanel projectId={projectId} />}
{tab === "elements" && <ElementsPanel projectId={projectId} />}
{tab === "effects" && <EffectsPanel />}
{tab === "transitions" && <TransitionsPanel />}
@@ -531,6 +515,8 @@ function ExportingRow({ job }: { job: ExportJob }) {
);
}
+/** The Media tab: Project Files is this project's own imports and exports;
+ * Library is the shared cross-project shelf. */
function MediaPanel({
projectId,
onImport,
@@ -539,6 +525,56 @@ function MediaPanel({
projectId: string;
onImport: (files: FileList | File[], opts?: { mediaOnly?: boolean }) => void;
importing: boolean;
+}) {
+ // A shared view shows only the project's own files — the Library is the
+ // viewer's cross-project shelf, so the toggle drops and a plain head stays.
+ const sharedFeatures = useEditor((s) => s.sharedFeatures);
+ const [sub, setSub] = useLocalPref<"project" | "library">(
+ "cut-media-subtab",
+ "project",
+ (v) => v === "project" || v === "library"
+ );
+ const view = sharedFeatures ? "project" : sub;
+ // A revealed card may sit on the other sub-tab; bring its side on screen.
+ useRevealEffect((ref) => {
+ if (ref.scope === "project") setSub("project");
+ else if (ref.scope === "library") setSub("library");
+ });
+ return (
+ <>
+ {sharedFeatures ? (
+ <PanelHead title="Media" />
+ ) : (
+ /* PanelHead's height, so the side panel's floating close button lands
+ on the toggle's centerline; the right padding keeps clear of it. */
+ <div className="flex h-12 shrink-0 items-center pr-12 pl-3.5">
+ <SubTabs
+ tabs={[
+ { id: "project", label: "Project Files" },
+ { id: "library", label: "Library" },
+ ]}
+ value={view}
+ onChange={setSub}
+ />
+ </div>
+ )}
+ {view === "project" ? (
+ <ProjectFilesPanel projectId={projectId} onImport={onImport} importing={importing} />
+ ) : (
+ <LibraryPanel projectId={projectId} />
+ )}
+ </>
+ );
+}
+
+function ProjectFilesPanel({
+ projectId,
+ onImport,
+ importing,
+}: {
+ projectId: string;
+ onImport: (files: FileList | File[], opts?: { mediaOnly?: boolean }) => void;
+ importing: boolean;
}) {
const caps = useCutCaps();
// Only user-imported media lives here; anything Cut created (recordings, AI
@@ -636,7 +672,6 @@ function MediaPanel({
)}
>
{/* An export in flight spins on the Media rail tile, not here. */}
- <PanelHead title="Media" />
{!readOnly && (
<div className="px-3.5 pb-3">
<Button variant="outline" className="w-full" onClick={() => inputRef.current?.click()}>
@@ -1210,7 +1245,7 @@ function LibraryPanel({ projectId }: { projectId: string }) {
"rounded-xl bg-[#0a84ff]/5 outline-2 outline-dashed outline-offset-[-4px] outline-[#0a84ff]/60"
)}
>
- {openFolder !== null ? (
+ {openFolder !== null && (
<div className="flex h-12 shrink-0 items-center pr-2.5 pl-2.5">
<FolderCrumb
className="text-sm"
@@ -1221,8 +1256,6 @@ function LibraryPanel({ projectId }: { projectId: string }) {
onDropOut={(ids) => ids.forEach((id) => void move(id, null))}
/>
</div>
- ) : (
- <PanelHead title="Library" />
)}
{openFolder === null && folders.length > 0 ? (
<div className="shrink-0 px-3.5">
@@ -1396,42 +1429,12 @@ function CopyChip({ text, label }: { text: string; label: string }) {
);
}
-/** Whole-video fade slider (project-level: veils picture, titles, captions,
- * and the mix at the cut's start or end). Lives here — the only
- * project-scoped panel — since per-clip fades moved into clip Effects. */
-function ProjectFadeRow({ label, value, onChange }: {
- label: string;
- value: number;
- onChange: (v: number) => void;
-}) {
- return (
- <label className="flex items-center justify-between gap-3 text-[12px] text-muted-foreground">
- {label}
- <span className="flex items-center gap-2">
- <Slider
- className={`project-${label.toLowerCase().replace(" ", "-")} data-horizontal:w-28`}
- min={0}
- max={TRANSITION_MAX}
- step={0.1}
- value={value}
- onValueChange={(v) => onChange(Number(v))}
- />
- <span className="w-9 text-right font-mono text-[11.5px]">
- {value < 0.05 ? "Off" : `${value.toFixed(1)}s`}
- </span>
- </span>
- </label>
- );
-}
-
function PublishPanel() {
const readOnly = useEditor((s) => s.readOnly);
const publish = useEditor((s) => s.publish);
const setPublish = useEditor((s) => s.setPublish);
const notes = useEditor((s) => s.notes);
const setNotes = useEditor((s) => s.setNotes);
- const fadeIn = useEditor((s) => s.fadeIn);
- const fadeOut = useEditor((s) => s.fadeOut);
const tagsLine = normalizeTags(publish.tags);
const combined = [publish.caption.trim(), tagsLine].filter(Boolean).join("\n\n");
const count = combined.length;
@@ -1441,22 +1444,6 @@ function PublishPanel() {
<>
<PanelHead title="Details" />
<ScrollArea className="min-h-0" contentClassName="flex flex-col gap-4 px-3.5 pb-4">
- {!readOnly && (
- <div className="flex flex-col gap-1.5">
- <SectionTitle>Video</SectionTitle>
- <ProjectFadeRow
- label="Fade in"
- value={fadeIn}
- onChange={(v) => useEditor.getState().setProjectFade({ fadeIn: v })}
- />
- <ProjectFadeRow
- label="Fade out"
- value={fadeOut}
- onChange={(v) => useEditor.getState().setProjectFade({ fadeOut: v })}
- />
- </div>
- )}
-
<div className="flex flex-col gap-1.5">
<div className="flex items-center justify-between">
<SectionTitle>Caption</SectionTitle>
@@ -1509,10 +1496,6 @@ function PublishPanel() {
readOnly={readOnly}
onChange={(e) => setPublish({ soundTitle: e.target.value })}
/>
- <p className="text-[11px] leading-relaxed text-muted-foreground">
- TikTok names uploads “original sound – you”. You can rename the
- sound once after posting — paste this then.
- </p>
</div>
<div className="flex flex-col gap-1.5 border-t border-border pt-4">
diff --git a/site/src/cut/components/Stickers.tsx b/site/src/cut/components/Stickers.tsx
index 70bf62c3..5c34957c 100644
--- a/site/src/cut/components/Stickers.tsx
+++ b/site/src/cut/components/Stickers.tsx
@@ -76,7 +76,8 @@ export function StickerTile({
<div className={cn("group relative rounded-lg", picked && PICKED_RING)}>
<button
title={a.name}
- className="block w-full overflow-hidden rounded-lg bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ data-pick-id={a.id}
+ className="block w-full overflow-hidden rounded-lg bg-muted outline-none"
draggable
onDragStart={(e) => {
setAssetDragData(e, a.id);
diff --git a/site/src/cut/components/SubTabs.tsx b/site/src/cut/components/SubTabs.tsx
new file mode 100644
index 00000000..f542138f
--- /dev/null
+++ b/site/src/cut/components/SubTabs.tsx
@@ -0,0 +1,35 @@
+"use client";
+
+import { cn } from "@/lib/utils";
+
+/** The segmented sub-tab toggle at the top of a side-panel tab — Voice/Music
+ * on Audio, Moving/Filters on Effects, Stickers/Shapes on Elements. */
+export function SubTabs<T extends string>({
+ tabs,
+ value,
+ onChange,
+}: {
+ tabs: readonly { id: T; label: string }[];
+ value: T;
+ onChange: (v: T) => void;
+}) {
+ return (
+ <div className="flex w-full rounded-lg bg-muted p-0.5 text-[11.5px]">
+ {tabs.map((t) => (
+ <button
+ key={t.id}
+ type="button"
+ onClick={() => onChange(t.id)}
+ className={cn(
+ "flex-1 rounded-md px-3 py-0.5 font-medium transition-colors",
+ value === t.id
+ ? "bg-background text-foreground shadow-sm"
+ : "text-muted-foreground hover:text-foreground"
+ )}
+ >
+ {t.label}
+ </button>
+ ))}
+ </div>
+ );
+}
diff --git a/site/src/cut/components/Timeline.tsx b/site/src/cut/components/Timeline.tsx
index 73223696..869e5a67 100644
--- a/site/src/cut/components/Timeline.tsx
+++ b/site/src/cut/components/Timeline.tsx
@@ -3099,7 +3099,7 @@ function ClipMenu({
});
}}
>
- <FolderPlus /> Add to library
+ <FolderPlus /> Add to Library
</DropdownMenuItem>
<DropdownMenuItem onClick={() => exportSegment(asset, clip)}>
<ArrowDownToLine /> Export segment
diff --git a/site/src/cut/components/editor-mock/MockSidePanel.tsx b/site/src/cut/components/editor-mock/MockSidePanel.tsx
index af0eb8dc..9def8cfd 100644
--- a/site/src/cut/components/editor-mock/MockSidePanel.tsx
+++ b/site/src/cut/components/editor-mock/MockSidePanel.tsx
@@ -6,7 +6,6 @@ import {
Clapperboard,
ClipboardList,
Film,
- FolderOpen,
Image as ImageIcon,
Layers,
Music,
@@ -30,7 +29,6 @@ import type {
const TABS: { id: MockPanelTab; label: string; icon: typeof Film }[] = [
{ id: "media", label: "Media", icon: Clapperboard },
- { id: "library", label: "Library", icon: FolderOpen },
{ id: "video", label: "Video", icon: Film },
{ id: "image", label: "Image", icon: ImageIcon },
{ id: "audio", label: "Audio", icon: Music },
@@ -106,8 +104,15 @@ export function MockSidePanel({ project }: { project: MockProject }) {
function MediaPanel({ panel }: { panel: Extract<MockPanel, { tab: "media" }> }) {
return (
<>
- <div className="flex h-12 shrink-0 items-center pr-2.5 pl-4">
- <span className="text-sm font-semibold tracking-tight">Media</span>
+ <div className="flex h-12 shrink-0 items-center px-3.5">
+ <div className="flex w-full rounded-lg bg-muted p-0.5 text-[11.5px]">
+ <span className="flex-1 rounded-md bg-background px-3 py-0.5 text-center font-medium text-foreground shadow-sm">
+ Project Files
+ </span>
+ <span className="flex-1 rounded-md px-3 py-0.5 text-center font-medium text-muted-foreground">
+ Library
+ </span>
+ </div>
</div>
<div className="shrink-0 px-3.5 pb-3">
<span className="flex h-8 w-full items-center justify-center gap-1.5 rounded-lg border border-input text-sm font-medium">
diff --git a/site/src/cut/components/editor-mock/mockData.ts b/site/src/cut/components/editor-mock/mockData.ts
index 431ab642..aa38b8fa 100644
--- a/site/src/cut/components/editor-mock/mockData.ts
+++ b/site/src/cut/components/editor-mock/mockData.ts
@@ -5,7 +5,6 @@ export type MockAspect = "9:16" | "16:9";
export type MockPanelTab =
| "media"
- | "library"
| "video"
| "image"
| "audio"
diff --git a/site/src/cut/lib/assetPick.ts b/site/src/cut/lib/assetPick.ts
index f9a6ba83..da3961ee 100644
--- a/site/src/cut/lib/assetPick.ts
+++ b/site/src/cut/lib/assetPick.ts
@@ -35,3 +35,32 @@ export function useAssetPick(assetId: string): { picked: boolean; pick: () => vo
/** The ring a picked tile wears. One class string so the tabs cannot drift. */
export const PICKED_RING = "ring-2 ring-[#0a84ff] ring-offset-1 ring-offset-card";
+
+/** Arrow-key navigation across a grid of pickable tiles. Mark each tile's
+ * button with `data-pick-id` and put this handler on the grid container: while
+ * the pick (or focus) is in the grid, an arrow clicks the neighboring tile, so
+ * keyboard moves carry the exact click semantics — picking, or retuning a
+ * selected element. The column count is read off the rendered rows, so one
+ * handler serves every grid width. Arrows are swallowed here either way; the
+ * editor's window-level seek must not fire while the keyboard is on tiles. */
+export function pickGridNav(e: React.KeyboardEvent<HTMLElement>) {
+ if (!e.key.startsWith("Arrow") || e.metaKey || e.ctrlKey || e.altKey) return;
+ const tiles = Array.from(e.currentTarget.querySelectorAll<HTMLElement>("[data-pick-id]"));
+ if (tiles.length === 0) return;
+ const picked = usePickedAsset.getState().id;
+ let from = tiles.findIndex((t) => t.dataset.pickId === picked);
+ if (from < 0)
+ from = tiles.findIndex(
+ (t) => t === document.activeElement || t.contains(document.activeElement)
+ );
+ if (from < 0) return;
+ e.preventDefault();
+ e.stopPropagation();
+ const cols = tiles.filter((t) => t.offsetTop === tiles[0].offsetTop).length;
+ const step =
+ e.key === "ArrowLeft" ? -1 : e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" ? -cols : cols;
+ const to = from + step;
+ if (to < 0 || to >= tiles.length) return;
+ tiles[to].click();
+ tiles[to].focus();
+}
diff --git a/site/src/cut/lib/panelRequest.ts b/site/src/cut/lib/panelRequest.ts
index ce3f8206..16e31178 100644
--- a/site/src/cut/lib/panelRequest.ts
+++ b/site/src/cut/lib/panelRequest.ts
@@ -11,7 +11,6 @@ import type { SidePanelTab } from "./types";
export const SIDE_PANEL_TABS: SidePanelTab[] = [
"media",
- "library",
"elements",
"effects",
"transitions",
diff --git a/site/src/cut/lib/types.ts b/site/src/cut/lib/types.ts
index 3b0c9bea..8328070e 100644
--- a/site/src/cut/lib/types.ts
+++ b/site/src/cut/lib/types.ts
@@ -856,7 +856,6 @@ export interface ShareFeatures {
/** The editor's side-panel tabs ("publish" shows as Details). */
export type SidePanelTab =
| "media"
- | "library"
| "elements"
| "effects"
| "transitions"
diff --git a/site/src/cut/server/ai/catalog.ts b/site/src/cut/server/ai/catalog.ts
index 34693d73..b99e8698 100644
--- a/site/src/cut/server/ai/catalog.ts
+++ b/site/src/cut/server/ai/catalog.ts
@@ -102,11 +102,11 @@ export const AI_TOOLS: AiToolDef[] = [
{
name: "set_side_panel",
description:
- "Open a side-panel tab, or collapse the panel to the icon rail with 'none' so the preview canvas takes the freed width — use 'none' when the user asks to clean up or maximize the workspace. 'publish' is the Details tab.",
+ "Open a side-panel tab, or collapse the panel to the icon rail with 'none' so the preview canvas takes the freed width — use 'none' when the user asks to clean up or maximize the workspace. 'publish' is the Details tab; 'media' holds the project's files and the shared Library.",
inputSchema: obj({
panel: {
type: "string",
- enum: ["media", "library", "elements", "effects", "transitions", "video", "image", "audio", "subtitles", "publish", "none"],
+ enum: ["media", "elements", "effects", "transitions", "video", "image", "audio", "subtitles", "publish", "none"],
description: "Tab to open, or 'none' to collapse the panel",
},
}, ["panel"]),