From aa3cc9b9a0a341234e21dd8904084a74da7c365c Mon Sep 17 00:00:00 2001 From: yyh Date: Fri, 23 Jan 2026 13:15:39 +0800 Subject: [PATCH] fix(skill-editor): add START_TAB_ID guards to prevent invalid metadata operations - Add guards in tool-block component to skip metadata read/write when Start tab is active - Add guard in tool-picker-block to prevent writing tool config to Start tab - Add guard in use-sync-tree-with-active-tab to skip tree sync for Start tab --- .../editor/skill-editor/plugins/tool-block/component.tsx | 5 +++-- .../skill-editor/plugins/tool-block/tool-picker-block.tsx | 3 ++- .../workflow/skill/hooks/use-sync-tree-with-active-tab.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx index 6977f17644..8263bdb3e8 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/component.tsx @@ -18,6 +18,7 @@ import { ReadmeShowType } from '@/app/components/plugins/readme-panel/store' import { CollectionType } from '@/app/components/tools/types' import { generateFormValue, toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import { VarKindType } from '@/app/components/workflow/nodes/_base/types' +import { START_TAB_ID } from '@/app/components/workflow/skill/constants' import ToolSettingsSection from '@/app/components/workflow/skill/editor/skill-editor/tool-setting/tool-settings-section' import { useStore, useWorkflowStore } from '@/app/components/workflow/store' import { useGetLanguage } from '@/context/i18n' @@ -169,7 +170,7 @@ const ToolBlockComponent: FC = ({ const metadata = toolBlockContext?.metadata as SkillFileMetadata | undefined return metadata?.tools?.[configId] } - if (!activeTabId) + if (!activeTabId || activeTabId === START_TAB_ID) return undefined const metadata = fileMetadata.get(activeTabId) as SkillFileMetadata | undefined return metadata?.tools?.[configId] @@ -365,7 +366,7 @@ const ToolBlockComponent: FC = ({ toolBlockContext?.onMetadataChange?.(nextMetadata) return } - if (!activeTabId) + if (!activeTabId || activeTabId === START_TAB_ID) return const metadata = (fileMetadata.get(activeTabId) || {}) as SkillFileMetadata const toolType = currentProvider.type === CollectionType.mcp ? 'mcp' : 'builtin' diff --git a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx index 454fa2ce0f..2beb92ed9e 100644 --- a/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx +++ b/web/app/components/workflow/skill/editor/skill-editor/plugins/tool-block/tool-picker-block.tsx @@ -16,6 +16,7 @@ import { useBasicTypeaheadTriggerMatch } from '@/app/components/base/prompt-edit import { $splitNodeContainingQuery } from '@/app/components/base/prompt-editor/utils' import { toolParametersToFormSchemas } from '@/app/components/tools/utils/to-form-schema' import ToolPicker from '@/app/components/workflow/block-selector/tool-picker' +import { START_TAB_ID } from '@/app/components/workflow/skill/constants' import { useWorkflowStore } from '@/app/components/workflow/store' import { $createToolBlockNode } from './node' import { useToolBlockContext } from './tool-block-context' @@ -95,7 +96,7 @@ const ToolPickerBlock: FC = ({ scope = 'all' }) => { return } const { activeTabId, fileMetadata, setDraftMetadata, pinTab } = storeApi.getState() - if (!activeTabId) + if (!activeTabId || activeTabId === START_TAB_ID) return const metadata = (fileMetadata.get(activeTabId) || {}) as Record const nextTools = { ...(metadata.tools || {}) } as Record diff --git a/web/app/components/workflow/skill/hooks/use-sync-tree-with-active-tab.ts b/web/app/components/workflow/skill/hooks/use-sync-tree-with-active-tab.ts index 75d5dbc8f4..19a75f36de 100644 --- a/web/app/components/workflow/skill/hooks/use-sync-tree-with-active-tab.ts +++ b/web/app/components/workflow/skill/hooks/use-sync-tree-with-active-tab.ts @@ -3,6 +3,7 @@ import type { TreeApi } from 'react-arborist' import type { TreeNodeData } from '../type' import { useEffect } from 'react' +import { START_TAB_ID } from '@/app/components/workflow/skill/constants' import { useWorkflowStore } from '@/app/components/workflow/store' type UseSyncTreeWithActiveTabOptions = { @@ -24,7 +25,7 @@ export function useSyncTreeWithActiveTab({ const storeApi = useWorkflowStore() useEffect(() => { - if (!activeTabId) + if (!activeTabId || activeTabId === START_TAB_ID) return const tree = treeRef.current