Skip to content

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

Closed
@dmitrykok

Description

@dmitrykok

Description of the new feature

Multi local state and settings and multi instance with --localstate command-line argument

Summary

Introduce a new command-line option -L or --localstate to allow users to specify a custom local state directory for Windows Terminal, enabling multiple local states, settings and multi-instance scenarios.

Enhancements:

  • Modify command-line argument parsing to support the new local state option
  • Update environment variable handling to use the new local state path

Proposed technical implementation details

Reviewer Guide

Introducing the ability to run multiple instances of Windows Terminal with separate settings and state by using the --localstate command-line argument. Modify parsing to support the new local state option. 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.

This pull request adds support for a new command-line argument -L or --localstate to allow users to specify a custom local state directory for Windows Terminal. The implementation involves modifying command-line argument parsing, updating environment variable handling, and updating file utilities to use the new local state path.

Sequence diagram for handling the new localstate argument

sequenceDiagram
    participant User
    participant Command Line
    participant AppCommandlineArgs
    participant WindowEmperor
    participant FileUtils

    User->>Command Line: wt --localstate <path>
    Command Line->>AppCommandlineArgs: Parse arguments
    AppCommandlineArgs->>AppCommandlineArgs: Store local state path
    AppCommandlineArgs->>WindowEmperor: Launch Terminal
    WindowEmperor->>WindowEmperor: Handle Commandline Args
    WindowEmperor->>AppCommandlineArgs: Get Local State
    WindowEmperor->>FileUtils: Set ENV_WT_BASE_SETTINGS_PATH to local state path
    FileUtils->>FileUtils: Create directories at local state path
Loading

Updated class diagram for AppCommandlineArgs

classDiagram
  class AppCommandlineArgs {
    -std::wregex _commandDelimiterRegex
    -std::vector<std::wstring> _args
    -bool _hasParseError
    -bool _shouldExitEarly
    -bool _isHandoffListener
    -int _loadPersistedLayoutIdx
    -std::string _windowTarget
    -std::string _localState
    +FullResetState()
    +GetTargetWindow() string_view
    +GetLocalState() string_view
    -_getNewTerminalArgs(NewTerminalSubcommand& subcommand) NewTerminalArgs
  }
Loading

File-Level Changes

Change Details Files
Introduced a new command-line argument -L or --localstate to allow users to specify a custom local state directory for Windows Terminal.
  • Added _localState field to AppCommandlineArgs class to store the local state path.
  • Added -L,--localstate option to the command-line argument parser.
  • Implemented GetLocalState() method in AppCommandlineArgs to retrieve the local state path.
  • Added LocalState() property to the CommandlineArgs class in Remoting.idl and implemented it in Remoting.cpp.
  • Modified WindowEmperor::HandleCommandlineArgs to retrieve the settings path from the command line arguments.
  • Updated FileUtils::GetBaseSettingsPath to retrieve the settings path from the environment variables.
src/cascadia/WindowsTerminal/WindowEmperor.cpp
src/cascadia/TerminalSettingsModel/FileUtils.cpp
src/cascadia/TerminalApp/AppCommandlineArgs.cpp
src/cascadia/TerminalApp/Remoting.cpp
src/cascadia/TerminalApp/AppCommandlineArgs.h
src/cascadia/TerminalApp/Remoting.h
src/cascadia/CascadiaPackage/Package-Dev.appxmanifest
src/cascadia/TerminalApp/Remoting.idl
src/cascadia/TerminalApp/Resources/en-US/Resources.resw

Motivation

I created Windows Terminal Layout Manager application. Which is an advanced yet user-friendly application designed to simplify and streamline the management of your Windows Terminal sessions. Effortlessly save, restore, and dynamically manage multiple terminal layouts and settings, ensuring a smooth and consistent workflow.
WTLayoutManager

Image

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRThis issue has a related PRIssue-FeatureComplex enough to require an in depth planning process and actual budgeted, scheduled work.Needs-DiscussionSomething that requires a team discussion before we can proceedResolution-DuplicateThere's another issue on the tracker that's pretty much the same thing.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions