[PR #17786] Improve reliability of VT responses #31371

Open
opened 2026-01-31 09:46:50 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/17786

State: closed
Merged: Yes


  • Repurposes _sendInputToConnection to send output to the connection
    no matter whether the terminal is read-only or not.
    Now SendInput is the function responsible for the UI handling.
  • Buffers responses in a VT string into a single string
    before sending it as a response all at once.

This reduces the chances for the UI thread to insert cursor positions
and similar into the input pipe, because we're not constantly unlocking
the terminal lock anymore for every response. The only way now that
unrelated inputs are inserted into the input pipe is because the VT
requests (e.g. DA1, DSR, etc.) are broken up across >1 reads.

This also fixes VT responses in read-only panes.

Closes #17775

Validation Steps Performed

  • Repeatedly run echo ^[[c in cmd.
    DA1 responses don't stack & always stay the same
  • Run nvim in WSL. Doesn't deadlock when pasting 1MB.
  • Run the repro from #17775, which requests a ton of OSC 4
    (color palette) responses. Jiggle the cursor on top of the window.
    Responses never get split up.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/17786 **State:** closed **Merged:** Yes --- * Repurposes `_sendInputToConnection` to send output to the connection no matter whether the terminal is read-only or not. Now `SendInput` is the function responsible for the UI handling. * Buffers responses in a VT string into a single string before sending it as a response all at once. This reduces the chances for the UI thread to insert cursor positions and similar into the input pipe, because we're not constantly unlocking the terminal lock anymore for every response. The only way now that unrelated inputs are inserted into the input pipe is because the VT requests (e.g. DA1, DSR, etc.) are broken up across >1 reads. This also fixes VT responses in read-only panes. Closes #17775 ## Validation Steps Performed * Repeatedly run `echo ^[[c` in cmd. DA1 responses don't stack & always stay the same ✅ * Run nvim in WSL. Doesn't deadlock when pasting 1MB. ✅ * Run the repro from #17775, which requests a ton of OSC 4 (color palette) responses. Jiggle the cursor on top of the window. Responses never get split up. ✅
claunia added the pull-request label 2026-01-31 09:46:50 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#31371