From 76d5ae4c18d414ed3ee580e9e03b1638322c7d8b Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Wed, 20 Nov 2024 14:43:26 -0800 Subject: [PATCH 1/4] Add specific tag for errors originating from ComfyUI core side. (#308) --- src/main-process/comfyDesktopApp.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main-process/comfyDesktopApp.ts b/src/main-process/comfyDesktopApp.ts index 62fe1090..3cf3dfef 100644 --- a/src/main-process/comfyDesktopApp.ts +++ b/src/main-process/comfyDesktopApp.ts @@ -103,6 +103,9 @@ export class ComfyDesktopApp { return Sentry.captureMessage(error, { level: 'error', extra: { ...extras, comfyUIExecutionError: true }, + tags: { + comfyorigin: 'core', + }, }); } catch (err) { log.error('Failed to send error to Sentry:', err); From fd5f1d7321563e9b05452dfc00fa311ae08a83fc Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Wed, 20 Nov 2024 14:43:39 -0800 Subject: [PATCH 2/4] Disable sentry for local dev by default. (#307) --- .env_example | 5 ++++- .env_test_example | 5 ++++- .prettierignore | 1 + src/main.ts | 1 + 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.env_example b/.env_example index b8485b49..80f318c6 100644 --- a/.env_example +++ b/.env_example @@ -14,4 +14,7 @@ USE_EXTERNAL_SERVER=false DEV_SERVER_URL=http://192.168.2.20:5173 # The level of logging to use. -LOG_LEVEL=debug \ No newline at end of file +LOG_LEVEL=debug + +# Send events to Sentry +SENTRY_ENABLED=false diff --git a/.env_test_example b/.env_test_example index 94f2d29b..4f470caf 100644 --- a/.env_test_example +++ b/.env_test_example @@ -7,4 +7,7 @@ COMFY_HOST=localhost COMFY_PORT=5173 # Whether to use an external server instead of starting one locally. -USE_EXTERNAL_SERVER=true \ No newline at end of file +USE_EXTERNAL_SERVER=true + +# Send events to Sentry +SENTRY_ENABLED=false diff --git a/.prettierignore b/.prettierignore index da5dc2a5..c1a693e5 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,4 @@ dist assets .vite scripts +.env_* diff --git a/src/main.ts b/src/main.ts index 5eb0a5de..76472bb1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -34,6 +34,7 @@ let alwaysSendCrashReports = false; Sentry.init({ dsn: SENTRY_URL_ENDPOINT, autoSessionTracking: false, + enabled: process.env.SENTRY_ENABLED === 'true' || app.isPackaged, beforeSend: async (event, hint) => { if (event.extra?.comfyUIExecutionError || alwaysSendCrashReports) { return event; From 35d005464a811018baed8baf17bceb0e13b3d540 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Wed, 20 Nov 2024 19:09:05 -0800 Subject: [PATCH 3/4] Alias pip to uv pip in the integrated terminal. (#313) * Add.. * Zsh as the default shell on mac. --- src/main-process/comfyDesktopApp.ts | 35 ++++++++++++++++------------- src/terminal.ts | 25 +++++++++++++++++++-- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/main-process/comfyDesktopApp.ts b/src/main-process/comfyDesktopApp.ts index 3cf3dfef..9ffb36a9 100644 --- a/src/main-process/comfyDesktopApp.ts +++ b/src/main-process/comfyDesktopApp.ts @@ -20,15 +20,13 @@ import { getAppResourcesPath } from '../install/resourcePaths'; export class ComfyDesktopApp { public comfyServer: ComfyServer | null = null; - private terminal: Terminal; + private terminal: Terminal | null = null; // Only created after server starts. constructor( public basePath: string, public comfySettings: ComfySettings, public appWindow: AppWindow - ) { - this.terminal = new Terminal(this.appWindow, getAppResourcesPath()); - } + ) {} get pythonInstallPath() { return app.isPackaged ? this.basePath : path.join(app.getAppPath(), 'assets'); @@ -50,6 +48,22 @@ export class ComfyDesktopApp { }); } + private initializeTerminal(virtualEnvironment: VirtualEnvironment) { + this.terminal = new Terminal(this.appWindow, this.basePath, virtualEnvironment.uvPath); + + ipcMain.handle(IPC_CHANNELS.TERMINAL_WRITE, (_event, command: string) => { + this.terminal?.write(command); + }); + + ipcMain.handle(IPC_CHANNELS.TERMINAL_RESIZE, (_event, cols: number, rows: number) => { + this.terminal?.resize(cols, rows); + }); + + ipcMain.handle(IPC_CHANNELS.TERMINAL_RESTORE, (_event) => { + return this.terminal?.restore(); + }); + } + async setupGPUContext(): Promise { log.debug('Setting up GPU context'); try { @@ -112,18 +126,6 @@ export class ComfyDesktopApp { return null; } }); - - ipcMain.handle(IPC_CHANNELS.TERMINAL_WRITE, (_event, command: string) => { - this.terminal.write(command); - }); - - ipcMain.handle(IPC_CHANNELS.TERMINAL_RESIZE, (_event, cols: number, rows: number) => { - this.terminal.resize(cols, rows); - }); - - ipcMain.handle(IPC_CHANNELS.TERMINAL_RESTORE, (_event) => { - return this.terminal.restore(); - }); } /** @@ -175,6 +177,7 @@ export class ComfyDesktopApp { this.appWindow.sendServerStartProgress(ProgressStatus.STARTING_SERVER); this.comfyServer = new ComfyServer(this.basePath, serverArgs, virtualEnvironment, this.appWindow); await this.comfyServer.start(); + this.initializeTerminal(virtualEnvironment); } static async create(appWindow: AppWindow): Promise { diff --git a/src/terminal.ts b/src/terminal.ts index a42cc3df..4b27c1cc 100644 --- a/src/terminal.ts +++ b/src/terminal.ts @@ -7,6 +7,7 @@ export class Terminal { #pty: pty.IPty | undefined; #window: AppWindow | undefined; #cwd: string | undefined; + #uvPath: string | undefined; readonly sessionBuffer: string[] = []; readonly size = { cols: 80, rows: 30 }; @@ -21,9 +22,10 @@ export class Terminal { return this.#window; } - constructor(window: AppWindow, cwd: string) { + constructor(window: AppWindow, cwd: string, uvPath: string) { this.#window = window; this.#cwd = cwd; + this.#uvPath = uvPath; } write(data: string) { @@ -46,7 +48,7 @@ export class Terminal { #createPty() { const window = this.window; // TODO: does this want to be a setting? - const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash'; + const shell = this.#getDefaultShell(); const instance = pty.spawn(shell, [], { handleFlowControl: false, conptyInheritCursor: false, @@ -56,6 +58,14 @@ export class Terminal { cwd: this.#cwd, }); + if (process.platform === 'win32') { + // PowerShell function + instance.write(`function pip { & "${this.#uvPath}" pip $args }\r\n`); + } else { + // Bash/Zsh alias + instance.write(`alias pip='"${this.#uvPath}" pip'\r\n`); + } + instance.onData((data) => { this.sessionBuffer.push(data); window.send(IPC_CHANNELS.TERMINAL_ON_OUTPUT, data); @@ -64,4 +74,15 @@ export class Terminal { return instance; } + + #getDefaultShell(): string { + switch (os.platform()) { + case 'win32': + return 'powershell.exe'; + case 'darwin': + return 'zsh'; + default: // Linux and others + return 'bash'; + } + } } From fedad31aad4b79d8f22b6171a6565d0c02f37790 Mon Sep 17 00:00:00 2001 From: Robin Huang Date: Wed, 20 Nov 2024 19:09:14 -0800 Subject: [PATCH 4/4] Frontend: v0.1.4.6 (#314) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2ba4515a..87e28f2e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "main": ".vite/build/main.js", "packageManager": "yarn@4.5.0", "config": { - "frontendVersion": "1.4.4", + "frontendVersion": "1.4.6", "comfyVersion": "0.2.7", "managerCommit": "e629215c100c89a9a9d33fc03be3248069ff67ef", "uvVersion": "0.5.2"