Skip to content

Commit 2766a39

Browse files
MaxwellCalkinclaude
andcommitted
fix: address review feedback on validation logic
- Allow single-block workflows to run (blockCount > 1 check instead of hasBlocks && !hasEdges, which incorrectly blocked standalone blocks) - Guard Mod+Enter keyboard shortcut with isButtonDisabled to match Run button behavior and prevent bypassing validation - Add explicit variables: {} default in deploy route to avoid relying on type assertion to paper over a missing field Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a072602 commit 2766a39

File tree

2 files changed

+7
-3
lines changed
  • apps/sim/app
    • api/workflows/[id]/deploy
    • workspace/[workspaceId]/w/[workflowId]/components/panel

2 files changed

+7
-3
lines changed

apps/sim/app/api/workflows/[id]/deploy/route.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export async function POST(request: NextRequest, { params }: { params: Promise<{
141141
edges: normalizedData.edges,
142142
loops: normalizedData.loops,
143143
parallels: normalizedData.parallels,
144+
variables: {},
144145
} as WorkflowState)
145146
if (!workflowValidation.valid) {
146147
const errorSummary = workflowValidation.errors.join('; ')

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,12 @@ export const Panel = memo(function Panel() {
357357
const canRun = userPermissions.canRead // Running only requires read permissions
358358
const isLoadingPermissions = userPermissions.isLoading
359359

360-
// Validate workflow has connected blocks (at least one edge means blocks are wired together)
360+
// Validate workflow has connected blocks when multiple blocks exist.
361+
// A single-block workflow (e.g. one starter or agent block) is valid without edges,
362+
// but multiple blocks with no edges indicates a disconnected graph.
363+
const blockCount = useWorkflowStore((state) => Object.keys(state.blocks).length)
361364
const hasEdges = useWorkflowStore((state) => state.edges.length > 0)
362-
const hasValidationErrors = hasBlocks && !hasEdges
365+
const hasValidationErrors = blockCount > 1 && !hasEdges
363366

364367
const isWorkflowBlocked = isExecuting || hasValidationErrors
365368
const isButtonDisabled = !isExecuting && (isWorkflowBlocked || (!canRun && !isLoadingPermissions))
@@ -377,7 +380,7 @@ export const Panel = memo(function Panel() {
377380
handler: () => {
378381
if (isExecuting) {
379382
void cancelWorkflow()
380-
} else {
383+
} else if (!isButtonDisabled) {
381384
void runWorkflow()
382385
}
383386
},

0 commit comments

Comments
 (0)