Avoid window events during ASB by lhecker · Pull Request #20617 · microsoft/terminal · GitHub
Skip to content

Avoid window events during ASB - #20617

Open
Leonard Hecker (lhecker) wants to merge 3 commits into
mainfrom
dev/lhecker/asb-window-event
Open

Avoid window events during ASB#20617
Leonard Hecker (lhecker) wants to merge 3 commits into
mainfrom
dev/lhecker/asb-window-event

Conversation

@lhecker

@lhecker Leonard Hecker (lhecker) commented Aug 27, 2026

Copy link
Copy Markdown
Member

Important context: To make a window smaller programmatically,
the win32 console APIs have since forever required you to

  • narrow the viewport
  • then narrow the buffer

To make the window larger you had to

  • enlarge the buffer
  • then enlarge the viewport

This is because a viewport had to fit into the buffer and vice versa.
ConEmu was very popular in the past and used this to implement proper
terminals around conhost. When WSL came along this resulted in a
problem: It wants SIGWINCH-style notifications. And there are none
on Windows. A long time ago, a hack was introduced that simply
raised buffer size events on any viewport size changes.

The problem: It was raised for any viewport size changes.
And it was also raised for ASB switching.

Problema numero due: OpenSSH for WIndows is like WSL, but it has a
severe bug: A SIGWINCH during a partial input read will corrupt the
read and the other side will read either garbage or duplicate input.

Well, we can fix that by just not raising buffer size events.
It's very dangerous, because it may easily regress ConEmu (etc.).

See: PowerShell/Win32-OpenSSH#2275

Also: Fun fact, we've been ignoring ENABLE_WINDOW_INPUT
since Windows 1607! No way fixing this breaks anything! /s

So, this PR introduces two regressions:

  • ENABLE_WINDOW_INPUT is being respected again
  • WINDOW_BUFFER_SIZE_EVENT is not sent anymore
    when the viewport changes if VT mode disabled

Changes:

  • Reintroduce support for ENABLE_WINDOW_INPUT
  • Coalesce buffer size events
  • Avoid such events when switching ASB on/off
  • Ensure we reliably raise the events for viewport size changes

This is part of #281.

Validation Steps Performed

  • Spawn OpenConsole
  • Run ConEmuC64.exe -AUTOATTACH -GHWND=NEW
  • Run wsl -- bash
  • Run while stty size; do read -rt .05 ||:; done
  • Narrowing the window reduces the WSL width ✅
  • Widening the window increases the WSL width ✅

Comment thread src/host/screenInfo.cpp Outdated
@lhecker Leonard Hecker (lhecker) added Product-Conhost For issues in the Console codebase Product-Conpty For console issues specifically related to conpty Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) labels Aug 27, 2026
Comment on lines -656 to -657

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last famous words.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Server Down in the muck of API call servicing, interprocess communication, eventing, etc. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Conhost For issues in the Console codebase Product-Conpty For console issues specifically related to conpty

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants