Removed dynamic profiles permanently filtered out if another dynamic profile is added #18530

Closed
opened 2026-01-31 06:16:50 +00:00 by claunia · 3 comments
Owner

Originally created by @jonthysell on GitHub (Sep 22, 2022).

Windows Terminal version

0.0.1.0

Windows build number

10.0.25206.1000

Other Software

No response

Steps to reproduce

  1. Install WSL with only one distro A (Ubuntu)
  2. Launch Terminal for the first time, see that Ubuntu profile was added
    • See in Debugger that all generated profiles are added to the ApplicationState
  3. Close Terminal
  4. Install WSL distro B (Ubuntu 20.04.5 LTS)
  5. Launch Terminal, see that Ubuntu 20.04.5 LTS profile was added
    • See in Debugger that a new profile for distro B was added to the ApplicationState
  6. Close Terminal
  7. Uninstall WSL distro B (Ubuntu 20.04.05 LTS)
  8. Install WSL distro C (Ubuntu 22.04.1 LTS)
  9. Launch Terminal, see that distro B is gone and distro C is added (Ubuntu 20.04.05 LTS gone, Ubuntu 22.04.1 LTS added)
    • See in Debugger that a new profile for distro C is added to ApplicationState
  10. Re-install WSL distro B (Ubuntu 20.04.05 LTS)
  11. Launch Terminal

Expected Behavior

I would expect that the re-installed distro B (Ubuntu 20.04.05 LTS) reappears.

Actual Behavior

The re-installed distro B does not appear. In the debugger, we can see that although a profile for distro B is actually generated, it gets set to deleted by SettingsLoader::DisableDeletedProfiles().

The code is meant to catch when a user purposefully deletes a profile from their config. Note that at no point did I enter Settings, touch or even view my config file during this repo.

I believe this has to due with the assertion in code that the number of generated profiles only ever increases, so the count of profiles is used when determining if new generated profiles are present. However, by removing a profile (B), generating a new one (C, with a different guid), now the assertion is broken, and profile B will be filtered out forever.

Note that this doesn't repo if you simply add and remove the same profile over and over. That works fine. It only happens when you remove a profile and add a different one.

Workaround: This is can be resolved by uninstalling and re-installing Terminal, which resets the ApplicationState, but of course then you have to reconfigure everything.

Originally created by @jonthysell on GitHub (Sep 22, 2022). ### Windows Terminal version 0.0.1.0 ### Windows build number 10.0.25206.1000 ### Other Software _No response_ ### Steps to reproduce 1. Install WSL with only one distro A (Ubuntu) 2. Launch Terminal for the first time, see that Ubuntu profile was added - See in Debugger that all generated profiles are added to the ApplicationState 3. Close Terminal 4. Install WSL distro B (Ubuntu 20.04.5 LTS) 5. Launch Terminal, see that Ubuntu 20.04.5 LTS profile was added - See in Debugger that a new profile for distro B was added to the ApplicationState 6. Close Terminal 7. Uninstall WSL distro B (Ubuntu 20.04.05 LTS) 8. Install WSL distro C (Ubuntu 22.04.1 LTS) 9. Launch Terminal, see that distro B is gone and distro C is added (Ubuntu 20.04.05 LTS gone, Ubuntu 22.04.1 LTS added) - See in Debugger that a new profile for distro C is added to ApplicationState 10. Re-install WSL distro B (Ubuntu 20.04.05 LTS) 11. Launch Terminal ### Expected Behavior I would expect that the re-installed distro B (Ubuntu 20.04.05 LTS) reappears. ### Actual Behavior The re-installed distro B does not appear. In the debugger, we can see that although a profile for distro B is actually generated, it gets set to deleted by `SettingsLoader::DisableDeletedProfiles()`. The code is meant to catch when a user purposefully deletes a profile from their config. Note that at no point did I enter Settings, touch or even view my config file during this repo. I believe this has to due with the assertion in code that the number of generated profiles only ever increases, so the count of profiles is used when determining if new generated profiles are present. However, by removing a profile (B), generating a new one (C, with a different guid), now the assertion is broken, and profile B will be filtered out forever. Note that this doesn't repo if you simply add and remove the same profile over and over. That works fine. It only happens when you remove a profile and add a different one. Workaround: This is can be resolved by uninstalling and re-installing Terminal, which resets the ApplicationState, but of course then you have to reconfigure everything.
claunia added the Area-SettingsIssue-BugIn-PRNeeds-Tag-FixProduct-Terminal labels 2026-01-31 06:16:50 +00:00
Author
Owner

@jonthysell commented on GitHub (Sep 22, 2022):

FYI I found this issue while implementing #14042, which makes it far easier to repro, since adding/removing/replacing SSH Host entries in the OpenSSH config file is much faster than (un/re)-installing WSL distros, but produces the same behavior of filtering out "old" profiles and never letting them come back.

@jonthysell commented on GitHub (Sep 22, 2022): FYI I found this issue while implementing #14042, which makes it far easier to repro, since adding/removing/replacing SSH Host entries in the OpenSSH config file is much faster than (un/re)-installing WSL distros, but produces the same behavior of filtering out "old" profiles and never letting them come back.
Author
Owner

@zadjii-msft commented on GitHub (Sep 23, 2022):

This is a great test case. If a dynamic profile is in the state.json, but we didn't generate it, maybe we should just remove it from state.json. I believe there was another thread about this recently (and I think @DHowett remembers which)

@zadjii-msft commented on GitHub (Sep 23, 2022): This is a great test case. If a dynamic profile is in the `state.json`, but we didn't generate it, maybe we should just remove it from `state.json`. I believe there was another thread about this recently (and I think @DHowett remembers which)
Author
Owner

@cnshenj commented on GitHub (Sep 27, 2022):

A similar issue (maybe the same):

It would be helpful if there is a "Detect shells" command in the command palette.

@cnshenj commented on GitHub (Sep 27, 2022): A similar issue (maybe the same): - Install PowerShell from Windows Store - Launch Windows Terminal and see the PowerShell profile - Uninstall PowerShell - Launch Windows Terminal and see the PowerShell profile is gone - Install PowerShell using https://github.com/PowerShell/PowerShell/releases/download/v7.2.6/PowerShell-7.2.6-win-x64.msi - Launch Windows Terminal and the PowerShell profile is missing It would be helpful if there is a "Detect shells" command in the command palette.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18530