用户引导沙箱优化

This commit is contained in:
董宏凯 committed 2026-08-26 14:14:26 +08:00
1 parent 21f3787b8b
commit 910cee9e67
8 files changed
+604 -224

No files matched your search

@@ -11,12 +11,11 @@ import { basicLightInit } from "@uiw/codemirror-theme-basic";
import { monokaiInit } from "@uiw/codemirror-theme-monokai";
import CodeMirror from "@uiw/react-codemirror";
import { useTheme } from "next-themes";
import { useMemo } from "react";
import { memo, useMemo } from "react";
import { Textarea } from "@/components/ui/textarea";
import { cn } from "@/lib/utils";
import { useThread } from "./messages/context";
const customDarkTheme = monokaiInit({
settings: {
background: "transparent",
@@ -34,7 +33,7 @@ const customLightTheme = basicLightInit({
},
});
export function CodeEditor({
export const CodeEditor = memo(function CodeEditor({
className,
placeholder,
value,
@@ -43,6 +42,7 @@ export function CodeEditor({
disabled,
autoFocus,
settings,
isStreaming = false,
streamingReadonlyFallback = true,
}: {
className?: string;
@@ -53,11 +53,10 @@ export function CodeEditor({
disabled?: boolean;
autoFocus?: boolean;
settings?: unknown;
/** Parent-owned streaming flag so this editor does not subscribe to `thread`. */
isStreaming?: boolean;
streamingReadonlyFallback?: boolean;
}) {
const {
thread: { isLoading },
} = useThread();
const { resolvedTheme } = useTheme();
const extensions = useMemo(() => {
@@ -81,7 +80,7 @@ export function CodeEditor({
className,
)}
>
{isLoading && streamingReadonlyFallback ? (
{isStreaming && streamingReadonlyFallback ? (
<Textarea
className={cn(
"h-full overflow-auto font-mono [&_.cm-editor]:h-full [&_.cm-focused]:outline-none!",
@@ -116,4 +115,4 @@ export function CodeEditor({
)}
</div>
);
}
});