feat: smarter diff filtering for minDiffLines + pass cache (hook v1.2.0) - #4
Open
darrylmorley wants to merge 2 commits into
Open
feat: smarter diff filtering for minDiffLines + pass cache (hook v1.2.0)#4darrylmorley wants to merge 2 commits into
darrylmorley wants to merge 2 commits into
Conversation
Replace raw line counting with countMeaningfulDiffLines: only +/- change lines are considered (git metadata and context lines are ignored), and import-only, comment-only, and blank lines are filtered out. Within each hunk, removed/added lines with identical whitespace-normalized content cancel out, so reindents and pure line moves no longer count toward the threshold. The hook script is now guarded by import.meta.main so its pure functions can be imported by the new bun test suite without executing the hook. Script version bumped to v1.1.0 so the app offers the update. Fixes #1 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaLnfPXe58Gthpy6RoCwMJ
Fingerprint the diff plus review-relevant config (model, temperature, weights, custom instructions, blockOnWarnings) and store it per-project in /tmp after a non-blocking review. Subsequent stops with an unchanged diff skip the Ollama call and log SKIPPED. Config changes invalidate the cache; ERROR and blocking reviews never populate it. Bumps hook to v1.2.0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GaLnfPXe58Gthpy6RoCwMJ
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 #1
Problem
Two sources of wasted/misleading QA runs:
minDiffLinesskip threshold counted every non-empty line of the diff — includingdiff --git/index/@@metadata and unchanged context lines — so it barely reflected meaningful change. Import reordering could trigger a review while a one-line logic fix could still be dominated by noise.Changes
hookqa-hook.ts(v1.0.0 → v1.2.0)Smarter diff counting (#1):
countDiffLineswithcountMeaningfulDiffLines, which counts only+/-change lines (file headers+++/---, metadata, and context lines are ignored).//,/* */,*continuations,#style,<!-- -->), and import-only lines (JS/TS/Swift/Python/Javaimport, Pythonfrom … import, JS re-exports, CommonJSrequire, Rubyrequire, C/ObjC#include/#import, C#using, Rust/PHPuse, Swift@testable import).#includeis filtered as an import, but#defineand#!shebangs still count as meaningful;*ptr = x;is not mistaken for a block-comment continuation.Diff too small (N meaningful lines, min M).Pass cache (skip redundant reviews):
/tmp(same lifecycle as the existing retry files).SKIPPED: Unchanged diff already reviewed — skipping.Structural:
import.meta.mainso the pure functions are importable by tests without executing the hook. Runtime behavior is unchanged and the never-block-Claude-Code exit-0 safety path is preserved. Still fully standalone — Bun built-ins only.v1.2.0, so installed copies show the update prompt in the app's Hook tab.tests/hookqa-hook.test.ts(new)26
bun testcases: realistic multi-file diffs, per-language import filtering, whitespace cancellation, move semantics within/across hunks, multiset handling of duplicate lines, comment/preprocessor edge cases, fingerprint determinism and sensitivity (changes for diff/model/temperature/weights/instructions/blockOnWarnings; stable for unrelated fields like timeout and logging), and cache-path hygiene.BehaviourTab.swiftUpdated the "Min Diff Lines" slider description to reflect the new semantics (imports, comments, and whitespace don't count).
Behavioral note
Meaningful-line counts are lower than raw counts, so an unchanged
minDiffLinesvalue is now effectively stricter — more trivial stops will skip QA. Combined with the pass cache, repeat stops on an unchanged tree no longer hit Ollama at all. Both are the intent of #1, but existing configs will notice the shift.Testing
bun test tests/— 26 pass, 0 fail.xcodebuildbefore release.🤖 Generated with Claude Code
https://claude.ai/code/session_01GaLnfPXe58Gthpy6RoCwMJ