@@ -24,8 +24,8 @@ import {
2424 Redo2 ,
2525 Save ,
2626 Search ,
27- Upload ,
2827 Undo2 ,
28+ Upload ,
2929} from "lucide-react" ;
3030import NodePropertiesPanel from "@/components/NodePropertiesPanel" ;
3131import CropImageNode from "@/components/nodes/CropImageNode" ;
@@ -240,6 +240,7 @@ function CanvasEditorInner() {
240240 loadWorkflow,
241241 undo,
242242 redo,
243+ setSelectedNodes,
243244 } = useCanvasStore ( ) ;
244245 const {
245246 startRun,
@@ -359,15 +360,31 @@ function CanvasEditorInner() {
359360 }
360361 } , [ workflowId ] ) ;
361362
363+ // Track selection for single/multi-select runs
364+ const onSelectionChange = useCallback (
365+ ( { nodes : selected } : { nodes : Node [ ] } ) => {
366+ setSelectedNodes ( selected . map ( ( n ) => n . id ) ) ;
367+ } ,
368+ [ setSelectedNodes ] ,
369+ ) ;
370+
362371 // Run execution
363372 const runWorkflow = useCallback ( async ( ) => {
364- const nodeIds = useCanvasStore . getState ( ) . nodes . map ( ( n ) => n . id ) ;
373+ const state = useCanvasStore . getState ( ) ;
374+ const nodeIds =
375+ state . selectedNodeIds . length > 0
376+ ? state . selectedNodeIds
377+ : state . nodes . map ( ( n ) => n . id ) ;
365378
366379 try {
367380 const res = await fetch ( `/api/workflows/${ workflowId } /run` , {
368381 method : "POST" ,
369382 headers : { "Content-Type" : "application/json" } ,
370- body : JSON . stringify ( { } ) ,
383+ body : JSON . stringify (
384+ nodeIds . length < useCanvasStore . getState ( ) . nodes . length
385+ ? { selectedNodeIds : nodeIds }
386+ : { } ,
387+ ) ,
371388 } ) ;
372389 if ( ! res . ok ) return ;
373390
@@ -616,6 +633,7 @@ function CanvasEditorInner() {
616633 isValidConnection = { isValidConnection }
617634 deleteKeyCode = "Delete"
618635 multiSelectionKeyCode = "Shift"
636+ onSelectionChange = { onSelectionChange }
619637 fitView
620638 colorMode = "light"
621639 className = "bg-white text-gray-900"
0 commit comments