From 439727746ca9bdcebfb649eee437831c6047e730 Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 21 Oct 2025 18:21:37 +0800 Subject: [PATCH] fix: trigger timestamp show place --- web/app/components/workflow/constants.ts | 2 +- .../workflow/hooks/use-inspect-vars-crud.ts | 26 +++++++++++++++++-- .../panel/global-variable-panel/index.tsx | 2 +- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/constants.ts b/web/app/components/workflow/constants.ts index eb93ab916d..83ebcf0029 100644 --- a/web/app/components/workflow/constants.ts +++ b/web/app/components/workflow/constants.ts @@ -68,7 +68,7 @@ export const getGlobalVars = (isChatMode: boolean): Var[] => { variable: 'sys.workflow_run_id', type: VarType.string, }, - ...(isInWorkflow ? [ + ...((isInWorkflow && !isChatMode) ? [ { variable: 'sys.trigger_timestamp', type: VarType.string, diff --git a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts index c922192267..0f58cf8be2 100644 --- a/web/app/components/workflow/hooks/use-inspect-vars-crud.ts +++ b/web/app/components/workflow/hooks/use-inspect-vars-crud.ts @@ -5,13 +5,35 @@ import { useSysVarValues, } from '@/service/use-workflow' import { FlowType } from '@/types/common' +import { produce } from 'immer' +import { BlockEnum } from '../types' +const varsAppendStartNodeKeys = ['query', 'files'] const useInspectVarsCrud = () => { - const nodesWithInspectVars = useStore(s => s.nodesWithInspectVars) + const partOfNodesWithInspectVars = useStore(s => s.nodesWithInspectVars) const configsMap = useHooksStore(s => s.configsMap) const isRagPipeline = configsMap?.flowType === FlowType.ragPipeline const { data: conversationVars } = useConversationVarValues(configsMap?.flowType, !isRagPipeline ? configsMap?.flowId : '') - const { data: systemVars } = useSysVarValues(configsMap?.flowType, !isRagPipeline ? configsMap?.flowId : '') + const { data: allSystemVars } = useSysVarValues(configsMap?.flowType, !isRagPipeline ? configsMap?.flowId : '') + const { varsAppendStartNode, systemVars } = (() => { + if(allSystemVars?.length === 0) + return { varsAppendStartNode: [], systemVars: [] } + const varsAppendStartNode = allSystemVars?.filter(({ name }) => varsAppendStartNodeKeys.includes(name)) || [] + const systemVars = allSystemVars?.filter(({ name }) => !varsAppendStartNodeKeys.includes(name)) || [] + return { varsAppendStartNode, systemVars } + })() + const nodesWithInspectVars = (() => { + if(!partOfNodesWithInspectVars || partOfNodesWithInspectVars.length === 0) + return [] + + const nodesWithInspectVars = produce(partOfNodesWithInspectVars, (draft) => { + draft.forEach((nodeWithVars) => { + if(nodeWithVars.nodeType === BlockEnum.Start) + nodeWithVars.vars = [...nodeWithVars.vars, ...varsAppendStartNode] + }) + }) + return nodesWithInspectVars + })() const hasNodeInspectVars = useHooksStore(s => s.hasNodeInspectVars) const hasSetInspectVar = useHooksStore(s => s.hasSetInspectVar) const fetchInspectVarValue = useHooksStore(s => s.fetchInspectVarValue) diff --git a/web/app/components/workflow/panel/global-variable-panel/index.tsx b/web/app/components/workflow/panel/global-variable-panel/index.tsx index 3deea891db..bcad9b52ec 100644 --- a/web/app/components/workflow/panel/global-variable-panel/index.tsx +++ b/web/app/components/workflow/panel/global-variable-panel/index.tsx @@ -50,7 +50,7 @@ const Panel = () => { description: t('workflow.globalVar.fieldsDescription.workflowRunId'), }, // is workflow - ...(isWorkflowPage ? [{ + ...((isWorkflowPage && !isChatMode) ? [{ name: 'trigger_timestamp', value_type: 'string' as const, description: t('workflow.globalVar.fieldsDescription.triggerTimestamp'),