[PR #11083] [MERGED] Persist window layout cont. save multiple windows #28408

Open
opened 2026-01-31 09:28:20 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11083
Author: @Rosefield
Created: 8/30/2021
Status: ✅ Merged
Merged: 9/27/2021
Merged by: @undefined

Base: main ← Head: feature/gh766-cont-save-multiple-windows


📝 Commits (10+)

  • 5fa7842 Add multi window layout saving
  • 99060c8 Try to be a bit safer with saving the layouts now that there are multiple windows contending with the same state file.
  • 4f67b08 move read into lock incase there is lock contention
  • eece18f Move more close window saving logic up to applogic, fix unit test build
  • 6779a79 Also save window name and runtime set tab color. Using the renamewindow action instead of storing a separate name property because that proved more difficult to insert into the lifecycle correctly when the window/peasant was created than afterwards.
  • 91e4388 Disable feature if in an elevated window (until separate elevated-state is added)
  • 5aa455d Fix usage of function that was removed in origin, but missed in merge
  • 58aa48d Merge remote-tracking branch 'origin/main' into feature/gh766-cont-save-multiple-windows
  • 1afacfa Save window layout on quit.
  • 824be53 Add new files because I forgot commit -a doesnt include them

📊 Changes

40 files changed (+788 additions, -133 deletions)

View changed files

📝 .github/actions/spelling/allow/microsoft.txt (+1 -0)
➕ src/cascadia/Remoting/GetWindowLayoutArgs.cpp (+5 -0)
➕ src/cascadia/Remoting/GetWindowLayoutArgs.h (+32 -0)
📝 src/cascadia/Remoting/Microsoft.Terminal.RemotingLib.vcxproj (+13 -3)
📝 src/cascadia/Remoting/Monarch.cpp (+34 -3)
📝 src/cascadia/Remoting/Monarch.h (+8 -3)
📝 src/cascadia/Remoting/Monarch.idl (+8 -1)
📝 src/cascadia/Remoting/Peasant.cpp (+21 -0)
📝 src/cascadia/Remoting/Peasant.h (+4 -0)
📝 src/cascadia/Remoting/Peasant.idl (+7 -0)
➕ src/cascadia/Remoting/QuitAllRequestedArgs.cpp (+5 -0)
➕ src/cascadia/Remoting/QuitAllRequestedArgs.h (+30 -0)
📝 src/cascadia/Remoting/WindowManager.cpp (+16 -1)
📝 src/cascadia/Remoting/WindowManager.h (+3 -1)
📝 src/cascadia/Remoting/WindowManager.idl (+4 -1)
📝 src/cascadia/TerminalApp/AppActionHandlers.cpp (+1 -1)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.cpp (+11 -0)
📝 src/cascadia/TerminalApp/AppCommandlineArgs.h (+2 -0)
📝 src/cascadia/TerminalApp/AppLogic.cpp (+76 -11)
📝 src/cascadia/TerminalApp/AppLogic.h (+10 -1)

...and 20 more files

📄 Description

Summary of the Pull Request

Continuation of https://github.com/microsoft/terminal/pull/10972 to handle multiple windows, requires that to be merged first.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

Rough changelog:
Normally saving is triggered to occur every 30s, or sooner if a window is created/closed. The existing behavior of saving on last close is maintained to bypass that throttling. The automatic saving allows for crash recovery. Additionally all window layouts will be saved upon taking the quit action.

For loading we will check if we are the first window, that there are any saved layouts, and if the setting is enabled, and then depending on if we were given command line args or startup actions.

  • create a new window for each saved layout, or
  • take the first layout for our self and then a new window for each other layout.

This also saves the layout when the quit action is taken.

Misc changes

  • A -s,--saved argument was added to the command line to facilitate opening all of the windows with the right settings. This also means that while a terminal session is running you can do wt -s idx to open a copy of window idx. There isn't a stable ordering of which idx each window gets saved as (it is whatever the iteration order of _peasants is), so it is just a cute hack for now.
  • All position calculation has been moved up to AppHost this does mean we need to awkwardly pass around positions in a couple of unexpected places, but no solution was perfect.
  • Renamed "Open tabs from a previous session" to "Open windows from a previous session". (not reflected in video below)
  • Now save runtime tab color and window names
  • Only enabled for non-elevated windows
  • Add some change tracking to ApplicationState

Validation Steps Performed

output


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/11083 **Author:** [@Rosefield](https://github.com/Rosefield) **Created:** 8/30/2021 **Status:** ✅ Merged **Merged:** 9/27/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `feature/gh766-cont-save-multiple-windows` --- ### 📝 Commits (10+) - [`5fa7842`](https://github.com/microsoft/terminal/commit/5fa78421be3ef9b0c50e8c144bd50195e1faefe8) Add multi window layout saving - [`99060c8`](https://github.com/microsoft/terminal/commit/99060c8576579430b719094f2203fccce3dea9c6) Try to be a bit safer with saving the layouts now that there are multiple windows contending with the same state file. - [`4f67b08`](https://github.com/microsoft/terminal/commit/4f67b0881582eac41fe3bc6c60151c5fe28122c8) move read into lock incase there is lock contention - [`eece18f`](https://github.com/microsoft/terminal/commit/eece18f2bcb705c912dcfb733b3106537d5047ed) Move more close window saving logic up to applogic, fix unit test build - [`6779a79`](https://github.com/microsoft/terminal/commit/6779a7954ea63d103d049fd283eac69efe570359) Also save window name and runtime set tab color. Using the renamewindow action instead of storing a separate `name` property because that proved more difficult to insert into the lifecycle correctly when the window/peasant was created than afterwards. - [`91e4388`](https://github.com/microsoft/terminal/commit/91e4388438cebf3dee6ca8e6bb6a894372102836) Disable feature if in an elevated window (until separate elevated-state is added) - [`5aa455d`](https://github.com/microsoft/terminal/commit/5aa455d23e26d143d1097a9f194e468b609bc73d) Fix usage of function that was removed in origin, but missed in merge - [`58aa48d`](https://github.com/microsoft/terminal/commit/58aa48d0c8e7e24c2e6ad265028db11168ede023) Merge remote-tracking branch 'origin/main' into feature/gh766-cont-save-multiple-windows - [`1afacfa`](https://github.com/microsoft/terminal/commit/1afacfa75622b41ab7dfbe3a0c312d1fd0dd5c17) Save window layout on quit. - [`824be53`](https://github.com/microsoft/terminal/commit/824be53dd501cf46951a394b551d6dc51cd6cfa3) Add new files because I forgot commit -a doesnt include them ### 📊 Changes **40 files changed** (+788 additions, -133 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/allow/microsoft.txt` (+1 -0) ➕ `src/cascadia/Remoting/GetWindowLayoutArgs.cpp` (+5 -0) ➕ `src/cascadia/Remoting/GetWindowLayoutArgs.h` (+32 -0) 📝 `src/cascadia/Remoting/Microsoft.Terminal.RemotingLib.vcxproj` (+13 -3) 📝 `src/cascadia/Remoting/Monarch.cpp` (+34 -3) 📝 `src/cascadia/Remoting/Monarch.h` (+8 -3) 📝 `src/cascadia/Remoting/Monarch.idl` (+8 -1) 📝 `src/cascadia/Remoting/Peasant.cpp` (+21 -0) 📝 `src/cascadia/Remoting/Peasant.h` (+4 -0) 📝 `src/cascadia/Remoting/Peasant.idl` (+7 -0) ➕ `src/cascadia/Remoting/QuitAllRequestedArgs.cpp` (+5 -0) ➕ `src/cascadia/Remoting/QuitAllRequestedArgs.h` (+30 -0) 📝 `src/cascadia/Remoting/WindowManager.cpp` (+16 -1) 📝 `src/cascadia/Remoting/WindowManager.h` (+3 -1) 📝 `src/cascadia/Remoting/WindowManager.idl` (+4 -1) 📝 `src/cascadia/TerminalApp/AppActionHandlers.cpp` (+1 -1) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.cpp` (+11 -0) 📝 `src/cascadia/TerminalApp/AppCommandlineArgs.h` (+2 -0) 📝 `src/cascadia/TerminalApp/AppLogic.cpp` (+76 -11) 📝 `src/cascadia/TerminalApp/AppLogic.h` (+10 -1) _...and 20 more files_ </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Continuation of https://github.com/microsoft/terminal/pull/10972 to handle multiple windows, requires that to be merged first. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Also closes #766 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [x] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments Rough changelog: Normally saving is triggered to occur every 30s, or sooner if a window is created/closed. The existing behavior of saving on last close is maintained to bypass that throttling. The automatic saving allows for crash recovery. Additionally all window layouts will be saved upon taking the `quit` action. For loading we will check if we are the first window, that there are any saved layouts, and if the setting is enabled, and then depending on if we were given command line args or startup actions. - create a new window for each saved layout, or - take the first layout for our self and then a new window for each other layout. This also saves the layout when the quit action is taken. Misc changes - A -s,--saved argument was added to the command line to facilitate opening all of the windows with the right settings. This also means that while a terminal session is running you can do wt -s idx to open a copy of window idx. There isn't a stable ordering of which idx each window gets saved as (it is whatever the iteration order of _peasants is), so it is just a cute hack for now. - All position calculation has been moved up to AppHost this does mean we need to awkwardly pass around positions in a couple of unexpected places, but no solution was perfect. - Renamed "Open tabs from a previous session" to "Open windows from a previous session". (not reflected in video below) - Now save runtime tab color and window names - Only enabled for non-elevated windows - Add some change tracking to ApplicationState <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed ![output](https://user-images.githubusercontent.com/6185249/131163473-d649d204-a589-41ad-b9d9-c4c0528cb684.gif) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:28:20 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28408