Repository: microsoft/terminal (language: cpp)

Issue:
Minimize to tray not working
### Windows Terminal version

1.11.3471.0

### Windows build number

10.0.19043.1288

### Other Software

n/a

### Steps to reproduce

1. Add `"minimizeToNotificationArea": true` to `settings.json`.
2. Restart Windows Terminal.
3. Click window's minimise button.

### Expected Behavior

Minimises to tray ("notification area")

### Actual Behavior

Minises to taskbar.

### Note

See #5727. According to the releases log this feature should be there, even in the settings UI.


Discussion / hints:
Hmm. This might be a docs issue.

The tray icon functionality is still only available in Preview builds of the Terminal:
https://github.com/microsoft/terminal/blob/0480597abb3bacb7bc9c0d88e4ef529e4fc08e1a/src/features.xml#L67-L72

We did this to restrict the audience a bit while we sorted out remaining issues with the implementation. It's been a few months though and there haven't really been any issues with it, so maybe we should just turn that on for stable 🤔 

(tray icon did first ship in https://github.com/microsoft/terminal/releases/tag/v1.11.2421.0 but the bot was down then so none of the issue/PR have the release number posted)

(for linking #10448)
Great, that clears it up, thanks for looking into it!
team discusion: Let's yank the velocity flag off this. It's been in preview long enough. 

Fix patch:
diff --git a/src/cascadia/Remoting/WindowManager.cpp b/src/cascadia/Remoting/WindowManager.cpp
index 5fc8b1eed00..8ce04464cda 100644
--- a/src/cascadia/Remoting/WindowManager.cpp
+++ b/src/cascadia/Remoting/WindowManager.cpp
@@ -542,10 +542,7 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
 
     void WindowManager::SummonAllWindows()
     {
-        if constexpr (Feature_NotificationIcon::IsEnabled())
-        {
-            _monarch.SummonAllWindows();
-        }
+        _monarch.SummonAllWindows();
     }
 
     Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Terminal::Remoting::PeasantInfo> WindowManager::GetPeasantInfos()
diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp
index 4f774dc205a..cdf97cfd099 100644
--- a/src/cascadia/TerminalApp/AppLogic.cpp
+++ b/src/cascadia/TerminalApp/AppLogic.cpp
@@ -1587,38 +1587,24 @@ namespace winrt::TerminalApp::implementation
 
     bool AppLogic::GetMinimizeToNotificationArea()
     {
-        if constexpr (Feature_NotificationIcon::IsEnabled())
-        {
-            if (!_loadedInitialSettings)
-            {
-                // Load settings if we haven't already
-                LoadSettings();
-            }
-
-            return _settings.GlobalSettings().MinimizeToNotificationArea();
-        }
-        else
+        if (!_loadedInitialSettings)
         {
-            return false;
+            // Load settings if we haven't already
+            LoadSettings();
         }
+
+        return _settings.GlobalSettings().MinimizeToNotificationArea();
     }
 
     bool AppLogic::GetAlwaysShowNotificationIcon()
     {
-        if constexpr (Feature_NotificationIcon::IsEnabled())
-        {
-            if (!_loadedInitialSettings)
-            {
-                // Load settings if we haven't already
-                LoadSettings();
-            }
-
-            return _settings.GlobalSettings().AlwaysShowNotificationIcon();
-        }
-        else
+        if (!_loadedInitialSettings)
         {
-            return false;
+            // Load settings if we haven't already
+            LoadSettings();
         }
+
+        return _settings.GlobalSettings().AlwaysShowNotificationIcon();
     }
 
     bool AppLogic::GetShowTitleInTitlebar()
diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp
index 9d6c0e08849..399f00440a8 100644
--- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp
+++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.cpp
@@ -199,8 +199,4 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
         }
     }
 
-    bool GlobalAppearance::FeatureNotificationIconEnabled() const noexcept
-    {
-        return Feature_NotificationIcon::IsEnabled();
-    }
 }
diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h
index dd8b56fa242..236c8478778 100644
--- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h
+++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.h
@@ -25,8 +25,6 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
 
         void OnNavigatedTo(const winrt::Windows::UI::Xaml::Navigation::NavigationEventArgs& e);
 
-        bool FeatureNotificationIconEnabled() const noexcept;
-
         WINRT_PROPERTY(Editor::GlobalAppearancePageNavigationState, State, nullptr);
         GETSET_BINDABLE_ENUM_SETTING(Theme, winrt::Windows::UI::Xaml::ElementTheme, State().Globals(), Theme);
         GETSET_BINDABLE_ENUM_SETTING(TabWidthMode, winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode, State().Globals(), TabWidthMode);
diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl
index 9840a4a3d68..7e3483140ab 100644
--- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl
+++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.idl
@@ -25,7 +25,5 @@ namespace Microsoft.Terminal.Settings.Editor
 
         IInspectable CurrentTabWidthMode;
         Windows.Foundation.Collections.IObservableVector<Microsoft.Terminal.Settings.Editor.EnumEntry> TabWidthModeList { get; };
-
-        Boolean FeatureNotificationIconEnabled { get; };
     }
 }
diff --git a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
index 7361ec7cb8a..11df06c5482 100644
--- a/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
+++ b/src/cascadia/TerminalSettingsEditor/GlobalAppearance.xaml
@@ -88,14 +88,12 @@
             </local:SettingContainer>
 
             <!--  Always Show Notification Icon  -->
-            <local:SettingContainer x:Uid="Globals_AlwaysShowNotificationIcon"
-                                    Visibility="{x:Bind FeatureNotificationIconEnabled}">
+            <local:SettingContainer x:Uid="Globals_AlwaysShowNotificationIcon">
                 <ToggleSwitch IsOn="{x:Bind State.Globals.AlwaysShowNotificationIcon, Mode=TwoWay}" />
             </local:SettingContainer>
 
             <!--  Minimize To Notification Area  -->
-            <local:SettingContainer x:Uid="Globals_MinimizeToNotificationArea"
-                                    Visibility="{x:Bind FeatureNotificationIconEnabled}">
+            <local:SettingContainer x:Uid="Globals_MinimizeToNotificationArea">
                 <ToggleSwitch IsOn="{x:Bind State.Globals.MinimizeToNotificationArea, Mode=TwoWay}" />
             </local:SettingContainer>
         </StackPanel>
diff --git a/src/cascadia/WindowsTerminal/AppHost.cpp b/src/cascadia/WindowsTerminal/AppHost.cpp
index 747169f5151..09fcb564f7b 100644
--- a/src/cascadia/WindowsTerminal/AppHost.cpp
+++ b/src/cascadia/WindowsTerminal/AppHost.cpp
@@ -1365,17 +1365,14 @@ void AppHost::_SystemMenuChangeRequested(const winrt::Windows::Foundation::IInsp
 // - <none>
 void AppHost::_CreateNotificationIcon()
 {
-    if constexpr (Feature_NotificationIcon::IsEnabled())
-    {
-        _notificationIcon = std::make_unique<NotificationIcon>(_window->GetHandle());
-
-        // Hookup the handlers, save the tokens for revoking if settings change.
-        _ReAddNotificationIconToken = _window->NotifyReAddNotificationIcon([this]() { _notificationIcon->ReAddNotificationIcon(); });
-        _NotificationIconPressedToken = _window->NotifyNotificationIconPressed([this]() { _notificationIcon->NotificationIconPressed(); });
-        _ShowNotificationIconContextMenuToken = _window->NotifyShowNotificationIconContextMenu([this](til::point coord) { _notificationIcon->ShowContextMenu(coord, _windowManager.GetPeasantInfos()); });
-        _NotificationIconMenuItemSelectedToken = _window->NotifyNotificationIconMenuItemSelected([this](HMENU hm, UINT idx) { _notificationIcon->MenuItemSelected(hm, idx); });
-        _notificationIcon->SummonWindowRequested([this](auto& args) { _windowManager.SummonWindow(args); });
-    }
+    _notificationIcon = std::make_unique<NotificationIcon>(_window->GetHandle());
+
+    // Hookup the handlers, save the tokens for revoking if settings change.
+    _ReAddNotificationIconToken = _window->NotifyReAddNotificationIcon([this]() { _notificationIcon->ReAddNotificationIcon(); });
+    _NotificationIconPressedToken = _window->NotifyNotificationIconPressed([this]() { _notificationIcon->NotificationIconPressed(); });
+    _ShowNotificationIconContextMenuToken = _window->NotifyShowNotificationIconContextMenu([this](til::point coord) { _notificationIcon->ShowContextMenu(coord, _windowManager.GetPeasantInfos()); });
+    _NotificationIconMenuItemSelectedToken = _window->NotifyNotificationIconMenuItemSelected([this](HMENU hm, UINT idx) { _notificationIcon->MenuItemSelected(hm, idx); });
+    _notificationIcon->SummonWindowRequested([this](auto& args) { _windowManager.SummonWindow(args); });
 }
 
 // Method Description:
@@ -1386,55 +1383,46 @@ void AppHost::_CreateNotificationIcon()
 // - <none>
 void AppHost::_DestroyNotificationIcon()
 {
-    if constexpr (Feature_NotificationIcon::IsEnabled())
-    {
-        _window->NotifyReAddNotificationIcon(_ReAddNotificationIconToken);
-        _window->NotifyNotificationIconPressed(_NotificationIconPressedToken);
-        _window->NotifyShowNotificationIconContextMenu(_ShowNotificationIconContextMenuToken);
-        _window->NotifyNotificationIconMenuItemSelected(_NotificationIconMenuItemSelectedToken);
+    _window->NotifyReAddNotificationIcon(_ReAddNotificationIconToken);
+    _window->NotifyNotificationIconPressed(_NotificationIconPressedToken);
+    _window->NotifyShowNotificationIconContextMenu(_ShowNotificationIconContextMenuToken);
+    _window->NotifyNotificationIconMenuItemSelected(_NotificationIconMenuItemSelectedToken);
 
-        _notificationIcon->RemoveIconFromNotificationArea();
-        _notificationIcon = nullptr;
-    }
+    _notificationIcon->RemoveIconFromNotificationArea();
+    _notificationIcon = nullptr;
 }
 
 void AppHost::_ShowNotificationIconRequested()
 {
-    if constexpr (Feature_NotificationIcon::IsEnabled())
+    if (_windowManager.IsMonarch())
     {
-        if (_windowManager.IsMonarch())
+        if (!_notificationIcon)
         {
-            if (!_notificationIcon)
-            {
-                _CreateNotificationIcon();
-            }
-        }
-        else
-        {
-            _windowManager.RequestShowNotificationIcon();
+            _CreateNotificationIcon();
         }
     }
+    else
+    {
+        _windowManager.RequestShowNotificationIcon();
+    }
 }
 
 void AppHost::_HideNotificationIconRequested()
 {
-    if constexpr (Feature_NotificationIcon::IsEnabled())
+    if (_windowManager.IsMonarch())
     {
-        if (_windowManager.IsMonarch())
+        // Destroy it only if our settings allow it
+        if (_notificationIcon &&
+            !_logic.GetAlwaysShowNotificationIcon() &&
+            !_logic.GetMinimizeToNotificationArea())
         {
-            // Destroy it only if our settings allow it
-            if (_notificationIcon &&
-                !_logic.GetAlwaysShowNotificationIcon() &&
-                !_logic.GetMinimizeToNotificationArea())
-            {
-                _DestroyNotificationIcon();
-            }
-        }
-        else
-        {
-            _windowManager.RequestHideNotificationIcon();
+            _DestroyNotificationIcon();
         }
     }
+    else
+    {
+        _windowManager.RequestHideNotificationIcon();
+    }
 }
 
 // Method Description:
diff --git a/src/features.xml b/src/features.xml
index 31642a0adfd..3fffd6c04de 100644
--- a/src/features.xml
+++ b/src/features.xml
@@ -57,13 +57,6 @@
         </alwaysEnabledBrandingTokens>
     </feature>
 
-    <feature>
-        <name>Feature_NotificationIcon</name>
-        <description>Controls whether the Notification Icon and related settings (aka. MinimizeToNotificationArea and AlwaysShowNotificationIcon) are enabled</description>
-        <stage>AlwaysEnabled</stage>
-        <alwaysDisabledReleaseTokens/>
-    </feature>
-
     <feature>
         <name>Feature_PersistedWindowLayout</name>
         <description>Whether to allow the user to enable persisted window layout saving and loading</description>


Test patch: