Repository navigation
fix(gain): report a missing hook on every view, not just the default one with data - #4038
Merged
Merged
Conversation
📊 Automated PR Analysis
SummaryFixes Review Checklist
Linked issues: #4035 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
KuSh
force-pushed
the
fix/gain-hook-warning-every-view
branch
2 times, most recently
from
September 19, 2026 08:40
f046585 to
7caab43
Compare
4 tasks done
TaKO8Ki
requested changes
Oct 5, 2026
`rtk gain` only reported a missing or outdated hook on the default view with tracking data, so `--daily`, `--weekly`, `--monthly`, `--all` and the empty report stayed silent. The empty report is where the advice matters most: with no hook nothing is tracked, which is the likeliest reason there is nothing to show. Hoist the check into `warn_hook_issues()` and call it once, above the empty-report early return and outside the view branch. The JSON and CSV exports return earlier and stay free of it. `suppress_hook_warning` keeps hiding the missing-hook arm, and keeps leaving the outdated-hook arm visible. The tests spawn the binary through `common::rtk_command()` and pin `HOME`, `RTK_DB_PATH` and the `XDG_*` directories onto a temporary home, so a runner that exports any of them cannot reach past it. Co-Authored-By: Angel V. Rodriguez C. <[email protected]> Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
KuSh
force-pushed
the
fix/gain-hook-warning-every-view
branch
from
October 5, 2026 16:51
7caab43 to
7231fd2
Compare
Merged
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.
Fixes #4035
Problem
rtk gainreports a missing or outdated hook on only one of its invocations: the default view, and only when there is tracking data.--daily,--weekly,--monthly,--alland the empty report all stay silent.The empty report is the worst case. With no hook installed nothing is tracked, so "no data" is usually caused by the missing hook — and that is the one run where the user is told nothing:
The advice never appears there, because
rtk gainis also exempt from the daily[rtk] /!\ No hook installedreminder — exempt on the grounds that it prints its own.Cause
The
hook_check::status()block sits inside the default-view branch (if !daily && !weekly && !monthly && !all), which is itself after thesummary.total_commands == 0early return. Two gates, so four of five views and the empty report never reach it.Fix
Hoist the check into
warn_hook_issues()and call it once, above the early return and outside the view branch. The JSON and CSV exports return earlier and stay free of it.suppress_hook_warningkeeps hiding the missing-hook arm, and keeps leaving the outdated-hook arm visible — hoisting must not hand the warning back to users who opted out on the views that were previously silent.Measured
Isolated
HOMEholding a.claudedirectory with no hook registered, counting[warn] No hook installedlines:rtk gain(with data)rtk gain --dailyrtk gain --weeklyrtk gain --monthlyrtk gain --allrtk gain(empty database)rtk gain --format json/csvRTK_SUPPRESS_HOOK_WARNING=1~/.claudeat allTests
tests/gain_hook_warning_test.rs— 12 cases. The nine-case matrix is @AngelVRodC's from #4039, which covered this ground better than my original three: it counts occurrences rather than testingcontains, so a double-print fails; it seeds real tracking data viartk proxy true, so the view flags exercise the with-data path instead of the early return; it separates stdout from stderr; and it pins the not-applicable state (no~/.claude→ silent). #4039 is closed as a duplicate in favour of this PR.Three cases added on top, covering the
suppress_hook_warninginteraction.Mutation-checked, both directions:
hook_warning_suppressed()gate → 1 fails (suppress_hook_warning_hides_the_missing_arm_on_every_view)That second one is worth noting: both this PR's first revision and #4039 dropped that gate, because both were written before #776 landed. Neither the original three tests nor the nine-case matrix caught it.
The tests spawn the binary through
common::rtk_command()and pinHOME,RTK_DB_PATH,XDG_CONFIG_HOMEandXDG_DATA_HOMEonto a per-test temporary home, the sameisolating_envpattern astests/hook_warning_scope_test.rs. The earlier version pinned onlyHOME, which passed either way while writing a realrtk/history.dbinto an exportedXDG_DATA_HOME; the same run now leaves nothing outside the temporary home.Unix-gated, because
hook_check::status()resolves the Claude directory through the home directory and only Unix takes that from$HOME.Gate
Rebased on
develop.cargo fmt --allclean,cargo clippy --all-targetsclean,cargo test --all4125 passed / 0 failed, Windows cross-check clean, and green underLC_ALL=de_DE.UTF-8withGIT_DIRpointed at a real repository.🤖 Generated with Claude Code