mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 01:18:05 +08:00
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
This commit is contained in:
@ -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<ToolBlockComponentProps> = ({
|
||||
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<ToolBlockComponentProps> = ({
|
||||
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'
|
||||
|
||||
@ -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<ToolPickerBlockProps> = ({ 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<string, unknown>
|
||||
const nextTools = { ...(metadata.tools || {}) } as Record<string, unknown>
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user