Two windows are opened when using "--startingDirectory" option while no other wt instances are opened #22909

Open
opened 2026-01-31 08:26:52 +00:00 by claunia · 13 comments
Owner

Originally created by @Video-Nomad on GitHub (Feb 12, 2025).

Windows Terminal version

1.23.10353.0

Windows build number

10.0.26100.0

Other Software

cmd
(and any software that can execute "wt -d ..." command)

Steps to reproduce

  1. Have NO Windows Terminal instances opened
  2. open cmd
  3. type: wt -d "C:\" or any other location

Expected Behavior

If no Windows Terminal instances exist Windows Terminal opens a single window with the working directory specified in "-d" option.

Actual Behavior

If no Windows Terminal instances exist Windows Terminal opens two windows, one is the default working directory (%USERPROFILE% in my case) and one with actual "-d" specified directory.

https://github.com/user-attachments/assets/36bbb8ad-d6ce-4890-a320-f2e6bde73b35

Originally created by @Video-Nomad on GitHub (Feb 12, 2025). ### Windows Terminal version 1.23.10353.0 ### Windows build number 10.0.26100.0 ### Other Software cmd (and any software that can execute "wt -d ..." command) ### Steps to reproduce 1. Have NO Windows Terminal instances opened 2. open cmd 3. type: wt -d "C:\\" or any other location ### Expected Behavior If no Windows Terminal instances exist Windows Terminal opens a single window with the working directory specified in "-d" option. ### Actual Behavior If no Windows Terminal instances exist Windows Terminal opens two windows, one is the default working directory (%USERPROFILE% in my case) and one with actual "-d" specified directory. https://github.com/user-attachments/assets/36bbb8ad-d6ce-4890-a320-f2e6bde73b35
claunia added the Needs-TriageIssue-BugNeeds-Attention labels 2026-01-31 08:26:52 +00:00
Author
Owner

@carlos-zamora commented on GitHub (Feb 12, 2025):

Thanks for filing! Can you share your settings.json and state.json files with us /? We're suspicious that the global "firstWindowPreference" setting may be the cause of bringing back that second window.

@carlos-zamora commented on GitHub (Feb 12, 2025): Thanks for filing! Can you share your settings.json and state.json files with us /? We're suspicious that the global "firstWindowPreference" setting may be the cause of bringing back that second window.
Author
Owner

@Video-Nomad commented on GitHub (Feb 12, 2025):

Of course, here's the files.

state.json
settings.json

@Video-Nomad commented on GitHub (Feb 12, 2025): Of course, here's the files. [state.json](https://github.com/user-attachments/files/18774812/state.json) [settings.json](https://github.com/user-attachments/files/18774811/settings.json)
Author
Owner

@Video-Nomad commented on GitHub (Feb 12, 2025):

I'm a bit confused. I've searched for similar issues and found this one https://github.com/microsoft/terminal/issues/13272

I've tried changing:
"firstWindowPreference": "defaultProfile"
to
"firstWindowPreference": "persistedWindowLayout"
saved and then went back to the original "defaultProfile" and now it's fixed (???)

I haven't touched this option on all the previous versions at all and -d was behaving as it should wit the exact same config.

I guess it's fixed now?

@Video-Nomad commented on GitHub (Feb 12, 2025): I'm a bit confused. I've searched for similar issues and found this one https://github.com/microsoft/terminal/issues/13272 I've tried changing: "firstWindowPreference": "defaultProfile" to "firstWindowPreference": "persistedWindowLayout" saved and then **went back to the original "defaultProfile"** and now it's fixed (???) I haven't touched this option on all the previous versions at all and -d was behaving as it should wit the exact same config. I guess it's fixed now?
Author
Owner

@Video-Nomad commented on GitHub (Feb 13, 2025):

Fixed by... toggling one option on and off 🤷‍♂

@Video-Nomad commented on GitHub (Feb 13, 2025): Fixed by... toggling one option on and off 🤷‍♂
Author
Owner

@carlos-zamora commented on GitHub (Feb 19, 2025):

Interesting! I wonder if the state.json got in a weird state, then it got fixed after toggling the setting. Now that you're not experiencing the bug, mind checking if the new state.json looks the same as the old one /? Happy to take a look myself if you share it too 😊

@carlos-zamora commented on GitHub (Feb 19, 2025): Interesting! I wonder if the state.json got in a weird state, then it got fixed after toggling the setting. Now that you're not experiencing the bug, mind checking if the new state.json looks the same as the old one /? Happy to take a look myself if you share it too 😊
Author
Owner

@Video-Nomad commented on GitHub (Feb 19, 2025):

Yes, the persistedWindowLayouts list is now empty. That's really strange, because as I said, I changed nothing between updates and it was on "defaultProfile" for as long as I remember.

Here's the new state.json: state.json
And settings.json for reference: settings.json

I actually removed the firstWindowPreference option altogether from the settings.json, just in case 😅

Thank you for pointing to the right setting!

@Video-Nomad commented on GitHub (Feb 19, 2025): Yes, the persistedWindowLayouts list is now empty. That's really strange, because as I said, I changed nothing between updates and it was on "defaultProfile" for as long as I remember. Here's the new state.json: [state.json](https://github.com/user-attachments/files/18873905/state.json) And settings.json for reference: [settings.json](https://github.com/user-attachments/files/18873915/settings.json) I actually removed the firstWindowPreference option altogether from the settings.json, just in case 😅 Thank you for pointing to the right setting!
Author
Owner

@Video-Nomad commented on GitHub (Mar 1, 2025):

The issue seems to re-appear randomly again. Checked the state.json and it had persistedWindowLayouts filled again even though I did not change anything. Same issue as described above. Even though I removed firstWindowPreference option completely.

@Video-Nomad commented on GitHub (Mar 1, 2025): The issue seems to re-appear randomly again. Checked the state.json and it had persistedWindowLayouts filled again even though I did not change anything. Same issue as described above. Even though I removed firstWindowPreference option completely.
Author
Owner

@kristof-mattei commented on GitHub (Mar 4, 2025):

I had to remove "persistedWindowLayouts" : in state.json.

Flipping "firstWindowPreference": "defaultProfile" to "firstWindowPreference": "persistedWindowLayout" and back, whether via the UI or settings.json (and restarting in between) didn't 'disable' the bug.

@kristof-mattei commented on GitHub (Mar 4, 2025): I had to remove ` "persistedWindowLayouts" :` in `state.json`. Flipping `"firstWindowPreference": "defaultProfile"` to `"firstWindowPreference": "persistedWindowLayout"` and back, whether via the UI or `settings.json` (and restarting in between) didn't 'disable' the bug.
Author
Owner

@Video-Nomad commented on GitHub (Mar 5, 2025):

I had to remove "persistedWindowLayouts" : in state.json.

Flipping "firstWindowPreference": "defaultProfile" to "firstWindowPreference": "persistedWindowLayout" and back, whether via the UI or settings.json (and restarting in between) didn't 'disable' the bug.

Well I removed everything once again. The "firstWindowPreference" option from settings.json and "persistedWindowLayouts" from state.json
Never touched these options before and never had this issue before. Hence, the bug report. Let's see if they just appear one day again.

@Video-Nomad commented on GitHub (Mar 5, 2025): > I had to remove ` "persistedWindowLayouts" :` in `state.json`. > > Flipping `"firstWindowPreference": "defaultProfile"` to `"firstWindowPreference": "persistedWindowLayout"` and back, whether via the UI or `settings.json` (and restarting in between) didn't 'disable' the bug. Well I removed everything once again. The "firstWindowPreference" option from settings.json and "persistedWindowLayouts" from state.json Never touched these options before and never had this issue before. Hence, the bug report. Let's see if they just appear one day again.
Author
Owner

@Video-Nomad commented on GitHub (Mar 6, 2025):

Rebooted the PC today while the terminal was opened and the state.json have persistedWindowLayouts once again and the same issue appeared again. Two terminals are opening now just like before.

If that's intended behavior, I would love to know how to disable this.

@Video-Nomad commented on GitHub (Mar 6, 2025): Rebooted the PC today while the terminal was opened and the state.json have persistedWindowLayouts once again and the same issue appeared again. Two terminals are opening now just like before. If that's intended behavior, I would love to know how to disable this.
Author
Owner

@PankajBhojwani commented on GitHub (Mar 12, 2025):

@Video-Nomad thank you for updating us! We are fairly certain we fixed this in #18623 and #18622, can you try this in Windows Terminal Canary and see if you can repro this /?

@PankajBhojwani commented on GitHub (Mar 12, 2025): @Video-Nomad thank you for updating us! We are fairly certain we fixed this in #18623 and #18622, can you try this in Windows Terminal Canary and see if you can repro this /?
Author
Owner

@Video-Nomad commented on GitHub (Mar 12, 2025):

Thank you @PankajBhojwani for the update. Will try to repro this. Just switched to Canary as main terminal for now.

@Video-Nomad commented on GitHub (Mar 12, 2025): Thank you @PankajBhojwani for the update. Will try to repro this. Just switched to Canary as main terminal for now.
Author
Owner

@Video-Nomad commented on GitHub (Mar 13, 2025):

@PankajBhojwani and @carlos-zamora

Unfortunately #18623 and #18622 had no effect on this issue in the latest Canary update.
Tested on Windows Terminal Canary Version: 1.24.711.0

Found out a reliable way to repro this issue:

  1. I open three separate terminal windows
  2. cd into some different directories (not sure if that's relevant, but still)
  3. I do not close the terminals and reboot my pc (or shutdown).
  4. When the windows is loaded again, the state file has persistedWindowLayouts array filled and there are buffer files in the canary LocalState folder.
  5. When I open a new terminal window now - three windows are opened.

Closing the three terminal windows and trying to open just one will spawn three empty terminals consistently now.

"firstWindowPreference": "defaultProfile" has no effect whatsoever. Tested with this option, and with it removed completely from the settings.json. Same effect.

Image

Here's my settings, state and buffer files:
buffer_38d4e5a3-87a4-4176-9d88-84461911a343.txt
buffer_474e05c4-4c85-43d3-a73b-2c97344d2c4e.txt
buffer_7982ccf7-81e0-4b9d-82ac-e1cb401fd180.txt
settings.json
state.json

@Video-Nomad commented on GitHub (Mar 13, 2025): @PankajBhojwani and @carlos-zamora Unfortunately #18623 and #18622 had no effect on this issue in the latest Canary update. Tested on Windows Terminal Canary Version: 1.24.711.0 Found out a reliable way to repro this issue: 1. I open three separate terminal windows 2. cd into some different directories (not sure if that's relevant, but still) 3. I **do not** close the terminals and reboot my pc (or shutdown). 4. When the windows is loaded again, the state file has persistedWindowLayouts array filled and there are buffer files in the canary LocalState folder. 5. When I open a new terminal window now - three windows are opened. Closing the three terminal windows and trying to open just one will spawn three empty terminals consistently now. `"firstWindowPreference": "defaultProfile"` has no effect whatsoever. Tested with this option, and with it removed completely from the settings.json. Same effect. ![Image](https://github.com/user-attachments/assets/fc52ef8b-885c-492a-b901-5ec472d2b6ae) Here's my settings, state and buffer files: [buffer_38d4e5a3-87a4-4176-9d88-84461911a343.txt](https://github.com/user-attachments/files/19225372/buffer_38d4e5a3-87a4-4176-9d88-84461911a343.txt) [buffer_474e05c4-4c85-43d3-a73b-2c97344d2c4e.txt](https://github.com/user-attachments/files/19225371/buffer_474e05c4-4c85-43d3-a73b-2c97344d2c4e.txt) [buffer_7982ccf7-81e0-4b9d-82ac-e1cb401fd180.txt](https://github.com/user-attachments/files/19225373/buffer_7982ccf7-81e0-4b9d-82ac-e1cb401fd180.txt) [settings.json](https://github.com/user-attachments/files/19225374/settings.json) [state.json](https://github.com/user-attachments/files/19225491/state.json)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22909