/go/cmd/dolt/cli: only emit backspace characters in a tty - #11332
Merged
Conversation
Contributor
Author
|
@coffeegoddd DOLT
|
Contributor
Author
|
@coffeegoddd DOLT
|
Contributor
Author
|
@coffeegoddd DOLT
|
Contributor
There was a problem hiding this comment.
Pull request overview
Updates Dolt’s CLI progress spinner redraw behavior to avoid emitting backspace control characters when output isn’t attached to a terminal, preventing captured logs (CI, pipes, redirected output) from being visually “erased” by control bytes.
Changes:
- Detects whether output is a TTY and gates
DeleteAndPrint’s backspace-based redraw behavior on that. - Adds unit tests asserting no backspaces are emitted when output is treated as non-TTY, and that captured error output isn’t corrupted.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| go/cmd/dolt/cli/stdio.go | Adds TTY detection and skips emitting backspaces in DeleteAndPrint when not running in a terminal. |
| go/cmd/dolt/cli/stdio_test.go | Adds tests for non-TTY behavior and ensures spinner output doesn’t corrupt captured error logs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
57
to
+60
| stdOut, stdErr := os.Stdout, os.Stderr | ||
|
|
||
| outputIsTerminal = isatty.IsTerminal(stdErr.Fd()) || isatty.IsCygwinTerminal(stdErr.Fd()) | ||
|
|
Contributor
Author
|
@coffeegoddd DOLT
|
macneale4
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CLI's progress spinners (dolt push, pull, fetch, assist, and import/sql progress output) redraw themselves in place by writing backspace control characters. This was done unconditionally, with no check for whether output was going to a terminal.
When stdout/stderr is captured to a file or pipe — a script, a CI job, dolt push > push.log 2>&1 — those backspaces become literal bytes in the log instead of cursor movements. Rendering the log then "erases" the surrounding text. The worst case: an error is printed while the spinner is active, and the spinner's trailing backspaces overwrite the error text, so the captured log looks empty exactly when something went wrong.
This PR fixes this so that TTY is detected and redraw is gated on it.