Document the resize quirk for ConPTY #21427

Closed
opened 2026-01-31 07:44:24 +00:00 by claunia · 6 comments
Owner

Originally created by @Unit2795 on GitHub (Mar 21, 2024).

Description of the new feature/enhancement

When I issue a ResizePseudoConsole call, if the buffer is changing from a smaller size to a larger one, ConPTY outputs the reflowed buffer and overwrites any content currently in the terminal. If there were 50 lines of output, the buffer size was 24 lines, and I resize to 30 lines, the output will be overwritten with 24 lines. (The amount of content in the buffer at the time of the resize).

Proposed technical implementation details

Possible Solutions:

  1. Add the ability to disable the automatic output of the reflowed buffer
  2. Add ability to specify differing buffer and window sizes for ConPTY, such that the window size will ensure VT sequences are emitted in sync with the terminal ConPTY may be connected to and therefore output looks visually correct. While also allowing a scrollback buffer to be maintained and reflowed as needed.
    • Example Pseudocode:

      CreatePseudoConsole(windowSize, bufferSize, hInput, hOutput, dwFlags, phPC)
      

Related

Originally created by @Unit2795 on GitHub (Mar 21, 2024). # Description of the new feature/enhancement When I issue a [ResizePseudoConsole](https://learn.microsoft.com/en-us/windows/console/resizepseudoconsole) call, if the buffer is changing from a smaller size to a larger one, ConPTY outputs the reflowed buffer and overwrites any content currently in the terminal. If there were 50 lines of output, the buffer size was 24 lines, and I resize to 30 lines, the output will be overwritten with 24 lines. (The amount of content in the buffer at the time of the resize). # Proposed technical implementation details Possible Solutions: 1. Add the ability to disable the automatic output of the reflowed buffer 2. Add ability to specify differing buffer and window sizes for ConPTY, such that the window size will ensure VT sequences are emitted in sync with the terminal ConPTY may be connected to and therefore output looks visually correct. While also allowing a scrollback buffer to be maintained and reflowed as needed. - Example Pseudocode: ``` CreatePseudoConsole(windowSize, bufferSize, hInput, hOutput, dwFlags, phPC) ``` # Related - https://github.com/microsoft/terminal/issues/5800 - https://github.com/wez/wezterm/issues/1265 - https://github.com/microsoft/terminal/issues/14291
claunia added the Issue-TaskIn-PRNeeds-Tag-FixProduct-Conpty labels 2026-01-31 07:44:25 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Mar 22, 2024):

in lieu of a longer, more thorough response:

That's in the OpenConsole version of conpty. I forget if we shipped that to the OS conpty. We never really documented it cause it felt like a hack at the time, but we've been using for a few years now. Also I think we assumed that a caller who passed that would need to reflow their own buffer in the exact same way, to keep things in sync.

But that might be helpful to experiment with?

@zadjii-msft commented on GitHub (Mar 22, 2024): in lieu of a longer, more thorough response: * https://github.com/microsoft/terminal/blob/5b8e731e5d64eafc1df5bd0467d4df82028fd13a/src/cascadia/TerminalConnection/ConptyConnection.cpp#L323 * https://github.com/microsoft/terminal/blob/5b8e731e5d64eafc1df5bd0467d4df82028fd13a/src/inc/conpty-static.h#L26 * https://github.com/microsoft/terminal/blob/5b8e731e5d64eafc1df5bd0467d4df82028fd13a/src/winconpty/winconpty.cpp#L140-L147 That's in the OpenConsole version of conpty. I forget if we shipped that to the OS conpty. We never really documented it cause it felt like a hack at the time, but we've been using for a few years now. Also I think we assumed that a caller who passed that would need to reflow their own buffer in the exact same way, to keep things in sync. But that might be helpful to experiment with?
Author
Owner

@Unit2795 commented on GitHub (Mar 22, 2024):

I saw this flag mentioned in another issue (I can't recall which one). I gave it a try but it had no effect, it doesn't appear to be in my OS version. I'll research obtaining the openconsole version. If I can get the resize quirk working I will just have to do my own reflow. My library shows a terminal quite a while after ConPTY has begun producing output, so I have to reflow my own buffer contents. Perhaps I could mimic the reflow capability from this repo's TextBuffer::Reflow?

@Unit2795 commented on GitHub (Mar 22, 2024): I saw this flag mentioned in another issue (I can't recall which one). I gave it a try but it had no effect, it doesn't appear to be in my OS version. I'll research obtaining the openconsole version. If I can get the resize quirk working I will just have to do my own reflow. My library shows a terminal quite a while after ConPTY has begun producing output, so I have to reflow my own buffer contents. Perhaps I could mimic the reflow capability from this repo's `TextBuffer::Reflow`?
Author
Owner

@Unit2795 commented on GitHub (Mar 25, 2024):

For anyone who may be curious, I managed to obtain the ConPTY.dll and OpenConsole.exe prebuilt from this link (https://dev.azure.com/ms/terminal/_build?definitionId=136&branchFilter=26987%2C26987%2C26987%2C26987) by finding the latest build for the main branch, then found the Build x64 stage's build-x64-Release.zip artifact and downloaded it.

2024-03-25_02-07-35
2024-03-25_02-07-57
2024-03-25_02-08-56

@Unit2795 commented on GitHub (Mar 25, 2024): For anyone who may be curious, I managed to obtain the ConPTY.dll and OpenConsole.exe prebuilt from this link (https://dev.azure.com/ms/terminal/_build?definitionId=136&branchFilter=26987%2C26987%2C26987%2C26987) by finding the latest build for the main branch, then found the Build x64 stage's build-x64-Release.zip artifact and downloaded it. ![2024-03-25_02-07-35](https://github.com/microsoft/terminal/assets/25918877/18ffadba-0922-4ff3-af19-17b60aaee1d3) ![2024-03-25_02-07-57](https://github.com/microsoft/terminal/assets/25918877/866409e4-53d2-4514-985f-ba8ceb43ec8d) ![2024-03-25_02-08-56](https://github.com/microsoft/terminal/assets/25918877/532fc457-2e98-4353-9264-7926d938effe)
Author
Owner

@Unit2795 commented on GitHub (Mar 27, 2024):

After downloading the latest ConPTY.dll, PSEUDOCONSOLE_RESIZE_QUIRK did work. Thank you for pointing this out @zadjii-msft . I've since adjusted this issue to remove the request for disabling reflow output. I did add another request for a possible plain-text render feature as it seemed like it could be related to my request for programmatic reflow. If I need to break that out into another issue I can do that.

@Unit2795 commented on GitHub (Mar 27, 2024): After downloading the latest ConPTY.dll, PSEUDOCONSOLE_RESIZE_QUIRK did work. Thank you for pointing this out @zadjii-msft . I've since adjusted this issue to remove the request for disabling reflow output. I did add another request for a possible plain-text render feature as it seemed like it could be related to my request for programmatic reflow. If I need to break that out into another issue I can do that.
Author
Owner

@zadjii-msft commented on GitHub (Mar 27, 2024):

Okay, thanks for trying that out! I'd also caution - it's called the "quirk" because it's expecting the hosting terminal application to be able to reflow their own buffer in the same way conpty does. No one else has really tried that out, so do send feedback if you collect any.

For now, I'm gonna convert this issue into "document and ship this". Thanks!

(also linked up to #15065 which is what we're using for actually shipping conpty)

@zadjii-msft commented on GitHub (Mar 27, 2024): Okay, thanks for trying that out! I'd also caution - it's called the "quirk" because it's expecting the hosting terminal application to be able to reflow their own buffer in the same way conpty does. No one else has really tried that out, so do send feedback if you collect any. For now, I'm gonna convert this issue into "document and ship this". Thanks! (also linked up to #15065 which is what we're using for actually shipping conpty)
Author
Owner

@Unit2795 commented on GitHub (Apr 1, 2024):

Since this is now serving as the issue for documenting the resize quirk, I've moved the request for programmatic reflow and plain-text rendering to this issue:

@Unit2795 commented on GitHub (Apr 1, 2024): Since this is now serving as the issue for documenting the resize quirk, I've moved the request for programmatic reflow and plain-text rendering to this issue: - https://github.com/microsoft/terminal/issues/16985
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21427