From 776fb04bf0b098db6664327f341697aa2d186133 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 6 Feb 2026 18:10:32 +0800 Subject: [PATCH] chore: use more good availableNodes --- .../components/base/prompt-editor/index.tsx | 23 ++++++------------- web/eslint-suppressions.json | 5 ---- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/web/app/components/base/prompt-editor/index.tsx b/web/app/components/base/prompt-editor/index.tsx index 80e83ec048..e4a97c163f 100644 --- a/web/app/components/base/prompt-editor/index.tsx +++ b/web/app/components/base/prompt-editor/index.tsx @@ -16,7 +16,6 @@ import type { VariableBlockType, WorkflowVariableBlockType, } from './types' -import type { Node } from '@/app/components/workflow/types' import type { EventPayload } from '@/context/event-emitter' import { CodeNode } from '@lexical/code' import { LexicalComposer } from '@lexical/react/LexicalComposer' @@ -49,12 +48,13 @@ import { ToolBlockContextProvider } from '@/app/components/workflow/skill/editor import ToolPickerBlock from '@/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block' import { useEventEmitterContextContext } from '@/context/event-emitter' import { cn } from '@/utils/classnames' +import { useWorkflow } from '../../workflow/hooks' import { UPDATE_DATASETS_EVENT_EMITTER, UPDATE_HISTORY_EVENT_EMITTER, } from './constants' -import ComponentPickerBlock from './plugins/component-picker-block' +import ComponentPickerBlock from './plugins/component-picker-block' import { ContextBlock, ContextBlockNode, @@ -264,20 +264,11 @@ const PromptEditor: FC = ({ } as EventPayload) }, [eventEmitter, historyBlock?.history]) - const availableNodes = React.useMemo(() => { - if (!workflowVariableBlock?.workflowNodesMap) - return undefined - return Object.entries(workflowVariableBlock.workflowNodesMap).map(([id, data]) => ({ - id, - data: { - title: data.title, - type: data.type, - } as any, - position: data.position ?? { x: 0, y: 0 }, - width: data.width, - height: data.height, - })) as Node[] - }, [workflowVariableBlock?.workflowNodesMap]) + const { getBeforeNodesInSameBranch } = useWorkflow() + const availableNodes = React.useMemo( + () => nodeId && isSupportSandbox ? getBeforeNodesInSameBranch(nodeId || '') : [], + [getBeforeNodesInSameBranch, isSupportSandbox, nodeId], + ) const toolBlockContextValue = React.useMemo(() => { if (!onToolMetadataChange) diff --git a/web/eslint-suppressions.json b/web/eslint-suppressions.json index d2332d54a4..e5056a9205 100644 --- a/web/eslint-suppressions.json +++ b/web/eslint-suppressions.json @@ -1427,11 +1427,6 @@ "count": 2 } }, - "app/components/base/prompt-editor/index.tsx": { - "ts/no-explicit-any": { - "count": 1 - } - }, "app/components/base/prompt-editor/plugins/component-picker-block/index.tsx": { "ts/no-explicit-any": { "count": 1