Bug: When headless, GetLargestConsoleWindowSize reports a MUCH too small size #3811

Open
opened 2026-01-30 23:30:40 +00:00 by claunia · 4 comments
Owner

Originally created by @jazzdelightsme on GitHub (Sep 10, 2019).

Environment

ssh client: recent internal build of Windows
ssh server: recent internal build of Windows (WCOS)
vim: custom build that can load on the server

In a headless pseudoconsole session (such as over ssh), GetLargestConsoleWindowSize is reporting a maximum possible window size of 640 columns and 18 rows (on my particular SKU of Windows, which might differ from others). 640 columns isn't bad, I suppose, but 18 rows is downright tiny. I debugged a bit and found that internally (in conhost) this is due to a "screen" size in pixels of 640x300, and a font size of {1, 16}. (Of course there is not really a screen or pixels in a headless scenario, and that font size seems strange.)

Over ssh, I believe the console does not have any way to determine the ssh client's maximum possible window size (it doesn't know the size of the monitor the client is using, or the font being used, or even if it's a windows machine). It can be notified of window size changes on the client side (section 6.7: "Window Dimension Change Message" of RFC 4254), but not what the max possible size is. (Although I know very little about ssh; it's possible there's some extension or convention or something.)

So I propose that since there is no monitor hooked up to a headless session, GetLargestConsoleWindowSize should just report { SHRT_MAX, SHRT_MAX } (and let the client deal with whatever happens if the client sets the console's size too big).

(Without this, vim running in an ssh session is stuck at 18 lines high and cannot be made any bigger.)

Originally created by @jazzdelightsme on GitHub (Sep 10, 2019). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none ssh client: recent internal build of Windows ssh server: recent internal build of Windows (WCOS) vim: custom build that can load on the server ``` In a headless pseudoconsole session (such as over ssh), `GetLargestConsoleWindowSize` is reporting a maximum possible window size of 640 columns and 18 rows (on my particular SKU of Windows, which might differ from others). 640 columns isn't bad, I suppose, but 18 rows is downright *tiny*. I debugged a bit and found that internally (in conhost) this is due to a "screen" size in pixels of 640x300, and a font size of {1, 16}. (Of course there is not really a screen or pixels in a headless scenario, and that font size seems strange.) Over ssh, I believe the console does not have any way to determine the ssh client's maximum possible window size (it doesn't know the size of the monitor the client is using, or the font being used, or even if it's a windows machine). It can be notified of window size changes on the client side (section 6.7: "Window Dimension Change Message" of RFC 4254), but not what the max possible size is. (Although I know very little about ssh; it's possible there's some extension or convention or something.) So I propose that since there is no monitor hooked up to a headless session, `GetLargestConsoleWindowSize` should just report `{ SHRT_MAX, SHRT_MAX }` (and let the client deal with whatever happens if the client sets the console's size too big). (Without this, vim running in an ssh session is stuck at 18 lines high and cannot be made any bigger.)
claunia added the Help WantedIssue-BugArea-ServerProduct-ConptyPriority-2 labels 2026-01-30 23:30:40 +00:00
Author
Owner

@jazzdelightsme commented on GitHub (Sep 10, 2019):

An alternate idea (floated by DHowett on an email) would be to limit GetLargestConsoleWindowSize to reporting just the values the pseudoconsole caller provides in Resize or on initialization so the connected client application never tries to break out.

The problem with that, as noted by DHowett, is "VT applications are allowed to resize their terminals..."

What that would mean for vim over sssh, for example, is that if you wanted to grow it (":set lines="), you'd have to exit vim, resize your console, then re-launch vim. But at least that would work.

@jazzdelightsme commented on GitHub (Sep 10, 2019): An alternate idea (floated by DHowett on an email) would be to limit `GetLargestConsoleWindowSize` to reporting just the values the pseudoconsole caller provides in Resize or on initialization so the connected client application never tries to break out. The problem with that, as noted by DHowett, is "VT applications _are_ allowed to resize their terminals..." What that would mean for vim over sssh, for example, is that if you wanted to grow it (":set lines=<more>"), you'd have to exit vim, resize your console, then re-launch vim. But at least that would work.
Author
Owner

@DHowett-MSFT commented on GitHub (Sep 14, 2019):

I'm tagging this one up, but leaving Triage on so we discuss it on Monday. 😄

@DHowett-MSFT commented on GitHub (Sep 14, 2019): I'm tagging this one up, but leaving Triage on so we discuss it on Monday. :smile:
Author
Owner

@DHowett-MSFT commented on GitHub (Sep 16, 2019):

Current thoughts: for pseudoconsole hosts only, we can return {SHRT_MAX, SHRT_MAX} through the service locator. If not the service locator, all the API methods in "getset". We can't necessarily use the pty-requested size as the "maximum" because a few other console APIs that resize the buffer use ...Largest... as a bounds check.

@DHowett-MSFT commented on GitHub (Sep 16, 2019): Current thoughts: _for pseudoconsole hosts only_, we can return `{SHRT_MAX, SHRT_MAX}` through the service locator. If not the service locator, all the API methods in "getset". We can't necessarily use the pty-requested size as the "maximum" because a few other console APIs that resize the buffer use ...Largest... as a bounds check.
Author
Owner

@zadjii-msft commented on GitHub (Sep 16, 2019):

Functions in discussion:

ApiRoutines::GetLargestConsoleWindowSizeImpl
SCREEN_INFORMATION::GetLargestWindowSizeInCharacters
IWindowMetrics::GetMaxClientRectInPixels
@zadjii-msft commented on GitHub (Sep 16, 2019): Functions in discussion: ```c++ ApiRoutines::GetLargestConsoleWindowSizeImpl SCREEN_INFORMATION::GetLargestWindowSizeInCharacters IWindowMetrics::GetMaxClientRectInPixels ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3811