Skip to content

feat(config): add suppress_hook_warning option - #776

Merged
KuSh merged 3 commits into
rtk-ai:developfrom
mvanhorn:osc/682-suppress-hook-warning-config
Sep 18, 2026
Merged

KuSh merged 3 commits into
rtk-ai:developfrom
mvanhorn:osc/682-suppress-hook-warning-config

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

  • Add hooks.suppress_hook_warning config option in config.toml
  • Add RTK_SUPPRESS_HOOK_WARNING=1 env var as zero-config alternative

Why this matters

Users running rtk via CLAUDE.md instructions (instead of hooks) or with tools like OpenCode get [rtk] /!\ No hook installed on every command (#682). The warning wastes tokens and confuses AI agents - @btbxbob reports it printing on every git add, git commit, and git status. 5 users across Windows and OpenCode report the same problem.

Currently the warning is rate-limited to once per day, but there's no way to suppress it permanently.

Changes

src/config.rs:

  • Added suppress_hook_warning: bool field to HooksConfig (defaults to false)
  • Added hook_warning_suppressed() helper that checks the env var first, then config file

src/hook_check.rs:

  • check_and_warn() now returns early when hook_warning_suppressed() is true

The rtk gain diagnostic output (src/gain.rs) still shows hook status since that's an explicit diagnostic command.

Usage

Config file (~/.config/rtk/config.toml):

[hooks]
suppress_hook_warning = true

Or env var (useful for CI, OpenCode, non-Claude tools):

export RTK_SUPPRESS_HOOK_WARNING=1

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets && cargo test (1074 tests pass)
  • suppress_hook_warning deserializes correctly from TOML
  • Default is false (existing behavior unchanged)
  • Missing field in [hooks] section defaults to false

Fixes #682

This contribution was developed with AI assistance (Claude Code).

@pszymkowiak

Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

✨ Type feature
🟢 Risk low

Summary

Adds a new suppress_hook_warning config option and RTK_SUPPRESS_HOOK_WARNING env var to let users permanently silence the recurring 'No hook installed' and 'Hook outdated' warnings. This addresses user complaints where the warning wastes tokens and confuses AI agents when rtk is run via CLAUDE.md instructions or non-Claude tools like OpenCode.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #682


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

@pszymkowiak pszymkowiak 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.

LGTM — clean and useful. Config field + env var, serde(default) for backward compat, 4 tests. Exactly what OpenCode and non-hook setups need.

One minor suggestion: consider also checking the env var in runtime_check() (integrity.rs) for consistency, but not a blocker.

@aeppling

Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

@mvanhorn
mvanhorn force-pushed the osc/682-suppress-hook-warning-config branch from 02ea499 to f8d2f3c Compare March 26, 2026 18:58
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Rebased onto develop in f8d2f3c.

@mvanhorn
mvanhorn force-pushed the osc/682-suppress-hook-warning-config branch from f8d2f3c to 65795c6 Compare April 18, 2026 13:51
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Rebased onto develop in 65795c6 - resolved a conflict in src/core/config.rs (kept the helper functions I originally added) and fixed a stale import path in hook_check.rs. The two suppress_hook_warning tests pass locally.

Let me know if anything else is needed before merge.

@KuSh KuSh 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.

Thanks for the rebase work on this — the feature itself is the right shape, and the [hooks] config + env-var pair is the correct place for it. One blocker before this can go in, plus three smaller things worth folding in while the branch is being touched.

Blocker

telemetry_enabled() in src/core/config.rs has no callers and will fail the build (see inline comment). It's unrelated to this PR's scope and appears to be a conflict-resolution artifact.

This PR needs another rebase

develop has since added transparent_prefixes: Vec<String> to HooksConfig, and GitHub now reports this branch as CONFLICTING / DIRTY.

Note: develop itself is currently broken — not your fault, and not something you need to fix here

While verifying this PR I applied both hunks onto develop and found that develop does not build on its own, independently of this PR: src/cmds/php/phpt_cmd.rs:162 uses lazy_static::lazy_static! but lazy_static is not in Cargo.toml, and src/discover/rules.rs is missing the pipeline_final_safe field. Both regressions came in with the .phpt filter merge (#1503, e8541d1).

That is already fixed by #3793. So when you rebase and cargo clippy --all-targets explodes with E0433 cannot find crate lazy_static and E0063 missing field pipeline_final_safe, those seven errors are not yours — ignore them, or rebase on top of #3793 to get a clean run. The only error attributable to this PR is the telemetry_enabled one flagged inline.

Note on the existing approval

The 2026-03-26 approval predates two rebases and was given on 02ea499, before the conflict resolution that introduced telemetry_enabled(), so it doesn't cover the current head.

On the suggestion to also check the env var in integrity.rs::runtime_check() — I'd leave that one alone. That path only prints on IntegrityStatus::Tampered, which is a security signal rather than recurring noise, so it shouldn't be suppressible by the same switch.

Comment thread src/core/config.rs Resolved
Comment thread src/core/config.rs Resolved
Comment thread src/hooks/hook_check.rs Resolved
Comment thread src/core/config.rs Resolved
@mvanhorn
mvanhorn force-pushed the osc/682-suppress-hook-warning-config branch from 65795c6 to dfb8886 Compare September 3, 2026 15:45
@mvanhorn

mvanhorn commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

All four are in dfb8886, rebased onto current develop.

The dead telemetry_enabled is gone. It was a conflict-resolution artifact exactly as you guessed, and dropping it is what makes the branch build under warnings = deny.

The env var is a real override now: Ok("1") suppresses, any other value forces the warning back on, and only an unset var falls through to config.toml. That also moves it onto the as_deref() == Ok("1") shape the rest of the repo uses.

hook_warning_suppressed() runs before status() now, so a suppressed user pays neither the hook probe nor the config read that used to follow it.

Documented in configuration.md, both the [hooks] sample and the environment variable table, plus the README snippet.

On develop being broken: it builds clean at f83c0cf. cargo fmt --check, cargo clippy --all-targets with zero warnings, and the config and hook tests all pass locally against that base, so the lazy_static and pipeline_final_safe errors you hit are gone.

@KuSh KuSh 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.

Second pass on dfb8886f. All four threads from the previous round are genuinely addressed and I've resolved them — the rebase is clean, telemetry_enabled() is gone, docs are in, and I verified cargo clippy --all-targets is clean with 3074 tests passing at this head.

Three new points below. Up front: the first one is partly my fault — my previous comment asked for an env-var override and the literal implementation of that ask has a sharper edge than I anticipated. The suggested fix below reconciles both rounds, so please don't just revert to what you had.

Also worth noting my earlier pointer to #3793 for the develop build break is now stale — that PR was closed, but the lazy_static breakage is gone from your base anyway, so it's moot.

Comment thread src/core/config.rs Resolved
Comment thread src/hooks/hook_check.rs Resolved
Comment thread src/core/config.rs Resolved
mvanhorn and others added 2 commits September 16, 2026 07:27
Add hooks.suppress_hook_warning config option and RTK_SUPPRESS_HOOK_WARNING
env var to disable "No hook installed" and "Hook outdated" warnings.

Users running rtk via CLAUDE.md instructions instead of hooks, or with
tools like OpenCode, get these warnings on every command. The warnings
waste tokens and confuse AI agents since rtk is working correctly.

RTK_SUPPRESS_HOOK_WARNING=1 suppresses; any other value forces the warning
on; unset falls back to the config file. Both default to false so existing
behavior is unchanged. The env parse follows the repo's
as_deref() == Ok("1") convention.

The suppression check runs before status() so the suppressed path does not
pay for the hook probe.

Documented in configuration.md (the hooks block and the env var table) and
README.md.

Fixes rtk-ai#682

Signed-off-by: Matt Van Horn <[email protected]>
…verride

Parse RTK_SUPPRESS_HOOK_WARNING as a truthy/falsy override that falls
back to config when unset or unrecognised, keep the HookStatus::Ok fast
path free of config loading, and suppress only the missing-hook warning
so the outdated-hook upgrade prompt stays visible.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01CNmJZVV9u6pBhcwVhwkPp6
@mvanhorn
mvanhorn force-pushed the osc/682-suppress-hook-warning-config branch from dfb8886 to 4e53f76 Compare September 16, 2026 14:46
@mvanhorn

Copy link
Copy Markdown
Contributor Author

All three are in 4e53f76, on top of a rebase onto develop. The env var now parses truthy and falsy values and only overrides when it is actually set, so true works and an unrecognised value no longer vetoes config.toml. check_and_warn() probes status() first and returns on Ok before touching Config::load(), so the common path pays nothing new. And the flag is scoped to Missing: an outdated hook still prints the upgrade prompt, which is what #682 asked for and no more. Docs and README say so now.

…sition

`rtk gain` printed its own missing-hook line from a bare `status()` match,
outside `maybe_warn`, so neither `hooks.suppress_hook_warning` nor
`RTK_SUPPRESS_HOOK_WARNING` reached it — on the report the no-hook audience
reads most. Gate that arm on the same helper; the outdated-hook prompt stays
visible, as it does everywhere else.

The new unit tests exercise the parser alone, so folding env and config
together with `||` — which drops the falsy force-off — left the whole suite
green. Drive the composition through the binary instead, and give the env
table the `=0` row that overrides the config flag.

The suite pins `XDG_CONFIG_HOME`/`XDG_DATA_HOME` to the temporary home and
seeds the config in both the XDG and the macOS location, so the loader cannot
resolve past it: `dirs::config_dir` is `~/.config` on Linux but
`~/Library/Application Support` on macOS, and a runner that exports either
`XDG_*` reached the developer's own config before.

Co-Authored-By: Claude Opus 5 <[email protected]>
@KuSh
KuSh force-pushed the osc/682-suppress-hook-warning-config branch from f3e2cbf to d2e906a Compare September 18, 2026 00:16

@KuSh KuSh 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.

Round 3 of 3 — APPROVED

Claim: let users permanently silence the recurring missing-hook warning via hooks.suppress_hook_warning and RTK_SUPPRESS_HOOK_WARNING.
Scope: accept.
CI @d2e906a0: all green — clippy, fmt, doc review, test presence, ubuntu/macos/windows, Security Scan, semgrep, benchmark, CLA.

Blocks merge (0)

Everything from the first two rounds is verified fixed by execution, not by reading. I built this head and the previously reviewed one with separate target dirs (hashes confirmed distinct) and ran a 90-cell matrix — 2 hook states x 3 config states x 15 env values — each cell in a fresh HOME/XDG_CONFIG_HOME/XDG_DATA_HOME/CLAUDE_CONFIG_DIR under LC_ALL=C:

before after
cfg=true, env "" / " " (the CI empty-string veto) WARNS silent
cfg=*, env true/TRUE/" true "/yes/on WARNS silent
cfg=true, env maybe / 2 WARNS silent
Outdated hook + suppression silent WARN-outdated

23 of 90 cells changed, all in the intended direction, and the falsy force-off (0/false/no/off beating cfg=true) is intact. The hot-path fix is confirmed by syscall count: on HookStatus::Ok the previous head opened config.toml twice, this one opens it once. Merge onto latest develop is clean and green.

Nicely done on parse_suppress_hook_warning_env — extracting the pure parser is what made the precedence testable without touching process env or the config cache.

Fixup pushed — d2e906a0

Two things I folded in rather than sending back for a fourth round:

  1. rtk gain ignored the flag. It prints its own missing-hook line from a bare status() match, outside maybe_warn, so neither the config option nor the env var reached it — on the report the no-hook audience reads most, which is the audience #682 is about. Its Missing arm is now gated on hook_warning_suppressed(); the outdated prompt stays visible, consistent with the scoping in this PR.
  2. The env tests were tautologies. They exercise the parser alone, so hook_warning_suppressed() — which composes env and config — had no coverage. Rewriting it as config || env.unwrap_or(false), dropping the falsy force-off this PR just added, kept the entire suite green while the binary silently regressed. tests/hook_warning_scope_test.rs now drives the composition through the real binary, and both gaps are mutation-checked: reverting either fix fails a test.

The suite also now pins XDG_CONFIG_HOME/XDG_DATA_HOME to the temp home and seeds the config in both the XDG and macOS locations. My first attempt at these tests passed locally and failed on both Unix runners — dirs::config_dir() is ~/.config on Linux but ~/Library/Application Support on macOS. That was my bug, fixed in the same commit; it incidentally hardens the pre-existing tests in that file, which were reading the developer's real config too.

Next

Nothing — approving. Merges as-is.

@KuSh
KuSh merged commit 6d10430 into rtk-ai:develop Sep 18, 2026
11 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Sep 18, 2026
@mvanhorn

Copy link
Copy Markdown
Contributor Author

Thanks for the merge, @KuSh. The env var should cover the CLAUDE.md and OpenCode paths without anyone needing to touch config.toml.

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

Labels

effort-small Quelques heures, 1 fichier enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need config to suppress warnings like "No hook installed — run rtk init -g for automatic token savings"

4 participants