-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: enable workflow validation before deployment (was hardcoded to false) #3579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
1376793
70dd04d
30c68ae
d646ee1
945b207
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…recomputation - Use individual selectors for blocks/edges/loops/parallels with useShallow - Memoize validation result with useMemo, only recomputing when deps change - Pass shallow copies of state to validateWorkflowState to prevent any internal mutation from affecting Zustand store state Addresses Bugbot review feedback for #3579
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| 'use client' | ||
|
|
||
| import { memo, useCallback, useEffect, useRef, useState } from 'react' | ||
| import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react' | ||
| import { createLogger } from '@sim/logger' | ||
| import { ArrowUp, Lock, Square, Unlock } from 'lucide-react' | ||
| import { useParams, useRouter } from 'next/navigation' | ||
|
|
@@ -357,16 +357,25 @@ export const Panel = memo(function Panel() { | |
| // Compute run button state | ||
| const canRun = userPermissions.canRead // Running only requires read permissions | ||
| const isLoadingPermissions = userPermissions.isLoading | ||
| const hasValidationErrors = useWorkflowStore((state) => { | ||
| if (Object.keys(state.blocks).length === 0) return false | ||
| // Memoize workflow structure to avoid re-validating on every store change | ||
| // (e.g. block dragging at 60fps, text input, etc.) | ||
| const blocks = useWorkflowStore((state) => state.blocks) | ||
| const edges = useWorkflowStore((state) => state.edges) | ||
| const loops = useWorkflowStore((state) => state.loops) | ||
| const parallels = useWorkflowStore((state) => state.parallels) | ||
|
|
||
| const hasValidationErrors = useMemo(() => { | ||
| if (Object.keys(blocks).length === 0) return false | ||
| // Pass shallow copies to validateWorkflowState to prevent any | ||
| // internal mutation from affecting Zustand store state | ||
| const result = validateWorkflowState({ | ||
| blocks: state.blocks, | ||
| edges: state.edges, | ||
| loops: state.loops || {}, | ||
| parallels: state.parallels || {}, | ||
| blocks: { ...blocks }, | ||
| edges: [...edges], | ||
| loops: { ...(loops || {}) }, | ||
| parallels: { ...(parallels || {}) }, | ||
| }) | ||
| return !result.valid | ||
| }) | ||
| }, [blocks, edges, loops, parallels]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keyboard shortcut bypasses validation-disabled Run buttonMedium Severity The Additional Locations (1) |
||
| const isWorkflowBlocked = isExecuting || hasValidationErrors | ||
| const isButtonDisabled = !isExecuting && (isWorkflowBlocked || (!canRun && !isLoadingPermissions)) | ||
|
|
||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deploy button not disabled when validation errors exist
Medium Severity
The new
hasValidationErrorsvalue only feeds intoisWorkflowBlocked→isButtonDisabled, which is wired to the Run button. TheDeploycomponent doesn't receivehasValidationErrorsas a prop and its ownisDisabled(isDeploying || !canDeploy || isEmpty) doesn't account for validation errors. Users can still click Deploy on an invalid workflow. The backend will reject it, but the UI-layer prevention described in the PR is missing for the Deploy button.