Opening a file in any Office app will restore your windows when you have defterm enabled #15468

Closed
opened 2026-01-31 04:39:29 +00:00 by claunia · 6 comments
Owner

Originally created by @zadjii-msft on GitHub (Oct 6, 2021).

Yep, that's just as insane as it sounds.

It's on 1.12

but like, delayed? Like I opened excel, opened a file, then like 10s later, BAM the terminal's back

Yeah exactly

I'm grabbing a screenshot of the icon of whatever is launching

image
image

it says I'm up to date ._.
​​
wild theory: office boots some cmdline something or other that triggers a defapp launch. We don't end up sticking to the thing that office launched, but the act of creating the wt to try to delegate to also spawns the other restored windows

It's that yellow icon thing

Yeah what's weird is I can't get defapp to work with just plain CMD lol

that's weird... AppVlp is for executing untrusted scripts AFAIK

image
look at that - the window that got restored WAS WINDOW 2. So some other wt was launched that thought it also needed to bring this one back

Originally created by @zadjii-msft on GitHub (Oct 6, 2021). Yep, that's just as insane as it sounds. It's on 1.12 > but like, delayed? Like I opened excel, opened a file, then like 10s later, BAM the terminal's back > ​ > Yeah exactly > ​ > I'm grabbing a screenshot of the icon of whatever is launching > ​ > ![image](https://user-images.githubusercontent.com/18356694/136257795-dccd32e7-680e-4486-ab28-58be729aa701.png) > ![image](https://user-images.githubusercontent.com/18356694/136257823-e77d135c-6409-4c40-bea9-4ca524273bbf.png) > > it says I'm up to date ._. > ​​ > wild theory: office boots some cmdline something or other that triggers a defapp launch. We don't end up sticking to the thing that office launched, but the act of creating the wt to _try_ to delegate to also spawns the other restored windows > ​ > It's that yellow icon thing > ​ > Yeah what's weird is I can't get defapp to work with just plain CMD lol > ​ > that's weird... AppVlp is for executing untrusted scripts AFAIK > > > ![image](https://user-images.githubusercontent.com/18356694/136257901-55b34b12-b559-4461-bb09-7510ccd95f36.png) > look at that - the window that got restored WAS WINDOW 2. So some other wt was launched that thought it also needed to bring this one back
Author
Owner

@Rosefield commented on GitHub (Oct 6, 2021):

torpedoing the feature Does this mean the converse is also true, that if you quit a terminal you could cause excel to crash? If you create a new terminal separately, does it have a different monarch than the one(s) created by excel?

This sounds a lot like we'll need some level of isolation or disabling of the feature if running under a different program's context so it doesn't clobber the saved state.

@Rosefield commented on GitHub (Oct 6, 2021): *torpedoing the feature* Does this mean the converse is also true, that if you `quit` a terminal you could cause excel to crash? If you create a new terminal separately, does it have a different monarch than the one(s) created by excel? This sounds a lot like we'll need some level of isolation or disabling of the feature if running under a different program's context so it doesn't clobber the saved state.
Author
Owner

@zadjii-msft commented on GitHub (Oct 6, 2021):

No so what I think it happening: Office is launching some helper.exe that's a commandline app. We detect that a commandline app is trying to run, and we decide to delegate it to the terminal (for defterm). helper.exe exits nearly instantly, so no terminal window sticks around for it. However, the Terminal did launch, and it determined it needed to restore the windows from the previous session (in addition to this new window for the defterm connection).

This is probably going to be true for a class of apps that have poorly implemented commandline helpers that pop open console windows quickly.

We've got some filters we use for consoles where the caller requested they be hidden to try and prevent defterm kicking in for them. This is just going to be another case of that.

@zadjii-msft commented on GitHub (Oct 6, 2021): No so what I think it happening: Office is launching some helper.exe that's a commandline app. We detect that a commandline app is trying to run, and we decide to delegate it to the terminal (for defterm). `helper.exe` exits nearly instantly, so no terminal window sticks around for it. However, the Terminal did launch, and it determined it needed to restore the windows from the previous session (in addition to this new window for the defterm connection). This is probably going to be true for a class of apps that have poorly implemented commandline helpers that pop open console windows quickly. We've got some filters we use for consoles where the caller requested they be hidden to try and prevent defterm kicking in for them. This is just going to be another case of that.
Author
Owner

@DHowett commented on GitHub (Oct 6, 2021):

This is just going to be another case of that.

I don't think it is, though? It sounds like it will also do session restore if I Win+R cmd, too, which I for sure don't want.

after some testing ...

Oh yes, this is exactly what happens.

Unfortunately, if Office would have popped up an actual console window on the user's session as the user, there was no flag we could have used to detect that Office didn't want that.

@DHowett commented on GitHub (Oct 6, 2021): > This is just going to be another case of that. I don't think it is, though? It sounds like it will also do session restore if I <kbd>Win+R</kbd> `cmd`, too, which I for sure don't want. _after some testing ..._ Oh yes, this is exactly what happens. Unfortunately, if Office would have popped up an actual console window on the user's session _as the user_, there was no flag we could have used to detect that Office didn't want that.
Author
Owner

@zadjii-msft commented on GitHub (Oct 6, 2021):

I don't think it is, though? It sounds like it will also do session restore if I Win+R cmd, too, which I for sure don't want.

Yea, we went with that because that's how chrome.exe bing.com works, how sublime works, etc. They restore the tabs you had in addition to this new thing you wanted. There's otherwise no good way of saying "this session is special, it was in response to a defterm invocation, we don't want to persist it. Next time we launch, do the restore thing".

@zadjii-msft commented on GitHub (Oct 6, 2021): > I don't think it is, though? It sounds like it will also do session restore if I Win+R `cmd`, too, which I for sure don't want. Yea, we went with that because that's how `chrome.exe bing.com` works, how sublime works, etc. They restore the tabs you had _in addition_ to this new thing you wanted. There's otherwise no good way of saying "this session is special, it was in response to a defterm invocation, we don't want to persist it. Next time we launch, do the restore thing".
Author
Owner

@zadjii-msft commented on GitHub (Jan 31, 2022):

This is also the same thing as #11627. May want to use this as a list of apps where this occurs.

@zadjii-msft commented on GitHub (Jan 31, 2022): This is also the same thing as #11627. May want to use this as a list of apps where this occurs.
Author
Owner

@zadjii-msft commented on GitHub (Mar 8, 2022):

Well, I can't repro this anymore (on 1.14). I bet our changes to determining if we need to make a window for defterm or not fixed this along the way.

@zadjii-msft commented on GitHub (Mar 8, 2022): Well, I can't repro this anymore (on 1.14). I bet our changes to determining if we need to make a window for defterm or not fixed this along the way.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15468