Skip to content

Prepare for per-window settings#20328

Open
zadjii-msft wants to merge 18 commits into
mainfrom
user/migrie/per-window-prequel
Open

Prepare for per-window settings#20328
zadjii-msft wants to merge 18 commits into
mainfrom
user/migrie/per-window-prequel

Conversation

@zadjii-msft

Copy link
Copy Markdown
Member

This is part one of a two-part pair of PRs to add support for per window name settings to the Windows terminal.

This first PR functionally does very little. It introduces the concept of a WindowSettings object, where each WindowSettings object may be different based off of the name of the window. However, the settings model doesn't actually expose different instances of WindowSettings currently. It just introduces one fake instance that actually just wraps the global settings object to store all of them. This means that functionally the code hasn't actually changed in this PR. We are just accessing these properties through an intermediate type.

Largely this PR is mostly mechanical. where we previously would have been accessing properties on the GlobalAppSettings, now we are just accessing the _currentWindowSettings() (via a helper, or passing as a parameter).

All of this refactoring can be done now to always access the correct window settings object so that the next PR is much easier to read. That is where it will get more interesting and we will have more instances of window settings.

re: #9992

@carlos-zamora carlos-zamora left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok. I reviewed the PR and took a look at how it's used in part 2 (PR #20329) to get an idea of the feature being implemented.

Off the bat, the main design/architecture issues I have are...

  1. I don't like that WindowSettings is now everywhere. Though the changes are mechanical, it feels weird that everywhere in the code now has a responsibility of knowing what window we're in so that we can retrieve the right set of settings. I'd rather that that's only/mainly the responsibility of the settings model layer, so that each consumer just has to say "give me the value of this setting" rather than "give me the value in this window". I get why that's not the case, but I have an idea on how to fix it (more below).
  2. I don't like that the settings are using themes to apply them. Themes sound like they are intended to be purely visual. In MTSMSettings.h, I see that MTSM_GLOBAL_ONLY_SETTINGS are settings that cannot differ across windows (good), but there's a good amount of settings in MTSM_WINDOW_SETTINGS that don't make sense to me. For example, copyOnSelect, scrollToX are more interactivity-focused, so it would be weird to have two different windows have two different interaction behaviors. I also personally don't like that themes isn't in the settings UI yet, but that's a broader issue, so I feel weird about adding more functionality to an area that isn't exposed there yet.
  3. (maybe more of a question for part 2) Should settings changed at runtime (i.e. "toggle always on top") be preserved? I think that would make sense.

I've been thinking about how these issues can be addressed. Some ideas:

  1. Replace WindowSettings + GlobalAppSettings coupling with GlobalAppSettings inheritance
    • IInheritable already does the kind of behavior I want: consumer calls a getter for a setting (i.e. AlwaysShowTabs()) and they just get the value directly without needing to think about the context. If we can use this, we could remove WindowSettingsDefaults() entirely because the value would just be resolved by the getter nice and clean.
    • Profile already has a similar system with profile defaults, so doing something like this would be more consistent.
    • One of the main issues right now is that GlobalAppSettings carries around _actionMap, _colorSchemes, and _themes. That said, I think we could just move them up to CascadiaSettings and it shouldn't be too much trouble. Honestly, it would make more sense like that anyways.
  2. Directly allow global settings to be set in each "windows" entry
    • I think this is more intuitive. Again, it follows the design of profiles and profile defaults, so it should be much easier to understand. Means that you can have dockWindow be a global setting too.

Hope this helps!

Comment on lines +376 to +380
const auto themePair = window ? window.Theme() : nullptr;
if (!themePair)
{
return nullptr;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we have a default theme?

{
// Create this only on the first time we load the settings.
_terminalSettingsCache = std::make_shared<TerminalSettingsCache>(settings);
_terminalSettingsCache = std::make_shared<TerminalSettingsCache>(settings, settings.WindowSettings(_WindowProperties.WindowName()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
_terminalSettingsCache = std::make_shared<TerminalSettingsCache>(settings, settings.WindowSettings(_WindowProperties.WindowName()));
_terminalSettingsCache = std::make_shared<TerminalSettingsCache>(settings, _currentWindowSettings());

nit: easier to read

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants