From e528112394100db44264112493b8c76423f94684 Mon Sep 17 00:00:00 2001 From: zhsama Date: Sat, 7 Feb 2026 16:07:21 +0800 Subject: [PATCH] fix: Hide Agent node in sandboxed apps and relabel LLM --- .../hooks/use-available-nodes-meta-data.ts | 14 ++++++++++---- .../workflow-app/hooks/use-workflow-template.ts | 8 +++++++- web/i18n/en-US/workflow.json | 6 +++--- web/i18n/ja-JP/workflow.json | 4 +++- web/i18n/zh-Hans/workflow.json | 6 +++--- web/i18n/zh-Hant/workflow.json | 4 +++- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/web/app/components/workflow-app/hooks/use-available-nodes-meta-data.ts b/web/app/components/workflow-app/hooks/use-available-nodes-meta-data.ts index 0a278be688..dc85598dbb 100644 --- a/web/app/components/workflow-app/hooks/use-available-nodes-meta-data.ts +++ b/web/app/components/workflow-app/hooks/use-available-nodes-meta-data.ts @@ -3,6 +3,7 @@ import type { CommonNodeType, NodeDefault, NodeDefaultBase } from '@/app/compone import type { DocPathWithoutLang } from '@/types/doc-paths' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' +import { useStore as useAppStore } from '@/app/components/app/store' import { WORKFLOW_COMMON_NODES } from '@/app/components/workflow/constants/node' import AnswerDefault from '@/app/components/workflow/nodes/answer/default' import EndDefault from '@/app/components/workflow/nodes/end/default' @@ -17,6 +18,7 @@ import { useIsChatMode } from './use-is-chat-mode' export const useAvailableNodesMetaData = () => { const { t } = useTranslation() const isChatMode = useIsChatMode() + const isSandboxed = useAppStore(s => s.appDetail?.runtime_type === 'sandboxed') const docLink = useDocLink() const startNodeMetaData = useMemo(() => ({ @@ -28,7 +30,9 @@ export const useAvailableNodesMetaData = () => { }), [isChatMode]) const mergedNodesMetaData = useMemo(() => [ - ...WORKFLOW_COMMON_NODES, + ...(isSandboxed + ? WORKFLOW_COMMON_NODES.filter(node => node.metaData.type !== BlockEnum.Agent) + : WORKFLOW_COMMON_NODES), startNodeMetaData, ...( isChatMode @@ -40,7 +44,7 @@ export const useAvailableNodesMetaData = () => { TriggerPluginDefault, ] ), - ] as AvailableNodesMetaData['nodes'], [isChatMode, startNodeMetaData]) + ] as AvailableNodesMetaData['nodes'], [isChatMode, isSandboxed, startNodeMetaData]) const availableNodesMetaData = useMemo(() => { const toNodeDefaultBase = ( @@ -69,7 +73,9 @@ export const useAvailableNodesMetaData = () => { // normalize per-node defaults into a shared metadata shape. const typedNode = node as NodeDefault const { metaData } = typedNode - const title = t(`blocks.${metaData.type}`, { ns: 'workflow' }) + const title = isSandboxed && metaData.type === BlockEnum.LLM + ? t('blocks.agent', { ns: 'workflow' }) + : t(`blocks.${metaData.type}` as const, { ns: 'workflow' }) const description = t(`blocksAbout.${metaData.type}`, { ns: 'workflow' }) const helpLinkPath = `/use-dify/nodes/${metaData.helpLinkUri}` as DocPathWithoutLang return toNodeDefaultBase(typedNode, { @@ -83,7 +89,7 @@ export const useAvailableNodesMetaData = () => { title, }) }) - }, [mergedNodesMetaData, t, docLink]) + }, [mergedNodesMetaData, t, docLink, isSandboxed]) const availableNodesMetaDataMap = useMemo(() => availableNodesMetaData.reduce((acc, node) => { acc![node.metaData.type] = node diff --git a/web/app/components/workflow-app/hooks/use-workflow-template.ts b/web/app/components/workflow-app/hooks/use-workflow-template.ts index 4763377893..7dfd4f0f9d 100644 --- a/web/app/components/workflow-app/hooks/use-workflow-template.ts +++ b/web/app/components/workflow-app/hooks/use-workflow-template.ts @@ -1,5 +1,6 @@ import type { StartNodeType } from '@/app/components/workflow/nodes/start/types' import { useTranslation } from 'react-i18next' +import { useStore as useAppStore } from '@/app/components/app/store' import { NODE_WIDTH_X_OFFSET, START_INITIAL_POSITION, @@ -12,6 +13,7 @@ import { useIsChatMode } from './use-is-chat-mode' export const useWorkflowTemplate = () => { const isChatMode = useIsChatMode() + const isSandboxed = useAppStore(s => s.appDetail?.runtime_type === 'sandboxed') const { t } = useTranslation() const { newNode: startNode } = generateNewNode({ @@ -24,6 +26,10 @@ export const useWorkflowTemplate = () => { }) if (isChatMode) { + const llmTitle = isSandboxed + ? t('blocks.agent', { ns: 'workflow' }) + : t(`blocks.${llmDefault.metaData.type}` as const, { ns: 'workflow' }) + const { newNode: llmNode } = generateNewNode({ id: 'llm', data: { @@ -34,7 +40,7 @@ export const useWorkflowTemplate = () => { }, selected: true, type: llmDefault.metaData.type, - title: t(`blocks.${llmDefault.metaData.type}`, { ns: 'workflow' }), + title: llmTitle, }, position: { x: START_INITIAL_POSITION.x + NODE_WIDTH_X_OFFSET, diff --git a/web/i18n/en-US/workflow.json b/web/i18n/en-US/workflow.json index 95d7dcc0e3..f6eabb6247 100644 --- a/web/i18n/en-US/workflow.json +++ b/web/i18n/en-US/workflow.json @@ -673,11 +673,11 @@ "nodes.llm.addContext": "Add Context", "nodes.llm.addMessage": "Add Message", "nodes.llm.advancedSettings": "Advanced Settings", - "nodes.llm.computerUse.disabledByStructuredOutput": "Computer Use is disabled when Structured Output is enabled.", + "nodes.llm.computerUse.disabledByStructuredOutput": "Agent mode is disabled when Structured Output is enabled.", "nodes.llm.computerUse.referenceTools": "Reference Tools", "nodes.llm.computerUse.referenceToolsEmpty": "Tools referenced in the prompt will appear here", - "nodes.llm.computerUse.title": "Computer Use", - "nodes.llm.computerUse.tooltip": "Manage the runtime filesystem and tool access for your agent.", + "nodes.llm.computerUse.title": "Agent mode", + "nodes.llm.computerUse.tooltip": "Manage the runtime filesystem and tool access in Agent mode.", "nodes.llm.context": "context", "nodes.llm.contextBlock": "Context Block", "nodes.llm.contextMissing": "Missing context from node {{nodeName}}. Please select a context variable.", diff --git a/web/i18n/ja-JP/workflow.json b/web/i18n/ja-JP/workflow.json index 1e84148160..eabb921a3e 100644 --- a/web/i18n/ja-JP/workflow.json +++ b/web/i18n/ja-JP/workflow.json @@ -648,7 +648,9 @@ "nodes.listFilter.selectVariableKeyPlaceholder": "サブ変数キーを選択する", "nodes.llm.addContext": "コンテキスト追加", "nodes.llm.addMessage": "メッセージ追加", - "nodes.llm.computerUse.disabledByStructuredOutput": "構造化出力を有効にすると、コンピュータ使用は無効になります。", + "nodes.llm.computerUse.disabledByStructuredOutput": "構造化出力を有効にすると、Agent mode は無効になります。", + "nodes.llm.computerUse.title": "Agent mode", + "nodes.llm.computerUse.tooltip": "Agent mode で実行時ファイルシステムとツールアクセスを管理します。", "nodes.llm.context": "コンテキスト", "nodes.llm.contextBlock": "コンテキストブロック", "nodes.llm.contextMissing": "ノード「{{nodeName}}」のコンテキストがありません。コンテキスト変数を選択してください。", diff --git a/web/i18n/zh-Hans/workflow.json b/web/i18n/zh-Hans/workflow.json index cf42023ad7..05ca51b79e 100644 --- a/web/i18n/zh-Hans/workflow.json +++ b/web/i18n/zh-Hans/workflow.json @@ -666,11 +666,11 @@ "nodes.listFilter.selectVariableKeyPlaceholder": "选择子变量的 Key", "nodes.llm.addContext": "添加上下文", "nodes.llm.addMessage": "添加消息", - "nodes.llm.computerUse.disabledByStructuredOutput": "启用结构化输出时,将禁用计算机使用。", + "nodes.llm.computerUse.disabledByStructuredOutput": "启用结构化输出时,将禁用 Agent 模式。", "nodes.llm.computerUse.referenceTools": "引用工具", "nodes.llm.computerUse.referenceToolsEmpty": "提示词中引用的工具会显示在这里", - "nodes.llm.computerUse.title": "计算机使用", - "nodes.llm.computerUse.tooltip": "管理代理的运行时文件系统与工具访问权限。", + "nodes.llm.computerUse.title": "Agent 模式", + "nodes.llm.computerUse.tooltip": "管理 Agent 模式下的运行时文件系统与工具访问权限。", "nodes.llm.context": "上下文", "nodes.llm.contextBlock": "上下文块", "nodes.llm.contextMissing": "缺少前序节点「{{nodeName}}」的上下文,请先选择上下文变量。", diff --git a/web/i18n/zh-Hant/workflow.json b/web/i18n/zh-Hant/workflow.json index 3d86a5c4f3..34c34b5f82 100644 --- a/web/i18n/zh-Hant/workflow.json +++ b/web/i18n/zh-Hant/workflow.json @@ -648,8 +648,10 @@ "nodes.listFilter.selectVariableKeyPlaceholder": "Select sub variable key(選擇子變數鍵)", "nodes.llm.addContext": "新增上下文", "nodes.llm.addMessage": "新增消息", - "nodes.llm.computerUse.disabledByStructuredOutput": "啟用結構化輸出時,將停用電腦使用。", + "nodes.llm.computerUse.disabledByStructuredOutput": "啟用結構化輸出時,將停用 Agent 模式。", "nodes.llm.computerUse.referenceToolsEmpty": "提示詞中引用的工具會顯示在這裡", + "nodes.llm.computerUse.title": "Agent 模式", + "nodes.llm.computerUse.tooltip": "管理 Agent 模式下的執行階段檔案系統與工具存取權限。", "nodes.llm.context": "上下文", "nodes.llm.contextBlock": "上下文區塊", "nodes.llm.contextMissing": "缺少前序節點「{{nodeName}}」的上下文,請先選擇上下文變數。",