Skip to content

Commit c6b73bd

Browse files
committed
improvement(execution): use useShallow selector in workflow.tsx to avoid re-renders from lastRunPath/lastRunEdges changes
1 parent 5f5657f commit c6b73bd

File tree

1 file changed

+12
-2
lines changed
  • apps/sim/app/workspace/[workspaceId]/w/[workflowId]

1 file changed

+12
-2
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import { useStreamCleanup } from '@/hooks/use-stream-cleanup'
7474
import { useCanvasModeStore } from '@/stores/canvas-mode'
7575
import { useChatStore } from '@/stores/chat/store'
7676
import { useCopilotTrainingStore } from '@/stores/copilot-training/store'
77-
import { useCurrentWorkflowExecution, useExecutionStore } from '@/stores/execution'
77+
import { defaultWorkflowExecutionState, useExecutionStore } from '@/stores/execution'
7878
import { useSearchModalStore } from '@/stores/modals/search/store'
7979
import { useNotificationStore } from '@/stores/notifications'
8080
import { useCopilotStore, usePanelEditorStore } from '@/stores/panel'
@@ -740,7 +740,17 @@ const WorkflowContent = React.memo(() => {
740740
[collaborativeBatchAddBlocks, setSelectedEdges, setPendingSelection]
741741
)
742742

743-
const { activeBlockIds, pendingBlocks, isDebugging, isExecuting } = useCurrentWorkflowExecution()
743+
const { activeBlockIds, pendingBlocks, isDebugging, isExecuting } = useExecutionStore(
744+
useShallow((state) => {
745+
const wf = activeWorkflowId ? state.workflowExecutions.get(activeWorkflowId) : undefined
746+
return {
747+
activeBlockIds: wf?.activeBlockIds ?? defaultWorkflowExecutionState.activeBlockIds,
748+
pendingBlocks: wf?.pendingBlocks ?? defaultWorkflowExecutionState.pendingBlocks,
749+
isDebugging: wf?.isDebugging ?? false,
750+
isExecuting: wf?.isExecuting ?? false,
751+
}
752+
})
753+
)
744754
const getLastExecutionSnapshot = useExecutionStore((s) => s.getLastExecutionSnapshot)
745755

746756
const [dragStartParentId, setDragStartParentId] = useState<string | null>(null)

0 commit comments

Comments
 (0)