"persistedWindowLayout" bug when starting with arguments #20975

Closed
opened 2026-01-31 07:29:22 +00:00 by claunia · 8 comments
Owner

Originally created by @alex-jitbit on GitHub (Dec 10, 2023).

Windows Terminal version

1.18.3181.0

Windows build number

10.0.22631.2715

Other Software

No response

Steps to reproduce

I have "firstWindowPreference": "persistedWindowLayout"

Also "new instance behavior" is set to "Attach to most recently used"

  • When starting Windows Terminal from command prompt via wt - all godd
  • When starting by clicking a pinned taskbar icon - all good.
  • When starting via wt -d . to start in current directory and the terminal is already running - all good.
  • When starting via wt -d . when no termonal instance is running yet - it opens in a weird random location.

Expected Behavior

No response

Actual Behavior

  • When starting via wt -d . when no termonal instance is running yet - it opens in a weird random location.
Originally created by @alex-jitbit on GitHub (Dec 10, 2023). ### Windows Terminal version 1.18.3181.0 ### Windows build number 10.0.22631.2715 ### Other Software _No response_ ### Steps to reproduce I have `"firstWindowPreference": "persistedWindowLayout"` Also "new instance behavior" is set to "Attach to most recently used" * When starting Windows Terminal from command prompt via `wt` - all godd * When starting by clicking a pinned taskbar icon - all good. * When starting via `wt -d .` to start in current directory and the terminal is already running - all good. * ***When starting via `wt -d .` when no termonal instance is running yet - it opens in a weird random location.*** ### Expected Behavior _No response_ ### Actual Behavior * ***When starting via `wt -d .` when no termonal instance is running yet - it opens in a weird random location.***
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 07:29:22 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Dec 11, 2023):

What "weird random location", exactly/?

I'd expect, with your settings, that if you're cold starting the terminal with wt -d ., that the Terminal should spawn either {one} or {two or more} tabs:

  • one tab, if you closed out the last tab when closing the terminal previously, so that there was nothing for the terminal to restore from the previous session.
  • two or more, if you just closed the terminal with lots of tabs before. In this case, the terminal should open your previous tabs, and a new tab for the new-tab -d . request.
@zadjii-msft commented on GitHub (Dec 11, 2023): What "weird random location", _exactly_/? I'd expect, with your settings, that if you're cold starting the terminal with `wt -d .`, that the Terminal should spawn either {one} or {two or more} tabs: * **one** tab, if you closed out the last tab when closing the terminal previously, so that there was nothing for the terminal to restore from the previous session. * **two or more**, if you just closed the terminal with lots of tabs before. In this case, the terminal should open your previous tabs, and a _new_ tab for the `new-tab -d .` request.
Author
Owner

@alex-jitbit commented on GitHub (Dec 11, 2023):

What "weird random location", exactly/?

In my case it's at the center with half of the window hidden outside the screen (top edge). Do you need the exact coordinates?

And sometimes when cold-starting with wt -d . it opens TWO separate windows, one in the profile folder (%HOMEPATH%) positioned correctly, and one in the current folder it's instructed to go to (this window is half outside the screen centered)

Have you tried reproducing the problem?

@alex-jitbit commented on GitHub (Dec 11, 2023): > What "weird random location", exactly/? In my case it's at the center with half of the window hidden outside the screen (top edge). Do you need the exact coordinates? And sometimes when cold-starting with `wt -d .` it opens TWO separate windows, one in the profile folder (`%HOMEPATH%`) positioned correctly, and one in the current folder it's instructed to go to (this window is half outside the screen centered) Have you tried reproducing the problem?
Author
Owner

@alex-jitbit commented on GitHub (Dec 11, 2023):

Also saving the current position only works when closing the window by clicking the top-right "X" window icon.

Closing the last open tab should do the same, but nope, after that the new terminal windows starts at a random position again.

But that's another bug...

Do you want me to record a video so you see how broken it is?

@alex-jitbit commented on GitHub (Dec 11, 2023): Also saving the current position only works when closing the window by clicking the top-right "X" window icon. Closing the last open tab should do the same, but nope, after that the new terminal windows starts at a random position again. But that's another bug... Do you want me to record a video so you see how broken it is?
Author
Owner

@zadjii-msft commented on GitHub (Dec 13, 2023):

Okay, we're a little bit psychic debugging here. I think what you're seeing here is a bit of a weird combo of "things that are mostly by design":

  • There's slightly different behavior for persisted layouts, depending on how you close things. If you close the tab, then we take that as a signal of "I don't want this to be persisted". If you close the window with one tab - then we'll persist that tab.
    • when you close the tab (so there's no tab left to persist), the next window will use the position from your settings
  • Depending on what your initialPosition is in the settings, that probably accounts for the "random position" you're seeing. The default value will let the system position the window, which is behavior that seems apparently random

#12633 is the dupe around here for "I want to persist window positions but not really the tabs".

Does that clear things up/?

@zadjii-msft commented on GitHub (Dec 13, 2023): Okay, we're a little bit psychic debugging here. I think what you're seeing here is a bit of a weird combo of "things that are mostly by design": * There's slightly different behavior for persisted layouts, depending on how you close things. If you close the tab, then we take that as a signal of "I don't want this to be persisted". If you close the _window_ with one tab - then we'll persist that tab. * when you close the tab (so there's no tab left to persist), the _next_ window will use the position from your settings * Depending on what your `initialPosition` is in the settings, that probably accounts for the "random position" you're seeing. The default value will let the system position the window, which is behavior that seems apparently random #12633 is the dupe around here for "I want to persist window positions but not really the tabs". Does that clear things up/?
Author
Owner

@alex-jitbit commented on GitHub (Dec 14, 2023):

Nope. This stilll does not explain why the app starts at a different location when I run wt -d .

@alex-jitbit commented on GitHub (Dec 14, 2023): Nope. This stilll does not explain why the app starts at a different location when I run `wt -d .`
Author
Owner

@alex-jitbit commented on GitHub (Dec 14, 2023):

TL;DR

  • press WIN + R, type wt - correct location. Close terminal window
  • press WIN + R, type wt - again correct location. Close terminal window
  • press WIN + R, type wt -d . - I get two separate Terminal windows, one at random location, one at correct
@alex-jitbit commented on GitHub (Dec 14, 2023): TL;DR * press `WIN + R`, type `wt` - correct location. Close terminal window * press `WIN + R`, type `wt` - _again_ correct location. Close terminal window * press `WIN + R`, type `wt -d .` - I get two separate Terminal windows, one at random location, one at correct
Author
Owner

@zadjii-msft commented on GitHub (Jan 10, 2024):

So, yea that does kinda explain it. When you do the wt -d . command (with no open windows), what you get is

  • the last window you closed, at the size and position you closed it at
  • a brand new window, at the random location

It's kinda wacky, but ultimately, it's the same thing that browsers do in the case of a cold launch with edge.exe github.com (or similar)

and ultimately, I think what you're expecting here is the behavior that we'd add with /dup #12633.

@zadjii-msft commented on GitHub (Jan 10, 2024): So, yea that does kinda explain it. When you do the `wt -d .` command (with no open windows), what you get is * the last window you closed, at the size and position you closed it at * a brand new window, at the random location It's kinda wacky, but ultimately, it's the same thing that browsers do in the case of a cold launch with `edge.exe github.com` (or similar) and ultimately, I think what you're expecting here is the behavior that we'd add with /dup #12633.
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (Jan 10, 2024):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (Jan 10, 2024): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20975