Skip to content

Resolve issue where first input gets ignored on new conpty with a ding sound#271556

Merged
anthonykim1 merged 10 commits intomainfrom
anthonykim1/FixConptyFirstInputGettingIgnored
Oct 19, 2025
Merged

Resolve issue where first input gets ignored on new conpty with a ding sound#271556
anthonykim1 merged 10 commits intomainfrom
anthonykim1/FixConptyFirstInputGettingIgnored

Conversation

@anthonykim1
Copy link
Contributor

@anthonykim1 anthonykim1 commented Oct 15, 2025

Resolves: #243584

Updated summary:
There were two request I think in \e[6n\e[c.
We were sending \e[?61;4c\e[2;1R, which is wrong.
The one ending with 4c, was supposed to come later.

Because the order was wrong, ConPTY "ate" the first input from user thinking that must've been the response to their cursor position request, and made a ding sound because it was invalid.

@anthonykim1 anthonykim1 self-assigned this Oct 15, 2025
@anthonykim1 anthonykim1 added this to the October 2025 milestone Oct 15, 2025
@anthonykim1 anthonykim1 requested a review from Tyriar October 15, 2025 18:11
@anthonykim1
Copy link
Contributor Author

I see pauseInputBarrier was introduced here: https://github.com/microsoft/vscode/pull/225336/files but I don't think its being used there anymore.


this._register(this._processManager.onProcessData(e => this._onProcessData(e)));
this._register(xterm.raw.onData(async data => {
await this._pauseInputEventBarrier?.wait();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the approach is we remove the wait from onData and explicitly put this._processManager.write('\x1b[?61;4c');. I'm thinking this would allow this._processManager.write('\x1b[?61;4c'); to be sent later.

@anthonykim1 anthonykim1 requested a review from Tyriar October 16, 2025 22:30
@anthonykim1 anthonykim1 marked this pull request as ready for review October 16, 2025 22:30
@anthonykim1 anthonykim1 requested review from Copilot and removed request for Copilot October 16, 2025 22:30
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Forgot to submit the review 🤦

Comment on lines 856 to 858
queueMicrotask(() => {
this._processManager.write('\x1b[?61;4c');
});
Copy link
Member

Choose a reason for hiding this comment

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

Instead of this, a method for the onData listener and have this call that would be better. That will also mean that we get logs in the Terminal channel for this (one of the reasons it was hard to debug), and any future changes to that listener will also behave properly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good!
Do you like the name _sendDataToProcess or should it be _writeDataToProcess? c53bef2

Copy link
Member

Choose a reason for hiding this comment

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

_handleOnData is what I'd probably have gone with, but these are fine names too.

@anthonykim1 anthonykim1 marked this pull request as draft October 19, 2025 00:34
@anthonykim1 anthonykim1 marked this pull request as ready for review October 19, 2025 00:41
Copilot AI review requested due to automatic review settings October 19, 2025 00:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Fixes incorrect ordering of terminal negotiation sequences that caused ConPTY to misinterpret the user's first input as a cursor position response and emit a bell.

  • Removes the pauseInputEvents barrier mechanism and introduces a helper _sendDataToProcess for consistent write + event firing.
  • Refactors CSI handler for final 'c' to use the new helper when responding with ESC [?61;4c.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/vs/workbench/contrib/terminal/browser/terminalInstance.ts Removes pause input barrier, adds _sendDataToProcess, and changes CSI 'c' handler logic to use it.
src/vs/workbench/contrib/terminal/browser/terminal.ts Updates ITerminalInstance interface by removing pauseInputEvents API no longer used.

@anthonykim1 anthonykim1 requested a review from Tyriar October 19, 2025 00:44
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Just the async thing needs to change

@anthonykim1 anthonykim1 requested a review from Tyriar October 19, 2025 00:59
@anthonykim1 anthonykim1 merged commit 6068612 into main Oct 19, 2025
28 checks passed
@anthonykim1 anthonykim1 deleted the anthonykim1/FixConptyFirstInputGettingIgnored branch October 19, 2025 05:02
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

First input gets ignored on pwsh/conpty

3 participants