Skip to content

Commit af9cc5b

Browse files
committed
fix(cli): adopt DA1 sandwich technique for robust OSC color query detection (#986)
Replace ad-hoc environment checks (CI, Warp, tmux, Docker) with a comprehensive `is_osc_query_unsupported()` pre-screen modelled after `terminal-colorsaurus`, and implement the DA1 sandwich technique to detect unsupported terminals at runtime without waiting for timeouts. Key changes: - Centralized quirks detection covering CI, Docker, devcontainers, Kubernetes, Emacs, GNU Screen, Eterm, tmux, and TERM=dumb - DA1 sentinel query appended after OSC queries; if its response arrives first the terminal doesn't support OSC and we bail immediately - drain_da1() consumes the trailing DA1 response to prevent leaks - BEL terminator instead of ST to work around urxvt response bug - SSH-aware timeout (1000ms vs 200ms local) - Ported regression test from terminal-colorsaurus issue #38 - Extended test coverage for parsing edge cases Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches low-level `/dev/tty` I/O, raw-mode handling, and timeout/polling logic, so regressions could reintroduce hangs or garbled terminal output in edge-case terminals/environments. > > **Overview** > Makes terminal color detection for the Vite+ CLI header more robust by replacing ad-hoc OSC query handling with a centralized `is_osc_query_unsupported()` pre-screen and a DA1 “sandwich” sentinel to quickly detect terminals that won’t answer OSC color queries. > > Reworks `query_terminal_colors` to send BEL-terminated OSC 10/4 queries plus DA1, parse responses from `/dev/tty` via `BufReader` with delimiter-aware reads, apply SSH-aware timeouts, and drain DA1/CSI output to prevent escape-sequence leakage; adds extensive unit tests covering hex/RGB parsing edge cases, BEL termination, stream parsing helpers, and a non-hanging regression test. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 2ca0070. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent e3607ec commit af9cc5b

1 file changed

Lines changed: 414 additions & 70 deletions

File tree

0 commit comments

Comments
 (0)