Skip to content

Retain terminal processes between window reloads #20013

Closed

Description

Hi

Please implement Hot Exit on Integrated Terminal.

Thanks

  • VSCode Version: 1.9.0
  • OS Version: Windows 10

Activity

  1. Tyriar commented on Feb 6, 2017

    @Tyriar
    Contributor

    This would be cool, I'm not sure it could be done in the sense of retaining the processes (as they should be killed once VS Code is done). Maybe the shell and environment could be restored though?

    There's a PR out for hyper which is relevant vercel/hyper#945

  2. added
    feature-request
    terminal
    on Feb 6, 2017
  3. ppot commented on Feb 12, 2017

    @ppot

    Daniel Imms (@Tyriar) Thanks. I'm here if you have questions!

  4. sibowilldo commented on Feb 13, 2017

    @sibowilldo
    Author

    Daniel Imms (@Tyriar) Yes restoration is exactly what i was referring to, e.g If I'm working on a Laravel Project and I run the serve artisan command, after restarting VS due to an update, it would be a great implementation if VS would automatically run the "php artisan serve" command on its own.

  5. added this to the Backlog milestone on Apr 21, 2017
  6. Tyriar commented on Jul 13, 2017

    @Tyriar
    Contributor
  7. fabiospampinato commented on Jul 13, 2017

    @fabiospampinato
    Contributor

    Looks like my extension mitigates this issue almost entirely.

    It would be pretty cool to retain the output of those terminals between sessions, but I guess an API for getting it as text, and another one for writing it (without executing it as a command) are necessary for this (Daniel Imms (@Tyriar) do you think it would be possible to add them?) . We can leverage the fact that by using this extension no two terminals opened by it would probably have the same name, so we could safely link terminals' names with their text.

    I guess it would also be nicer to have the terminals ready as soon as you open the project's folder, without the need to run the Terminals: Run command, I'll add an option for this tomorrow 👍

  8. Tyriar commented on Jul 13, 2017

    @Tyriar
    Contributor

    Fabio Spampinato (@fabiospampinato) no plan on adding the ability to read or write right now.

    Something that will help you though is that you will be able to add/remove environment variable from the environment in 1.15.

  9. Tyriar commented on Oct 27, 2017

    @Tyriar
    Contributor

    This issue is a little ambiguous at the moment, here's what I see covered by it:

    1. Support reloading VS Code without terminating terminal processes

    This can be accomplished by moving the terminal process to live under Electron's main process instead of the browser process, then reinstating the terminals after a load occurs. There is quite a bit of refactoring that needs to happen here, probably most significantly is splitting node-pty into 2 components; one that launches the process and exposes the file descriptorunix socket/named pipe (under the main process), and one that takes the file descriptorunix socket/named pipe and connects to it (under the browser process). We do not want the pty's data stream to just be passed through IPC as it will slow down everything.

    2. Restore terminals with their cwd/environments they were created with when restoring a workspace

    Note that this should only happen when 1. does not occur. The solution for this should allow for split terminals to be restored in the future #7504

  10. jerch commented on Oct 28, 2017

    @jerch

    one that launches the process and exposes the file descriptor (under the main process), and one that takes the file descriptor and connects to it (under the browser process)

    Daniel Imms (@Tyriar) Some OSes do not allow the pty master fd to be duped/cloned, e.g. used by another process than the original creating process. IPC is the only platform independent way imho (os pipes are pretty fast though).

  11. Tyriar commented on Oct 28, 2017

    @Tyriar
    Contributor

    jerch good to know. The sheer amount of data that's possible to go through the terminal is the concern as it could lock up the main process which is shared between all VS Code windows 😕. Maybe I'm just overestimating the impact it would have on the main process? Any more details on the some OSes part?

  12. jerch commented on Oct 29, 2017

    @jerch

    Daniel Imms (@Tyriar) It is still possible to carry the master fds around without duping it, if O_CLOEXEC is not set. It is important to reenable it in the browser process, otherwise the fds will leak to all subprocesses (assuming you have no control of electron's subprocess creation, the fds could also be closed by hand between fork and exec).

  13. Tyriar commented on Feb 7, 2018

    @Tyriar
    Contributor

    I amended my commend in #20013 (comment) to replace file descriptor with named pipe (Windows) and unix socket (Linux/macOS) as file descriptors are per-process. Implementation would use the net module https://nodejs.org/api/net.html#net_ipc_support

    I'm thinking this is the way forward as node-pty is a standalone project (not just VS Code), plus plumbing terminal data streams through the standard main process IPC could block other communication if the terminal is spitting out lots of data.

  14. 38 remaining items

  15. jerch commented on Sep 11, 2020

    @jerch

    mmis1000 (@mmis1000) Again not sure what you are trying to say, as it is somewhat self contra-dictionary:

    That didn't work unless there is a reset control code somewhere in the response, then it can serve as a cut point.

    True, but unreliable for a "skip-over" replay, as sequences like RIS or DECSTR typically dont happen during normal session run.

    Still your observation here contradicts this:

    You can't get the correct result unless you actually replay all of it.

    If you find a state-destructive sequence (like RIS, and DECSTR to some degree), you dont have to replay it all. Note that for me there is a difference between full replay (as full emulation) vs. search accumulated data for for those points.

    Again - thats not reliable, as it is likely to never happen (thus you are likely to never find a clean state entrypoint for replay beside the very beginning). But before replaying everything, there is another option you didnt consider - do some state back reporting from an active terminal endpoint, and link this to the stream data position. This way you get an unclean entrypoint (a replay from that point needs to apply the state itself first, before working on the follow-up stream data). Those unclean entrypoints can be managed by the daemon, even with discarding older stream data completely, while a healthy looking replay from there is still possible. No second full replay needed at all. (This is abit like doing terminal state snapshots, and starting from there.)

  16. mmis1000 commented on Sep 12, 2020

    @mmis1000

    I'd consider assume you can always read data from client not reliable at all. As it always have been, client may lost/corrupt data for some reason, like a app crash, system BSOD. A recovery method that require client not encounter error at all is …weird? Even in the vscode case. If it is going to run in the browser, then things like such is very likely to happen.

  17. jerch commented on Sep 12, 2020

    @jerch

    mmis1000 (@mmis1000) Sorry I cannot see how your last comment is related to anything above. Plz lets not jump to random conclusions without proper context, as it derails the discussion.

  18. mmis1000 commented on Sep 12, 2020

    @mmis1000

    From the beginning, the only reason I think it is a terminal multiplexer protocol is the reconnect without resend everything', nothing more is included.

    Terminal protocol is a stream of patch, and unlike video, you don't have a P frame somewhere by default to skip over to near the end of stream unless user issue a 'reset' manually (which is basically does not exist and does not matter at all because user seldom do that).

    In order to able skip over without break the output completely. Somewhere in the system need to generate the P frame. So you can 'start from here' or you just can't (think of a video that trying to start from a I frame, it really can't).

    It can be client (the terminal send all its last state to server, and the server response with it when reconnect), or it can be server (something like tmux but with far less function). Or probably mixed, server only do it if client is unavailable.

    But I feel completely rely on client and assume the client will just do it well is a bad assumption, clients always break for variable of reasons. I am not not think of it. I am assume it is going to break.
    So the only reliable option will be the server render it (always or on required).

    Is there a third way can handle the reconnect correctly without show you a half broken screen?
    Or show you a non broken screen on reconnect isn't one of the goal?

  19. jerch commented on Sep 13, 2020

    @jerch

    mmis1000 (@mmis1000)

    There are different scenarios possible to get better fault tolerance (imho thats what you are trying to say above). But note that currently a short terminal disconnect/reconnect is simply not possible for vscode by any means, thus even a best effort approach, which has to bail out for rare edge cases, is already a huge overall win.

    What you describe as "it is going to break" is currently the default case from where developing a better idea would start. Whether the final concept should aim for 99% fault tolerance or is good enough to cover most cases (80:20 rule), depends alot on the circumstances, like manpower to implement such a solution and last but not least its technical implications like additional runtime costs (more CPU/memory hungry for "play along emulation", storage needs on server side etc). Since I am not going to implement it, I wont judge about it. From a user's perspective anything into that direction will be better than now, as easy as that.

    If you have some profound terminal interface experience and time to share, maybe try helping to get it shaped. I for myself have not enough time for that, thus can only give some ideas here.

  20. Bessonov commented on Dec 5, 2020

    @Bessonov

    Usually I close all terminals before exit because of "loss" of terminal tabs. But yesterday I didn't. Today I've noticed, that after I've connected to remote container my terminal was restored. It lost terminal tabs, but scroll history is here. It work even with multiple terminals. And it is able to processing executed commands. For example, I can execute sleep 60; echo "test", quit and connect again. It seems like it doesn't lost running command and after 60 seconds pass, it prints "test". Tested it with simulation of network failure and "reload window". It worked as expected.

    For me, everything is already here. I'm very happy :D

    (the only one wish - terminal tabs should be restored too or integrated)

    Version: 1.51.0
    Commit: fcac248
    Date: 2020-11-05T18:16:10.374Z
    Electron: 9.3.3
    Chrome: 83.0.4103.122
    Node.js: 12.14.1
    V8: 8.3.110.13-electron.0
    OS: Linux x64 5.4.0-56-generic

  21. Bessonov commented on Dec 7, 2020

    @Bessonov

    Unfortunately, it doesn't work every time. It seems like something dying after some time...

  22. Tyriar commented on Feb 22, 2021

    @Tyriar
    Contributor

    Done in #116449 🎉

  23. added
    on-release-notes
    on Feb 22, 2021
  24. locked and limited conversation to collaborators on Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

feature-requeston-release-noteson-testplanterminal

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions