Repository navigation
Open
Labels
Area-RemotingCommunication layer between windows. Often for windowing behavior, quake mode, etc.Communication layer between windows. Often for windowing behavior, quake mode, etc.Issue-ScenarioProduct-TerminalThe new Windows Terminal.The new Windows Terminal.
Milestone
Description
[Original thread: #766] [Spec: {none}] [Initial PR: #10972] [Multiple windows PR: #11083]
This thread is being used to track all the component work for restoring the window state. Additionally related threads:
- Enable Terminal to persist / restore instance settings #766 - Restore the layout, position of windows
- This is partially implemented in Persist window layout on window close #10972
- Persist window layout cont. save multiple windows #11083 handles this for multiple windows.
- Restore previously closed session's state (Buffer contents) #961 - Restore the contents of the buffer when resuming a tab.
- This is not about restoring the process state entirely, since that's impossible. Simply the text content is good enough.
- Stashing this in JSON doesn't really make sense - imagine
SHRT_MAXlines of text + attributes in a json string.
- Feature Request - Restore closed tab #960 - Re-open a recently closed tab
- This means we shouldn't just discard the terminal control when closing a pane/tab. This is similar to the ctrl+shift+t shortcut in (Chromium) browsers
- Likely best to wait for Add support for tab tearoff and tab merge #1256 and Scenario: Windows Terminal 2.0 Process Model Improvements #5000 to sort themselves out before starting this one.
- Move the commandline args to their own project #8841 and Add startupActions to SUI #8812 need to merge, so we can properly reflect all these options in the SUI.
- Add a "Quit" action #11081
- Preserve WT_SESSION across restarts #6362
2.0 Bugs
these are all presuming that #10972 merges basically as is
- We should wrap this feature up in a Preview-only feature flag (no external community member should have to deal with that)
- Opening an elevated window will automatically re-open all the unelevated window state (as elevated!). This is because there are separate monarchs for elevated and unelevated windows.
- Elevated windows should probably just participate at all in persist/restore for now. That's okay. We may revisit after https://github.com/microsoft/terminal/projects/5#card-67023745
- How do we persist something like
wt -- cmd.exe? That won't have a profile, only aNewTerminalArgs, that we don't cache at runtime- We've mentioned in team syncs before that we may need to keep the
NewTerminalArgsaround when spawning a
- We've mentioned in team syncs before that we may need to keep the
- Same idea with a defterm connection - We won't be able to restore defterm panes at all, because we have no idea what profile they were. Right?
- How exactly does this work with the
_quakewindow? Should that participate in the session restore? Probably, yea. - Window names need to be persisted as well.
- Closing the last window with
ClosePanewill clear out any persisted layout.- This is by design
- Similarly with closing the last tab by clicking the
xon the tab itself. Doesn't seem to save the window layout in that case.- This is by design
- If you have a profile with a
background, then the colorscheme will blow away the profile's background on restore. - Terminal doesn't remember maximized, focus, fullscreen states Terminal doesn't remember maximized, focus, fullscreen states #11426
- Windows Terminal failed to restore the position in the 2nd or 3rd monitor with maximized window mode. #11639
- Terminal should also restore runtime tab titles #11878
- Move tab to new window, launch position, center on launch? #18670
- Tab position is not restored for
restoreLastClosedaction #12902 - Opening a new terminal window does not restore the previous window's size and position on the screen #12633
- The size of a focus mode window is wrong after a session restore. I believe this is actually the same root cause as:
Reacted by Alexander and wiktor-golonka
Metadata
Metadata
Assignees
Labels
Area-RemotingCommunication layer between windows. Often for windowing behavior, quake mode, etc.Communication layer between windows. Often for windowing behavior, quake mode, etc.Issue-ScenarioProduct-TerminalThe new Windows Terminal.The new Windows Terminal.

Activity
[-]<reserved>[/-][+]megathread: Window State Persistence[/+]Rosefield commentedon Sep 1, 2021
Re
I can answer that concretely, just fine (the TerminalSettings on a control has all of these properties)
Rosefield commentedon Sep 3, 2021
Re
This is done on 10972 now
I disabled the feature entirely for elevated processes on 11083 in 8ffd314
Was added to 11083 in a93d3b1
With some minor modification it should be pretty safe to cherry-pick these if necessary.
With just 10972 this is a problem since that is explicitly checking for the existence of only one window remaining. With 11083 the
_quakewindow will be saved just fine, but might lead to confusing users if they closed all of their visible windows and thinking that it saved the last layout. If thequitaction is added that just becomes a point of user education thatquitis the proper way to close all of their windows and save them. There might be some issues with saving the position/size of the quake window, but there is already special logic to handle_quakeso it might just turn out OK magically.Hypothetically this should be the same as the commandline version above in that it saves fine, but as the "Default" profile.
zadjii-msft commentedon Sep 7, 2021
wowow I half-assed a list of showerthoughts of things that might go wrong with this (that could be fixed in post), and the man just goes and fixes/addresses all of them. That's great, thanks!
Rosefield commentedon Sep 20, 2021
Re
That was deliberate behavior because I took those actions to mean "I don't want to save these tab(s)". If you close all of your tabs in your browser and then re-open the browser it wouldn't have saved anything either. This is yet again a problem that is ameliorated by
quit.zadjii-msft commentedon Sep 20, 2021
Okay, thanks for clearing that up. That makes sense, it was a little unexpected by that's fine so long as we've got it all documented.
2 remaining items
Try to persist the Pane's working directory if we know what it is. (#…
ykoehler commentedon Oct 15, 2021
In the same idea, I would like to be able to "obtain" the wt command to execute to open up my tab exactly the same way (with same panes and panes size, etc). From there I could paste that into a shortcut icon and create a different layout for each icon to open with. So if somehow we could dump a wt command output that I re-run and get a window with the same tab/pane and size that would be appreciated, in this case, I do not care about running commands in those, but I get you would have to support it.
zadjii-msft commentedon Nov 23, 2021
I'm stashing this here because it was weird, but not because I think we need to do anything about it.
I restarted after an update and found two of these entries in my
state.json:(The other was for
21.226.1101.0001, but otherwise idendical)Both of them opened like

Which is quite curious. Presumably these are defterm windows that got captured by the Terminal, but also the Terminal must have been closed at just the right time that these were open.
Change the `ControlCore` layer to own a copy of its settings (#11619)
Persist Runtime TabTitle and Maximize/Focus/Fullscreen states (#12073)
Add restore recently closed panes (#11471)
Rosefield commentedon Feb 6, 2022
What should still be done in order to enable persisted layouts for stable builds? I'm not sure if there is any telemetry for how often the feature is enabled / crashes related to it. My n=1 data says that it has been working quite well :).
zadjii-msft commentedon Feb 7, 2022
That's a great question. I'm personally happy with it, I kinda forgot it was preview only. IMO we should have this in 1.12 Stable, but I'll discuss with the team.
zadjii-msft commentedon Feb 7, 2022
Okay, team consensus. We're gonna move this to stable in 1.14. Just give it a little more time to bake. Overall, we're really happy with it, you did a great job☺️
Remove the need for TerminalPage to know the number of open windows