@@ -98,6 +98,38 @@ document.addEventListener('comfy-extension-registered', (event) => {
9898 }
9999} ) ;
100100
101+ async function restartComfyUI ( ) {
102+ try {
103+ const response = await fetch ( '/comfyui/restart' , {
104+ method : 'POST' ,
105+ headers : {
106+ 'Content-Type' : 'application/json' ,
107+ 'Accept' : 'application/json'
108+ } ,
109+ body : "" // No body needed
110+ } ) ;
111+
112+ if ( ! response . ok ) {
113+ const errorText = await response . text ( ) ;
114+ console . error ( "[ComfyStream] ComfyUI restart returned error response:" , response . status , errorText ) ;
115+ try {
116+ const errorData = JSON . parse ( errorText ) ;
117+ throw new Error ( errorData . error || `Server error: ${ response . status } ` ) ;
118+ } catch ( e ) {
119+ throw new Error ( `Server error: ${ response . status } - ${ errorText } ` ) ;
120+ }
121+ }
122+
123+ const data = await response . json ( ) ;
124+
125+ return data ;
126+ } catch ( error ) {
127+ console . error ( '[ComfyStream] Error restarting ComfyUI:' , error ) ;
128+ app . ui . dialog . show ( 'Error' , error . message || 'Failed to restart ComfyUI' ) ;
129+ throw error ;
130+ }
131+ }
132+
101133async function controlServer ( action ) {
102134 try {
103135 // Get settings from the settings manager
@@ -256,6 +288,12 @@ const extension = {
256288 icon : "pi pi-cog" ,
257289 label : "Server Settings" ,
258290 function : openSettings
291+ } ,
292+ {
293+ id : "ComfyStream.RestartComfyUI" ,
294+ icon : "pi pi-refresh" ,
295+ label : "Restart ComfyUI" ,
296+ function : restartComfyUI
259297 }
260298 ] ,
261299
@@ -270,7 +308,9 @@ const extension = {
270308 "ComfyStream.StopServer" ,
271309 "ComfyStream.RestartServer" ,
272310 null , // Separator
273- "ComfyStream.Settings"
311+ "ComfyStream.Settings" ,
312+ null , // Separator
313+ "ComfyStream.RestartComfyUI"
274314 ]
275315 }
276316 ] ,
@@ -300,6 +340,8 @@ const extension = {
300340 comfyStreamMenu . addItem ( "Restart Server" , ( ) => controlServer ( 'restart' ) , { icon : "pi pi-refresh" } ) ;
301341 comfyStreamMenu . addSeparator ( ) ;
302342 comfyStreamMenu . addItem ( "Server Settings" , openSettings , { icon : "pi pi-cog" } ) ;
343+ comfyStreamMenu . addSeparator ( ) ;
344+ comfyStreamMenu . addItem ( "Restart Server" , ( ) => restartComfyUI ( ) , { icon : "pi pi-refresh" } ) ;
303345 }
304346 // New menu system is handled automatically by the menuCommands registration
305347
0 commit comments