-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Terminal commands"" (#292)
* Revert "Revert "Terminal commands (#237)" (#291)" This reverts commit 6848467. * Add electron-builder version to 25+. * Add node-abi * Remove node-abi.
- Loading branch information
1 parent
5b15c9c
commit 1bcae96
Showing
10 changed files
with
216 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"main": ".vite/build/main.js", | ||
"packageManager": "[email protected]", | ||
"config": { | ||
"frontendVersion": "1.4.0", | ||
"frontendVersion": "1.4.2", | ||
"comfyVersion": "0.2.7", | ||
"managerCommit": "e629215c100c89a9a9d33fc03be3248069ff67ef", | ||
"uvVersion": "0.5.1" | ||
|
@@ -55,6 +55,7 @@ | |
"devDependencies": { | ||
"@electron/fuses": "^1.8.0", | ||
"@electron/notarize": "^2.4.0", | ||
"@electron/rebuild": "^3.7.1", | ||
"@electron/windows-sign": "^1.1.3", | ||
"@playwright/test": "^1.47.2", | ||
"@sentry/wizard": "^3.30.0", | ||
|
@@ -97,6 +98,7 @@ | |
"electron-log": "^5.2.0", | ||
"electron-store": "8.2.0", | ||
"jest": "^29.7.0", | ||
"node-pty": "^1.0.0", | ||
"systeminformation": "^5.23.5", | ||
"tar": "^7.4.3", | ||
"wait-on": "^8.0.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import * as os from 'node:os'; | ||
import * as pty from 'node-pty'; | ||
import { AppWindow } from './main-process/appWindow'; | ||
import { IPC_CHANNELS } from './constants'; | ||
|
||
export class Terminal { | ||
#pty: pty.IPty | undefined; | ||
#window: AppWindow | undefined; | ||
#cwd: string | undefined; | ||
|
||
readonly sessionBuffer: string[] = []; | ||
readonly size = { cols: 80, rows: 30 }; | ||
|
||
get pty() { | ||
this.#pty ??= this.#createPty(); | ||
return this.#pty; | ||
} | ||
|
||
get window() { | ||
if (!this.#window) throw new Error('AppWindow not initialized.'); | ||
return this.#window; | ||
} | ||
|
||
constructor(window: AppWindow, cwd: string) { | ||
this.#window = window; | ||
this.#cwd = cwd; | ||
} | ||
|
||
write(data: string) { | ||
this.pty.write(data); | ||
} | ||
|
||
resize(cols: number, rows: number) { | ||
this.pty.resize(cols, rows); | ||
this.size.cols = cols; | ||
this.size.rows = rows; | ||
} | ||
|
||
restore() { | ||
return { | ||
buffer: this.sessionBuffer, | ||
size: this.size, | ||
}; | ||
} | ||
|
||
#createPty() { | ||
const window = this.window; | ||
// TODO: does this want to be a setting? | ||
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash'; | ||
const instance = pty.spawn(shell, [], { | ||
handleFlowControl: false, | ||
conptyInheritCursor: false, | ||
name: 'comfyui-terminal', | ||
cols: this.size.cols, | ||
rows: this.size.rows, | ||
cwd: this.#cwd, | ||
}); | ||
|
||
instance.onData((data) => { | ||
this.sessionBuffer.push(data); | ||
window.send(IPC_CHANNELS.TERMINAL_ON_OUTPUT, data); | ||
if (this.sessionBuffer.length > 1000) this.sessionBuffer.shift(); | ||
}); | ||
|
||
return instance; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters