implement a new method of interacting with bit-server: node-pty #9247
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Until now we supported two methods to communicate with cli-server: SSE and TTY. See server-commander.ts for more details.
With this approach, we spawn a pty (pseudo terminal) process to communicate between the client and the server.
The client connects to the server using a (TCP) socket. The server writes to the socket and the client reads from it.
The client also writes to the socket and the server reads from it. See server-forever.ts to understand better.
In order to pass terminal sequences, such as arrow keys or Ctrl+C, the stdin of the client is set to raw mode.
In theory, this approach could work by spawning a normal process, not pty, however, then, the stdin/stdout are non-tty, and as a result, loaders such as Ora and chalk won't work.
With this new approach, we also support terminating and reloading the server. A new command is added
bit server-forever
, which spawns the pty-process. If the client hits Ctrl+C, this server-forever process will kill the pty-process and re-load it.