@@ -98,13 +98,47 @@ app.registerExtension({
9898 // Update prompt addition names
9999 if ( node . promptAdditionNameWidget ) {
100100 const additionNames = Object . keys ( this . promptAdditions ) ;
101+ const currentValue = node . promptAdditionNameWidget . value ;
101102 node . promptAdditionNameWidget . options . values = additionNames . length > 0 ? additionNames : [ "" ] ;
103+
104+ // Trigger a redraw of the widget dropdown
105+ if ( node . promptAdditionNameWidget . inputEl ) {
106+ // Clear existing options
107+ node . promptAdditionNameWidget . inputEl . innerHTML = "" ;
108+ // Rebuild options
109+ node . promptAdditionNameWidget . options . values . forEach ( value => {
110+ const option = document . createElement ( "option" ) ;
111+ option . value = value ;
112+ option . textContent = value ;
113+ if ( value === currentValue ) {
114+ option . selected = true ;
115+ }
116+ node . promptAdditionNameWidget . inputEl . appendChild ( option ) ;
117+ } ) ;
118+ }
102119 }
103120
104121 // Update prompt group names
105122 if ( node . promptAdditionGroupWidget ) {
106123 const groupNames = this . promptGroups . map ( g => g . name ) ;
124+ const currentValue = node . promptAdditionGroupWidget . value ;
107125 node . promptAdditionGroupWidget . options . values = groupNames . length > 0 ? groupNames : [ "" ] ;
126+
127+ // Trigger a redraw of the widget dropdown
128+ if ( node . promptAdditionGroupWidget . inputEl ) {
129+ // Clear existing options
130+ node . promptAdditionGroupWidget . inputEl . innerHTML = "" ;
131+ // Rebuild options
132+ node . promptAdditionGroupWidget . options . values . forEach ( value => {
133+ const option = document . createElement ( "option" ) ;
134+ option . value = value ;
135+ option . textContent = value ;
136+ if ( value === currentValue ) {
137+ option . selected = true ;
138+ }
139+ node . promptAdditionGroupWidget . inputEl . appendChild ( option ) ;
140+ } ) ;
141+ }
108142 }
109143
110144 // Handle widget visibility based on addition_type
@@ -540,6 +574,57 @@ app.registerExtension({
540574 node . promptAdditions = { } ;
541575 node . promptAdditionNames = { } ;
542576 node . promptGroups = [ ] ;
577+
578+ // Add refreshWidgetOptions method to all nodes that might have dropdown widgets
579+ if ( ! node . refreshWidgetOptions ) {
580+ node . refreshWidgetOptions = function ( node ) {
581+ // Update prompt addition names (for nodes with prompt_addition_name dropdown)
582+ if ( node . promptAdditionNameWidget ) {
583+ const additionNames = Object . keys ( this . promptAdditions ) ;
584+ const currentValue = node . promptAdditionNameWidget . value ;
585+ node . promptAdditionNameWidget . options . values = additionNames . length > 0 ? additionNames : [ "" ] ;
586+
587+ // Trigger a redraw of the widget dropdown
588+ if ( node . promptAdditionNameWidget . inputEl ) {
589+ // Clear existing options
590+ node . promptAdditionNameWidget . inputEl . innerHTML = "" ;
591+ // Rebuild options
592+ node . promptAdditionNameWidget . options . values . forEach ( value => {
593+ const option = document . createElement ( "option" ) ;
594+ option . value = value ;
595+ option . textContent = value ;
596+ if ( value === currentValue ) {
597+ option . selected = true ;
598+ }
599+ node . promptAdditionNameWidget . inputEl . appendChild ( option ) ;
600+ } ) ;
601+ }
602+ }
603+
604+ // Update prompt group names (for nodes with prompt_addition_group dropdown)
605+ if ( node . promptAdditionGroupWidget ) {
606+ const groupNames = this . promptGroups . map ( g => g . name ) ;
607+ const currentValue = node . promptAdditionGroupWidget . value ;
608+ node . promptAdditionGroupWidget . options . values = groupNames . length > 0 ? groupNames : [ "" ] ;
609+
610+ // Trigger a redraw of the widget dropdown
611+ if ( node . promptAdditionGroupWidget . inputEl ) {
612+ // Clear existing options
613+ node . promptAdditionGroupWidget . inputEl . innerHTML = "" ;
614+ // Rebuild options
615+ node . promptAdditionGroupWidget . options . values . forEach ( value => {
616+ const option = document . createElement ( "option" ) ;
617+ option . value = value ;
618+ option . textContent = value ;
619+ if ( value === currentValue ) {
620+ option . selected = true ;
621+ }
622+ node . promptAdditionGroupWidget . inputEl . appendChild ( option ) ;
623+ } ) ;
624+ }
625+ }
626+ } ;
627+ }
543628
544629 // Load prompt data
545630 const promptAdditions = await ApiOperations . getPromptAdditions ( ) ;
@@ -579,13 +664,27 @@ app.registerExtension({
579664 node . promptAdditions = newPromptAdditionsObject ;
580665 node . promptAdditionNames = Object . keys ( newPromptAdditionsObject ) ;
581666 node . promptGroups = event . detail . prompt_groups || [ ] ;
667+
668+ // Refresh dropdown widgets for nodes without updatePromptData method
669+ if ( node . refreshWidgetOptions ) {
670+ node . refreshWidgetOptions ( node ) ;
671+ }
582672 }
583673 } ;
584674
585675 api . addEventListener ( "prompt-companion.addition-list" , eventListener ) ;
586676
587677 // Store the event listener for cleanup
588678 node . eventListener = eventListener ;
679+
680+ // Set up widget references for nodes that have dropdown widgets
681+ if ( node . comfyClass === "PromptCompanionSingleAddition" || node . comfyClass === "PromptCompanion" ) {
682+ node . promptAdditionNameWidget = node . widgets ?. find ( ( w ) => w . name === "prompt_addition_name" ) ;
683+ }
684+
685+ if ( node . comfyClass === "PromptCompanionPromptGroup" || node . comfyClass === "PromptCompanion" ) {
686+ node . promptAdditionGroupWidget = node . widgets ?. find ( ( w ) => w . name === "prompt_addition_group" ) ;
687+ }
589688 }
590689
591690 if ( node . comfyClass == "PromptCompanion" ) {
0 commit comments