Skip to content

/go/cmd/dolt/cli: only emit backspace characters in a tty - #11332

Merged
coffeegoddd merged 4 commits into
mainfrom
db/printing
Jul 21, 2026
Merged

/go/cmd/dolt/cli: only emit backspace characters in a tty#11332
coffeegoddd merged 4 commits into
mainfrom
db/printing

Conversation

@coffeegoddd

Copy link
Copy Markdown
Contributor

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.

@coffeegoddd

coffeegoddd commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

read_tests from_latency to_latency percent_change
covering_index_scan 2.3 2.3 0.0
groupby_scan 144.97 142.39 -1.78
index_join 1.93 1.89 -2.07
index_join_scan 1.32 1.32 0.0
index_scan 215.44 215.44 0.0
oltp_point_select 0.25 0.25 0.0
oltp_read_only 5.0 5.0 0.0
select_random_points 0.5 0.51 2.0
select_random_ranges 0.64 0.64 0.0
table_scan 200.47 200.47 0.0
types_table_scan 458.96 458.96 0.0
write_tests from_latency to_latency percent_change
oltp_delete_insert 6.09 6.09 0.0
oltp_insert 3.13 3.13 0.0
oltp_read_write 11.24 11.24 0.0
oltp_update_index 3.3 3.3 0.0
oltp_update_non_index 2.97 3.02 1.68
oltp_write_only 6.21 6.21 0.0
types_delete_insert 6.79 6.79 0.0

@coffeegoddd

Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
2486a0d ok 5937471
version total_tests
2486a0d 5937471
correctness_percentage
100.0

@coffeegoddd

coffeegoddd commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

test_name from_latency_p95 to_latency_p95 percent_change
tpcc-scale-factor-1 43.39 45.79 5.53
test_name from_server_name from_server_version from_tps to_server_name to_server_version to_tps percent_change
tpcc-scale-factor-1 dolt 0e9a297 53.1 dolt 782d3a2 52.79 -0.58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 thread go/cmd/dolt/cli/stdio.go
Comment on lines 57 to +60
stdOut, stdErr := os.Stdout, os.Stderr

outputIsTerminal = isatty.IsTerminal(stdErr.Fd()) || isatty.IsCygwinTerminal(stdErr.Fd())

@coffeegoddd

Copy link
Copy Markdown
Contributor Author

@coffeegoddd DOLT

comparing_percentages
100.000000 to 100.000000
version result total
782d3a2 ok 5937471
version total_tests
782d3a2 5937471
correctness_percentage
100.0

@coffeegoddd
coffeegoddd merged commit 4b28215 into main Jul 21, 2026
26 checks passed
@coffeegoddd
coffeegoddd deleted the db/printing branch July 21, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants