Repository navigation
feat: add exclusion for large files and snapshots - #37
Conversation
WalkthroughAdds a new exclusion_reason carried on FileChange, expands exclusion rules (snapshot patterns and a MAX_CHANGE_LINES threshold), computes per-file changed-line totals to set exclusion reasons, and updates animation output to display the dynamic exclusion reason for skipped files. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant GitParser as Git parser
participant FileChange as FileChange struct
participant Animation as Animation loader
GitParser->>GitParser: parse diff hunks\ncompute total_changed_lines
GitParser-->>FileChange: create entry with\nexclusion_reason (Some or None)
Note right of FileChange `#DDFFDD`: exclusion_reason set to\n"too many changes (<n> lines)",\n"lock/generated file", or None
FileChange->>Animation: yield FileChange
Animation->>Animation: if FileChange.exclusion_reason.is_some()
Animation-->>Terminal: emit "📦 {path} (skipped - {reason})"
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/animation.rs(1 hunks)src/git.rs(6 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
src/git.rs
[error] 416-416: cargo fmt --all -- --check failed: code is not properly formatted. rustfmt would reformat the string literal.
🔇 Additional comments (6)
src/animation.rs (1)
331-336: LGTM! Dynamic exclusion reason display.The implementation correctly retrieves the exclusion reason from
change.exclusion_reasonand provides a sensible fallback. This allows users to see specific reasons like "too many changes (756953 lines)" or "lock/generated file" instead of a generic message.src/git.rs (5)
11-13: LGTM! Well-chosen threshold.The 2000-line limit is a reasonable threshold based on the memory estimates (~4 MB at ~2 KB per line), effectively preventing the 1.5 GB memory consumption issue while still allowing most normal file changes to animate.
60-62: LGTM! Snapshot patterns added.The
.snapand__snapshots__patterns correctly target Jest/testing snapshot files, which commonly have massive line counts and are the primary culprits for the freezing issue described in the PR.
76-76: Enhanced pattern matching for directory-based exclusions.The addition of
path.contains(pattern)correctly handles directory-based patterns like__snapshots__, allowing paths such astests/__snapshots__/test.snapto be excluded. While this could theoretically cause false positives for unusual filenames containing these patterns, the specific patterns in use make this unlikely.
164-164: LGTM! New field for exclusion metadata.The
exclusion_reasonfield appropriately captures and propagates the specific reason why a file was excluded, enabling better user feedback in the animation UI.
519-525: LGTM! Comprehensive snapshot exclusion test.The test correctly validates that snapshot files are excluded in various scenarios: standalone
.snapfiles, files within__snapshots__directories, and nested paths. Good coverage of the new exclusion patterns.
- Add snapshot files (.snap, __snapshots__) to exclusion patterns - Limit animation to files with ≤2000 changed lines to prevent memory issues - Add exclusion_reason field to FileChange to show why files are skipped - Display specific exclusion reasons in terminal output 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
9dcb567 to
c9d197f
Compare
Summary
Problem
The application would freeze when encountering commits with very large files (e.g., test snapshots with 750k+ lines of changes). This caused excessive memory consumption (~1.5GB) and made the application unusable.
Solution
.snapand__snapshots__to excluded patternsMemory Estimation
Test Plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests