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

Clicking shortcut to WT PowerShell profile opens 2 windows #14799

Open
WillPittenger opened this issue Feb 6, 2023 · 11 comments
Open

Clicking shortcut to WT PowerShell profile opens 2 windows #14799

WillPittenger opened this issue Feb 6, 2023 · 11 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Milestone

Comments

@WillPittenger
Copy link

Windows Terminal version

1.16.10261.0

Windows build number

Edition Windows 11 Pro Version 22H2 Installed on ‎12-‎8-‎2022 OS build 22621.1194 Experience Windows Feature Experience Pack 1000.22638.1000.0

Other Software

PowerShell 7.3.2

Steps to reproduce

1 Create a Windows shortcut with the command line C:\Users\willp\AppData\Local\Microsoft\WindowsApps\wt.exe -p "PowerShell"
2 Create a matching WT profile
3 Click the shortcut

How many windows opened?

Expected Behavior

I'd expect only at most one new window.

Actual Behavior

With no WT widows open, I get two to the same profile.

@WillPittenger WillPittenger 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 Feb 6, 2023
@lhecker
Copy link
Member

lhecker commented Feb 7, 2023

Are you sure you have 1.16.10261 installed? That's the version for Windows 10. You can replace it with 1.16.10262 from here.

Additionally I'm not sure how your 1. and 2. step fit together: The "PowerShell" profile is a standard profile and should always exist unless you deleted it previously. Is "PowerShell" in your first step just an example or is the 2. step optional?


Interesting... I can't reproduce this behavior with 1.16.10262.0 and PowerShell 7.3.2. What happens if you add -NoProfile to the command line of your "PowerShell" profile? If that doesn't fix the issue, could you share your settings.json?

@WillPittenger
Copy link
Author

It's proving to be intermittent. Yes, that's the version I see installed. I copied the version number from the About dialog.
image

@DHowett
Copy link
Member

DHowett commented Feb 7, 2023

Do you, by chance, have this setting set?

image

@WillPittenger
Copy link
Author

WillPittenger commented Feb 7, 2023

I have "Open Windows from a previous session". That might be it. I was hoping to see my previous PS session.

@carlos-zamora carlos-zamora added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Feb 8, 2023
@carlos-zamora
Copy link
Member

Did this turn out to be your issue?

@akbyrd
Copy link

akbyrd commented Feb 12, 2023

I've run into this as well. Using "firstWindowPreference": "persistedWindowLayout" causes Windows Terminal to open multiple windows, depending on the command line used to launch it.

wt -d . will open 2 windows. One with the previous session and a new one with a shell window for the current directory.

I think the expected behavior here is that a single window is opened with the previous session and a new shell instance is added to that window.

wt -p "PowerShell" has the same issue.

Version 1.16.10261.0 on Windows 10

@zadjii-msft
Copy link
Member

Yea, this is just kinda by-design for now. If you don't have any Terminal windows open, and have "firstWindowPreference": "persistedWindowLayout" set, and run a wt commandline that's not just wt.exe (e.g. wt -d .), then we'll open up the old windows, AND open the new thing you've asked for (in this case, the new-tab -d .). This is roughly consistent with how browsers work, if you did something like edge.exe github.com without any windows currently open.

I suppose theoretically, this could also respect the "windowingBehavior" setting. If that was set to use*Existing, then theoretically I suppose we should append the passed commandline to whatever commandline we're going to restore from. That would make sense.

I'll leave this open, on the backlog. I've been playing in the state restoration code quite a bit recently, and I don't think this would be super easy to fix...

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. Priority-2 A description (P2) and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Feb 13, 2023
@zadjii-msft zadjii-msft added this to the Backlog milestone Feb 13, 2023
@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Feb 13, 2023
@akbyrd
Copy link

akbyrd commented Feb 13, 2023

Just as a data point one place where this comes up naturally is vscode. When it launches an external terminal it passes the current directory. I don't think this is configurable by the user, but it's the desired behavior in any case.

Respecting windowingBehavior makes sense to me, personally, and would be desirable.

@aderchox
Copy link

aderchox commented May 27, 2023

I had the same issue and I initially (naively confused!) thought this was VSCode's issue.
I've added a GIF at: microsoft/vscode#183401
I think it's annoying in case of VSCode and makes such a brilliant option (open external terminal) useless. My laptop screen is small and I tend to use the external terminal rather than the integrated one, but everytime I re-open the external terminal, I have to close the extra one.
Another similar issue has also been added at: #14932

Based on what I've read here, the current behavior is respecting some conventions, but I guess you might be able to add some third option or a flag? Then that flag might be usable in VSCode default terminal settings (I've not tested this though).

@mtaalas
Copy link

mtaalas commented Jun 4, 2023

My expected behavior is also, that if I use default Start Menu shortcut (that Windows store created when installing Terminal) to launch the Terminal, it'll restore my old session as/if configured from the settings to do so, but does NOT open anything else UNLESS I specifically tell it to with separate arguments. And there's a lot of different possibilities:

There's a difference choosing between these things:

Open previous session tabs and windows
Open previous session and ATTACH the new window as a tab to the previous session window
Open previous session and open this new shell/terminal as a new window
Open new window and discard old session

It's many things and possibilities and as it stands it doesn't seem to be very exclusive in how to handle it properly.

From browsers I've come to expect (and from notepad++ for that matter) that launching the application itself without arguments doesn't automatically open new tab or window, it either restores my old session 1:1 OR starts from scratch depending what configuration was active. If I want to open extra tab/window to a location, I should explicitly command it to do so.

As a user, I expect it to open to the last window I used in the session that's being restored (let's say session had 3 windows, if I was using specific window before closing the session [based on what window was in focus?], THAT'S the one I expect the new tab to open to), unless I specifically have an option to choose where it opens to based on arguments or profile configuration.

Like in NPP, It opens all the previous tabs AND it'll attach the new file that I gave as an argument to the end of that tab list.

I hope you'll figure it out... it's not an easy problem by any means to tackle. :)

@zadjii
Copy link

zadjii commented Jun 4, 2023

Guys what if we restored both the unelevated and the elevated windows when either are launched?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

9 participants