Skip to content

Commit 5f5657f

Browse files
committed
improvement(execution): use individual selectors to avoid unnecessary re-renders from unselectored store hook
1 parent b641c6f commit 5f5657f

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/action-bar/action-bar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export const ActionBar = memo(
115115

116116
const { activeWorkflowId } = useWorkflowRegistry()
117117
const { isExecuting } = useCurrentWorkflowExecution()
118-
const { getLastExecutionSnapshot } = useExecutionStore()
118+
const getLastExecutionSnapshot = useExecutionStore((s) => s.getLastExecutionSnapshot)
119119
const userPermissions = useUserPermissionsContext()
120120
const edges = useWorkflowStore((state) => state.edges)
121121

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,17 @@ export function useWorkflowExecution() {
114114
const { getVariablesByWorkflowId, variables } = useVariablesStore()
115115
const { isExecuting, isDebugging, pendingBlocks, executor, debugContext } =
116116
useCurrentWorkflowExecution()
117-
const {
118-
setIsExecuting,
119-
setIsDebugging,
120-
setPendingBlocks,
121-
setExecutor,
122-
setDebugContext,
123-
setActiveBlocks,
124-
setBlockRunStatus,
125-
setEdgeRunStatus,
126-
setLastExecutionSnapshot,
127-
getLastExecutionSnapshot,
128-
clearLastExecutionSnapshot,
129-
} = useExecutionStore()
117+
const setIsExecuting = useExecutionStore((s) => s.setIsExecuting)
118+
const setIsDebugging = useExecutionStore((s) => s.setIsDebugging)
119+
const setPendingBlocks = useExecutionStore((s) => s.setPendingBlocks)
120+
const setExecutor = useExecutionStore((s) => s.setExecutor)
121+
const setDebugContext = useExecutionStore((s) => s.setDebugContext)
122+
const setActiveBlocks = useExecutionStore((s) => s.setActiveBlocks)
123+
const setBlockRunStatus = useExecutionStore((s) => s.setBlockRunStatus)
124+
const setEdgeRunStatus = useExecutionStore((s) => s.setEdgeRunStatus)
125+
const setLastExecutionSnapshot = useExecutionStore((s) => s.setLastExecutionSnapshot)
126+
const getLastExecutionSnapshot = useExecutionStore((s) => s.getLastExecutionSnapshot)
127+
const clearLastExecutionSnapshot = useExecutionStore((s) => s.clearLastExecutionSnapshot)
130128
const [executionResult, setExecutionResult] = useState<ExecutionResult | null>(null)
131129
const executionStream = useExecutionStream()
132130
const currentChatExecutionIdRef = useRef<string | null>(null)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ const WorkflowContent = React.memo(() => {
741741
)
742742

743743
const { activeBlockIds, pendingBlocks, isDebugging, isExecuting } = useCurrentWorkflowExecution()
744-
const { getLastExecutionSnapshot } = useExecutionStore()
744+
const getLastExecutionSnapshot = useExecutionStore((s) => s.getLastExecutionSnapshot)
745745

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

0 commit comments

Comments
 (0)