quarto emits ANSI cursor-control sequences when stderr is not a terminal
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 74/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- typescript
- 领域
- cli
调研方向
从 src/core/console.ts 开始,然后阅读 src/core/platform.ts 中的 isInteractiveTerminal() 以及 src/core/log.ts 中相关的处理逻辑。使用 quarto check versions 2>\u00261 | cat -v 重现该问题,然后仅在 stderr 是交互式终端时输出光标控制和进度信息。完成的标准是:重定向或通过管道传输的输出不包含原始 ANSI 光标控制序列,同时终端行为仍保持交互式。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- JavaScript
- 星标
- 6k
- 派生
- 458
- 平均合并
- 21 小时 49 分钟
- 30 天内合并 PR
- 53
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
quarto-dev/quarto-cli 的其他 Issue
-
accessibility bug typst
难度 2/5 1-3 小时 新手友好度 75/100
quarto-dev/quarto-cli#14947 · 2 条评论 ·
维护者通常 1 天内回复
-
accessibility documentation
难度 1/5 1 小时以内 新手友好度 90/100
quarto-dev/quarto-cli#14944 ·
维护者通常 1 天内回复
-
maintenance ojs-engine
难度 2/5 1-3 小时 新手友好度 65/100
quarto-dev/quarto-cli#14934 ·
维护者通常 1 天内回复
-
accessibility bug html themes
难度 2/5 1-3 小时 新手友好度 75/100
quarto-dev/quarto-cli#14932 ·
维护者通常 1 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 86/100
quarto-dev/quarto-cli#14915 ·
维护者通常 1 天内回复
查看 quarto-dev/quarto-cli 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
curriculum documentation quality
难度 2/5 1-3 小时 新手友好度 78/100
githubnext/gh-aw-workshop#3897 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
难度 2/5 1-3 小时 新手友好度 91/100
维护者通常 1 天内回复