Skip to content

fix(cli): skip telemetry ping and hook reminder in rtk rewrite - #4619

Open
viniciusdsandrade wants to merge 2 commits into
rtk-ai:developfrom
viniciusdsandrade:fix/rewrite-skip-background-checks
Open

viniciusdsandrade wants to merge 2 commits into
rtk-ai:developfrom
viniciusdsandrade:fix/rewrite-skip-background-checks

Conversation

@viniciusdsandrade

@viniciusdsandrade viniciusdsandrade commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Skip core::telemetry::maybe_ping() and hooks::hook_check::maybe_warn() when rtk is invoked as rtk rewrite, matching the existing exclusion for rtk hook.

Closes #4615

Context & Problem

In src/lib.rs, run_cli() skips the daily telemetry ping (pings_telemetry) and the once-a-day missing/outdated hook check (hooks::hook_check::maybe_warn()) for Commands::Hook { .. }, but still runs both for Commands::Rewrite { .. }.

Shell hooks and plugin adapters invoke rtk rewrite "$CMD" 2>/dev/null before every command on the hot path. Because Commands::Rewrite is not excluded:

  1. When the daily hook reminder is due, rtk rewrite prints the warning to stderr (where the hook wrapper redirects it to /dev/null or captures it in hook plumbing) and touches .hook_warn_last, silencing the reminder for the actual user-visible command that runs next.
  2. rtk rewrite runs the daily telemetry check and spawns a background ping thread on a short-lived process that exits immediately after printing the rewritten command.

Solution

  • Add Commands::Rewrite { .. } to pings_telemetry() in src/lib.rs.
  • Add Commands::Rewrite { .. } to the !matches!(cli.command, ...) guard before hooks::hook_check::maybe_warn() in src/lib.rs.
  • Extend hook_commands_skip_the_telemetry_ping in src/lib.rs and hook_entry_leaves_startup_warning_for_a_normal_command in tests/hook_warning_scope_test.rs to cover rtk rewrite.

How to Test

Verified by static code inspection of src/lib.rs, src/hooks/hook_check.rs, and tests/hook_warning_scope_test.rs; execution is delegated to the PR CI matrix:

cargo test --lib hook_commands_skip_the_telemetry_ping
cargo test --test hook_warning_scope_test

Checklist

  • cargo test passes (pending CI execution; not run locally)
  • cargo clippy --all-targets clean (pending CI execution; not run locally)
  • cargo fmt --check clean (pending CI execution; not run locally)
  • Single-line format adds [\u{26a1} N tokens] badge (via format_badge()) (N/A: CLI startup guard fix)
  • Multi-line format ends with summary_footer() line (N/A: CLI startup guard fix)
  • Saved tokens > 0 on realistic fixture (no negative savings) (N/A: CLI startup guard fix)

rtk rewrite is invoked on the hook path before every command with stderr redirected or discarded. Running the daily telemetry ping and hook status check on Commands::Rewrite adds startup overhead on the hot path and consumes the once-a-day hook reminder marker before a user-visible command can display it.

Signed-off-by: Vinícius DS Andrade <[email protected]>
Verify that rtk rewrite neither prints the daily missing-hook reminder nor consumes the startup marker before a normal filtered command runs.

Signed-off-by: Vinícius DS Andrade <[email protected]>
@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working cli hooks labels Oct 17, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Adds Commands::Rewrite to the exclusion lists for the daily telemetry ping and the hook-check warning in src/lib.rs, matching the existing exclusion for Commands::Hook, since rtk rewrite runs on the hot path before every shell command. Extends existing unit and integration tests to cover the rewrite subcommand's behavior.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #4615


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working cli hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk rewrite runs the daily hook reminder and telemetry ping on the hook path, so shell hooks spend the reminder into /dev/null

1 participant