Forward SOS/PM/APC strings verbatim on the ConPTY input path #20953
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #20953"
general
weight: 0.35
DHowett
Fixes #20952.
Summary
Problem. ConPTY's input path forwards DCS strings verbatim (SIXEL, tmux
DCS tmux;payloads) via the_expectingStringTerminator→FlushToTerminal→ActionPassThroughStringmechanism, and since the VtEngine removal the output path relays the client's raw byte stream including every image-protocol escape (#19926 confirmed this for APC).But an APC string (
ESC _ … ESC \) written into the ConPTY input pipe is silently dropped: it shares theSosPmApcStringstate with SOS/PM, whose event handler is_ActionIgnore(), and the accumulated run is discarded when the terminator dispatches. The practical consequence: the kitty graphics protocol's request/response loop cannot work over ConPTY — a program hosted in a pane can emit a graphics request on output (relayed fine), but the terminal's APC acknowledgement (ESC _ i=… ESC \) written back into the ConPTY input never reaches it. Multiplexers and ConPTY hosts that pipe bytes through (tmux-style, rmux, terminal desktops) hit exactly this.Evidence (measured live, Windows 11 build 26200.6584, ConPTY = OpenConsole 1.25.2609.30003 via pywinpty 3.1.0's conpty.dll,
CreatePseudoConsoleflags 0):Output direction (child → ConPTY output pipe, verbatim survival):
| Sequence | Result |
| --- | --- |
| CSI SGR
ESC[31m X ESC[0m| relayed verbatim || SIXEL DCS
ESC P0;1q … ESC \| relayed verbatim || OSC 1337 (iTerm2)
ESC]1337;…BEL| relayed verbatim || APC kitty
ESC_G…ESC \| relayed verbatim || tmux DCS
ESC Ptmux;…ESC \| relayed verbatim |Input direction (parent → ConPTY input pipe → child stdin, raw bytes):
| Sequence | Result |
| --- | --- |
| SIXEL DCS intact | arrives verbatim (26/26 bytes) |
| OSC 1337 intact / split | arrives verbatim |
| tmux DCS wrap | arrives verbatim |
| APC kitty intact | dropped — nothing arrives |
| APC kitty split mid-body | dropped |
| DCS DECRQSS
$q, OSC10;?, CSI DA1 | dropped — host answers them (correct) || CSI SGR as input | dropped — parsed as keys (correct) |
The asymmetry (DCS forwarded, APC dropped; output relays APC, input drops it) is what this PR fixes, by giving SOS/PM/APC the exact treatment DCS already gets. Dropping queries the host answers is correct and untouched.
Design
Mirror the DCS path, no new engine surface:
1.
StateMachine::ProcessCharacter, from-anywhere ESC branch: when the ESC that terminates aSosPmApcStringarrives on the input path (gated on the existing_isEngineForInput), set_pendingSosPmApcFlush.2.
_ActionEscDispatch: if the flag is set and the dispatched escape is the ST (ESC \), flush the pending run verbatim throughFlushToTerminal()(which routes throughActionPassThroughString→InteractDispatch::WriteStringRaw, the same path DCS uses) and suppress the spuriousAlt+\key dispatch. If anything but ST follows, the string was aborted and stays dropped.3. CAN/SUB and
_EnterGroundclear the flag (abort semantics, same as DCS's terminator handling).4. The output engine is untouched:
OutputStateMachineEngine::ActionPassThroughStringremains a no-op, and ConPTY's output side already relays the raw client stream inWriteCharsVT.No opt-in flag is proposed here because the output side already relays these sequences unconditionally — this only makes input consistent with output. (If reviewers prefer an opt-in gate, the natural place is the existing parser
Modeenum; happy to rework.)Tests
New, in
src/terminal/parser/ut_parser/StateMachineTest.cpp(TAEF):InputApcStringFlushedVerbatim— intact kitty-graphics-shaped APC reachesWriteStringRawbyte-identical.InputSosStringFlushedVerbatim— SOS shares the state; same outcome.InputApcStringAbortedByCsiStaysDropped— abort (CSI instead of ST) stays dropped, no flush leak.OutputApcStringNotPassedThrough— output engine unchanged.Verification performed on the contributor's machine
Parser.UnitTests.vcxproj(Debug x64) builds clean; full parser DLL:763/764 passed, 0 failed (the one skip is the pre-existing self-skipped
InputEngineTest::RoundTripTest, TODO GH#4405).Adapter.UnitTests.vcxprojbuilds and runs clean: 413/413.TerminalCoreunit tests could not be built standalone here (Windows SDK retarget required outside the .slnx build); CI covers them.Live end-to-end behavior after a fix lands can be verified with any ConPTY host that writes raw bytes into the input pipe (pywinpty /winpty-rs harnesses) by writing
ESC _ i=… ESC \and observing the child receive it.Limitations
cacheUnusedRunexclusion coversSosPmApcString,DcsPassThrough,DcsIgnorealike). Intact sequences — the common case for terminal-originated ACKs — are fully covered. If reviewers want, caching for the input path can be added for all three states as a follow-up.Upstream context / prior discussion