Open source CapCut alternative.
TypeScript
refactor(cut): the message queue renders chat's own pills
David Lebd6314b9ecc8
diff --git a/site/src/cut/components/AiPanel.tsx b/site/src/cut/components/AiPanel.tsxindex 81904ac6..5920b813 100644--- a/site/src/cut/components/AiPanel.tsx+++ b/site/src/cut/components/AiPanel.tsx@@ -76,7 +76,6 @@ import {normalizeRef,sameRef,setRefDragData,- splitMentions,upsertRef,useRefCandidates,useAssetDrop,@@ -101,7 +100,7 @@ import { useEditor } from "@/cut/lib/store";import { reportActivity } from "@/cut/lib/tabActivity";import { cn } from "@/lib/utils";import { cardIconButton } from "@/cut/components/iconButton";-import { MentionTextarea, RefChips, RefThumb, RefTokenChip } from "./AssetRefs";+import { MentionedText, MentionTextarea, RefChips, RefThumb } from "./AssetRefs";import { ComposerQueue, type QueuedMessage } from "./ComposerQueue";import { DictationBody } from "./MicDictation";import { RECORD_RUNNING_TTL_MS, ToolOutputAssets } from "./ChatAssets";@@ -1535,34 +1534,6 @@ function MessageAssetCard({ asset }: { asset: AssetRef }) {);}-/** User-message text with resolved `@` mentions rendered as interactive token- * chips. Tokens resolve against the message's own attachments first (they hold- * what was meant at send time), then the live candidates. */-function MentionedText({- text,- attachments,-}: {- text: string;- attachments: AssetRef[];-}) {- const candidates = useRefCandidates();- const parts = useMemo(- () => splitMentions(text, [...attachments, ...candidates]),- [text, attachments, candidates],- );- return (- <>- {parts.map((p, i) =>- typeof p === "string" ? (- <span key={i}>{p}</span>- ) : (- <RefTokenChip key={i} item={p} onDark />- ),- )}- </>- );-}-/** Copy-to-clipboard affordance revealed on message hover. */function MessageCopy({ text }: { text: string }) {const [copied, setCopied] = useState(false);@@ -1885,7 +1856,7 @@ const MessageView = memo(function MessageView({)}{text && (<div className="max-w-[85%] rounded-2xl rounded-br-md bg-neutral-900 px-3 py-2 text-[12.5px] leading-relaxed break-words whitespace-pre-wrap text-white">- <MentionedText text={text} attachments={attachments} />+ <MentionedText text={text} attachments={attachments} onDark /></div>)}<MessageCopy text={text} />diff --git a/site/src/cut/components/AssetRefs.tsx b/site/src/cut/components/AssetRefs.tsxindex 35ea561d..32293511 100644--- a/site/src/cut/components/AssetRefs.tsx+++ b/site/src/cut/components/AssetRefs.tsx@@ -8,6 +8,7 @@ import {mentionToken,refToken,sameRef,+ splitMentions,type AssetRef,} from "@/cut/lib/assetRef";import { MEDIA_CORS } from "@/cut/lib/mediaCors";@@ -287,7 +288,7 @@ export function RefTokenChip({peekSide = "top",}: {item: AssetRef;- /** Style for a dark bubble (the user message) instead of the light page. */+ /** Style for a dark bubble — the user message. */onDark?: boolean;peekSide?: "top" | "bottom";}) {@@ -336,6 +337,40 @@ export function RefTokenChip({);}+/** Message text with its resolved `@` mentions drawn as token chips. One+ * renderer for every place a written message is shown — the chat thread and+ * the queue tray above the composer — so a message reads the same before it+ * is sent, while it waits, and after it lands. Tokens resolve against the+ * message's own attachments first (they hold what was meant when it was+ * written), then the live candidates. */+export function MentionedText({+ text,+ attachments = [],+ onDark,+}: {+ text: string;+ attachments?: AssetRef[];+ /** Style for a dark bubble — the user message. */+ onDark?: boolean;+}) {+ const candidates = useRefCandidates();+ const parts = useMemo(+ () => splitMentions(text, [...attachments, ...candidates]),+ [text, attachments, candidates]+ );+ return (+ <>+ {parts.map((p, i) =>+ typeof p === "string" ? (+ <span key={i}>{p}</span>+ ) : (+ <RefTokenChip key={i} item={p} onDark={onDark} />+ )+ )}+ </>+ );+}+/** Removable attachment chips shown above an input — hover peeks, clicking* the thumb reveals the original asset. With `onUpdate`, a video or audio* chip opens the moment picker on click instead, so the user can pin thediff --git a/site/src/cut/components/ComposerQueue.tsx b/site/src/cut/components/ComposerQueue.tsxindex d1422abf..fee34e53 100644--- a/site/src/cut/components/ComposerQueue.tsx+++ b/site/src/cut/components/ComposerQueue.tsx@@ -14,7 +14,7 @@ import {import { cn } from "@/lib/utils";import { ScrollArea } from "@/components/ui/scroll-area";import { useDragSort } from "@/components/Sortable";-import { RefThumb } from "./AssetRefs";+import { MentionedText, RefThumb } from "./AssetRefs";import type { AssetRef } from "@/cut/lib/assetRef";/** Small icon control on a tray row or the tray header. */@@ -230,7 +230,10 @@ export function ComposerQueue({gone && "line-through decoration-muted-foreground/40",)}>- {it.text}+ <MentionedText+ text={it.text}+ attachments={it.attachments}+ /></div>{it.attachments.length > 0 && (<div