OSC escape sequences received out-of-order in 3rd-party terminals #21764

Closed
opened 2026-01-31 07:54:16 +00:00 by claunia · 4 comments
Owner

Originally created by @acarl005 on GitHub (May 23, 2024).

Windows Terminal version

1.19.11213.0

Windows build number

10.0.22631.0

Other Software

No response

Steps to reproduce

ANSI compatibility has been pretty good in ConPTY. We're coming up on some niche cases.

In a 3rd-party terminal, e.g. alacritty, produce some text with an OSC escape sequence interleaved between some text.

PowerShell 7.4.2
PS> echo "hello `e]2;new title`a world"
hello  world

Visually, things look pretty OK. The correct text is echo'd and the title is changed.

Screenshot 2024-05-23 195707

But, here is the exact data that alacritty read out of ConPTY:


hello  world
PS> ESC]0;new titleBEL

Observe that when the text was produced in the shell, the OSC command to set title was between "hello" and "world". However, when the text was read out of ConPTY by the terminal, the ordering is changed.

Expected Behavior

I expect the ordering of text, including the ANSI escape sequences, to be preserved.

Actual Behavior

ANSI escape sequences are being parsed and re-serialized in a "lossy" way. While this may be necessary when a Windows Terminal is involved, it isn't when the terminal application only receives ANSI sequences. That is, there is no need to try to parse the ANSI. ConPTY does still need to convert console API calls coming from Windows command-line apps, but plain ANSI text doesn't need any conversion.

Originally created by @acarl005 on GitHub (May 23, 2024). ### Windows Terminal version 1.19.11213.0 ### Windows build number 10.0.22631.0 ### Other Software _No response_ ### Steps to reproduce ANSI compatibility has been pretty good in ConPTY. We're coming up on some niche cases. In a 3rd-party terminal, e.g. alacritty, produce some text with an OSC escape sequence _interleaved_ between some text. ``` PowerShell 7.4.2 PS> echo "hello `e]2;new title`a world" hello world ``` Visually, things look pretty OK. The correct text is echo'd and the title is changed. ![Screenshot 2024-05-23 195707](https://github.com/microsoft/terminal/assets/8334252/55ecf7a0-4559-474c-b9ed-a8625c4f0fd0) But, here is the exact data that alacritty read out of ConPTY: ``` hello world PS> ESC]0;new titleBEL ``` Observe that when the text was produced in the shell, the OSC command to set title was between "hello" and "world". However, when the text was read out of ConPTY by the terminal, the ordering is changed. ### Expected Behavior I expect the ordering of text, including the ANSI escape sequences, to be preserved. ### Actual Behavior ANSI escape sequences are being parsed and re-serialized in a "lossy" way. While this may be necessary when a Windows Terminal is involved, it isn't when the terminal application only receives ANSI sequences. That is, there is no need to try to parse the ANSI. ConPTY does still need to convert console API calls coming from Windows command-line apps, but plain ANSI text doesn't need any conversion.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 07:54:16 +00:00
Author
Owner

@github-actions[bot] commented on GitHub (May 23, 2024):

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@github-actions[bot] commented on GitHub (May 23, 2024): Hi I'm an AI powered bot that finds similar issues based off the issue title. Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you! ### Open similar issues: - [terminal/parser: determine what to do when split escape sequence writes show up (#4037)](https://github.com/microsoft/terminal/issues/4037), similarity score: 0.75 ### Closed similar issues: - [ConPTY flush unknown CSI sequences too early (#15230)](https://github.com/microsoft/terminal/issues/15230), similarity score: 0.77 - [Some ANSI sequences (including "inert" ones) are not output as-is (#10072)](https://github.com/microsoft/terminal/issues/10072), similarity score: 0.77 - [Bug Report: What is reordering VT escape sequences in my string? (#2011)](https://github.com/microsoft/terminal/issues/2011), similarity score: 0.77 - [OSC sequences in prompt get front loaded (#11220)](https://github.com/microsoft/terminal/issues/11220), similarity score: 0.77 > Note: You can give me feedback by thumbs upping or thumbs downing this comment.
Author
Owner

@j4james commented on GitHub (May 25, 2024):

This is essentially a duplicate of #8698, and is probably not generically solvable without passing through the ANSI sequences directly, as you're proposing. That's tracked in #1173.

@j4james commented on GitHub (May 25, 2024): This is essentially a duplicate of #8698, and is probably not generically solvable without passing through the ANSI sequences directly, as you're proposing. That's tracked in #1173.
Author
Owner

@carlos-zamora commented on GitHub (May 29, 2024):

Thanks for filing! We're going to mark this as a /dup of #8698 then 😊

@carlos-zamora commented on GitHub (May 29, 2024): Thanks for filing! We're going to mark this as a /dup of #8698 then 😊
Author
Owner

@microsoft-github-policy-service[bot] commented on GitHub (May 29, 2024):

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service[bot] commented on GitHub (May 29, 2024): Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! <!-- Policy app identification https://img.shields.io/static/v1?label=PullRequestIssueManagement. -->
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21764