Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

Commit a68ba63

Browse files
committed
fix: use node-pty for terminal
1 parent 6ea52a7 commit a68ba63

File tree

4 files changed

+125
-11
lines changed

4 files changed

+125
-11
lines changed

package-lock.json

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"dependencies": {
2222
"@electron/remote": "2.1.2",
2323
"@ietf-tools/idnits": "3.0.0-alpha.36",
24+
"@lydell/node-pty": "1.1.0",
2425
"@msgpack/msgpack": "3.0.1",
2526
"@opentelemetry/api": "1.9.0",
2627
"@opentelemetry/auto-instrumentations-node": "0.56.0",

src-electron/terminal.js

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import os from 'node:os'
2-
import { spawn } from 'node:child_process'
2+
// import { spawn } from 'node:child_process'
3+
import * as pty from '@lydell/node-pty'
34

4-
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash'
5+
const shell = os.platform() === 'win32'
6+
? {
7+
cmd: 'powershell.exe',
8+
args: ['-NoLogo']
9+
}
10+
: {
11+
cmd: 'bash',
12+
args: []
13+
}
514

615
export default {
716
term: null,
@@ -10,23 +19,37 @@ export default {
1019
*/
1120
initialize (mainWindow, cwd) {
1221
if (this.term) { return }
13-
this.term = spawn(shell, [], {
14-
windowsHide: true,
15-
cwd
16-
})
17-
this.term.stdout.on('data', data => {
18-
mainWindow.webContents.send('terminal.incomingData', data)
22+
this.term = pty.spawn(shell.cmd, shell.args, {
23+
name: 'draftforge-terminal',
24+
cols: 80,
25+
rows: 30,
26+
cwd,
27+
env: process.env
1928
})
20-
this.term.stderr.on('data', data => {
29+
this.term.onData(data => {
2130
mainWindow.webContents.send('terminal.incomingData', data)
2231
})
23-
this.term.on('exit', () => {
32+
this.term.onExit(() => {
2433
this.term = null
2534
})
35+
// this.term = spawn(shell, [], {
36+
// windowsHide: true,
37+
// cwd
38+
// })
39+
// this.term.stdout.on('data', data => {
40+
// mainWindow.webContents.send('terminal.incomingData', data)
41+
// })
42+
// this.term.stderr.on('data', data => {
43+
// mainWindow.webContents.send('terminal.incomingData', data)
44+
// })
45+
// this.term.on('exit', () => {
46+
// this.term = null
47+
// })
2648
},
2749
write (data) {
2850
if (this.term) {
29-
this.term.stdin.write(data)
51+
// this.term.stdin.write(data)
52+
this.term.write(data)
3053
}
3154
},
3255
/**

src/components/TerminalDialog.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ q-dialog(
1212
q-icon(name='mdi-console', left, size='sm')
1313
span Terminal
1414
q-space
15+
//- q-banner.q-mr-md.text-white.bg-negative.q-px-md(rounded, dense)
16+
//- template(#avatar)
17+
//- q-icon(name='mdi-alert', size='xs')
18+
//- span TTY not supported yet.
1519
q-btn(
1620
unelevated
1721
icon='mdi-close'

0 commit comments

Comments
 (0)