Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix terminals in editor area not reloading #151852

Merged
merged 11 commits into from Jul 6, 2022
Merged

Conversation

ssigwart
Copy link
Contributor

This PR fixes #140429

This isn't perfect because it just reopens then without setting the original location, but at least it reloads them.

If you have any thought on how to do that, I can try to implement it. I think people would probably appreciate them at least reloading though.

Testing

  • Make sure terminal.integrated.persistentSessionReviveProcess setting is enabled.
  • Other a few terminal in the terminal window.
  • Quit VS Code.
  • Reopen VS Code, which should reopen the terminals.

- Closes microsoft#140429
- This isn't perfect because it just reopens then without setting the original location, but at least it reloads them.
seenPersistentProcessIds.push(term.terminal);
}
}
const otherInstances = this.instances.filter(instance => typeof instance.persistentProcessId === 'number' && instance.shouldPersist && seenPersistentProcessIds.indexOf(instance.persistentProcessId) === -1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be simpler to get the terminals in the editor area from terminalEditorService

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried and that doesn't work, but should.

I believe it doesn't work because of this, which happens when you close the window and then the state is saved with no terminals
https://github.com/ssigwart/vscode/blob/a084f63f4d3e5477efbcd8851008e8d996a45681/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts#L92-L103

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tyriar pls checkout the commit I made to fix this ae7a4ba

meganrogge
meganrogge previously approved these changes Jun 15, 2022
@meganrogge meganrogge requested a review from Tyriar June 15, 2022 19:58
@ssigwart
Copy link
Contributor Author

Thank you for reviewing this and making the updates, @meganrogge. Please let me know if you need me to do anything more on this.

@Tyriar
Copy link
Member

Tyriar commented Jun 16, 2022

I see the CI failure is safely ignored, we're tracking the flake already

@Tyriar
Copy link
Member

Tyriar commented Jun 17, 2022

Looks like this doesn't play well with reconnection and it ends up printing the content twice:
Screen Shot 2022-06-16 at 6 24 27 pm

Still looking into it.

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ssigwart thanks for the PR, after looking a little closer at this I think it's the wrong approach. Instead of expanding the tabs like we do for terminal groups in the panel we want to rely on the editor's existing serialization as that will already get handled for us and it will then prevent focus/tabs appearing after start up problems.

It's been a while since I looked at this but I think there's a boolean somewhere near the serializer that says close the tab so it doesn't restore on quit (when process revive would be used) but allow is on reload (when process reconnect would be used).

@Tyriar Tyriar removed this from the June 2022 milestone Jun 17, 2022
- The issue is `_onWillShutdown` is called before `TerminalInputSerializer` serializes, so I added `shutdownPersistentProcessId`.
- When restoring the editor, it was using the wrong ID, so I added `getRevivedPtyNewId`.
@ssigwart
Copy link
Contributor Author

Thanks for the tip, @Tyriar. It took me quite a while to come up with this new fix, but I don't think I would have gotten there without your suggestion.

The issue is _onWillShutdown is called before TerminalInputSerializer serializes, so I added shutdownPersistentProcessId to record the ID for use in TerminalInputSerializer.

After that, when restoring the editor, it was using the ID from before the shutdown, which is no longer valid. So I added getRevivedPtyNewId to get the new ID.

I wasn't able to test the remote terminal settings because I wasn't really sure what "remote terminals" meant. I assumed it had something to do with https://code.visualstudio.com/docs/remote/ssh so I tried installing the extension and connect to SSH, but it failed after trying to install a VS Code Server on the server.

@Tyriar
Copy link
Member

Tyriar commented Jun 20, 2022

@ssigwart for remote you can create a test resolver window for the remote side of things:

image

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it out again, revive seems to work great but reconnect appears to have broken.

Repro:

  1. Create a terminal editor on left and right
  2. Type something in each
  3. Reload the window

Expected: What was typed in step 2 should show up (gif off main)

Recording 2022-06-20 at 15 15 51

Actual: New processes are created because reconnect fails:

image

@Tyriar Tyriar added this to the July 2022 milestone Jun 20, 2022
@ssigwart
Copy link
Contributor Author

Thanks, @Tyriar. I think I got that working now.

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, it works great 👍, it should land in v1.70

@Tyriar Tyriar merged commit 4ba0070 into microsoft:main Jul 6, 2022
@ssigwart ssigwart deleted the term branch July 7, 2022 00:43
@github-actions github-actions bot locked and limited conversation to collaborators Aug 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal in editor area not restored after vs code restart.
4 participants