"Open windows from a previous session" not working due to session not being saved at exit #22863

Closed
opened 2026-01-31 08:25:34 +00:00 by claunia · 8 comments
Owner

Originally created by @inertquartet on GitHub (Feb 6, 2025).

Originally assigned to: @lhecker on GitHub.

Windows Terminal version

1.23.10353.0 (Preview) / 1.24.352.0 (Canary

Windows build number

Other Software

No response

Steps to reproduce

  1. Install Windows Terminal Preview or Windows Terminal Canary
  2. Launch Windows Terminal Preview/Canary
  3. Launch Settings and set Startup > When Terminal starts to Open windows from a previous session
  4. Open up one or more additional tabs/windows
  5. (Optional) Do things in any of the open tabs/windows
  6. Close Windows Terminal Preview/Canary using the Close (X) window button or "Close all windows" from the command palette
  7. Relaunch Windows Terminal Preview/Canary

Expected Behavior

Previously opened tabs/windows are restored, including previous session history for each

Actual Behavior

Windows Terminal opens a single window with a single tab and launches a new instance of my default profile without any session history from the previous instance.

Originally created by @inertquartet on GitHub (Feb 6, 2025). Originally assigned to: @lhecker on GitHub. ### Windows Terminal version 1.23.10353.0 (Preview) / 1.24.352.0 (Canary ### Windows build number [Environment]::OSVersion ### Other Software _No response_ ### Steps to reproduce 1. Install Windows Terminal Preview or Windows Terminal Canary 2. Launch Windows Terminal Preview/Canary 3. Launch Settings and set **Startup** > **When Terminal starts** to _Open windows from a previous session_ 4. Open up one or more additional tabs/windows 5. (Optional) Do things in any of the open tabs/windows 6. Close Windows Terminal Preview/Canary using the Close (X) window button or "Close all windows" from the command palette 7. Relaunch Windows Terminal Preview/Canary ### Expected Behavior Previously opened tabs/windows are restored, including previous session history for each ### Actual Behavior Windows Terminal opens a single window with a single tab and launches a new instance of my default profile without any session history from the previous instance.
claunia added the Needs-TriageIssue-BugIn-PRProduct-TerminalArea-Windowing labels 2026-01-31 08:25:34 +00:00
Author
Owner

@inertquartet commented on GitHub (Feb 6, 2025):

Comparing the behavior to how the release version of Windows Terminal works, it looks like something is preventing persistedWindowLayouts in state.json from being populated.

When I close Windows Terminal with multiple tabs open, state.json looks like this:

{
	"dismissedMessages" : 
	[
		"closeOnExitInfo"
	],
	"generatedProfiles" : 
	[
		"{574e775e-4f2a-5b96-ac1e-a2962a402336}",
		"{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
		"{d8e96812-b789-5068-a5ae-10b2fb53e95f}",
		"{963ff2f7-6aed-5ce3-9d91-90d99571f53a}",
		"{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
		"{bc2da056-dd06-5879-b969-1dfcefc8d2c7}",
		"{47302f9c-1ac4-566c-aa3e-8cf29889d6ab}",
		"{b453ae62-4e3d-5e58-b989-0a998ec441b8}"
	],
	"persistedWindowLayouts" : 
	[
		{
			"initialPosition" : "104,104",
			"initialSize" : 
			{
				"height" : 852,
				"width" : 1517
			},
			"launchMode" : "default",
			"tabLayout" : 
			[
				{
					"action" : "newTab",
					"commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
					"profile" : "PowerShell",
					"sessionId" : "{redacted}",
					"startingDirectory" : "C:\\Users\\Username",
					"suppressApplicationTitle" : false,
					"tabTitle" : "PowerShell"
				},
				{
					"action" : "newTab",
					"commandline" : "ubuntu2404.exe",
					"profile" : "Ubuntu 24.04.1 LTS",
					"sessionId" : "{redacted}",
					"startingDirectory" : null,
					"suppressApplicationTitle" : false,
					"tabTitle" : "Ubuntu 24.04.1 LTS"
				},
				{
					"action" : "switchToTab",
					"index" : 0
				}
			]
		}
	],
	"settingsHash" : "{redacted}"
}

When I do the same with either Preview or Canary, the saved state.json looks like this:

{
	"persistedWindowLayouts" : [],
	"settingsHash" : "{redacted}"
}
@inertquartet commented on GitHub (Feb 6, 2025): Comparing the behavior to how the release version of Windows Terminal works, it looks like something is preventing **persistedWindowLayouts** in _state.json_ from being populated. When I close Windows Terminal with multiple tabs open, _state.json_ looks like this: ```json { "dismissedMessages" : [ "closeOnExitInfo" ], "generatedProfiles" : [ "{574e775e-4f2a-5b96-ac1e-a2962a402336}", "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}", "{d8e96812-b789-5068-a5ae-10b2fb53e95f}", "{963ff2f7-6aed-5ce3-9d91-90d99571f53a}", "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}", "{bc2da056-dd06-5879-b969-1dfcefc8d2c7}", "{47302f9c-1ac4-566c-aa3e-8cf29889d6ab}", "{b453ae62-4e3d-5e58-b989-0a998ec441b8}" ], "persistedWindowLayouts" : [ { "initialPosition" : "104,104", "initialSize" : { "height" : 852, "width" : 1517 }, "launchMode" : "default", "tabLayout" : [ { "action" : "newTab", "commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"", "profile" : "PowerShell", "sessionId" : "{redacted}", "startingDirectory" : "C:\\Users\\Username", "suppressApplicationTitle" : false, "tabTitle" : "PowerShell" }, { "action" : "newTab", "commandline" : "ubuntu2404.exe", "profile" : "Ubuntu 24.04.1 LTS", "sessionId" : "{redacted}", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "Ubuntu 24.04.1 LTS" }, { "action" : "switchToTab", "index" : 0 } ] } ], "settingsHash" : "{redacted}" } ``` When I do the same with either Preview or Canary, the saved _state.json_ looks like this: ``` json { "persistedWindowLayouts" : [], "settingsHash" : "{redacted}" } ```
Author
Owner

@lhecker commented on GitHub (Feb 6, 2025):

I implemented "Close all windows" as closing all windows. When persistence is enabled, it should turn into shutting down the application immediately after showing the dialog.

To work around this, you can open the command palette (Ctrl+Shift+P) and type "quit" ("Quit the terminal").

@lhecker commented on GitHub (Feb 6, 2025): I implemented "Close all windows" as closing all windows. When persistence is enabled, it should turn into shutting down the application immediately after showing the dialog. To work around this, you can open the command palette (Ctrl+Shift+P) and type "quit" ("Quit the terminal").
Author
Owner

@DHowett commented on GitHub (Feb 6, 2025):

(FWIW: we'll fix this!)

@DHowett commented on GitHub (Feb 6, 2025): (FWIW: we'll fix this!)
Author
Owner

@inertquartet commented on GitHub (Feb 6, 2025):

@lhecker Thanks for the quick response and workaround! I updated my description to clarify this only happens with the close button/"Close all windows" action, for anyone else who finds this.

@DHowett Thanks for the clarification! I assumed as much, otherwise it would've been closed as WONTFIX. :)

@inertquartet commented on GitHub (Feb 6, 2025): @lhecker Thanks for the quick response and workaround! I updated my description to clarify this only happens with the close button/"Close all windows" action, for anyone else who finds this. @DHowett Thanks for the clarification! I assumed as much, otherwise it would've been closed as WONTFIX. :)
Author
Owner

@gerhard4 commented on GitHub (Feb 14, 2025):

As a more comfortable workaround, I tried to add a keyboard shortcut to the action "Quit the Terminal". This didn't work; the terminal didn't quit. This may be related.

@gerhard4 commented on GitHub (Feb 14, 2025): As a more comfortable workaround, I tried to add a keyboard shortcut to the action "Quit the Terminal". This didn't work; the terminal didn't quit. This may be related.
Author
Owner

@itszn commented on GitHub (Feb 20, 2025):

I'm not sure if I have the same exact issue, but only some of my panes get saved. It seems ones created by duplicating (alt+shift+enter) are not saved.

@itszn commented on GitHub (Feb 20, 2025): I'm not sure if I have the same exact issue, but only some of my panes get saved. It seems ones created by duplicating (alt+shift+enter) are not saved.
Author
Owner

@foxtrottNB commented on GitHub (Feb 26, 2025):

Same issue for me.
The workaround fixes the behavior.

@foxtrottNB commented on GitHub (Feb 26, 2025): Same issue for me. The workaround fixes the behavior.
Author
Owner

@lupinsansei commented on GitHub (Nov 28, 2025):

I have this issue too, spent ages arranging and renaming all my tabs, Terminal lost all my nicely arranged tabs when Windows decided to update the system for patches :(

@lupinsansei commented on GitHub (Nov 28, 2025): I have this issue too, spent ages arranging and renaming all my tabs, Terminal lost all my nicely arranged tabs when Windows decided to update the system for patches :(
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22863