chore: refact tool and filepreveiw context to zustand to reduce rerender

This commit is contained in:
Joel
2026-02-09 16:05:53 +08:00
parent 8f6a8997f4
commit b014e91740
8 changed files with 234 additions and 88 deletions

View File

@ -333,6 +333,10 @@ const PromptEditorContent: FC<PromptEditorContentProps> = ({
}
}, [availableNodes, nodeId, onToolMetadataChange, toolMetadata, workflowVariableBlock?.variables])
const filePreviewContextValue = React.useMemo(() => ({
enabled: Boolean(isSupportSandbox),
}), [isSupportSandbox])
const sandboxPlaceHolder = React.useMemo(() => {
if (!isSupportSandbox)
return null
@ -387,7 +391,7 @@ const PromptEditorContent: FC<PromptEditorContentProps> = ({
return (
<LexicalComposer initialConfig={{ ...initialConfig, editable }}>
<ToolBlockContextProvider value={toolBlockContextValue}>
<FilePreviewContextProvider value={{ enabled: Boolean(isSupportSandbox) }}>
<FilePreviewContextProvider value={filePreviewContextValue}>
<div
className={cn('relative', wrapperClassName)}
data-skill-editor-root={isSupportSandbox ? 'true' : undefined}