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

Sometimes, saving a setting in the UI doesn't actually apply #9962

Closed
2 tasks
zadjii-msft opened this issue Apr 26, 2021 · 8 comments · Fixed by #9964
Closed
2 tasks

Sometimes, saving a setting in the UI doesn't actually apply #9962

zadjii-msft opened this issue Apr 26, 2021 · 8 comments · Fixed by #9964
Assignees
Labels
Area-Settings UI Anything specific to the SUI Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@zadjii-msft
Copy link
Member

The minimal repro:

  • Install powershell core, at least one of them
  • Close the Terminal.
  • Delete all the settings.json files.
  • Open the Terminal, go to the SUI, go to the "Appearance" of the Powershell Core.
  • Change scrollbar state to hidden.
  • Hit Save.

At this point, the SUI will reload. The scrollbar state didn't apply, and now you've got a mysterious "Default" profile. Also, the setting.json is now corrupted. It's now got

{},
{
  "scrollbarState": "hidden"
}

slammed in the profiles list, which is garbage data.

  • Figure out why the setting is blasting off to space.
  • Add a mitigation to ignore profile snippets without a GUID

/cc @carlos-zamora.

Now, I'm gonna close all the threads we think are a dupe of this one.

@zadjii-msft zadjii-msft added Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Priority-1 A description (P1) Area-Settings UI Anything specific to the SUI labels Apr 26, 2021
@zadjii-msft zadjii-msft added this to the Terminal v1.9 milestone Apr 26, 2021
@ghost ghost added the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Apr 26, 2021
@zadjii-msft zadjii-msft pinned this issue Apr 26, 2021
@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Apr 26, 2021
@ghost ghost added the In-PR This issue has a related PR label Apr 27, 2021
@Krrishdhaneja
Copy link

hey @zadjii-msft when I deleted the whole setting.json and got a new one generated, then the default profile was removed and it didn't reappear.

@zadjii-msft
Copy link
Member Author

@Krrishdhaneja That sounds like a totally different issue. Mind filing a new issue? (make sure to include version numbers, which profile you were expecting to see generated, your settings.json, etc.)

@Krrishdhaneja
Copy link

Krrishdhaneja commented Apr 27, 2021

@Krrishdhaneja That sounds like a totally different issue. Mind filing a new issue? (make sure to include version numbers, which profile you were expecting to see generated, your settings.json, etc.)

I don't mind making it, but I am rather saying that it might be the solution to that default json profile maybe, by deleting the settings.json and then make changes in the regenerated one to get back older settings?

Can it be it's solution?

@ghost ghost closed this as completed in #9964 Apr 28, 2021
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Apr 28, 2021
ghost pushed a commit that referenced this issue Apr 28, 2021
#9962 was caused by a serialization bug. _Technically_, `ToJson` works
as intended: if the current layer has any values set, write them out to
the json. However, on first load, the dynamic profile `Profile` objects
are actually empty (because they inherit from base layer, then the
dynamic profile generator). This means that `ToJson` writes the dynamic
profiles as empty objects `{}`. Then, on reload, we see that the dynamic
profiles aren't in the JSON, and we write them again.

To get around this issue, we added a simple check to `Profile::ToJson`:
if we have a source, make sure we write out the name, guid, hidden, and
source. This is intended to align with `Profile::GenerateStub`.

Closes #9962
@htcfreek
Copy link

htcfreek commented May 3, 2021

@zadjii-msft
Does the pr fixes the bug that new profiles don't have a guid?

Every new profile I generate doesn't have a guid. So if you ignore these profiles you create a new problem. (How will this be fixed on updating to the new release?)

@Krrishdhaneja
Copy link

Hey, today I encountered the issue again, and I think what could be possible reason for that is maybe when the modifications are made using SUI, the changes aren't registered in the profile we wanted/made changes for, but rather the SUI creates a completely new profile with those properties.

@zadjii-msft
Copy link
Member Author

@Krrishdhaneja Yep, that's basically the root cause of what we fixed in #9964

The "ignore snippets without a guid" mitigation should only apply to snippets without a name or guid. When a profile doesn't have an explicit guid, we generate one for that profile based on the name. in the case of the {} profile, there's no name or guid, so we can be relatively sure that blob isn't actually a valid profile.

I also think we didn't end up doing that, so it's not a big deal.

DHowett pushed a commit that referenced this issue May 14, 2021
#9962 was caused by a serialization bug. _Technically_, `ToJson` works
as intended: if the current layer has any values set, write them out to
the json. However, on first load, the dynamic profile `Profile` objects
are actually empty (because they inherit from base layer, then the
dynamic profile generator). This means that `ToJson` writes the dynamic
profiles as empty objects `{}`. Then, on reload, we see that the dynamic
profiles aren't in the JSON, and we write them again.

To get around this issue, we added a simple check to `Profile::ToJson`:
if we have a source, make sure we write out the name, guid, hidden, and
source. This is intended to align with `Profile::GenerateStub`.

Closes #9962

(cherry picked from commit 8f93f76)
DHowett pushed a commit that referenced this issue May 14, 2021
#9962 was caused by a serialization bug. _Technically_, `ToJson` works
as intended: if the current layer has any values set, write them out to
the json. However, on first load, the dynamic profile `Profile` objects
are actually empty (because they inherit from base layer, then the
dynamic profile generator). This means that `ToJson` writes the dynamic
profiles as empty objects `{}`. Then, on reload, we see that the dynamic
profiles aren't in the JSON, and we write them again.

To get around this issue, we added a simple check to `Profile::ToJson`:
if we have a source, make sure we write out the name, guid, hidden, and
source. This is intended to align with `Profile::GenerateStub`.

Closes #9962

(cherry picked from commit 8f93f76)
DHowett added a commit that referenced this issue May 20, 2021
The bug that caused #9962 resulted in folks getting profiles written to
their settings that didn't contain any identifying information (name or
guid), sometimes multiple times.

These profiles look (somewhat) like this:

```json
{ "colorScheme": "Campbell" },
{},
```

An empty profile serves no purpose -- it shows up in the list as being
named "Default", and it only launches CMD (unless the commandline is the
thing that the user successfully changed.)

We can heal the settings file by simply ignoring those profiles that
have *no identifying information* (a guid or a name that can be
converted into a guid).

Validation
----------
I created a number of profiles that fit this format and made sure that
they were ignored on load and destroyed on save.
ghost pushed a commit that referenced this issue May 21, 2021
The bug that caused #9962 resulted in folks getting profiles written to
their settings that didn't contain any identifying information (name or
guid), sometimes multiple times.

These profiles look (somewhat) like this:

```json
{ "colorScheme": "Campbell" },
{},
```

An empty profile serves no purpose -- it shows up in the list as being
named "Default", and it only launches CMD (unless the commandline is the
thing that the user successfully changed.)

We can heal the settings file by simply ignoring those profiles that
have *no identifying information* (a guid or a name that can be
converted into a guid).

Validation
----------
I created a number of profiles that fit this format and made sure that
they were ignored on load and destroyed on save.

## PR Checklist
* [x] Closes an annoyance we discovered after 9962.
DHowett added a commit that referenced this issue May 24, 2021
The bug that caused #9962 resulted in folks getting profiles written to
their settings that didn't contain any identifying information (name or
guid), sometimes multiple times.

These profiles look (somewhat) like this:

```json
{ "colorScheme": "Campbell" },
{},
```

An empty profile serves no purpose -- it shows up in the list as being
named "Default", and it only launches CMD (unless the commandline is the
thing that the user successfully changed.)

We can heal the settings file by simply ignoring those profiles that
have *no identifying information* (a guid or a name that can be
converted into a guid).

Validation
----------
I created a number of profiles that fit this format and made sure that
they were ignored on load and destroyed on save.

## PR Checklist
* [x] Closes an annoyance we discovered after 9962.

(cherry picked from commit 84f6a29)
@DHowett DHowett unpinned this issue May 25, 2021
@ghost
Copy link

ghost commented May 25, 2021

🎉This issue was addressed in #9964, which has now been successfully released as Windows Terminal v1.8.1444.0.:tada:

Handy links:

@ghost
Copy link

ghost commented May 25, 2021

🎉This issue was addressed in #9964, which has now been successfully released as Windows Terminal Preview v1.9.1445.0.:tada:

Handy links:

ghost pushed a commit that referenced this issue Sep 27, 2021
`SettingsLoader::_parse` used to skip profiles which didn't have either a "guid"
or "name" field, due to #9962. This is however wrong for fragment loading, as
fragments can alternatively use an "updates" field instead of guid/name.

`SettingsLoader::_parse` was updated to allow profiles with this alternative
field during fragment loading.

## PR Checklist
* [x] Closes #11331
* [x] I work here
* [x] Tests added/passed

## Validation Steps Performed

* Wrote the following to
  `%LOCALAPPDATA%\Microsoft\Windows Terminal\Fragments\test\test.json`:
  ```json
  {
    "profiles": [
      {
        "updates": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
        "background": "#FFD700"
      }
    ]
  }
  ```
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings UI Anything specific to the SUI Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants