diff --git a/javascript/sdppp-comfy.js b/javascript/sdppp-comfy.js index b0b868f..7054da8 100644 --- a/javascript/sdppp-comfy.js +++ b/javascript/sdppp-comfy.js @@ -29,6 +29,9 @@ socket.on('connect', () => { socket.emit('c_reset_changes'); + socket.emit('c_reset_instance_name', { + name: document.title + }) }); socket.on('disconnect', () => { }); @@ -48,6 +51,9 @@ boundsStrs = data.bound_strs; setLayerStrs = data.set_layer_strs; }) + socket.emit('c_reset_instance_name', { + name: document.title + }) }, 2000); }, async beforeRegisterNodeDef(nodeType, nodeData, app) { diff --git a/photoshop/dist/index.js b/photoshop/dist/index.js index 2dbbf29..b20977f 100644 --- a/photoshop/dist/index.js +++ b/photoshop/dist/index.js @@ -135,7 +135,6 @@ class Main extends react__WEBPACK_IMPORTED_MODULE_0__.Component { if (this.state.isConnected || this.state.isReconnecting) inputDisable = { disabled: true }; - console.log(this.state.backendURL); return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement(react__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("sp-textfield", _extends({ id: "url-bar", label: "backendURL", @@ -168,11 +167,11 @@ class Main extends react__WEBPACK_IMPORTED_MODULE_0__.Component { className: "client-list-item" }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("sp-label", { class: "client-name" - }, item.slice(0, 6)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("sp-link", { + }, item.name), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__.createElement("sp-link", { onClick: () => { - _system_ComfyConnection__WEBPACK_IMPORTED_MODULE_1__["default"].instance?.pageInstanceRun(item); + _system_ComfyConnection__WEBPACK_IMPORTED_MODULE_1__["default"].instance?.pageInstanceRun(item.sid); } - }, "Run")); + }, item.type == "comfy" ? "Queue Prompt" : "Execute")); }))); } } @@ -5297,10 +5296,10 @@ ___CSS_LOADER_EXPORT___.push([module.id, `.tabbar { align-items: center; } .client-list-item .client-name { - margin-left: 10px; + margin-left: 5px; } .client-list-item sp-link { - margin-right: 20px; + margin-right: 10px; }`, ""]); // Exports /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___); diff --git a/photoshop/src/panels/Main.jsx b/photoshop/src/panels/Main.jsx index 52844f2..4eaeda7 100644 --- a/photoshop/src/panels/Main.jsx +++ b/photoshop/src/panels/Main.jsx @@ -42,7 +42,6 @@ export default class Main extends React.Component { render() { let inputDisable = { }; if (this.state.isConnected || this.state.isReconnecting) inputDisable = { disabled: true }; - console.log(this.state.backendURL) return ( <> { return (
  • - {item.slice(0, 6)} - { ComfyConnection.instance?.pageInstanceRun(item) }}>Run + {item.name} + { ComfyConnection.instance?.pageInstanceRun(item.sid) }}>{item.type == "comfy" ? "Queue Prompt" : "Execute"}
  • ) }) diff --git a/photoshop/src/styles.css b/photoshop/src/styles.css index 88bc570..a35a87f 100644 --- a/photoshop/src/styles.css +++ b/photoshop/src/styles.css @@ -52,8 +52,8 @@ align-items: center; } .client-list-item .client-name { - margin-left: 10px; + margin-left: 5px; } .client-list-item sp-link { - margin-right: 20px; + margin-right: 10px; } \ No newline at end of file diff --git a/sdppp_python/apis.py b/sdppp_python/apis.py index a53082c..e7ea5e6 100644 --- a/sdppp_python/apis.py +++ b/sdppp_python/apis.py @@ -131,12 +131,9 @@ def registerSocketEvents(sdppp, sio): @sio.event async def b_get_pages(sid, data = {}): pages = [] - if sdppp.server_type == "comfy": - pages = list(sdppp.comfyui_instances.keys()) - elif sdppp.server_type == "SD": - pages = list(sdppp.sd_instances.keys()) - + pages = list(sdppp.page_instances.values()) pages.reverse() + return { 'pages': pages } @@ -147,7 +144,7 @@ def registerSocketEvents(sdppp, sio): await sdppp.sio.emit('s_run', to=data['sid']) @sio.event - async def check_changes(sid): + async def c_check_changes(sid): instance = sdppp.get_ps_instance() if instance is None: return @@ -156,8 +153,14 @@ def registerSocketEvents(sdppp, sio): await sio.emit('s_trigger_graph_change', to=sid) @sio.event - async def reset_changes(sid): + async def c_reset_changes(sid): instance = sdppp.get_ps_instance() if instance is None: return instance.reset_change_tracker() + + @sio.event + async def c_reset_instance_name(sid, data): + instance = sdppp.page_instances[sid] + instance["name"] = data["name"] + diff --git a/sdppp_python/sdppp.py b/sdppp_python/sdppp.py index 073c3ec..fbfc970 100644 --- a/sdppp_python/sdppp.py +++ b/sdppp_python/sdppp.py @@ -5,8 +5,7 @@ from .apis import registerSocketEvents, registerComfyHTTPEndpoints, registerSDHT class SDPPP: def __init__(self): self.photoshop_instances = dict() - self.comfyui_instances = dict() - self.sd_instances = dict() + self.page_instances = dict() def attach_to_comfyui(self, PromptServer): self.sio = socketio.AsyncServer(async_mode='aiohttp', cors_allowed_origins="*") @@ -47,10 +46,18 @@ class SDPPP: self.photoshop_instances[sid] = PhotoshopInstance(self, sid) elif qsobj['type'] == 'comfyui': - self.comfyui_instances[sid] = True + self.page_instances[sid] = { + "sid": sid, + "type": "comfy", + "name": "" + } elif qsobj['type'] == 'sd': - self.sd_instances[sid] = True + self.page_instances[sid] = { + "sid": sid, + "type": "sd", + "name": "" + } else: raise socketio.exceptions.ConnectionRefusedError('unknown instance type ' + qsobj['type']) @@ -59,13 +66,11 @@ class SDPPP: "server_type": self.server_type }) - # only emit by photoshop instance - @sio.event async def disconnect(sid): if sid in self.photoshop_instances: self.photoshop_instances.pop(sid, None) - elif sid in self.comfyui_instances: - self.comfyui_instances.pop(sid, None) + elif sid in self.page_instances: + self.page_instances.pop(sid, None) registerSocketEvents(self, self.sio) @@ -77,4 +82,4 @@ class SDPPP: return None if sid is None: sid = list(self.photoshop_instances.keys())[0] - return self.photoshop_instances[sid] \ No newline at end of file + return self.photoshop_instances[sid]