Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
import { useDeferredValue, type ComponentProps } from "react";
import { Streamdown } from "streamdown";
import { StaticMarkdownTable } from "./markdown-table";
import { useChatPreferencesStore } from "@/features/chat";
import { useT } from "@/i18n";
import { withLiteralUnknownTags } from "@/lib/markdown-data-images";
const REHYPE_PLUGINS = withLiteralUnknownTags();
const components: NonNullable<ComponentProps<typeof Streamdown>["components"]> =
{
a: ({ children }) => (
<span className="text-primary underline">{children}</span>
),
img: ({ alt }) => (
<span className="text-muted-foreground">[{alt || "image"}]</span>
),
table: StaticMarkdownTable,
};
export function ComposerDraftPreview({ text }: { text: string }) {
const plain = useChatPreferencesStore((s) => s.plainTextComposer);
const draft = useDeferredValue(text);
const t = useT();
if (plain || !text.trim() || !draft.trim()) return null;
return (
<section
aria-label={t("composerSettings.preview")}
className="mb-3 min-w-0 rounded-lg border border-border/60 bg-muted/20 p-3 text-sm"
>
{/* Scroller inset by the padding: a flush scrollbar squares the rounded corners. */}
<div className="max-h-48 min-w-0 overflow-auto">
<div className="mb-2 text-xs text-muted-foreground">
{t("composerSettings.preview")}
</div>
<Streamdown
mode="static"
controls={false}
components={components}
rehypePlugins={REHYPE_PLUGINS}
className="min-w-0 space-y-2 [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap"
>
{draft}
</Streamdown>
</div>
</section>
);
}