Open source CapCut alternative.
TypeScript
fix(site): chat composer file drops stay chat-owned
David Led47b69364577
diff --git a/site/src/cut/components/AiPanel.tsx b/site/src/cut/components/AiPanel.tsxindex 0e6eeb3b..a4b9a730 100644--- a/site/src/cut/components/AiPanel.tsx+++ b/site/src/cut/components/AiPanel.tsx@@ -361,11 +361,12 @@ function ChatSession({const { active: dropActive, attachTarget, targetProps } = useAssetDrop((ref) => setAttachments((prev) => addRefOnce(prev, ref)),// OS files dropped on the chat attach as references (media files import- // into the project on the way; text files ride as-is).+ // into the project on the way, chat-owned so they stay off the Media+ // panel; text files ride as-is).(files) => {const projectId = useEditor.getState().projectId;if (!projectId) return;- void refsFromDroppedFiles(projectId, files).then((refs) =>+ void refsFromDroppedFiles(projectId, files, { chatId: threadId }).then((refs) =>setAttachments((prev) => refs.reduce(addRefOnce, prev)));}diff --git a/site/src/cut/lib/refMedia.ts b/site/src/cut/lib/refMedia.tsindex 0a235761..4c64df5b 100644--- a/site/src/cut/lib/refMedia.ts+++ b/site/src/cut/lib/refMedia.ts@@ -1,6 +1,7 @@"use client";import { refFromAsset, refFromTextFile, type AssetRef } from "./assetRef";+import { tagChatAsset } from "./chatAssets";import { enrichAsset, importFileToProject, isMediaFile, isTextFile } from "./media";import { useEditor } from "./store";@@ -163,10 +164,17 @@ export const visualRefs = (refs: AssetRef[]): AssetRef[] =>refs.filter((r) => r.kind === "image" || r.kind === "video");/** Attach OS files dropped on a composer, returned as refs in drop order.- * Media files import into the project first (they land in the Media panel like- * any user import); text files become transient file refs read at send time.- * Files that are neither, and failed imports, are skipped. */-export async function refsFromDroppedFiles(projectId: string, files: File[]): Promise<AssetRef[]> {+ * Media files import into the project first; text files become transient file+ * refs read at send time. Files that are neither, and failed imports, are+ * skipped. `chatId` marks the imports chat-owned from creation: they live on+ * the chat (its card, thread deletion), never in the Media panel — a drop on+ * the chat composer is an attachment, not a filing. Panel drops omit it and+ * file into Media as user imports. */+export async function refsFromDroppedFiles(+ projectId: string,+ files: File[],+ opts?: { chatId?: string }+): Promise<AssetRef[]> {const refs: AssetRef[] = [];for (const file of files) {try {@@ -177,6 +185,7 @@ export async function refsFromDroppedFiles(projectId: string, files: File[]): Prconst asset = await importFileToProject(projectId, file);if (!asset) continue;useEditor.getState().addAsset(asset);+ if (opts?.chatId) tagChatAsset(asset.id, opts.chatId);void enrichAsset(asset);refs.push(refFromAsset(asset));} catch (err) {