@@ -13,20 +13,15 @@ import {
1313} from '@/components/emcn'
1414import { cn } from '@/lib/core/utils/cn'
1515import { FIELD_TYPE_LABELS , getPlaceholderForFieldType } from '@/lib/knowledge/constants'
16- import { buildCanonicalIndex , resolveDependencyValue } from '@/lib/workflows/subblocks/visibility'
1716import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text'
1817import { TagDropdown } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown'
18+ import { useDependsOnGate } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate'
1919import { useSubBlockInput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-input'
2020import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
21- import { resolvePreviewContextValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/utils'
2221import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-accessible-reference-prefixes'
23- import { getBlock } from '@/blocks/registry'
2422import type { SubBlockConfig } from '@/blocks/types'
2523import { useKnowledgeBaseTagDefinitions } from '@/hooks/kb/use-knowledge-base-tag-definitions'
2624import { useTagSelection } from '@/hooks/kb/use-tag-selection'
27- import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
28- import { useSubBlockStore } from '@/stores/workflows/subblock/store'
29- import { useWorkflowStore } from '@/stores/workflows/workflow/store'
3025
3126interface DocumentTag {
3227 id : string
@@ -65,26 +60,11 @@ export function DocumentTagEntry({
6560 previewValue,
6661 previewContextValues,
6762} : DocumentTagEntryProps ) {
68- const { activeWorkflowId } = useWorkflowRegistry ( )
6963 const [ storeValue , setStoreValue ] = useSubBlockValue < string > ( blockId , subBlock . id )
7064 const accessiblePrefixes = useAccessibleReferencePrefixes ( blockId )
7165 const valueInputRefs = useRef < Record < string , HTMLInputElement > > ( { } )
7266 const overlayRefs = useRef < Record < string , HTMLDivElement > > ( { } )
7367
74- const blockState = useWorkflowStore ( ( state ) => state . blocks [ blockId ] )
75- const blockConfig = blockState ?. type ? getBlock ( blockState . type ) : null
76- const canonicalIndex = useMemo (
77- ( ) => buildCanonicalIndex ( blockConfig ?. subBlocks || [ ] ) ,
78- [ blockConfig ?. subBlocks ]
79- )
80- const canonicalModeOverrides = blockState ?. data ?. canonicalModes
81-
82- const blockValues = useSubBlockStore ( ( state ) => {
83- if ( ! activeWorkflowId ) return { }
84- const workflowValues = state . workflowValues [ activeWorkflowId ] || { }
85- return ( workflowValues as Record < string , Record < string , unknown > > ) [ blockId ] || { }
86- } )
87-
8868 const inputController = useSubBlockInput ( {
8969 blockId,
9070 subBlockId : subBlock . id ,
@@ -97,18 +77,12 @@ export function DocumentTagEntry({
9777 disabled,
9878 } )
9979
100- const knowledgeBaseIdValue = useMemo (
101- ( ) =>
102- previewContextValues
103- ? resolvePreviewContextValue ( previewContextValues . knowledgeBaseId )
104- : resolveDependencyValue (
105- 'knowledgeBaseId' ,
106- blockValues ,
107- canonicalIndex ,
108- canonicalModeOverrides
109- ) ,
110- [ previewContextValues , blockValues , canonicalIndex , canonicalModeOverrides ]
111- )
80+ const { dependencyValues } = useDependsOnGate ( blockId , subBlock , {
81+ disabled,
82+ isPreview,
83+ previewContextValues,
84+ } )
85+ const knowledgeBaseIdValue = dependencyValues . knowledgeBaseSelector
11286 const knowledgeBaseId =
11387 typeof knowledgeBaseIdValue === 'string' && knowledgeBaseIdValue . trim ( ) . length > 0
11488 ? knowledgeBaseIdValue
0 commit comments