Skip to content

fix(cli): adopt DA1 sandwich technique for robust OSC color query detection#986

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/osc-da1-sandwich
Mar 18, 2026
Merged

fix(cli): adopt DA1 sandwich technique for robust OSC color query detection#986
graphite-app[bot] merged 1 commit intomainfrom
fix/osc-da1-sandwich

Conversation

@Brooooooklyn
Copy link
Copy Markdown
Member

@Brooooooklyn Brooooooklyn commented Mar 17, 2026

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 feat: support vite lint/build/test #38
  • Extended test coverage for parsing edge cases

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com


Note

Medium Risk
Changes low-level /dev/tty I/O and escape-sequence parsing to avoid hangs/leaked output across many terminal environments; mistakes could regress header color detection or terminal interaction timing.

Overview
Makes Vite+ header color probing more robust across terminal emulators and container/CI environments by replacing ad-hoc OSC query handling with a centralized is_osc_query_unsupported() gate plus the DA1 sandwich technique to detect lack of OSC support without waiting for timeouts.

Reworks query_terminal_colors to send BEL-terminated OSC queries (urxvt workaround), parse responses sequentially from the tty stream via BufReader (with a poll-based, deadline-aware reader), and drain trailing DA1 output; also adds SSH-aware timeouts.

Expands unix test coverage for hex/RGB parsing, BEL termination, mixed-response buffers, read_until_either, and includes a regression test ensuring query_terminal_colors doesn’t hang in CI.

Written by Cursor Bugbot for commit a2f3399. This will update automatically on new commits. Configure here.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 17, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit 55642c2
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69ba4dfb13d152000880d647

Copy link
Copy Markdown
Member Author


How to use the Graphite Merge Queue

Add the label auto-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b73c07ccc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ab0d96ca63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn Brooooooklyn force-pushed the fix/osc-da1-sandwich branch from ab0d96c to a855793 Compare March 17, 2026 06:53
@Brooooooklyn Brooooooklyn force-pushed the fix/osc-da1-sandwich branch from a855793 to c8801ed Compare March 17, 2026 07:27
@Brooooooklyn Brooooooklyn force-pushed the fix/osc-da1-sandwich branch from c8801ed to cf721f2 Compare March 17, 2026 08:46
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cf721f232e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn Brooooooklyn force-pushed the fix/osc-da1-sandwich branch from cf721f2 to 3e7fd1a Compare March 17, 2026 08:59
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e7fd1ace0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn Brooooooklyn force-pushed the fix/osc-da1-sandwich branch from 403de46 to f45a3fe Compare March 17, 2026 10:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f45a3fe0c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Brooooooklyn Brooooooklyn force-pushed the fix/osc-da1-sandwich branch from f45a3fe to 2ca0070 Compare March 17, 2026 10:57
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@graphite-app
Copy link
Copy Markdown

graphite-app bot commented Mar 17, 2026

Merge activity

  • Mar 17, 12:51 PM UTC: Brooooooklyn added this pull request to the Graphite merge queue.
  • Mar 17, 1:01 PM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'done', 'CLI E2E test (windows-latest)').
  • Mar 18, 6:16 AM UTC: Brooooooklyn added this pull request to the Graphite merge queue.
  • Mar 18, 6:27 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'done', 'CLI E2E test (macos-latest)').
  • Mar 18, 7:02 AM UTC: Brooooooklyn added this pull request to the Graphite merge queue.
  • Mar 18, 7:11 AM UTC: Merged by the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Mar 17, 2026
…ection (#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 -->
@graphite-app graphite-app bot force-pushed the fix/osc-da1-sandwich branch from 2ca0070 to af9cc5b Compare March 17, 2026 12:52
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a2f33995a3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

graphite-app bot pushed a commit that referenced this pull request Mar 18, 2026
…ection (#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**
> Changes low-level `/dev/tty` I/O and escape-sequence parsing to avoid hangs/leaked output across many terminal environments; mistakes could regress header color detection or terminal interaction timing.
>
> **Overview**
> Makes Vite+ header color probing **more robust across terminal emulators and container/CI environments** by replacing ad-hoc OSC query handling with a centralized `is_osc_query_unsupported()` gate plus the *DA1 sandwich* technique to detect lack of OSC support without waiting for timeouts.
>
> Reworks `query_terminal_colors` to send **BEL-terminated** OSC queries (urxvt workaround), parse responses **sequentially from the tty stream** via `BufReader` (with a poll-based, deadline-aware reader), and drain trailing DA1 output; also adds SSH-aware timeouts.
>
> Expands unix test coverage for hex/RGB parsing, BEL termination, mixed-response buffers, `read_until_either`, and includes a regression test ensuring `query_terminal_colors` doesn’t hang in CI.
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a2f3399. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@graphite-app graphite-app bot force-pushed the fix/osc-da1-sandwich branch from a2f3399 to cd41d58 Compare March 18, 2026 06:16
…ection (#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**
> Changes low-level `/dev/tty` I/O and escape-sequence parsing to avoid hangs/leaked output across many terminal environments; mistakes could regress header color detection or terminal interaction timing.
>
> **Overview**
> Makes Vite+ header color probing **more robust across terminal emulators and container/CI environments** by replacing ad-hoc OSC query handling with a centralized `is_osc_query_unsupported()` gate plus the *DA1 sandwich* technique to detect lack of OSC support without waiting for timeouts.
>
> Reworks `query_terminal_colors` to send **BEL-terminated** OSC queries (urxvt workaround), parse responses **sequentially from the tty stream** via `BufReader` (with a poll-based, deadline-aware reader), and drain trailing DA1 output; also adds SSH-aware timeouts.
>
> Expands unix test coverage for hex/RGB parsing, BEL termination, mixed-response buffers, `read_until_either`, and includes a regression test ensuring `query_terminal_colors` doesn’t hang in CI.
>
> <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit a2f3399. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@graphite-app graphite-app bot force-pushed the fix/osc-da1-sandwich branch from cd41d58 to 55642c2 Compare March 18, 2026 07:02
@graphite-app graphite-app bot merged commit 55642c2 into main Mar 18, 2026
23 checks passed
@graphite-app graphite-app bot deleted the fix/osc-da1-sandwich branch March 18, 2026 07:11
@fengmk2 fengmk2 mentioned this pull request Mar 18, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants