DCS sequences split across multiple "packets" can be corrupted by conpty #21573

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

Originally created by @j4james on GitHub (Apr 24, 2024).

Windows Terminal version

1.20.10822.0

Windows build number

10.0.19045.4291

Other Software

No response

Steps to reproduce

Run the following python script:

import sys
import time

sys.stdout.write('\033[37;40m\033[2J')
sys.stdout.write('\033P2$p0;2;50;0;0/')
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('0;2;0;0;0\033\\')

Expected Behavior

It should clear the screen and briefly make the background color red. It works as expected in OpenConsole.

Actual Behavior

In Windows Terminal, the background is left permanently red, and you can see the second half of the DCS sequence output on the screen: 0;2;0;0;0.

Looking at the debug tap, it appears that conpty is inserting an SGR reset sequence in the middle of the DCS stream (where the script sleeps for a bit). This seems similar to issue #16079, but that test case is now working correctly on the main branch, while this is still broken.

I haven't had a chance to git bisect it, so I'm not sure if it's a regression, but I wouldn't be surprised if it was always broken in some way (although possibly not obviously so). There may also be an element of timing involved, but I can reproduce the problem consistently with the script above.

Originally created by @j4james on GitHub (Apr 24, 2024). ### Windows Terminal version 1.20.10822.0 ### Windows build number 10.0.19045.4291 ### Other Software _No response_ ### Steps to reproduce Run the following python script: ```py import sys import time sys.stdout.write('\033[37;40m\033[2J') sys.stdout.write('\033P2$p0;2;50;0;0/') sys.stdout.flush() time.sleep(0.1) sys.stdout.write('0;2;0;0;0\033\\') ``` ### Expected Behavior It should clear the screen and briefly make the background color red. It works as expected in OpenConsole. ### Actual Behavior In Windows Terminal, the background is left permanently red, and you can see the second half of the DCS sequence output on the screen: `0;2;0;0;0`. Looking at the debug tap, it appears that conpty is inserting an SGR reset sequence in the middle of the DCS stream (where the script sleeps for a bit). This seems similar to issue #16079, but that test case is now working correctly on the main branch, while this is still broken. I haven't had a chance to git bisect it, so I'm not sure if it's a regression, but I wouldn't be surprised if it was always broken in some way (although possibly not obviously so). There may also be an element of timing involved, but I can reproduce the problem consistently with the script above.
claunia added the Issue-BugArea-VTNeeds-Tag-FixProduct-Conpty labels 2026-01-31 07:48:31 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21573