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

Fix layering of fragment profiles #11325

Merged
1 commit merged into from
Sep 24, 2021
Merged

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Sep 24, 2021

This commit fixes layering of fragment profiles without an update key.
The previous CascadiaSettings deserializer first assembled all builtin
profiles and only then parsed the user's settings.json file.
This meant that even though fragment profiles were added to _allProfiles
unconditionally, they did get layered properly with user profiles regardless,
as user profiles were always properly layered.

The new CascadiaSettings approach since 168d28b was a direct translation of this
approach but this is incorrect: As the new approach reads user profiles first,
all inbox profiles, including fragments, must equally use proper layering,
instead of adding profiles unconditionally.

While this commit fixes the bug it maintains a regression:
Duplicate fragment profile GUIDs will not be detected and instead fragments with
identical GUID will all be added as parents to a single user profile.
I considered to fix this regression, but felt that this new behavior is better
than the old one, since a user often can't directly control installed fragments,
and is unlikely to occur in practice. This simplifies the implementation.

PR Checklist

Validation Steps Performed

  • Fragment layering works ✔️

@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. labels Sep 24, 2021
@lhecker lhecker marked this pull request as ready for review September 24, 2021 01:41
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably add a test but I'm not sure we have any fragments tests tbh

@lhecker
Copy link
Member Author

lhecker commented Sep 24, 2021

Yeah I was about to write a test, but realized we never had the required infrastructure to test fragments properly. After all most of the complexity lies in finding fragments and less in layering...

@miniksa miniksa added the AutoMerge Marked for automatic merge by the bot when requirements are met label Sep 24, 2021
@ghost
Copy link

ghost commented Sep 24, 2021

Hello @miniksa!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@miniksa
Copy link
Member

miniksa commented Sep 24, 2021

Agree on tests. Maybe we should write a backlog item to test fragments? idk...

@ghost ghost merged commit 2be394f into main Sep 24, 2021
@ghost ghost deleted the dev/lhecker/11323-fragments-layering-fixup branch September 24, 2021 16:21
@jantari
Copy link
Contributor

jantari commented Oct 21, 2021

Was this not shipped yet? I am running Windows Terminal Version 1.12.2931.0 which just released yesterday but I still get the

Found multiple profiles with the same GUID in your settings file - ignoring duplicates. Make sure each profile's GUID is unique.

error.

@lhecker
Copy link
Member Author

lhecker commented Oct 21, 2021

@jantari Can you post your settings.json here, so that we can try and replicate your error?

@jantari
Copy link
Contributor

jantari commented Oct 24, 2021

@lhecker Yes of course. Also worth mentioning that this message/error only started appearing for me after updating from 1.11 to 1.12. Here are all my configs:

"${env:LocalAppData}\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json"
{
    "$help": "https://aka.ms/terminal-documentation",
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "actions": 
    [
        {
            "command": 
            {
                "action": "copy",
                "singleLine": false
            },
            "keys": "ctrl+c"
        },
        {
            "command": "find",
            "keys": "ctrl+shift+f"
        },
        {
            "command": "paste",
            "keys": "ctrl+v"
        },
        {
            "command": "toggleFocusMode",
            "keys": "ctrl+k"
        },
        {
            "command": "toggleShaderEffects",
            "keys": "shift+f10"
        },
        {
            "command": 
            {
                "action": "splitPane",
                "split": "auto",
                "splitMode": "duplicate"
            },
            "keys": "alt+shift+d"
        }
    ],
    "copyFormatting": "none",
    "copyOnSelect": false,
    "defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
    "profiles": 
    {
        "defaults": {},
        "list": 
        [
            {
                "colorScheme": "Dracula",
                "commandline": "powershell.exe",
                "font": 
                {
                    "face": "JetBrains Mono"
                },
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "hidden": false,
                "name": "Windows PowerShell"
            },
            {
                "colorScheme": "Campbell",
                "commandline": "cmd.exe",
                "cursorShape": "filledBox",
                "experimental.pixelShaderPath": "C:\\AMD\\crt.hlsl",
                "experimental.retroTerminalEffect": false,
                "font": 
                {
                    "size": 14
                },
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "hidden": false,
                "name": "Command Prompt"
            },
            {
                "colorScheme": "Nord",
                "font": 
                {
                    "face": "FantasqueSansMono Nerd Font",
                    "size": 16
                },
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "opacity": 92,
                "source": "Windows.Terminal.PowershellCore",
                "useAcrylic": true
            },
            {
                "colorScheme": "Nord",
                "font": 
                {
                    "face": "FantasqueSansMono Nerd Font"
                },
                "guid": "{a3a2e83a-884a-5379-baa8-16f193a13b21}",
                "hidden": false,
                "name": "PowerShell 7 Preview",
                "source": "Windows.Terminal.PowershellCore"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                "hidden": false,
                "name": "Ubuntu-20.04",
                "source": "Windows.Terminal.Wsl"
            },
            {
                "guid": "{ce790b10-c25b-5d26-b534-3cf2784a7e8d}",
                "hidden": false,
                "name": "Developer Command Prompt for VS 2019 (2)",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{77df2e76-a5d0-5e1d-8f1a-ec51abd32009}",
                "hidden": false,
                "name": "Developer PowerShell for VS 2019 (2)",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{da6733ec-26dd-59d5-bbf8-37b9fec5a6f0}",
                "hidden": true,
                "name": "Developer Command Prompt for VS 2019",
                "source": "Windows.Terminal.VisualStudio"
            },
            {
                "guid": "{08d48382-61ef-58de-a7cc-c66863bf9658}",
                "hidden": true,
                "name": "Developer PowerShell for VS 2019",
                "source": "Windows.Terminal.VisualStudio"
            }
        ]
    },
    "schemes":
    [
        {
            "background": "#0C0C0C",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#012456",
            "black": "#0C0C0C",
            "blue": "#0037DA",
            "brightBlack": "#767676",
            "brightBlue": "#3B78FF",
            "brightCyan": "#61D6D6",
            "brightGreen": "#16C60C",
            "brightPurple": "#B4009E",
            "brightRed": "#E74856",
            "brightWhite": "#F2F2F2",
            "brightYellow": "#F9F1A5",
            "cursorColor": "#FFFFFF",
            "cyan": "#3A96DD",
            "foreground": "#CCCCCC",
            "green": "#13A10E",
            "name": "Campbell Powershell",
            "purple": "#881798",
            "red": "#C50F1F",
            "selectionBackground": "#FFFFFF",
            "white": "#CCCCCC",
            "yellow": "#C19C00"
        },
        {
            "background": "#282A36",
            "black": "#21222C",
            "blue": "#BD93F9",
            "brightBlack": "#6272A4",
            "brightBlue": "#D6ACFF",
            "brightCyan": "#A4FFFF",
            "brightGreen": "#69FF94",
            "brightPurple": "#FF92DF",
            "brightRed": "#FF6E6E",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFFA5",
            "cursorColor": "#F8F8F2",
            "cyan": "#8BE9FD",
            "foreground": "#F8F8F2",
            "green": "#50FA7B",
            "name": "Dracula",
            "purple": "#FF79C6",
            "red": "#FF5555",
            "selectionBackground": "#44475A",
            "white": "#F8F8F2",
            "yellow": "#F1FA8C"
        },
        {
            "background": "#282828",
            "black": "#000000",
            "blue": "#458588",
            "brightBlack": "#928374",
            "brightBlue": "#83A598",
            "brightCyan": "#8EC07C",
            "brightGreen": "#B8BB26",
            "brightPurple": "#D3869B",
            "brightRed": "#FB4934",
            "brightWhite": "#EBDBB2",
            "brightYellow": "#FABD2F",
            "cursorColor": "#FFFFFF",
            "cyan": "#689D6A",
            "foreground": "#EBDBB2",
            "green": "#98971A",
            "name": "Gruvbox Dark",
            "purple": "#B16286",
            "red": "#CC241D",
            "selectionBackground": "#FFFFFF",
            "white": "#A89984",
            "yellow": "#D79921"
        },
        {
            "background": "#22272F",
            "black": "#3B4252",
            "blue": "#81A1C1",
            "brightBlack": "#4C566A",
            "brightBlue": "#81A1C1",
            "brightCyan": "#8FBCBB",
            "brightGreen": "#A3BE8C",
            "brightPurple": "#B48EAD",
            "brightRed": "#BF616A",
            "brightWhite": "#ECEFF4",
            "brightYellow": "#EBCB8B",
            "cursorColor": "#FFFFFF",
            "cyan": "#88C0D0",
            "foreground": "#D8DEE9",
            "green": "#A3BE8C",
            "name": "Nord",
            "purple": "#B48EAD",
            "red": "#BF616A",
            "selectionBackground": "#FFFFFF",
            "white": "#E5E9F0",
            "yellow": "#EBCB8B"
        },
        {
            "background": "#282C34",
            "black": "#282C34",
            "blue": "#61AFEF",
            "brightBlack": "#5A6374",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B6C2",
            "brightGreen": "#98C379",
            "brightPurple": "#C678DD",
            "brightRed": "#E06C75",
            "brightWhite": "#DCDFE4",
            "brightYellow": "#E5C07B",
            "cursorColor": "#FFFFFF",
            "cyan": "#56B6C2",
            "foreground": "#DCDFE4",
            "green": "#98C379",
            "name": "One Half Dark",
            "purple": "#C678DD",
            "red": "#E06C75",
            "selectionBackground": "#FFFFFF",
            "white": "#DCDFE4",
            "yellow": "#E5C07B"
        },
        {
            "background": "#FAFAFA",
            "black": "#383A42",
            "blue": "#0184BC",
            "brightBlack": "#4F525D",
            "brightBlue": "#61AFEF",
            "brightCyan": "#56B5C1",
            "brightGreen": "#98C379",
            "brightPurple": "#C577DD",
            "brightRed": "#DF6C75",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#E4C07A",
            "cursorColor": "#4F525D",
            "cyan": "#0997B3",
            "foreground": "#383A42",
            "green": "#50A14F",
            "name": "One Half Light",
            "purple": "#A626A4",
            "red": "#E45649",
            "selectionBackground": "#FFFFFF",
            "white": "#FAFAFA",
            "yellow": "#C18301"
        },
        {
            "background": "#002B36",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#FFFFFF",
            "cyan": "#2AA198",
            "foreground": "#839496",
            "green": "#859900",
            "name": "Solarized Dark",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#FDF6E3",
            "black": "#002B36",
            "blue": "#268BD2",
            "brightBlack": "#073642",
            "brightBlue": "#839496",
            "brightCyan": "#93A1A1",
            "brightGreen": "#586E75",
            "brightPurple": "#6C71C4",
            "brightRed": "#CB4B16",
            "brightWhite": "#FDF6E3",
            "brightYellow": "#657B83",
            "cursorColor": "#002B36",
            "cyan": "#2AA198",
            "foreground": "#657B83",
            "green": "#859900",
            "name": "Solarized Light",
            "purple": "#D33682",
            "red": "#DC322F",
            "selectionBackground": "#FFFFFF",
            "white": "#EEE8D5",
            "yellow": "#B58900"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#FFFFFF",
            "cyan": "#06989A",
            "foreground": "#D3D7CF",
            "green": "#4E9A06",
            "name": "Tango Dark",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#FFFFFF",
            "black": "#000000",
            "blue": "#3465A4",
            "brightBlack": "#555753",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#8AE234",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F",
            "cursorColor": "#000000",
            "cyan": "#06989A",
            "foreground": "#555753",
            "green": "#4E9A06",
            "name": "Tango Light",
            "purple": "#75507B",
            "red": "#CC0000",
            "selectionBackground": "#FFFFFF",
            "white": "#D3D7CF",
            "yellow": "#C4A000"
        },
        {
            "background": "#000000",
            "black": "#000000",
            "blue": "#000080",
            "brightBlack": "#808080",
            "brightBlue": "#0000FF",
            "brightCyan": "#00FFFF",
            "brightGreen": "#00FF00",
            "brightPurple": "#FF00FF",
            "brightRed": "#FF0000",
            "brightWhite": "#FFFFFF",
            "brightYellow": "#FFFF00",
            "cursorColor": "#FFFFFF",
            "cyan": "#008080",
            "foreground": "#C0C0C0",
            "green": "#008000",
            "name": "Vintage",
            "purple": "#800080",
            "red": "#800000",
            "selectionBackground": "#FFFFFF",
            "white": "#C0C0C0",
            "yellow": "#808000"
        }
    ],
    "tabSwitcherMode": "disabled",
    "useAcrylicInTabRow": false
}

Nothing in "${env:ProgramData}\Microsoft\Windows Terminal\Fragments" (directory doesn't exist).

Custom fragments - these have been here for a while, caused no error with Terminal 1.11 and contents weren't changed:

tree /f "${env:LocalAppData}\Microsoft\Windows Terminal\Fragments"
Folder PATH listing
Volume serial number is whatever
C:\USERS\JANTARI\APPDATA\LOCAL\MICROSOFT\WINDOWS TERMINAL\FRAGMENTS
└───jan-config
        nord.json
        wsl.json
"${env:LocalAppData}\Microsoft\Windows Terminal\Fragments\jan-config\nord.json"
{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "schemes":
    [
        {
            "name": "Nord",
            "background": "#22272F",
            "black": "#3B4252",
            "blue": "#81A1C1",
            "brightBlack": "#4C566A",
            "brightBlue": "#81A1C1",
            "brightCyan": "#8FBCBB",
            "brightGreen": "#A3BE8C",
            "brightPurple": "#B48EAD",
            "brightRed": "#BF616A",
            "brightWhite": "#ECEFF4",
            "brightYellow": "#EBCB8B",
            "cursorColor": "#FFFFFF",
            "cyan": "#88C0D0",
            "foreground": "#D8DEE9",
            "green": "#A3BE8C",
            "purple": "#B48EAD",
            "red": "#BF616A",
            "selectionBackground": "#FFFFFF",
            "white": "#E5E9F0",
            "yellow": "#EBCB8B"
        }
    ]
}
"${env:LocalAppData}\Microsoft\Windows Terminal\Fragments\jan-config\wsl.json"
{
    "$schema": "https://aka.ms/terminal-profiles-schema",
    "profiles":
    [
                {
                        "updates": "{58ad8b0c-3ef8-5f4d-bc6f-13e4c00f2530}",
                        //"name": "Debian",
                        "colorScheme" : "Nord",
                        "hidden": false,
                        "cursorShape":"underscore",
                        "fontFace" : "FantasqueSansMono Nerd Font",
                        "fontSize": 16,
                        "backgroundImage": "C:/Users/jantari/Openlogo-debianV2.svg - Kopie.png",
                        "backgroundImageStretchMode": "none",
                        "backgroundImageOpacity": 0.3,
                        "backgroundImageAlignment": "bottomRight",
                        "useAcrylic" : false,
                        "acrylicOpacity" : 0.86,
                        "source": "Windows.Terminal.Wsl"
                },
                {
                        "updates": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
                        //"name": "Ubuntu 20.04",
                        "colorScheme": "Nord",
                        "hidden": false,
                        "cursorShape":"underscore",
                        "fontFace" : "FantasqueSansMono Nerd Font",
                        "fontSize": 16,
                        "backgroundImage": "%LOCALAPPDATA%/WSL_ICONS/wt-wsl-ubuntu-logo.png",
                        "backgroundImageStretchMode": "none",
                        "backgroundImageOpacity": 0.3,
                        "backgroundImageAlignment": "bottomRight",
                        "useAcrylic": true,
                        "acrylicOpacity": 0.86,
                        "source": "Windows.Terminal.Wsl"
                }
    ]
}

@lhecker
Copy link
Member Author

lhecker commented Oct 24, 2021

@jantari Ah I see the problem is that "updates" is a valid "guid" for fragments.
During testing I only tested with fragments that contained a single "updates" profile, so I didn't catch this. I'm very sorry.
As you might've already noticed you can circumvent the issue by specifying a "name" for each fragment profile. I'll make sure to fix this as soon as possible.

@lhecker
Copy link
Member Author

lhecker commented Oct 24, 2021

I've created #11597 and already got a working fix ready (it's just <10 lines to change). 👍

@jantari
Copy link
Contributor

jantari commented Oct 24, 2021

No problem, glad I could help.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fragments cause the error 'Found multiple profiles with the same GUID in your settings file'
4 participants