fix(cli): suppress Vite+ header in non-TTY and git hook contexts#1439
Merged
fix(cli): suppress Vite+ header in non-TTY and git hook contexts#1439
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
Member
Author
How to use the Graphite Merge QueueAdd the label auto-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Member
Author
|
@cursor review |
fengmk2
commented
Apr 22, 2026
cpojer
approved these changes
Apr 22, 2026
The banner was printing from every `vp` invocation, cluttering captured output (lefthook/husky, `execSync`, CI pipes, pagers) and the git commit flow when a shell pre-commit hook runs `vp check --fix` — in the hook the colour detection is unreliable, so the banner also rendered in a degraded style. Banner emission now gates on two signals at every call site: - `stdout.is_terminal()` — catches piped/redirected contexts. - `GIT_INDEX_FILE` env var — catches direct shell hooks that inherit the terminal for stdout. Git sets this for pre-commit, commit-msg, and prepare-commit-msg, which is where `vp check --fix` typically runs. Centralised behind `vite_shared::header::print_header()` on the Rust side and a new `printHeader()` helper in `packages/cli/src/utils/ terminal.ts` on the Node CLI side. The interactive `prompts.intro()` in `vp create` and the interactive top-level command picker are left alone — they only run when genuinely interactive. Snap fixtures regenerated to reflect the removed banner lines.
Expose `shouldPrintVitePlusHeader()` from the NAPI binding so the Node CLI's `printHeader()` helper can defer to the same Rust predicate used by the Rust CLI. Removes the `process.stdout.isTTY` + `GIT_INDEX_FILE` checks that were duplicated on the JS side; future changes to the gate (e.g. lefthook detection) now only need to touch `vite_shared::header`. Regenerates the NAPI type definitions.
2f58d82 to
918c3db
Compare
Member
Author
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 918c3db. Configure here.
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 banner was printing from every
vpinvocation, cluttering capturedoutput (lefthook/husky,
execSync, CI pipes, pagers) and the git commitflow when a shell pre-commit hook runs
vp check --fix— in the hookthe colour detection is unreliable, so the banner also rendered in a
degraded style.
Banner emission now gates on two signals at every call site:
stdout.is_terminal()— catches piped/redirected contexts.GIT_INDEX_FILEenv var — catches direct shell hooks that inheritthe terminal for stdout. Git sets this for pre-commit, commit-msg,
and prepare-commit-msg, which is where
vp check --fixtypicallyruns.
Centralised behind
vite_shared::header::print_header()on the Rustside and a new
printHeader()helper inpackages/cli/src/utils/ terminal.tson the Node CLI side. The interactiveprompts.intro()invp createand the interactive top-level command picker are leftalone — they only run when genuinely interactive.
Snap fixtures regenerated to reflect the removed banner lines.
Note
Medium Risk
Primarily changes CLI stdout formatting, which may affect scripts/tests that assert exact output; the gating relies on TTY detection and
GIT_INDEX_FILE, so edge environments could suppress (or unexpectedly show) the banner.Overview
Prevents the Vite+ banner from being emitted in non-interactive contexts by introducing
vite_shared::header::should_print_header()(TTY +GIT_INDEX_FILEgating) and a centralizedprint_header()helper.Updates the Rust global CLI to call
print_header()(and to omit the header in clap help templates unlessshould_print_header()passes), and updates the Node CLI to use a newprintHeader()helper that delegates the same gating via a newly-exposed N-API bindingshouldPrintVitePlusHeader().Regenerates CLI snapshot fixtures to reflect the banner being absent in captured/help/test outputs where it’s now suppressed.
Reviewed by Cursor Bugbot for commit 918c3db. Configure here.