Skip to content

pty: for console compatibility, clear & home cursor if not inherited - #21026

Merged
Dustin L. Howett (DHowett) merged 2 commits into
mainfrom
dev/duhowett/conpty-compat-bug
Dec 5, 2026
Merged

Dustin L. Howett (DHowett) merged 2 commits into
mainfrom
dev/duhowett/conpty-compat-bug

Conversation

@DHowett

@DHowett Dustin L. Howett (DHowett) commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Old versions of ConPTY used to clear the screen and move the cursor to the top left. Unfortunately, that's still required, but we lost it in the rewrite.

Applications that host console apps may not be prepared to answer a CPR and if they aren't, we need to behave like a good citizen.

We could also make cursor inheritance the default, but since positioning the cursor is blocking we would be adding a 1s delay for all consumers who cannot answer DSR CPR.

Leonard and I hashed this out for quite a while, so in the interest of documenting:

  • ConPTY clears the screen and homes the cursor on startup because it was, originally, notionally similar to opening a new empty console window. Applications which pre-date VT support on Windows may even expect this.
  • We could have made cursor inheritance the default but there was never a guarantee we'd be connected to a terminal which could supply a CPR
  • If we did inherit cursor by default, we would have a non-zero number of applications trying to host processes and hitting the 1s timeout with no way to avoid it
  • If we moved the responsibility for cursor positioning into the PTY consumer with in-proc ConPTY (i.e. sshd), we have the same issues--just, at a different layer. Perhaps it's better for us since that layer is out of our control. But then,
    • sshd would need to request a cursor position from its client, and probably it would need a VT parser to receive it. If instead we added an out of band cursor sync message, existing clients (like the hypothetical ssh 8.3 on Ubuntu 13.04) wouldn't work properly.

Closes MSFT-62634678

Comment thread src/host/VtIo.cpp Fixed
Old versions of ConPTY used to clear the screen and move the cursor to
the top left. Unfortunately, that's still required, but we lost it in
the rewrite.

Applications that host console apps may not be prepared to answer a CPR
and if they aren't, we need to behave like a good citizen.

We could also make cursor inheritance the default, but since positioning
the cursor is blocking we would be adding a 1s delay for _all_ consumers
who cannot answer DSR CPR.
@github-actions

This comment has been minimized.

Comment thread src/host/VtIo.cpp Outdated
Comment on lines +199 to +200
writer.WriteED(DispatchTypes::EraseType::All);
writer.WriteCUP(til::point{});

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.

If we are never gonna use the flexibility here, we could also just...

writer.WriteUTF8("\x1b[2J\x1b[H");

@DHowett
Dustin L. Howett (DHowett) merged commit 74da6b6 into main Dec 5, 2026
29 checks passed
@DHowett
Dustin L. Howett (DHowett) deleted the dev/duhowett/conpty-compat-bug branch December 5, 2026 01:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants