Skip to content

Clicking shortcut to WT PowerShell profile opens 2 windows #14799

Open

Description

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.

Activity

  1. added
    Issue-BugIt either shouldn't be doing this or needs an investigation.
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Feb 6, 2023
  2. lhecker commented on Feb 7, 2023

    @lhecker
    Member

    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?

  3. WillPittenger commented on Feb 7, 2023

    @WillPittenger
    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

  4. DHowett commented on Feb 7, 2023

    @DHowett
    Member

    Do you, by chance, have this setting set?

    image

  5. WillPittenger commented on Feb 7, 2023

    @WillPittenger
    Author

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

  6. carlos-zamora commented on Feb 8, 2023

    @carlos-zamora

    Did this turn out to be your issue?

  7. akbyrd commented on Feb 12, 2023

    @akbyrd

    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

  8. zadjii-msft commented on Feb 13, 2023

    @zadjii-msft
    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...

  9. added
    Area-SettingsIssues related to settings and customizability, for console or terminal
    and removed
    Needs-Author-FeedbackThe original author of the issue/PR needs to come back and respond to something
    on Feb 13, 2023
  10. removed
    Needs-TriageIt's a new issue that the core contributor team needs to triage at the next triage meeting
    on Feb 13, 2023
  11. akbyrd commented on Feb 13, 2023

    @akbyrd

    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.

  12. aderchox commented on May 27, 2023

    @aderchox

    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).

  13. mtaalas commented on Jun 4, 2023

    @mtaalas

    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. :)

  14. zadjii commented on Jun 4, 2023

    @zadjii

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-SettingsIssues related to settings and customizability, for console or terminalIssue-BugIt either shouldn't be doing this or needs an investigation.Priority-2A description (P2)Product-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions