Window repetedly minimizes and focuses itself right after back from sleep #19799

Open
opened 2026-01-31 06:53:55 +00:00 by claunia · 4 comments
Owner

Originally created by @AadneEM on GitHub (May 3, 2023).

Windows Terminal version

1.16.10262.0

Windows build number

10.0.22621.0

Other Software

No response

Steps to reproduce

This happens infrequently. But always right as I come back to the PC and unlock it. Haven't been able to determine if there is anything specific that triggers it.

Expected Behavior

That the window maintains the previous state

Actual Behavior

The window rapidly and repetedly minimizes and "unminimizes" itself, no matter what other window was in focus

Originally created by @AadneEM on GitHub (May 3, 2023). ### Windows Terminal version 1.16.10262.0 ### Windows build number 10.0.22621.0 ### Other Software _No response_ ### Steps to reproduce This happens infrequently. But always right as I come back to the PC and unlock it. Haven't been able to determine if there is anything specific that triggers it. ### Expected Behavior That the window maintains the previous state ### Actual Behavior The window rapidly and repetedly minimizes and "unminimizes" itself, no matter what other window was in focus
claunia added the Help WantedIssue-BugProduct-TerminalArea-Windowing labels 2026-01-31 06:53:55 +00:00
Author
Owner

@zadjii-msft commented on GitHub (May 3, 2023):

A theory: if you've got a display port monitor, on Windows 11, then when the PC goes to sleep, then the OS will disconnect that display. And, when a display gets removed, the windows on it will get minimized.

We think there's a race somewhere between the Terminal's own HWND and the hidden conpty hwnd that's stuck in a loop here. One thinks it should be minimized, the other thinks it should be restored, and the two get stuck in a loop.

What we're not totally sure about is how to mitigate that loop...

@zadjii-msft commented on GitHub (May 3, 2023): A theory: if you've got a display port monitor, on Windows 11, then when the PC goes to sleep, then the OS will disconnect that display. And, when a display gets removed, the windows on it will get minimized. We think there's a race somewhere between the Terminal's own HWND and the hidden conpty hwnd that's stuck in a loop here. One thinks it should be minimized, the other thinks it should be restored, and the two get stuck in a loop. What we're not totally sure about is how to mitigate that loop...
Author
Owner

@lhecker commented on GitHub (May 3, 2023):

...one option would be to assume that any time we do a ShowWindow inside conhost on the hidden hwnd, the message will 100% arrive the loop immediately. We could then ignore that message. The problem is the question what happens if the user sends a show message followed by a hide message in between us sending ours. In that case we'd ignore the show message. But I feel like that this doesn't really matter, since the show/hide order between WT showing/hiden and the console application showing/hiding is a race condition already anyways.

@lhecker commented on GitHub (May 3, 2023): ...one option would be to assume that any time we do a `ShowWindow` inside conhost on the hidden hwnd, the message will 100% arrive the loop immediately. We could then ignore that message. The problem is the question what happens if the user sends a show message followed by a hide message in between us sending ours. In that case we'd ignore the show message. But I feel like that this doesn't really matter, since the show/hide order between WT showing/hiden and the console application showing/hiding is a race condition already anyways.
Author
Owner

@xpalidotious commented on GitHub (Nov 22, 2024):

I'm occasionally having a similar problem (although #17616 which was closed as a dupe of this issue is a better description of the problem I'm having).

I've only had the issue a few times, but in each case it occurred when I had a large number of open tabs (probably 140 tabs in the most recent case). I've always noticed that minimizing or restoring terminal once I've been running it for a while and have a large number of tabs open is very slow and can cause issues if I get impatient and click the taskbar icon more than once.

I've just tried to re-create the problem and had success by simply opening a large number of Windows command prompt tabs and rapidly clicking the Terminal icon on the taskbar a few times.

The first time I deliberately triggered the issue I had opened 132 tabs. I closed the program and tried to replicate the issue with fewer open tabs. With just over 40 open tabs I couldn't trigger the issue, so I opened a few more and tried again - this time with just over 60 open tabs a few rapid clicks on the taskbar icon instantly triggered the issue.

Hopefully someone can use this information to replicate the issue and fix the problem, because losing over a hundred open tabs is not fun at all!

@xpalidotious commented on GitHub (Nov 22, 2024): I'm occasionally having a similar problem (although #17616 which was closed as a dupe of this issue is a better description of the problem I'm having). I've only had the issue a few times, but in each case it occurred when I had a large number of open tabs (probably 140 tabs in the most recent case). I've always noticed that minimizing or restoring terminal once I've been running it for a while and have a large number of tabs open is very slow and can cause issues if I get impatient and click the taskbar icon more than once. I've just tried to re-create the problem and had success by simply opening a large number of Windows command prompt tabs and rapidly clicking the Terminal icon on the taskbar a few times. The first time I deliberately triggered the issue I had opened 132 tabs. I closed the program and tried to replicate the issue with fewer open tabs. With just over 40 open tabs I couldn't trigger the issue, so I opened a few more and tried again - this time with just over 60 open tabs a few rapid clicks on the taskbar icon instantly triggered the issue. Hopefully someone can use this information to replicate the issue and fix the problem, because losing over a hundred open tabs is not fun at all!
Author
Owner

@Candles commented on GitHub (Oct 6, 2025):

Good news for the people encountering this issue (@xpalidotious et al.), I've found that if you manage to highlight anything in Windows Terminal with the mouse while this is happening, it'll stop it without having to close the window entirely. I did it by accident a few months ago, and then when I ran into the issue just now I tried it again (by frantically clicking and dragging around in the terminal until it highlighted something) and it worked. It's still an annoyance, but now it's merely a small annoyance instead of a major workflow disruptor.

@Candles commented on GitHub (Oct 6, 2025): Good news for the people encountering this issue (@xpalidotious et al.), I've found that if you manage to highlight anything in Windows Terminal with the mouse while this is happening, it'll stop it without having to close the window entirely. I did it by accident a few months ago, and then when I ran into the issue just now I tried it again (by frantically clicking and dragging around in the terminal until it highlighted something) and it worked. It's still an annoyance, but now it's merely a small annoyance instead of a major workflow disruptor.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19799