microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.3k stars 8.28k forks source link

Explorer.exe reset/restart causes WT tray icon to disappear for the current instance #18057

Open Hlsgs opened 23 hours ago

Hlsgs commented 23 hours ago

Windows Terminal version

1.21.2701.0 (and all previous builds, this is not a new issue)

Windows build number

Both W10 and W11 regardless of build number

Other Software

No response

Steps to reproduce

  1. Run WT with hide in notification area when minimized and always display in notification area enabled(the latter is optional)
  2. Use task manager to restart explorer.exe

Expected Behavior

The tray icon should reappear after the reset

Actual Behavior

The tray icon does not reappear after the reset. Only way to get it back is to completly close WT and start it again. This also has some (very) undesirable side-effects such as losing access to the stuff you have currently running(akin to https://github.com/microsoft/terminal/issues/16755 ?). One would obviously not restart explorer.exe out of the blue but it does sometimes crash/restart on it's own, which has the same effect.

Zeroes1 commented 18 hours ago

@DHowett I check latest canary build terminal-1.23.2852.0, also latest preview terminal-1.22.2702.0 check on Windows 10.0.19045.5011 (22H2) [TEST: pskill64.exe explorer.exe and after manually ran again explorer.exe] and confirm that it does not work - there is no re-registration of the icon in fact...

Strange situation i see what code exist for this, but don't work...

\src\cascadia\WindowsTerminal\WindowEmperor.cpp 
static const UINT WM_TASKBARCREATED = []() { return RegisterWindowMessageW(L"TaskbarCreated"); }();
...
        if (message == WM_TASKBARCREATED)
        {
            _notificationIcon->ReAddNotificationIcon();
            return 0;
        }

src\cascadia\WindowsTerminal\NotificationIcon.cpp
void NotificationIcon::ReAddNotificationIcon()
{
    Shell_NotifyIcon(NIM_ADD, &_notificationIconData);
    Shell_NotifyIcon(NIM_SETVERSION, &_notificationIconData);
}

some need also? I think need debug :/