[PR #2665] Immediately flush a frame when we encounter a string we don't understand #25028

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

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

State: closed
Merged: No


Summary of the Pull Request

Whenever conpty encounters a VT sequence it doesn't understand, we'll make sure to flush the current frame before writing that string through to the connected terminal application.

References

This might have some long-term consequences for #1173. IIRC I wrote some code that was fairly similar for passthrough mode. This might be a subset of that code.

PR Checklist

  • Closes Bug Report (#2011)
  • I work here
  • Tests added/passed
  • [n/a] Requires documentation to be updated

Detailed Description of the Pull Request / Additional comments

We need to do this because some VT sequences might be dependent upon state that's currently buffered in the frame. So we'll flush the frame so the terminal also has that state, then we'll write the sequence we didn't understand/wanted to passthrough.

Validation Steps Performed

While testing this might be a bit trickier, I wrote a test script that changes the cursor color, in the middle of a big block of text. Changing the cursor color is a VT sequence we passthrough always. Before the change, the cursor color sequence would always appear before any of the related text. After the change, the text before the color sequence is always emitted before the sequence, and the text after the sequence is always emitted after.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/2665 **State:** closed **Merged:** No --- <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Whenever conpty encounters a VT sequence it doesn't understand, we'll make sure to flush the current frame before writing that string through to the connected terminal application. <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References This might have some long-term consequences for #1173. IIRC I wrote some code that was fairly similar for passthrough mode. This might be a subset of that code. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #2011 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments We need to do this because some VT sequences might be dependent upon state that's currently buffered in the frame. So we'll flush the frame so the terminal also has that state, then we'll write the sequence we didn't understand/wanted to passthrough. <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed While testing this might be a bit trickier, I wrote a test script that changes the cursor color, in the middle of a big block of text. Changing the cursor color is a VT sequence we passthrough always. Before the change, the cursor color sequence would always appear _before_ any of the related text. After the change, the text before the color sequence is always emitted before the sequence, and the text after the sequence is always emitted after.
claunia added the pull-request label 2026-01-31 09:06:48 +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#25028