Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
inertquartet opened this issue Feb 6, 2025 · 6 comments · May be fixed by #18623
Open
Assignees
Labels
Area-Windowing Window frame, quake mode, tearout In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal.

Comments

@inertquartet
Copy link

inertquartet commented Feb 6, 2025

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.

@inertquartet inertquartet added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Feb 6, 2025
@inertquartet
Copy link
Author

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}"
}

@lhecker
Copy link
Member

lhecker commented 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 lhecker self-assigned this Feb 6, 2025
@DHowett
Copy link
Member

DHowett commented Feb 6, 2025

(FWIW: we'll fix this!)

@inertquartet
Copy link
Author

@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. :)

@gerhard4
Copy link

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.

@itszn
Copy link

itszn commented 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.

@lhecker lhecker linked a pull request Feb 24, 2025 that will close this issue
@lhecker lhecker added Product-Terminal The new Windows Terminal. In-PR This issue has a related PR Area-Windowing Window frame, quake mode, tearout labels Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Windowing Window frame, quake mode, tearout In-PR This issue has a related PR Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants