Skip to content

fix(cli): suppress passive cache hint under --quiet#380

Merged
s0undt3ch merged 1 commit into
mainfrom
quiet_suppresses_cache_hint
Jul 14, 2026
Merged

fix(cli): suppress passive cache hint under --quiet#380
s0undt3ch merged 1 commit into
mainfrom
quiet_suppresses_cache_hint

Conversation

@s0undt3ch

Copy link
Copy Markdown
Owner

Problem

The passive "your cache is big, consider pruning" hint (crates/toolr/src/main.rs, maybe_emit_cache_hint_from_argv) runs before clap parses argv and was suppressed only for TOOLR_NO_CACHE_HINT, tab-completion, and self cache …. It never honoured --quiet.

--quiet promises to "suppress non-error output", and the hint is non-error output — so under --quiet it leaked to stderr anyway, once the cache accumulated enough orphans to trip the threshold. That breaks the "--quiet must be silent" contract the mise enter-hook depends on: toolr project venv sync --quiet runs on every cd and must stay silent in non-toolr directories regardless of cache state.

It surfaced as a flaky-looking failure of project_venv_sync::sync_quiet_silently_exits_when_not_a_toolr_repo — but only on a developer machine whose real cache had crossed the orphan threshold (CI's cache is clean, so CI never saw it). The test was right; the product was wrong.

Fix

Scan argv for --quiet / -q and gate the hint on it. The scan stops at the -- separator so a wrapped command's own quiet flag (toolr project venv run -- pytest --quiet) is never mistaken for toolr's, and it matches short clusters (-dq) as well as the long form.

Tests

  • Unit (argv_requests_quiet): long/short/cluster detection, absence, and the ---separator boundary in both directions.
  • Integration (tests/cache_hint_quiet.rs): builds a dirty cache (12 orphans), asserts the hint fires without --quiet (so the suppression test can't pass vacuously) and is suppressed with it.

Verification

Full mise run test umbrella passes against a real dirty local cache with no XDG_CACHE_HOME isolation — 382 passed, 8 skipped — proving the fix makes the suite robust to cache state, not just the isolated case. cargo clippy clean.

Independent of #379 (deps upgrade); branches off main.

The passive "your cache is big, consider pruning" hint is emitted
before clap parses argv, and only checked TOOLR_NO_CACHE_HINT,
`__complete`, and `self cache …`. It never honoured `--quiet`, so the
hint leaked to stderr even under `--quiet` once the cache accumulated
enough orphans to trip the threshold.

That broke the "`--quiet` must be silent" contract the mise enter-hook
depends on: `toolr project venv sync --quiet` runs on every `cd` and
must stay silent in non-toolr directories regardless of cache state.

Add an argv scan for `--quiet` / `-q` (stopping at the `--` separator so
a wrapped command's own `--quiet` doesn't count) and gate the hint on
it. Covered by unit tests for the scanner and integration tests that
build a dirty cache and assert the hint fires without `--quiet` and is
suppressed with it.
@s0undt3ch

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.8%. Comparing base (35b3d7e) to head (de97fb9).
⚠️ Report is 4 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main    #380   +/-   ##
=====================================
  Coverage   93.8%   93.8%           
=====================================
  Files         96      96           
  Lines      16023   16063   +40     
  Branches     118     118           
=====================================
+ Hits       15041   15081   +40     
  Misses       972     972           
  Partials      10      10           
Flag Coverage Δ
3.11 93.8% <100.0%> (+<0.1%) ⬆️
3.12 93.8% <100.0%> (+<0.1%) ⬆️
3.13 93.8% <100.0%> (+<0.1%) ⬆️
3.14 93.8% <100.0%> (+<0.1%) ⬆️
macos-latest 93.8% <100.0%> (+<0.1%) ⬆️
ubuntu-latest 93.8% <100.0%> (+<0.1%) ⬆️
windows-latest 90.6% <100.0%> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
toolr-core 94.3% <ø> (ø)
toolr 92.9% <100.0%> (+<0.1%) ⬆️
toolr-py 96.0% <ø> (ø)
xtask 90.3% <ø> (ø)
Files with missing lines Coverage Δ
crates/toolr/src/main.rs 99.0% <100.0%> (+0.5%) ⬆️

@s0undt3ch s0undt3ch marked this pull request as ready for review July 14, 2026 07:41
@s0undt3ch s0undt3ch merged commit 831b082 into main Jul 14, 2026
76 checks passed
@s0undt3ch s0undt3ch deleted the quiet_suppresses_cache_hint branch July 14, 2026 07:42
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.

1 participant