@@ -109,7 +109,7 @@ const InputControl = ({
109
109
110
110
export const ControlPanel = ( { panelState, onStateChange } : ControlPanelProps ) => {
111
111
const { controlChannel } = usePeerContext ( ) ;
112
- const { currentPrompt , setCurrentPrompt } = usePrompt ( ) ;
112
+ const { currentPrompts , setCurrentPrompts } = usePrompt ( ) ;
113
113
const [ availableNodes , setAvailableNodes ] = useState < Record < string , NodeInfo > > ( { } ) ;
114
114
115
115
// Add ref to track last sent value and timeout
@@ -139,7 +139,7 @@ export const ControlPanel = ({ panelState, onStateChange }: ControlPanelProps) =
139
139
const data = JSON . parse ( event . data ) ;
140
140
if ( data . type === "nodes_info" ) {
141
141
setAvailableNodes ( data . nodes ) ;
142
- } else if ( data . type === "prompt_updated " ) {
142
+ } else if ( data . type === "prompts_updated " ) {
143
143
if ( ! data . success ) {
144
144
console . error ( "[ControlPanel] Failed to update prompt" ) ;
145
145
}
@@ -171,7 +171,7 @@ export const ControlPanel = ({ panelState, onStateChange }: ControlPanelProps) =
171
171
// Modify the effect that sends updates with debouncing
172
172
useEffect ( ( ) => {
173
173
const currentInput = panelState . nodeId && panelState . fieldName ? availableNodes [ panelState . nodeId ] ?. inputs [ panelState . fieldName ] : null ;
174
- if ( ! currentInput || ! currentPrompt ) return ;
174
+ if ( ! currentInput || ! currentPrompts ) return ;
175
175
176
176
let isValidValue = true ;
177
177
let processedValue : any = panelState . value ;
@@ -218,6 +218,7 @@ export const ControlPanel = ({ panelState, onStateChange }: ControlPanelProps) =
218
218
// Set a new timeout for the update
219
219
updateTimeoutRef . current = setTimeout ( ( ) => {
220
220
// Create updated prompt while maintaining current structure
221
+ const currentPrompt = currentPrompts [ 0 ] ;
221
222
const updatedPrompt = JSON . parse ( JSON . stringify ( currentPrompt ) ) ; // Deep clone
222
223
if ( updatedPrompt [ panelState . nodeId ] && updatedPrompt [ panelState . nodeId ] . inputs ) {
223
224
updatedPrompt [ panelState . nodeId ] . inputs [ panelState . fieldName ] = processedValue ;
@@ -231,17 +232,17 @@ export const ControlPanel = ({ panelState, onStateChange }: ControlPanelProps) =
231
232
232
233
// Send the full prompt update
233
234
const message = JSON . stringify ( {
234
- type : "update_prompt " ,
235
- prompt : updatedPrompt
235
+ type : "update_prompts " ,
236
+ prompts : [ updatedPrompt ]
236
237
} ) ;
237
238
controlChannel . send ( message ) ;
238
239
239
240
// Only update current prompt after sending
240
- setCurrentPrompt ( updatedPrompt ) ;
241
+ setCurrentPrompts ( [ updatedPrompt ] ) ;
241
242
}
242
243
} , currentInput . type . toLowerCase ( ) === 'number' ? 100 : 300 ) ; // Shorter delay for numbers, longer for text
243
244
}
244
- } , [ panelState . value , panelState . nodeId , panelState . fieldName , panelState . isAutoUpdateEnabled , controlChannel , availableNodes , currentPrompt , setCurrentPrompt ] ) ;
245
+ } , [ panelState . value , panelState . nodeId , panelState . fieldName , panelState . isAutoUpdateEnabled , controlChannel , availableNodes , currentPrompts , setCurrentPrompts ] ) ;
245
246
246
247
const toggleAutoUpdate = ( ) => {
247
248
onStateChange ( { isAutoUpdateEnabled : ! panelState . isAutoUpdateEnabled } ) ;
0 commit comments