Skip to content

Hide progress bar if input is stdin only#1938

Merged
thomas-zahner merged 4 commits intomasterfrom
hide-progress-bar-stdin-fix2
Mar 26, 2026
Merged

Hide progress bar if input is stdin only#1938
thomas-zahner merged 4 commits intomasterfrom
hide-progress-bar-stdin-fix2

Conversation

@mre
Copy link
Copy Markdown
Member

@mre mre commented Nov 27, 2025

In #1914, work was done to hide the progress bar on stdin. The simple solution of removing enable_steady_tick for the progress bar. This worked well for avoiding cluttering the output while the user typed their input.

However, the initial progress bar still gets shown, which is not ideal. This commit slightly imporves the behavior by waiting for all inputs before showing the progress bar. We do this by iterating over the inputs and checking if any of them is stdin.

This way, the progress bar does no longer get shown. To start the processing, the user has to press Ctrl^D, which is customs for other Unix tools as well. Other behavior remains unchanged.

@mre mre requested a review from thomas-zahner November 27, 2025 18:01
@thomas-zahner
Copy link
Copy Markdown
Member

Personally, I'm okay with the current behaviour. As mentioned in #1914 (comment) and #1736 (comment) I find it unexpected to fully hide the bar if stdin is one of the inputs.

The main reason is that this might confuse users a lot. I assume the more common use case is to pipe something to lychee, rather than plain lychee -. With this PR if we now do cat README.md | lychee - the progress bar disappears without any apparent reason and there is no way for users to enable it again.

@mre
Copy link
Copy Markdown
Member Author

mre commented Nov 28, 2025

cat README.md | cargo run -- -

Oh, I hadn't thought of that. Nice catch!

Yeah, it's a bit of a tradeoff. In your recording (now archived), I got a bit irritated by the progress bar. It looked like a rendering bug, to be honest. But as you pointed out, there's no easy solution here. 😕

Or so I thought!

Maybe we should only hide the progress bar when stdin is not a TTY (i.e., it's being piped or redirected). If someone runs lychee - interactively and types into the terminal, stdin is still a TTY.

I tweaked the behavior a bit. The implementation now detects when stdin is piped or redirected and hides the progress bar only in those cases. What do you think? 🤩

@thomas-zahner
Copy link
Copy Markdown
Member

Ooh I didn't know this was possible 👍

It still feels a bit like a hack but I'm okay with it, if we are even more strict with the predicate and set stdin_input to true if stdin is the only input. (cargo run -) Because running cargo run - README.md also checks README.md. The order is non-deterministic so sometimes the file is checked while lychee also waits for stdin and sometimes it is only checked after the user finished writing the contents to stdin. If we do this then I'm okay with the PR.

@mre
Copy link
Copy Markdown
Member Author

mre commented Dec 4, 2025

Quick heads-up: When I tested this, I think I found a few issues. That means, we should test that thoroughly before merging. Don't have time to re-run the tests right now, but if someone wants to check out this branch and try it on a few inputs, that would be helpful.

mre added 3 commits March 13, 2026 23:52
In #1914, work was done to hide the
progress bar on `stdin`. The simple solution of removing enable_steady_tick for
the progress bar. This worked well for avoiding cluttering the output while the
user typed their input.

However, the initial progress bar still gets shown, which is not ideal. This
commit slightly imporves the behavior by waiting for all inputs before showing
the progress bar. We do this by iterating over the inputs and checking if any
of them is `stdin`.

This way, the progress bar does no longer get shown. To start the processing,
the user has to press Ctrl^D, which is customs for other Unix tools as well.
Other behavior remains unchanged.
@mre mre force-pushed the hide-progress-bar-stdin-fix2 branch from a3d4b01 to 0e128a9 Compare March 13, 2026 22:55
@mre
Copy link
Copy Markdown
Member Author

mre commented Mar 13, 2026

I took another look and decided to avoid hiding the progress bar if there are more inputs than just -. So in the case of

lychee - README.md

It would show the progress bar.

@thomas-zahner, wdyt?

mre added a commit that referenced this pull request Mar 25, 2026
mre added a commit that referenced this pull request Mar 25, 2026
@mre mre force-pushed the hide-progress-bar-stdin-fix2 branch from aa38bd2 to 67df0fa Compare March 25, 2026 21:49
@mre mre force-pushed the hide-progress-bar-stdin-fix2 branch from 67df0fa to 38c1889 Compare March 25, 2026 21:50
Copy link
Copy Markdown
Member

@thomas-zahner thomas-zahner left a comment

Choose a reason for hiding this comment

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

Cool, that's a lovely little improvement 🚀

@thomas-zahner thomas-zahner changed the title Fully hide progress bar if any input is stdin Hide progress bar if input is stdin only Mar 26, 2026
@thomas-zahner thomas-zahner merged commit 2d48998 into master Mar 26, 2026
7 checks passed
@thomas-zahner thomas-zahner deleted the hide-progress-bar-stdin-fix2 branch March 26, 2026 09:47
@mre mre mentioned this pull request Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants