@@ -126,11 +126,6 @@ function createKeyCombinationHook(
126
126
) : PhoenixHook {
127
127
return {
128
128
mounted ( ) {
129
- // Debug logging for OpenRunPanelViaCtrlEnter hook
130
- if ( action === openRunPanelAction ) {
131
- console . log ( '🔧 OpenRunPanelViaCtrlEnter hook mounted successfully!' ) ;
132
- }
133
-
134
129
const handler = { hook : this , keyCheck, action, priority, bindingScope } ;
135
130
keyHandlers . add ( handler ) ;
136
131
@@ -139,11 +134,6 @@ function createKeyCombinationHook(
139
134
this . callback = ( e : KeyboardEvent ) => {
140
135
if ( ! keyCheck ( e ) ) return ;
141
136
142
- // Debug logging for Ctrl+Enter
143
- if ( action === openRunPanelAction && keyCheck === isCtrlOrMetaEnter ) {
144
- console . log ( '⌨️ Ctrl+Enter detected by OpenRunPanelViaCtrlEnter hook' ) ;
145
- }
146
-
147
137
e . preventDefault ( ) ;
148
138
149
139
const target = e . target as HTMLElement ;
@@ -378,26 +368,52 @@ export const CloseNodePanelViaEscape = createKeyCombinationHook(
378
368
) ;
379
369
380
370
/**
381
- * Navigates to the run panel by clicking the existing run button .
371
+ * Handles Ctrl+Enter to either open run panel or execute workflow .
382
372
*
383
373
* @param e - The keyboard event that triggered the action.
384
374
* @param el - The DOM element associated with the hook.
385
375
*/
386
376
const openRunPanelAction = ( _e : KeyboardEvent , _el : HTMLElement ) => {
387
- console . log ( '🚀 OpenRunPanelViaCtrlEnter action triggered!' ) ;
377
+ // Check if run panel is already open by looking at the URL
378
+ const isRunPanelOpen = window . location . href . includes ( 'm=workflow_input' ) ;
388
379
389
- // Find the existing run button and click it
390
- const runButton = document . querySelector ( 'a[href*="m=workflow_input"]' ) as HTMLAnchorElement ;
391
- console . log ( '🔍 Found run button:' , runButton ) ;
392
-
393
- if ( runButton ) {
394
- console . log ( '✅ Clicking run button with href:' , runButton . href ) ;
395
- runButton . click ( ) ;
380
+ if ( isRunPanelOpen ) {
381
+ // Panel is open, try to click the "Run Workflow Now" button
382
+ // Look for various possible selectors for the run button
383
+ const selectors = [
384
+ 'button[type="submit"][form*="manual_run"]' ,
385
+ 'button[id*="save-and-run"]' ,
386
+ 'button[phx-click*="manual_run"]' ,
387
+ 'input[type="submit"][form*="manual"]'
388
+ ] ;
389
+
390
+ let foundButton : HTMLElement | null = null ;
391
+
392
+ // Try CSS selectors first
393
+ for ( const selector of selectors ) {
394
+ const element = document . querySelector ( selector ) as HTMLElement ;
395
+ if ( element && ! element . hasAttribute ( 'disabled' ) ) {
396
+ foundButton = element ;
397
+ break ;
398
+ }
399
+ }
400
+
401
+ // If no specific selector worked, search for buttons containing "Run"
402
+ if ( ! foundButton ) {
403
+ const buttons = document . querySelectorAll ( 'button, input[type="submit"]' ) ;
404
+ foundButton = Array . from ( buttons ) . find ( btn => {
405
+ const text = btn . textContent ?. toLowerCase ( ) || '' ;
406
+ return text . includes ( 'run' ) && ! btn . hasAttribute ( 'disabled' ) ;
407
+ } ) as HTMLElement | undefined || null ;
408
+ }
409
+
410
+ if ( foundButton ) {
411
+ foundButton . click ( ) ;
412
+ }
396
413
} else {
397
- console . log ( '❌ No run button found' ) ;
398
- // Let's also check for other run-related buttons
399
- const allRunButtons = document . querySelectorAll ( 'a[href*="workflow_input"], button[type="button"]' ) ;
400
- console . log ( '📋 All potential run buttons:' , allRunButtons ) ;
414
+ // Panel is not open, open it by clicking the run link
415
+ const runButton = document . querySelector ( 'a[href*="m=workflow_input"]' ) as HTMLAnchorElement ;
416
+ runButton ?. click ( ) ;
401
417
}
402
418
} ;
403
419
0 commit comments