发布

  • fix(core): strip terminal query sequences when replaying task output (#36432)

    frostbyte_neo 发布于 2026-07-21 22:37:22 +00:00

    Current Behavior

    When a task's captured pty output is replayed (TUI summary, static
    terminal output, cache replays), any terminal query escape sequences
    the child emitted are written to the real terminal verbatim. The
    terminal dutifully replies on stdin — but by then nx has restored cooked
    mode and nothing is consuming replies, so the reply gets echoed into the
    visible output as garbage next to the run summary, e.g.:

    > nvim
    
    ^[[?62;22;52c
     NX   Successfully ran target edit for project @nx/nx-source (3m)
    

    ESC[?62;22;52c is the terminal's Primary Device Attributes reply to
    the ESC[c probe nvim sends at startup. The existing passthrough filter
    only handles one such sequence (ESC[6n), fixing a single symptom
    rather than the class.

    Expected Behavior

    Replayed output is a recording — no process is waiting for the
    terminal's answers anymore, so reply-eliciting sequences are stripped
    before the replay is written. A new stripTerminalQueries() helper
    removes:

    • DA1/DA2/DA3 device attribute queries (CSI c, CSI > c, CSI = c) —
      replies (CSI ? … c) are intentionally preserved
    • DSR status/cursor reports (CSI 5 n, CSI 6 n, CSI ? Ps n)
    • XTVERSION (CSI > q) and DECRQM mode queries (CSI ? Ps $ p)
    • kitty keyboard protocol query (CSI ? u)
    • XTWINOPS report requests (CSI 14 t, CSI 18 t, …) while preserving
      non-reporting window ops
    • OSC color/clipboard queries (OSC 10;?, OSC 52;c;?, …) while
      preserving OSC sets like window titles
    • XTGETTCAP / DECRQSS (DCS + q … ST, DCS $ q … ST)

    The strip is applied in output.logCommandOutput, which every replay
    path (tui-summary, static run-one/run-many, empty, invoke-runner life
    cycles) funnels through. Live pty passthrough is untouched: while a task
    runs, queries must reach the real terminal and the replies are consumed
    in raw mode.

    Related Issue(s)

    N/A — reported while testing #36322 locally; reproduced on stock nx
    22.4.1, pre-existing and unrelated to that PR.


    View session information

    下载附件