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

Problems with session startup and resumption #16487

Closed
kamrann opened this issue Dec 21, 2023 · 8 comments · Fixed by #18215
Closed

Problems with session startup and resumption #16487

kamrann opened this issue Dec 21, 2023 · 8 comments · Fixed by #18215
Labels
Area-DefApp Area-Windowing Window frame, quake mode, tearout In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Milestone

Comments

@kamrann
Copy link

kamrann commented Dec 21, 2023

Windows Terminal version

1.18.3181.0

Windows build number

10.0.19045.0

Other Software

No response

Steps to reproduce

  • In Terminal settings, Default terminal application is Windows Terminal, Launch on machine startup is On, When terminal starts is set to Open windows from a previous session, and New instance behaviour to Create a new window.

Expected Behavior

My expectation would be that restoration of the previous session should apply only to the first Terminal instance (be it at machine startup or subsequently). Any further explicitly opened instances should open a tab with the default profile, whereas any instances opened to house an application that was launched explicitly should simply have a single tab for that application.

Actual Behavior

Initial startup is as expected (for the most part, see caveat below), however I'm seeing strange behaviour following that. With a single instance of Terminal open, if I attempt to launch any console application (cmd.exe, PS, or a console program launched via Visual Studio debugger), that application will open in a new Terminal window as expected, but alongside it a further Terminal window will be opened populated with tabs based on the prior session (so to clarify, I end up with 3 windows: the original session, a duplication of it, and the opened application).

  • The above does not occur when explicitly opening Terminal.
  • The above does not occur when I already have more than a single Terminal session open.

Regarding above noted caveat. It's not clear exactly how Terminal decides/updates what constitutes the previous session, but it seems far too easy for what I want to be considered my previous session to get replaced. Perhaps it's just based on the last window to be closed down? I really need some way to mark my 'main' session so that I don't end up losing the layout as a result of having at some point opened a secondary session. In particular, the fact that a session resulting from a request to open cmd.exe or similar directly can end up overwriting my Terminal layout restoration seems wrong.

@kamrann kamrann added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Dec 21, 2023
@Mubashir2611
Copy link

Can I contribute?

@zadjii-msft
Copy link
Member

Hmm. You wouldn't happen to be launching the Terminal as admin at any point in all this, would you? There's separate persisted state for each of those two instances, so that might be at play here/?

Sounds like there's something weird going on with defterm here, since it's like the defterm launch is then also triggering another state restore?

I'd reckon this may almost be related to #15509? Or maybe, more horrifyingly, there's an interplay here between defterm, session restore, and refrigeration. I coulda swore we had a better dupe somewhere for "a defterm session seemingly can't communicate with the existing WT process", but I can't find that.

Just to confirm - do you only have one version of the Terminal installed? (e.g. only Stable, not also Preview)

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Jan 10, 2024
@kamrann
Copy link
Author

kamrann commented Jan 18, 2024

Not opening as admin, no.
I've tested a bit and found that I don't see this behaviour on my laptop running Windows 11, but only on my other machine running Windows 10, on which I believe I updated the version of Windows Terminal at some point.

As far as I'm aware I only have a single version installed. I'm not too familiar with update process for Windows apps/Powershell though. Are there any commands you suggest I run to verify that the installations are as they should be?

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Jan 18, 2024
@zadjii-msft
Copy link
Member

zadjii-msft commented Jan 31, 2024

I need to go dedupe the set of

issue Windows? DefTerm? Restore prev session Launch on startup? issues?
#16487 10 true true true ❌ launch on boot restores normally, then defterm also restores?
#16487 10 true true true ✅ seemingly works fine?
#16557 10 ? true true ❌ launch on boot restores normally, then {{a second launch, unsure if defterm}} also restores?
#16561 10 ? ? (probably) true ❌ launch on boot restores double of the session
#16732 10 true true ? ❌ When opening a defterm even with window open, creates a window with a set of "restored" tabs

@zadjii-msft
Copy link
Member

zadjii-msft commented Feb 8, 2024

Seems like there's something up with the way Windows 10 restores the Terminal... we restore the session, but then a subsequent launch of the Terminal also tries to restore. Weird.

Oh no, I can't repro this in a VM, least, not on 10.0.19041 & 1.19.2682.0

@zadjii-msft zadjii-msft removed their assignment Feb 8, 2024
@zadjii-msft
Copy link
Member

oh man I wonder if there's some other console app that's starting at boot, triggering defterm, which triggers a session restore. But then also the Terminal gets launched, and it simultaneously finds no one else booted, so it also session restores. Is there anything else suspicious in "Startup" in Task Manager?

@carlos-zamora carlos-zamora added this to the Terminal v1.21 milestone Feb 14, 2024
@carlos-zamora carlos-zamora added Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. Product-Terminal The new Windows Terminal. Area-Windowing Window frame, quake mode, tearout and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Attention The core contributors need to come back around and look at this ASAP. labels Feb 14, 2024
@zadjii-msft
Copy link
Member

Details in #16732 make me think that this is less related to Start on Login and more related to defterm accidentally triggering a session restore.

@zadjii-msft
Copy link
Member

Note to self: Go look at #16598 (comment)

holy sh--, multi-window restore starts WindowsTerminal.exe which then gets a handle to our Monarch and sends it a commandline.

What the heck.

We could just... use Monarch directly here. I know you didn't write this code but I think we missed it when we migrated to single-proc.

@zadjii-msft zadjii-msft added this to the Backlog milestone Sep 4, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Dec 12, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DefApp Area-Windowing Window frame, quake mode, tearout In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Repro We can't figure out how to make this happen. Please help find a simplified repro. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants