quarto emits ANSI cursor-control sequences when stderr is not a terminal
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
- 74/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- typescript
- Lĩnh vực
- cli
Hướng nghiên cứu
Bắt đầu trong src/core/console.ts, sau đó đọc isInteractiveTerminal() trong src/core/platform.ts và phần xử lý liên quan trong src/core/log.ts. Tái hiện vấn đề bằng quarto check versions 2>\u00261 | cat -v, sau đó chỉ bật đầu ra điều khiển con trỏ và tiến trình khi stderr là một terminal tương tác. Hoàn tất khi đầu ra được chuyển hướng hoặc qua pipe không chứa các chuỗi điều khiển con trỏ ANSI thô, trong khi hành vi trên terminal vẫn mang tính tương tác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When quarto's stderr is piped, redirected to a file, or consumed by an editor build tool (e.g. Emacs M-x compile, VS Code tasks), progress and spinner helpers still emit ANSI cursor-control sequences. These appear as raw escape bytes in the output buffer:
^[[0G^[[2K^[[J^[[0G^[[2K^[[J^[[0G
Reported in https://github.com/orgs/quarto-dev/discussions/14403
Root cause
src/core/console.ts emits cursor-control bytes without checking whether the output stream is a terminal. Specifically, clearLine() calls ansi.eraseLine.cursorLeft() unconditionally, and spinner() and progressBar() gate their output on runningInCI() but not on whether stderr is actually a TTY. withSpinner()'s cancel path always calls clearLine(), regardless of where output goes.
NO_COLOR does not cover this — it governs colors only. --log-format plain governs the log file format, not console output.
The codebase already has the right helper: isInteractiveTerminal() in src/core/platform.ts, which returns Deno.stderr.isTerminal(). It is already used in command/create/cmd.ts and command/publish/cmd.ts to gate interactive prompts, but not in src/core/console.ts.
src/core/log.ts's LogFileHandler.format() already handles this for file output — messages starting with \r are dropped because they are progress lines. The same "progress is terminal-only" notion is not applied to the stderr console handler or to clearLine().
Reproduction
Any quarto command that uses withSpinner or progressBar shows this when stderr is piped. The cleanest CLI-only form:
quarto check versions 2>&1 | cat -v
quarto install tinytex 2>&1 | cat -v
leading to something like
$ quarto check versions 2>&1 | cat -v
Quarto 1.10.3
^M[>] Checking versions of quarto binary dependencies...
Pandoc version 3.8.3: OK
Dart Sass version 1.87.0: OK
Deno version 2.4.5: OK
Typst version 0.14.2: OK
^M[>] Checking versions of quarto dependencies......OK
Or via Emacs M-x compile running quarto render example.qmd --to html, where the compilation buffer is not a TTY.
Suggested direction
Gate clearLine(), spinner(), and progressBar() on isInteractiveTerminal() (extending the !runningInCI() check that is already there to also require a TTY). This matches the idiom already used for interactive prompts in create/publish, and aligns console behavior with the file-handler behavior in log.ts.
- Ngôn ngữ chính
- JavaScript
- Star
- 6k
- Fork
- 458
- Merge trung bình
- 21 giờ 49 phút
- Pull request đã merge (30 ngày)
- 53
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của quarto-dev/quarto-cli
-
accessibility bug typst
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
quarto-dev/quarto-cli#14947 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accessibility documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
quarto-dev/quarto-cli#14944 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
maintenance ojs-engine
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
quarto-dev/quarto-cli#14934 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accessibility bug html themes
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
quarto-dev/quarto-cli#14932 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
quarto-dev/quarto-cli#14915 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của quarto-dev/quarto-cli
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
curriculum documentation quality
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
githubnext/gh-aw-workshop#3897 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày