From 885c7d26e575b4f4007dcb454065289ba2845c32 Mon Sep 17 00:00:00 2001 From: Joel Date: Wed, 3 Sep 2025 11:05:07 +0800 Subject: [PATCH] feat: handle choose select --- web/app/components/workflow/hooks-store/store.ts | 2 +- .../workflow/hooks/use-inspect-vars-crud-common.ts | 5 ++--- web/app/components/workflow/variable-inspect/panel.tsx | 9 ++++++--- web/app/components/workflow/variable-inspect/right.tsx | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/web/app/components/workflow/hooks-store/store.ts b/web/app/components/workflow/hooks-store/store.ts index 83917493c9..4e8c189c49 100644 --- a/web/app/components/workflow/hooks-store/store.ts +++ b/web/app/components/workflow/hooks-store/store.ts @@ -52,7 +52,7 @@ export type CommonHooksFnMap = { fetchInspectVars: (params: { passInVars?: boolean, vars?: VarInInspect[], passedInAllPluginInfoList?: Record, passedInSchemaTypeDefinitions?: SchemaTypeDefinition[] }) => Promise hasNodeInspectVars: (nodeId: string) => boolean hasSetInspectVar: (nodeId: string, name: string, sysVars: VarInInspect[], conversationVars: VarInInspect[]) => boolean - fetchInspectVarValue: (selector: ValueSelector) => Promise + fetchInspectVarValue: (selector: ValueSelector, schemaTypeDefinitions: SchemaTypeDefinition[]) => Promise editInspectVarValue: (nodeId: string, varId: string, value: any) => Promise renameInspectVarName: (nodeId: string, oldName: string, newName: string) => Promise appendNodeInspectVars: (nodeId: string, payload: VarInInspect[], allNodes: Node[]) => void diff --git a/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts b/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts index aa16b5d4e7..89ad87133f 100644 --- a/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts +++ b/web/app/components/workflow/hooks/use-inspect-vars-crud-common.ts @@ -16,8 +16,8 @@ import { useNodesInteractionsWithoutSync } from '@/app/components/workflow/hooks import { useEdgesInteractionsWithoutSync } from '@/app/components/workflow/hooks/use-edges-interactions-without-sync' import type { FlowType } from '@/types/common' import useFLow from '@/service/use-flow' -import useMatchSchemaType from '../nodes/_base/components/variable/use-match-schema-type' import { useStoreApi } from 'reactflow' +import type { SchemaTypeDefinition } from '@/service/use-common' type Params = { flowId: string @@ -29,7 +29,6 @@ export const useInspectVarsCrudCommon = ({ }: Params) => { const workflowStore = useWorkflowStore() const store = useStoreApi() - const { schemaTypeDefinitions } = useMatchSchemaType() const { useInvalidateConversationVarValues, useInvalidateSysVarValues, @@ -96,7 +95,7 @@ export const useInspectVarsCrudCommon = ({ return !!getNodeInspectVars(nodeId) }, [getNodeInspectVars]) - const fetchInspectVarValue = useCallback(async (selector: ValueSelector) => { + const fetchInspectVarValue = useCallback(async (selector: ValueSelector, schemaTypeDefinitions: SchemaTypeDefinition[]) => { const { setNodeInspectVars, buildInTools, diff --git a/web/app/components/workflow/variable-inspect/panel.tsx b/web/app/components/workflow/variable-inspect/panel.tsx index 57ab3fa9dc..db0a6da8ab 100644 --- a/web/app/components/workflow/variable-inspect/panel.tsx +++ b/web/app/components/workflow/variable-inspect/panel.tsx @@ -15,6 +15,7 @@ import { VarInInspectType } from '@/types/workflow' import cn from '@/utils/classnames' import type { NodeProps } from '../types' +import useMatchSchemaType from '../nodes/_base/components/variable/use-match-schema-type' export type currentVarType = { nodeId: string @@ -133,13 +134,15 @@ const Panel: FC = () => { setCurrentVarId(node.var.id) }, [setCurrentFocusNodeId, setCurrentVarId]) + const { isLoading, schemaTypeDefinitions } = useMatchSchemaType() + useEffect(() => { - if (currentFocusNodeId && currentVarId) { + if (currentFocusNodeId && currentVarId && !isLoading) { const targetNode = nodesWithInspectVars.find(node => node.nodeId === currentFocusNodeId) if (targetNode && !targetNode.isValueFetched) - fetchInspectVarValue([currentFocusNodeId]) + fetchInspectVarValue([currentFocusNodeId], schemaTypeDefinitions!) } - }, [currentFocusNodeId, currentVarId, nodesWithInspectVars, fetchInspectVarValue]) + }, [currentFocusNodeId, currentVarId, nodesWithInspectVars, fetchInspectVarValue, schemaTypeDefinitions, isLoading]) if (isEmpty) { return ( diff --git a/web/app/components/workflow/variable-inspect/right.tsx b/web/app/components/workflow/variable-inspect/right.tsx index 4a321d6e59..5b6b165c88 100644 --- a/web/app/components/workflow/variable-inspect/right.tsx +++ b/web/app/components/workflow/variable-inspect/right.tsx @@ -56,6 +56,7 @@ const Right = ({ const toolIcon = useToolIcon(currentNodeVar?.nodeData) const isTruncated = currentNodeVar?.var.is_truncated const fullContent = currentNodeVar?.var.full_content + console.log(currentNodeVar?.var) // const isTruncated = true // const fullContent = { // size_bytes: 11289600,