fix(webui): persist markdown video previews

This commit is contained in:
Xubin Ren
2026-05-29 17:26:58 +08:00
parent 57563b671f
commit a71e6a0ae8
5 changed files with 89 additions and 4 deletions
@@ -8,6 +8,7 @@ import remarkMath from "remark-math";
import { CodeBlock } from "@/components/CodeBlock";
import { FileReferenceChip, isLikelyFilePath } from "@/components/FileReferenceChip";
import { inferMediaKind } from "@/lib/media";
import { cn } from "@/lib/utils";
import "katex/dist/katex.min.css";
@@ -114,6 +115,29 @@ export default function MarkdownTextRenderer({
const source = typeof src === "string" ? src : "";
if (!source) return null;
const label = typeof alt === "string" ? alt : "";
if (inferMediaKind({ url: source, name: label }) === "video") {
return (
<span
className={cn(
"not-prose my-3 block w-fit max-w-full overflow-hidden rounded-[14px]",
"border border-border/70 bg-background shadow-sm",
)}
>
<video
src={source}
controls
preload="metadata"
className="block max-h-[26rem] max-w-full bg-black"
aria-label={label ? `Video attachment: ${label}` : "Video attachment"}
/>
{label ? (
<span className="block max-w-full truncate px-3 py-2 text-xs text-muted-foreground">
{label}
</span>
) : null}
</span>
);
}
return (
<span
className={cn(