11import { useCallback , useMemo } from 'react'
2- import { cn } from '@/lib/utils'
32import { useExecutionStore } from '@/stores/execution/store'
43import { usePanelEditorStore } from '@/stores/panel-new/editor/store'
54import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
65import { useBlockState } from '../components/workflow-block/hooks'
76import type { WorkflowBlockProps } from '../components/workflow-block/types'
7+ import { getBlockRingStyles } from '../utils/block-ring-utils'
88import { useCurrentWorkflow } from './use-current-workflow'
99
1010interface UseBlockCoreOptions {
@@ -43,60 +43,19 @@ export function useBlockCore({ blockId, data, isPending = false }: UseBlockCoreO
4343 } , [ blockId , setCurrentBlockId ] )
4444
4545 // Ring styling based on all states
46- // Priority: active (animated) > pending > focused > deleted > diff > run path
47- const { hasRing, ringStyles } = useMemo ( ( ) => {
48- const hasRing =
49- isActive ||
50- isPending ||
51- isFocused ||
52- diffStatus === 'new' ||
53- diffStatus === 'edited' ||
54- isDeletedBlock ||
55- ! ! runPathStatus
56-
57- const ringStyles = cn (
58- // Executing block: animated ring cycling through gray tones (animation handles all styling)
59- isActive && 'animate-ring-pulse' ,
60- // Non-active states use standard ring utilities
61- ! isActive && hasRing && 'ring-[1.75px]' ,
62- // Pending state: warning ring
63- ! isActive && isPending && 'ring-[var(--warning)]' ,
64- // Focused (selected) state: brand ring
65- ! isActive && ! isPending && isFocused && 'ring-[var(--brand-secondary)]' ,
66- // Deleted state (highest priority after active/pending/focused)
67- ! isActive && ! isPending && ! isFocused && isDeletedBlock && 'ring-[var(--text-error)]' ,
68- // Diff states
69- ! isActive &&
70- ! isPending &&
71- ! isFocused &&
72- ! isDeletedBlock &&
73- diffStatus === 'new' &&
74- 'ring-[#22C55E]' ,
75- ! isActive &&
76- ! isPending &&
77- ! isFocused &&
78- ! isDeletedBlock &&
79- diffStatus === 'edited' &&
80- 'ring-[var(--warning)]' ,
81- // Run path states (lowest priority - only show if no other states active)
82- ! isActive &&
83- ! isPending &&
84- ! isFocused &&
85- ! isDeletedBlock &&
86- ! diffStatus &&
87- runPathStatus === 'success' &&
88- 'ring-[var(--surface-14)]' ,
89- ! isActive &&
90- ! isPending &&
91- ! isFocused &&
92- ! isDeletedBlock &&
93- ! diffStatus &&
94- runPathStatus === 'error' &&
95- 'ring-[var(--text-error)]'
96- )
97-
98- return { hasRing, ringStyles }
99- } , [ isActive , isPending , isFocused , diffStatus , isDeletedBlock , runPathStatus ] )
46+ // Priority: active (executing) > pending > focused > deleted > diff > run path
47+ const { hasRing, ringClassName : ringStyles } = useMemo (
48+ ( ) =>
49+ getBlockRingStyles ( {
50+ isActive,
51+ isPending,
52+ isFocused,
53+ isDeletedBlock,
54+ diffStatus,
55+ runPathStatus,
56+ } ) ,
57+ [ isActive , isPending , isFocused , isDeletedBlock , diffStatus , runPathStatus ]
58+ )
10059
10160 return {
10261 // Workflow context
@@ -116,5 +75,6 @@ export function useBlockCore({ blockId, data, isPending = false }: UseBlockCoreO
11675 // Ring styling
11776 hasRing,
11877 ringStyles,
78+ runPathStatus,
11979 }
12080}
0 commit comments