`nuxt dev`: takeover prompt loses raw mode when terminal doesn't answer OSC 11

Đang mở Phù hợp với người mới
#1,685 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
76/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript
Lĩnh vực
cli, developer-experience

Hướng nghiên cứu

Bắt đầu với withUserAttention và host.withTerminal, sau đó so sánh cách chúng xử lý stdin với attachKeys và whenStdinReleased() trong src/boot.ts và luồng lời nhắc tiếp quản. Tái hiện trong một terminal không phản hồi OSC 11 và xác nhận lời nhắc vẫn giữ chế độ raw sau timeout. Hoàn thành khi trong tình huống đó, các phím mũi tên di chuyển lựa chọn và Enter gửi lựa chọn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Version: @nuxt/cli 4.0.3, Nuxt 4.6.4, Node 24.16, macOS

Repro
  1. Start nuxt dev in a project and leave it running.
  2. In a terminal that does not reply to OSC 11 (ESC ] 11 ; ? BEL), run nuxt dev again in the same project.
  3. The "A Nuxt dev server is already running here" select prompt appears. Press ↑/↓.

Expected: the selection moves.

Actual: ~250ms after the prompt renders, stdin drops out of raw mode. Arrow keys echo as ^[[A, and Enter arrives as \n (readline names it enter, not return), so the prompt can't be answered. Only Ctrl-C gets out.

Cause

bootDevUI (src/boot.ts) paints the panel and calls queryBackground before the dev command reaches takeOverServer. listen() in src/dev/tui/background.ts captures wasRaw = false, sets raw mode, then in finish() (on reply or on the 250ms timeout) runs if (!wasRaw) stdin.setRawMode(false). By then clack's select has taken raw mode, so the restore turns it off underneath the prompt. attachKeys already waits for whenStdinReleased(); the takeover prompt (via withUserAttention) does not.

Verified by sampling the pty's termios flags: ICANON and ECHO switch back on 0.27s after the prompt appears. With NUXT_TERM_THEME=dark (no query sent), raw mode holds.

Suggested fix

Have withUserAttention / host.withTerminal await whenStdinReleased() before running the prompt, the same way attachKeys does. Alternatively, finish() could skip the raw-mode restore if stdin's raw state changed while the query was pending.

Workaround

export NUXT_TERM_THEME=dark (or light).

Ngôn ngữ chính
TypeScript
Star
402
Fork
125
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
37

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của nuxt/cli

Tất cả issue của nuxt/cli

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.