Opening a new terminal window does not restore the previous window's size and position on the screen #16938

Open
opened 2026-01-31 05:27:47 +00:00 by claunia · 16 comments
Owner

Originally created by @Poopooracoocoo on GitHub (Mar 6, 2022).

Windows Terminal version

1.13.10395.0

Windows build number

10.0.19044

Other Software

No response

Steps to reproduce

  1. Open Terminal
  2. Resize and reposition window
  3. Close window
  4. Open Terminal again

Expected Behavior

Terminal would open the window in the same position and size

Actual Behavior

The position and size are reset.

Note: I am not referring to session restore on start-up like you'd find in a web browser that can be enabled optionally. I'm referring to regular behaviour that people expect on desktop operating systems. And in particular, this makes it easier to use on smaller screens such as laptops.

Originally created by @Poopooracoocoo on GitHub (Mar 6, 2022). ### Windows Terminal version 1.13.10395.0 ### Windows build number 10.0.19044 ### Other Software _No response_ ### Steps to reproduce 1. Open Terminal 2. Resize and reposition window 3. Close window 4. Open Terminal again ### Expected Behavior Terminal would open the window in the same position and size ### Actual Behavior The position and size are reset. Note: I am not referring to session restore on start-up like you'd find in a web browser that can be enabled optionally. I'm referring to regular behaviour that people expect on desktop operating systems. And in particular, this makes it easier to use on smaller screens such as laptops.
claunia added the Area-SettingsIssue-TaskProduct-TerminalArea-Windowing labels 2026-01-31 05:27:48 +00:00
Author
Owner

@Rosefield commented on GitHub (Mar 6, 2022):

Do you have window layout saving enabled? In Settings -> Startup -> "When Terminal starts" select the "Open windows from a previous session" option.

image

https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#behavior-when-starting-a-new-terminal-session

@Rosefield commented on GitHub (Mar 6, 2022): Do you have window layout saving enabled? In Settings -> Startup -> "When Terminal starts" select the "Open windows from a previous session" option. ![image](https://user-images.githubusercontent.com/6185249/156939280-c487a790-58ad-4142-99aa-400d24443c95.png) https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#behavior-when-starting-a-new-terminal-session
Author
Owner

@Poopooracoocoo commented on GitHub (Mar 6, 2022):

Do you have window layout saving enabled? In Settings -> Startup -> "When Terminal starts" select the "Open windows from a previous session" option.

I don't want that, nor should I need that enabled to have this.

Edit: I even explicitly mentioned that option in my issue. No edits.

@Poopooracoocoo commented on GitHub (Mar 6, 2022): > Do you have window layout saving enabled? In Settings -> Startup -> "When Terminal starts" select the "Open windows from a previous session" option. I don't want that, nor should I need that enabled to have this. Edit: I even explicitly mentioned that option in my issue. No edits.
Author
Owner

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

Alright so this is a new feature request - a setting to use the initialPosition, initialSize in state.json instead of the ones in the settings file. I suppose that could be a checkbox within the Launch Size expander. Ah, but then we've got the trick that we'd want one checkbox for "use previous position" and another for "use previous size". (admittedly, initialPosition isn't in the SUI yet, #9075). Then there's also the complicating factor that enabling "Open windows from a previous session" would spooky-action-at-a-distance check and disable those boxes.

So then it makes more sense to put this as another radio option in "When Terminal starts...". Or like, a checkbox under the "Open a tab with the default profile", that only revealsenables itself when that radio button is selected? (hiding itself would be terrible discoverability)

@zadjii-msft commented on GitHub (Mar 7, 2022): Alright so this is a new feature request - a setting to use the `initialPosition`, `initialSize` in state.json instead of the ones in the settings file. I suppose that could be a checkbox within the Launch Size expander. Ah, but then we've got the trick that we'd want one checkbox for "use previous position" and another for "use previous size". (admittedly, initialPosition isn't in the SUI yet, #9075). Then there's also the complicating factor that enabling "Open windows from a previous session" would spooky-action-at-a-distance check and disable those boxes. So then it makes more sense to put this as another radio option in "When Terminal starts...". Or like, a checkbox under the "Open a tab with the default profile", that only ~reveals~enables itself when that radio button is selected? (hiding itself would be terrible discoverability)
Author
Owner

@Poopooracoocoo commented on GitHub (Mar 7, 2022):

An option doesn't really make sense to me. I don't really want anything complicated. I just want the default windowing behaviour I've come to expect from other apps. 🤷

@Poopooracoocoo commented on GitHub (Mar 7, 2022): An option doesn't really make sense to me. I don't really want anything complicated. I just want the default windowing behaviour I've come to expect from other apps. 🤷
Author
Owner

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

We already have some other settings to control where the window is positioned and how big it is, so already we're off the rails of "other apps". I'm of the strong opinion that user preference is king - I'd love to give everyone as many knobs to control the Terminal as possible, to make it work exactly like they'd like.

@zadjii-msft commented on GitHub (Mar 7, 2022): We already have some other settings to control [where the window is positioned](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#launch-position) and [how big it is](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#launch-size), so already we're off the rails of "other apps". I'm of the strong opinion that user preference is king - I'd love to give everyone as many knobs to control the Terminal as possible, to make it work exactly like they'd like.
Author
Owner

@Poopooracoocoo commented on GitHub (Mar 7, 2022):

Good defaults are always nice tho :)

@Poopooracoocoo commented on GitHub (Mar 7, 2022): Good defaults are always nice tho :)
Author
Owner

@SteveALee commented on GitHub (Mar 9, 2022):

I agree, it should just work its standard windows behaviour. Should respect the monitor it was on as well. Let people override if required but please follow principle of least surprises.

@SteveALee commented on GitHub (Mar 9, 2022): I agree, it should just work its standard windows behaviour. Should respect the monitor it was on as well. Let people override if required but please follow principle of least surprises.
Author
Owner

@DHowett commented on GitHub (Mar 14, 2022):

Discussion outcome: This probably needs a miniature spec (AKA: we agree on it in the issue, and check in a quick markdown document about it) as the team couldn't come to consensus on whether this is a firstWindowPreference or a launchPosition, and whether this is part of or not a part of the session restoration code.

@DHowett commented on GitHub (Mar 14, 2022): Discussion outcome: This probably needs a miniature spec (AKA: we agree on it in the issue, and check in a quick markdown document about it) as the team couldn't come to consensus on whether this is a `firstWindowPreference` or a `launchPosition`, and whether this is part of or not a part of the session restoration _code_.
Author
Owner

@SteveALee commented on GitHub (Mar 15, 2022):

Thanks for bringing the outcome here!

@SteveALee commented on GitHub (Mar 15, 2022): Thanks for bringing the outcome here!
Author
Owner

@Stanzilla commented on GitHub (Mar 24, 2022):

Hah just came here to report this, I was thinking of two suggestions:

  1. Option to always spawn at a set of coordinates OR at the center of the screen
  2. Remember position properly
@Stanzilla commented on GitHub (Mar 24, 2022): Hah just came here to report this, I was thinking of two suggestions: 1. Option to always spawn at a set of coordinates OR at the center of the screen 2. Remember position properly
Author
Owner

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

FWIW:

Option to always spawn at a set of coordinates OR at the center of the screen are already settings.

Unifying those two with bullet point 2 is the one that this issue is tracking - finding a good way of exposing that setting to the user both as a UI and in json is the hard part.

@zadjii-msft commented on GitHub (Mar 24, 2022): FWIW: [Option to always spawn at a set of coordinates](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#launch-position) OR [at the center of the screen](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#center-on-launch) are already settings. Unifying those two with bullet point 2 is the one that this issue is tracking - finding a good way of exposing that setting to the user both as a UI and in json is the hard part.
Author
Owner

@Stanzilla commented on GitHub (Mar 24, 2022):

FWIW:

Option to always spawn at a set of coordinates OR at the center of the screen are already settings.

Unifying those two with bullet point 2 is the one that this issue is tracking - finding a good way of exposing that setting to the user both as a UI and in json is the hard part.

Oh my bad, sorry. I didn't see it in the UI options.

@Stanzilla commented on GitHub (Mar 24, 2022): > FWIW: > > [Option to always spawn at a set of coordinates](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#launch-position) OR [at the center of the screen](https://docs.microsoft.com/en-us/windows/terminal/customize-settings/startup#center-on-launch) are already settings. > > Unifying those two with bullet point 2 is the one that this issue is tracking - finding a good way of exposing that setting to the user both as a UI and in json is the hard part. Oh my bad, sorry. I didn't see it in the UI options.
Author
Owner

@Poopooracoocoo commented on GitHub (Jan 24, 2023):

Any updates here?

I do use the subscribe button but I'm the author of this issue so I receive notifications by default. People have bumped other issues in Microsoft repos that were forgotten and that seemed to work for some of those issues. Doing so here isn't such a stretch.

@Poopooracoocoo commented on GitHub (Jan 24, 2023): Any updates here? I do use the subscribe button but I'm the author of this issue so I receive notifications by default. People have bumped other issues in Microsoft repos that were forgotten and that seemed to work for some of those issues. Doing so here isn't such a stretch.
Author
Owner

@zadjii-msft commented on GitHub (Jan 24, 2023):

Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button?
image
That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

As it stands, this issue remains at:

Discussion outcome: This probably needs a miniature spec (AKA: we agree on it in the issue, and check in a quick markdown document about it) as the team couldn't come to consensus on whether this is a firstWindowPreference or a launchPosition, and whether this is part of or not a part of the session restoration code.

If someone wants to sort out how exactly this should be implemented, we'd be more than happy to review a writeup ☺️


Some notes, march 2023:

  • On my branch
  • You delete tabLayout entirely (is null) -> right size & pos, but explodes
  • you set tabLayout to [] -> Right size & pos, and uses the default profile

around 434abc247 (during #14825), this was actually almost trivially easy. We made the logic concerning the number of tabs persisted a bit more strict, but honestly, I think we could undo that easily. Commit 1b59eb923 was the one to enforce the "we must have tabs" thing

@zadjii-msft commented on GitHub (Jan 24, 2023): Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button? ![image](https://user-images.githubusercontent.com/18356694/91237459-5cbb0c80-e700-11ea-9347-b9b1ec2813b1.png) That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️ As it stands, this issue remains at: > Discussion outcome: This probably needs a miniature spec (AKA: we agree on it in the issue, and check in a quick markdown document about it) as the team couldn't come to consensus on whether this is a `firstWindowPreference` or a `launchPosition`, and whether this is part of or not a part of the session restoration _code_. If someone wants to sort out how exactly this should be implemented, we'd be more than happy to review a writeup ☺️ <hr> Some notes, march 2023: > - On my branch > - You delete tabLayout entirely (is null) -> right size & pos, but explodes > - you set tabLayout to [] -> Right size & pos, and uses the default profile around 434abc247 (during #14825), this was actually almost trivially easy. We made the logic concerning the number of tabs persisted a bit more strict, but honestly, I think we could undo that easily. Commit 1b59eb923 was the one to enforce the "we must have tabs" thing
Author
Owner

@lhecker commented on GitHub (Mar 20, 2024):

If someone wants to sort out how exactly this should be implemented, we'd be more than happy to review a writeup ☺️

FWIW, and when it comes to the implementation specifically, I believe this should use the GetWindowPlacement and SetWindowPlacement APIs. Those have been in use by other HWND applications for this purpose since forever.

@lhecker commented on GitHub (Mar 20, 2024): > If someone wants to sort out how exactly this should be implemented, we'd be more than happy to review a writeup ☺️ FWIW, and when it comes to the implementation specifically, I believe this should use the [`GetWindowPlacement`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowplacement) and [`SetWindowPlacement`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowplacement) APIs. Those have been in use by other HWND applications for this purpose since forever.
Author
Owner

@Gavitron commented on GitHub (Nov 14, 2024):

Is this still an open bug? I'm unable to get wt to open on any monitor but the primary, without hard-coding an absolute position.

Windows Version 10.0.19045 Build 19045
Windows Terminal Version 1.17.11461.0

settings.json:

    "initialPosition": ",",
    "launchMode": "default",
    "firstWindowPreference": "defaultProfile",
    "centerOnLaunch": false,

Steps to reproduce:

  1. Start windows terminal from shortcut on desktop of monitor two.
    ( Shortcut points to %LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe)
  2. terminal opens on monitor one.
  3. drag window to monitor two.
  4. Close window via any method. (tested all of: window-close widget, tab-close widget, alt+F4. typing "exit" in terminal)
  5. Start windows terminal from shortcut on monitor two.

Expected behaviour:

terminal opens on monitor two, with previous state

Observed behaviour:

terminal opens on monitor one in a "default" state. (though not one explicitly set)

note: as alluded to above, I worked around this bug by hard-coding a window position, but now if I start a second terminal instance, it perfectly overlaps the first, instead of being offset by ~50px as usually happens when letting Windows decide.

@Gavitron commented on GitHub (Nov 14, 2024): Is this still an open bug? I'm unable to get `wt` to open on any monitor but the primary, without hard-coding an absolute position. Windows Version 10.0.19045 Build 19045 Windows Terminal Version 1.17.11461.0 **settings.json:** ``` "initialPosition": ",", "launchMode": "default", "firstWindowPreference": "defaultProfile", "centerOnLaunch": false, ``` ### Steps to reproduce: 1. Start windows terminal from shortcut on desktop of monitor two. ( Shortcut points to `%LOCALAPPDATA%\Microsoft\WindowsApps\wt.exe`) 2. terminal opens on monitor one. 3. drag window to monitor two. 4. Close window via any method. (tested all of: window-close widget, tab-close widget, alt+F4. typing "exit" in terminal) 5. Start windows terminal from shortcut on monitor two. ### Expected behaviour: terminal opens on monitor two, with previous state ### Observed behaviour: terminal opens on monitor one in a "default" state. (though not one explicitly set) note: as alluded to above, I worked around this bug by hard-coding a window position, but now if I start a second terminal instance, it perfectly overlaps the first, instead of being offset by ~50px as usually happens when letting Windows decide.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#16938