Open windows from a previous session does not restore the working directories of any tab #18736

Open
opened 2026-01-31 06:22:52 +00:00 by claunia · 0 comments
Owner

Originally created by @halim2209 on GitHub (Oct 21, 2022).

Windows Terminal version

1.15.2874.0

Windows build number

10.0.19042.0

Other Software

 pwsh > Get-Module

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   7.0.0.0               Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…}
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
Script     0.0                   oh-my-posh-core                     {Enable-PoshLineError, Enable-PoshTooltips, Enable-PoshTransientPrompt, Export-PoshTheme…}
Script     1.1.0                 posh-git                            {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranchName, Get-GitBranchStatusColor…}
Script     2.2.6                 PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…}
Script     0.10.0                Terminal-Icons                      {Add-TerminalIconsColorTheme, Add-TerminalIconsIconTheme, Format-TerminalIcons, Get-TerminalIconsColorThe…

Steps to reproduce

  1. Configure Windows Terminal to "open windows from a previous session"
  2. Open various tabs, switch to different working directories
  3. Close Windows Terminal

Expected Behavior

Windows Terminal to restore the previous session with all tabs having opened their last working directory.

Actual Behavior

Windows Terminal restores the tabs and panes as expected, but does not switch into the correct directories, instead remains in the default configured

Interestingly enough, all other attributes are saved correctly: Window position and size, names of the tabs, and panes including their sizes.

The states.json file only contains "null" as the startingDirectory:

{
	"persistedWindowLayouts" : 
	[
		{
			"initialPosition" : "-1468,116",
			"initialSize" : 
			{
				"height" : 586.0,
				"width" : 1113.0
			},
			"launchMode" : "default",
			"tabLayout" : 
			[
				{
					"action" : "newTab",
					"commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
					"profile" : "PowerShell",
					"startingDirectory" : null,
					"suppressApplicationTitle" : false,
					"tabTitle" : "PowerShell"
				},
				{
					"action" : "splitPane",
					"commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"",
					"profile" : "PowerShell",
					"size" : 0.24999994039535522,
					"split" : "down",
					"splitMode" : "manual",
					"startingDirectory" : null,
					"suppressApplicationTitle" : false,
					"tabTitle" : "PowerShell"
				},
				{
					"action" : "renameTab",
					"title" : "test-title"
				},
				{
					"action" : "focusPane",
					"id" : 1
				}
			]
		}
	]
}

The following are the contents of $PROFILE:


Import-Module posh-git
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\thecyberden.omp.json" | Invoke-Expression

Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
Set-PSReadLineOption -PredictionViewStyle ListView
Set-PSReadLineOption -EditMode Windows

Import-Module -Name Terminal-Icons
Originally created by @halim2209 on GitHub (Oct 21, 2022). ### Windows Terminal version 1.15.2874.0 ### Windows build number 10.0.19042.0 ### Other Software ``` pwsh > Get-Module ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty…} Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object…} Script 0.0 oh-my-posh-core {Enable-PoshLineError, Enable-PoshTooltips, Enable-PoshTransientPrompt, Export-PoshTheme…} Script 1.1.0 posh-git {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranchName, Get-GitBranchStatusColor…} Script 2.2.6 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler…} Script 0.10.0 Terminal-Icons {Add-TerminalIconsColorTheme, Add-TerminalIconsIconTheme, Format-TerminalIcons, Get-TerminalIconsColorThe… ``` ### Steps to reproduce 1. Configure Windows Terminal to "open windows from a previous session" 2. Open various tabs, switch to different working directories 3. Close Windows Terminal ### Expected Behavior Windows Terminal to restore the previous session with all tabs having opened their last working directory. ### Actual Behavior Windows Terminal restores the tabs and panes as expected, but does not switch into the correct directories, instead remains in the default configured Interestingly enough, all other attributes are saved correctly: Window position and size, names of the tabs, and panes including their sizes. The states.json file only contains "null" as the `startingDirectory`: ``` { "persistedWindowLayouts" : [ { "initialPosition" : "-1468,116", "initialSize" : { "height" : 586.0, "width" : 1113.0 }, "launchMode" : "default", "tabLayout" : [ { "action" : "newTab", "commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"", "profile" : "PowerShell", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "PowerShell" }, { "action" : "splitPane", "commandline" : "\"C:\\Program Files\\PowerShell\\7\\pwsh.exe\"", "profile" : "PowerShell", "size" : 0.24999994039535522, "split" : "down", "splitMode" : "manual", "startingDirectory" : null, "suppressApplicationTitle" : false, "tabTitle" : "PowerShell" }, { "action" : "renameTab", "title" : "test-title" }, { "action" : "focusPane", "id" : 1 } ] } ] } ``` The following are the contents of `$PROFILE`: ``` Import-Module posh-git oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\thecyberden.omp.json" | Invoke-Expression Import-Module PSReadLine Set-PSReadLineOption -PredictionSource History Set-PSReadLineOption -PredictionViewStyle ListView Set-PSReadLineOption -EditMode Windows Import-Module -Name Terminal-Icons ```
claunia added the Issue-QuestionNeeds-TriageResolution-AnsweredNeeds-Attention labels 2026-01-31 06:22:53 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18736