As of around a year ago node-pty is launched directly from the renderer process, while this does mean ctrl+c is responsive it has several downsides:
My proposal for these problems:
Is this also keeping extensions from talking to terminal processes via stdin? Because F# Interactive with Ionide has this severe issue right now where everything, including input sent from the extension, has to be echoed.
That also means that since user code is displayed in the terminal, they can't put #line directives in it, which means exception stack traces have incorrect line numbers.
Compounded with the fact that the terminal is already slow, sending 300+ lines of code takes a really long time.
@reinux I don't think so, I'll comment there.
Commit that moved the process into renderer: https://github.com/microsoft/vscode/commit/35cee02c9fa9a109c4d75c0f686793f903864ae5
Commit that converted to use amd https://github.com/microsoft/vscode/commit/ed9cdf55b0c9e327ab634cc3e09c97b63671af03
Did some exploration into this.
|
v
TerminalProcessManager
| |
v v
TerminalProcessExtHostProxy TerminalProcess
| (renderer proc)
v
(an ext host connection)
|
v
TerminalProcess
(ext host proc)
Issues:
|
v
TerminalProcessManager
|
v
TerminalProcessExtHostProxy
|
v
(local or remote ext host connection)
|
v
TerminalProcess
Issues:
yes command (flow control is eventual solution to this)Prototype: https://github.com/microsoft/vscode/pull/81106
|
(forked process)
v
TerminalProcess
(uses node-pty)
Issues:
|
v
TerminalProcessManager
| |
v v
TerminalProcessExtHostProxy TerminalPty <--> TerminalInstanceService[2]
| |
v (forked proc[1])
(an ext host connection) v
| TerminalPtyHostProcess
|
v
TerminalPty <--> ExtHostTerminalTerminalService[2]
|
(forked proc[1])
v
TerminalPtyHostProcess
[1] Uses ext host socket-based message protocol
[2] The terminal services own the host process and establish the connection
Prototype: https://github.com/microsoft/vscode/pull/81105
Note that this could be split into 2 stages:
ChildProcess.send and add flow controlArrayBuffersWe recently exposed a callback on xterm's write which fires when the data is parsed. This will make flow control much easier that the earlier proposals I talked about. For example we could provide a callback for event nth write and send messages over to TerminalPtyHostProcess to indicate where the renderer is at in parsing the data.
I did an exploration into moving node-pty into the main process (https://github.com/microsoft/vscode/pull/99897) and it worked pretty well. It's just a prototype and falls over when it comes to pty lifecycle management but it seems like it would be quite easy to tweak it to restore terminals across reloads https://github.com/microsoft/vscode/issues/20013 if it lived in the main process (as the prototype shows). Another benefit is it speeds up the terminal output _significantly_, tree running in the same directly was several times faster due to event loop being freed up, I expect this to also happen when we get https://github.com/microsoft/node-pty/pull/415 in, even when node-pty is hosted in the renderer.
My plan is to eventually move node-pty into a process that's forked from the main process and then establishing a direct socket connection for the terminal if possible to the window so we keep pretty much everything of the main process except for the setting up of the connection.
The branch in action with node-pty hosted on the main process and (the hacky) reload persistence:

Restoring the actual terminal session would be great, but restoring the shell layout with current directory and scrollback saved would give 99% of the benefits for me.
Most helpful comment
I did an exploration into moving node-pty into the main process (https://github.com/microsoft/vscode/pull/99897) and it worked pretty well. It's just a prototype and falls over when it comes to pty lifecycle management but it seems like it would be quite easy to tweak it to restore terminals across reloads https://github.com/microsoft/vscode/issues/20013 if it lived in the main process (as the prototype shows). Another benefit is it speeds up the terminal output _significantly_,
treerunning in the same directly was several times faster due to event loop being freed up, I expect this to also happen when we get https://github.com/microsoft/node-pty/pull/415 in, even when node-pty is hosted in the renderer.My plan is to eventually move node-pty into a process that's forked from the main process and then establishing a direct socket connection for the terminal if possible to the window so we keep pretty much everything of the main process except for the setting up of the connection.
The branch in action with node-pty hosted on the main process and (the hacky) reload persistence: