Skip to content

feat(pm): show download progress when fetching a package manager - #2369

Merged
fengmk2 merged 4 commits into
voidzero-dev:mainfrom
semimikoh:fix/pm-download-log
Aug 7, 2026
Merged

feat(pm): show download progress when fetching a package manager#2369
fengmk2 merged 4 commits into
voidzero-dev:mainfrom
semimikoh:fix/pm-download-log

Conversation

@semimikoh

Copy link
Copy Markdown
Contributor

Closes #2351

Problem

When a project's workspace declares a package manager (packageManager, lockfile, devEngines, etc.) that isn't installed yet, vp downloads it silently. On a slow connection there's no way to tell whether the download is progressing or has hung — no log line, no progress indicator, nothing until it either succeeds or errors out.

Root cause

The package-manager download path (crates/vp_pm_cli/src/request.rs: HttpClient::download_file, download_and_extract_tgz_with_hash) only emits tracing::debug! calls, which aren't shown at the default log level. This is unlike the Node.js runtime download path (crates/vp_js_runtime/src/download.rs), which already renders an indicatif progress bar.

Fix

Mirror the existing vp_js_runtime pattern in vp_pm_cli:

  • HttpClient::download_file takes an optional message, and shows a byte progress bar (speed, ETA) once Content-Length is known, gated on stderr being a TTY and not running in CI — non-interactive/piped output stays unchanged.
  • download_and_extract_tgz_with_hash threads the message through.
  • Each package-manager download call site (npm-style tgz for npm/pnpm<12/yarn, bun's platform binary, pnpm>=12's native binary, and the pnpm hash-verification download) now passes a message like "Downloading pnpm v10.0.0...".

Testing

  • cargo check -p vp_pm_cli, cargo clippy -p vp_pm_cli --all-targets, cargo fmt -p vp_pm_cli --check
  • cargo test -p vp_pm_cli --lib: all download-path tests pass (request::tests::*, package_manager::tests::test_download_*)

`vp env`/shim installs of npm, pnpm, yarn, and bun silently downloaded
in the background with only debug-level tracing, so users on a slow
connection couldn't tell if the CLI had hung. Mirror the progress-bar
pattern already used for Node.js runtime downloads (vp_js_runtime):
show a byte progress bar with speed/ETA on a TTY outside CI.

Closes voidzero-dev#2351
@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit dcef7e3
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a75cfba1fbe9400083b91a4

@jong-kyung

Copy link
Copy Markdown
Collaborator

could we add some test coverage for this?

Comment thread Cargo.lock
@jong-kyung

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 743f058992

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Extract the progress-bar visibility check into should_show_progress
and unit test its truth table, plus add download_file /
download_and_extract_tgz_with_hash regression tests that pass a
message to confirm it doesn't affect download/extract results.
@semimikoh

Copy link
Copy Markdown
Contributor Author

Good call — added coverage in fa7adc3:

  • Extracted the progress-bar visibility check into a pure should_show_progress(has_message, is_terminal, is_ci) helper and unit tested its truth table directly (independent of the actual TTY/CI state the test runs under).
  • Added download_file/download_and_extract_tgz_with_hash regression tests that pass a message and assert the downloaded/extracted content is unaffected.

@jong-kyung

jong-kyung commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

thanks for adding these. I was expecting a snapshot test for the visible progress bar, but it looks difficult to test reliably because the bar is cleared on completion. On a closer look, these tests don't exercise the visible progress-bar path, so I don't think they provide meaningful coverage. Could we remove them for now? Also, could you drop the unrelated Cargo.lock changes?

…sible path

Per review feedback: these tests didn't exercise the actual visible
progress-bar rendering (which is TTY-gated and cleared on completion,
so hard to assert on reliably), and left an extraction with no
meaningful test value. Also drop unrelated rolldown Cargo.lock churn
from a local vendored-checkout sync.
@semimikoh

Copy link
Copy Markdown
Contributor Author

Fair point on both — done in fc957c0:

  • Dropped the tests + the should_show_progress extraction that only supported them. Agreed they weren't exercising the actual visible-bar path, and reliably asserting on a TTY-gated, cleared-on-completion bar isn't worth the complexity here.
  • Cargo.lock is back to just the indicatif addition — the rolldown version churn was from my local vendored checkout being ahead of what this branch's lockfile expected, unrelated to this change.

@jong-kyung jong-kyung left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

vp migrate has its own spinner. @fengmk2, Would it be okay if I triggered a preview-build build to check wherter the two spinners interfere with each other? Everything else looks good to me.

@fengmk2

fengmk2 commented Aug 7, 2026

Copy link
Copy Markdown
Member

preview-build cannot currently run under PRs in forked repos, but that's fine, we can merge first.

@jong-kyung

jong-kyung commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

preview-build cannot currently run under PRs in forked repos, but that's fine, we can merge first.

If we merge it, I'll check it in my local 🙇‍♂️

@semimikoh

Copy link
Copy Markdown
Contributor Author

Sounds good, thanks both! Happy to have this merged first and verify the spinner interaction with vp migrate after — let me know if anything comes up when you check locally.

@fengmk2 fengmk2 self-assigned this Aug 7, 2026
@fengmk2 fengmk2 changed the title fix(pm): show download progress when fetching a package manager feat(pm): show download progress when fetching a package manager Aug 7, 2026
@fengmk2
fengmk2 merged commit 842ac5f into voidzero-dev:main Aug 7, 2026
58 checks passed
@fengmk2

fengmk2 commented Aug 7, 2026

Copy link
Copy Markdown
Member

publish a preview build at #2373 (comment)

@jong-kyung

Copy link
Copy Markdown
Collaborator

publish a preview build at #2373 (comment)

Checked locally, no spinner conflicts. Works well 👍

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.

Add download log when install package manager

3 participants