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

Allow users to specify a base settings path, enabling multiple local state and multi-instance scenarios. #18696

Open
dmitrykok opened this issue Mar 17, 2025 · 1 comment · May be fixed by #18697
Labels
In-PR This issue has a related PR Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting

Comments

@dmitrykok
Copy link

dmitrykok commented Mar 17, 2025

Description of the new feature

Multi local state and settings and multi instance with WT_BASE_SETTINGS_PATH env

Summary

Introduces the WT_BASE_SETTINGS_PATH environment variable to allow users to specify a base settings path for Windows Terminal, enabling multiple local states, settings and multi-instance scenarios.

Enhancements:

  • Adds support for the WT_BASE_SETTINGS_PATH environment variable to customize the settings path.
  • Allows running multiple instances of Windows Terminal with different settings and states by using different WT_BASE_SETTINGS_PATH values.

Proposed technical implementation details

Reviewer Guide

Introducing the ability to run multiple instances of Windows Terminal with separate settings and state by using the WT_BASE_SETTINGS_PATH environment variable. The changes modify the settings path retrieval logic and window class name generation to incorporate the environment variable, allowing for isolated settings for each instance.

Sequence diagram for settings path retrieval with WT_BASE_SETTINGS_PATH

Loading
sequenceDiagram
    participant User
    participant TerminalApp
    participant FileUtils

    User->>TerminalApp: Starts Terminal
    TerminalApp->>FileUtils: GetBaseSettingsPath()
    FileUtils->>FileUtils: Check ENV_WT_BASE_SETTINGS_PATH
    alt ENV_WT_BASE_SETTINGS_PATH is set
        FileUtils->>FileUtils: Create directories at ENV_WT_BASE_SETTINGS_PATH
        FileUtils-->>TerminalApp: Returns ENV_WT_BASE_SETTINGS_PATH
    else ENV_WT_BASE_SETTINGS_PATH is not set
        FileUtils->>FileUtils: Check IsPackaged() && IsPortableMode()
        alt IsPackaged() && IsPortableMode()
            FileUtils->>FileUtils: Get module path
            FileUtils-->>TerminalApp: Returns module path / "settings"
        else IsPackaged() && IsPortableMode() is false
            FileUtils->>FileUtils: Get local app data path
            FileUtils-->>TerminalApp: Returns local app data path / UnpackagedSettingsFolderName
        end
    end
    TerminalApp->>TerminalApp: Loads settings from path

Sequence diagram for window class name generation with WT_BASE_SETTINGS_PATH

Loading
sequenceDiagram
    participant TerminalApp
    participant WindowEmperor

    TerminalApp->>WindowEmperor: Starts Terminal
    WindowEmperor->>WindowEmperor: Generate window class name
    WindowEmperor->>WindowEmperor: Check ENV_WT_BASE_SETTINGS_PATH
    alt ENV_WT_BASE_SETTINGS_PATH is set
        WindowEmperor->>WindowEmperor: Hash ENV_WT_BASE_SETTINGS_PATH
        WindowEmperor->>WindowEmperor: Append hash to window class name
    else ENV_WT_BASE_SETTINGS_PATH is not set
        WindowEmperor->>WindowEmperor: Use default window class name
    end
    WindowEmperor->>WindowEmperor: Acquire mutex or handoff

File-Level Changes

Change Details Files
Introduces an environment variable to allow multiple instances of Windows Terminal with separate settings.
  • Added ENV_WT_BASE_SETTINGS_PATH constant to FileUtils.cpp and WindowEmperor.cpp.
  • In GetBaseSettingsPath and GetReleaseSettingsPath functions, attempts to read the settings path from the ENV_WT_BASE_SETTINGS_PATH environment variable.
  • If the environment variable is set, creates the directory specified by the path.
  • Appends a hash of the settings path to the window class name in WindowEmperor::HandleCommandlineArgs to allow multiple instances.
src/cascadia/TerminalSettingsModel/FileUtils.cpp
src/cascadia/WindowsTerminal/WindowEmperor.cpp
@dmitrykok dmitrykok added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Mar 17, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 17, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Mar 17, 2025
@lhecker
Copy link
Member

lhecker commented Mar 19, 2025

Thank you! We'll need a little bit more time to look into this. This feature has been previously suggested at #6687 where the idea was to make this a CLI parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In-PR This issue has a related PR Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting
Projects
None yet
2 participants