Skip to content

Terminal: feed raw bytes to the parser so C1/OSC control sequences (stray '0;') stop leaking #34

Description

@bedro96

What to build

Control sequences still leak as visible text — most visibly a stray 0; (and window-title / color payloads) printed at the start of prompt lines when running the GitHub Copilot CLI and other apps.

Root cause to address: the SSH read path decodes bytes to a UTF-8 String before the ANSI parser runs. Raw 8-bit C1 control bytes (OSC introducer 0x9D, CSI 0x9B, ST 0x9C, DCS 0x90, etc.) are not valid standalone UTF-8 and get turned into replacement characters by the decoder, so the parser never recognizes them and the payload (0;title, color specs) prints as text. The 7-bit ESC ] path is consumed, but the byte-level forms are lost.

Fix: feed raw bytes to the terminal parser (do the UTF-8 decoding for display inside the parser/emulator, where control bytes have already been handled), and ensure OSC (title 0;/2;, color set/query 4;/10;/11;) and other string sequences (DCS/PM/APC/SOS) are fully consumed for both 7-bit and 8-bit forms and across chunk boundaries.

Acceptance criteria

  • Remote output is delivered to the parser as raw bytes, not a pre-decoded UTF-8 String.
  • 0; / window-title OSC never appears as visible text (7-bit ESC ] and 8-bit 0x9D forms, BEL- or ST-terminated).
  • OSC color set/query payloads (10;?, 11;#RRGGBB, 4;n;?) and DCS/PM/APC/SOS strings are consumed, not printed.
  • Correct behavior when a sequence is split across read chunks at any offset.
  • Multibyte UTF-8 text (e.g. Korean) still renders correctly through the raw-byte path.
  • Unit tests cover the byte-level C1 forms and the split-chunk cases using the exact leaking fragments.

Blocked by

None - can start immediately.

Agent workflow

Work test-first (/tdd): reproduce the 0; leak as a failing byte-level test, switch the read path to raw bytes, and iterate (/fleet) until no fragments leak and Korean/UTF-8 still renders. Validate with ./run-tests.sh. Do not release/build the APK from untested code.

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions