Skip to content

tty: use terminal VT mode on Windows #58358

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2025

Conversation

addaleax
Copy link
Member

As of 0315283, the libuv UV_TTY_MODE_RAW_VT flag is available for applications on Windows in order to have the terminal itself translate keypresses into control sequences, rather than libuv. This aligns the TTY setup more closely with POSIX platforms, and enables handling of control sequences in applications which libuv is not able to emit at all.

Since the Node.js readline implementation already handles divergences between different control character sequences for the same keypresses (e.g. <ESC>[[A vs <ESC>OP for the F1 key), this should not present a visible change for typical Node.js TTY applications.

Testing is handled on the libuv side, and not easily feasible with Node.js’s current TTY test setup.

As of 0315283, the libuv `UV_TTY_MODE_RAW_VT` flag is available for
applications on Windows in order to have the terminal itself translate
keypresses into control sequences, rather than libuv.
This aligns the TTY setup more closely with POSIX platforms, and
enables handling of control sequences in applications which libuv
is not able to emit at all.

Since the Node.js `readline` implementation already handles divergences
between different control character sequences for the same keypresses
(e.g. `<ESC>[[A` vs `<ESC>OP` for the F1 key), this should not present
a visible change for typical Node.js TTY applications.

Testing is handled on the libuv side, and not easily feasible with
Node.js’s current TTY test setup.
@addaleax addaleax added the tty Issues and PRs related to the tty subsystem. label May 16, 2025
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 16, 2025
Copy link
Member

@juanarbol juanarbol left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link

codecov bot commented May 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.23%. Comparing base (8053a5c) to head (855796b).
Report is 34 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #58358   +/-   ##
=======================================
  Coverage   90.23%   90.23%           
=======================================
  Files         633      633           
  Lines      186847   186849    +2     
  Branches    36685    36680    -5     
=======================================
+ Hits       168594   168599    +5     
- Misses      11041    11044    +3     
+ Partials     7212     7206    -6     
Files with missing lines Coverage Δ
src/tty_wrap.cc 82.89% <100.00%> (+0.46%) ⬆️

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels May 16, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 16, 2025
@nodejs-github-bot
Copy link
Collaborator

@addaleax addaleax added the commit-queue Add this label to land a pull request using GitHub Actions. label May 18, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 18, 2025
@nodejs-github-bot nodejs-github-bot merged commit db2aae8 into nodejs:main May 18, 2025
77 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in db2aae8

@addaleax addaleax deleted the tty-use-raw-vt branch May 18, 2025 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. tty Issues and PRs related to the tty subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants