Skip to content

feat: add exclusion for large files and snapshots - #37

Merged
unhappychoice merged 1 commit into
mainfrom
feat/limit-large-files
Nov 11, 2025
Merged

unhappychoice merged 1 commit into
mainfrom
feat/limit-large-files

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Nov 11, 2025 •

Copy link
Copy Markdown
Owner

Summary

  • Add snapshot files to exclusion patterns to prevent animation freeze
  • Limit animation to files with ≤2000 changed lines
  • Display specific exclusion reasons in terminal output

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

  1. Snapshot File Exclusion: Added .snap and __snapshots__ to excluded patterns
  2. Change Line Limit: Files with more than 2000 changed lines are automatically skipped
    • Memory consumption: ~4MB per file (acceptable)
    • Animation time: ~1.3 hours (reasonable for screensaver mode)
  3. Exclusion Reason Display: Show why files are skipped (e.g., "too many changes (756953 lines)")

Memory Estimation

  • Per changed line: ~2KB (includes InsertLine, InsertChar for each character, Pause)
  • 2000 lines: ~4MB ✅
  • 750k lines: ~1.5GB ❌ (previous issue)

Test Plan

  • All existing tests pass
  • New test for snapshot file exclusion
  • Tested with problematic commit (684ba2b with 756k deletions)
  • Application no longer freezes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Skipped files now show a specific exclusion reason in the output for clearer feedback.
    • Snapshot and lock/generated file patterns are recognized and excluded automatically.
    • Files with very large changes are auto-excluded when they exceed a configured change threshold.
  • Tests

    • Added tests to verify snapshot and exclusion behaviors and retained coverage for lock/minified exclusions.

@coderabbitai

coderabbitai Bot commented Nov 11, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds 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

Cohort / File(s) Summary
Animation output
src/animation.rs
Use change.exclusion_reason (default "excluded file") in TerminalOutput for skipped files instead of the previous hard-coded "generated file" message.
Git parsing & exclusion logic
src/git.rs
Add MAX_CHANGE_LINES constant; detect snapshot-related patterns (.snap, __snapshots__) in full paths; compute total_changed_lines per file; set exclusion_reason when excluding due to lock/generated files or too many changes; add pub exclusion_reason: Option<String> to FileChange.
Tests
src/git.rs (tests)
Add test_should_exclude_snapshot_files; retain/extend tests covering lock/minified exclusion behavior.

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})"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Attention areas:
    • Correctness of total_changed_lines calculation (exclude context, count only changed lines)
    • Boundary behavior around MAX_CHANGE_LINES and its constant value
    • Snapshot pattern matching on full path (edge cases like directories vs filenames)
    • Propagation of exclusion_reason into animation rendering and tests

Possibly related PRs

Poem

🐰
I counted hunks and hopped the line,
If changes bloat, I skip in time.
Snapshots, locks — I know the reason,
I tell the log and save the season.
Tiny rabbit, tiny cheer, edits clear! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: exclusion of large files and snapshots to prevent application freezing.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/limit-large-files

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9dcb567 and c9d197f.

📒 Files selected for processing (2)
  • src/animation.rs (1 hunks)
  • src/git.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/animation.rs
🔇 Additional comments (5)
src/git.rs (5)

11-13: LGTM! Well-chosen threshold with clear documentation.

The 2000-line limit aligns with the PR's memory estimation (~4 MB) and effectively prevents the performance issues described in the PR objectives.


60-62: LGTM! Snapshot patterns correctly added.

The patterns correctly target Jest/Vitest snapshot files and directories, directly addressing the animation freeze issue described in the PR.


76-76: LGTM! Path matching correctly handles snapshot directories.

The added path.contains(pattern) check correctly enables matching of __snapshots__ directories anywhere in the path (e.g., tests/__snapshots__/file.snap). The patterns are specific enough to avoid significant false positives.


164-164: LGTM! Exclusion reason field properly added.

The exclusion_reason field enables dynamic skip messages in the animation output, as described in the PR objectives.


516-522: LGTM! Comprehensive test coverage for snapshot exclusion.

The test cases appropriately verify exclusion of .snap files and __snapshots__ directories in various path positions, ensuring the new patterns work as intended.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e934040 and 9dcb567.

📒 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_reason and 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 .snap and __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 as tests/__snapshots__/test.snap to 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_reason field 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 .snap files, files within __snapshots__ directories, and nested paths. Good coverage of the new exclusion patterns.

Comment thread src/git.rs Resolved
- 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]>
@unhappychoice
unhappychoice merged commit 90aae09 into main Nov 11, 2025
@unhappychoice
unhappychoice deleted the feat/limit-large-files branch November 11, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant