Skip to content

fix(cli): stop the header color query from hanging on macOS - #3569

Merged
fengmk2 merged 2 commits into
voidzero-dev:mainfrom
afterimaginary:fix/macos-tty-color-query
Nov 25, 2026
Merged

fengmk2 merged 2 commits into
voidzero-dev:mainfrom
afterimaginary:fix/macos-tty-color-query

Conversation

@afterimaginary

@afterimaginary afterimaginary commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3568

On macOS, poll() does not support /dev/tty: it returns POLLNVAL at once instead of waiting. The header's color query waits with poll() before each read, so the 200 ms deadline never applied and every read() blocked until the terminal sent something. In a terminal that never answers the DA1 sentinel, every command that prints the header hung before it ran.

This PR moves the wait into wait_readable(). On macOS it uses select(), which works with /dev/tty, as terminal-colorsaurus does. Other Unix platforms keep poll(). A descriptor too large for an fd_set counts as a timeout instead of panicking.

The new header_color_query_no_reply snapshot case sets COLORTERM=truecolor, so vp sends the query to the runner's terminal, which never answers. Before this change the case timed out after 120 s on macOS. It now passes in under a second. On Linux, where poll() works with /dev/tty, it should pass either way; I could only run it on macOS.

Checked on macOS 27.2.1 (arm64) with a debug build:

  • cargo test -p vp_shared and cargo clippy -p vp_shared --all-targets -- --deny warnings pass, with the poll() branch also compiled by swapping the cfg locally.
  • The reproduction returns in 0.3 s for a terminal that never answers, and in 0.1 s for one that does.
  • A terminal that answers still gets its own header colors: a reply of red gives a red header, and no reply gives the default blue gradient.

I did not touch the Warp entry in is_osc_query_unsupported(). Its comment describes this same hang, so it may no longer be needed, but I can't test Warp.

Investigated and written with Claude Code. I reviewed the change and the reproduction and can answer questions about either.

macOS poll() does not support /dev/tty: it returns POLLNVAL at once
instead of waiting, so the query's 200 ms deadline never applied and
each read blocked until the terminal answered. In a terminal that never
answers the DA1 sentinel, every command that prints the header hung
before it ran. Wait with select() on macOS, which works with /dev/tty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw labels Nov 25, 2026

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@afterimaginary Thanks!

@fengmk2 fengmk2 self-assigned this Nov 25, 2026
@fengmk2
fengmk2 merged commit ea0a2d8 into voidzero-dev:main Nov 25, 2026
150 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vp hangs on macOS before running any command when the terminal doesn't answer DA1

2 participants