feat: add heuristic cleanup for common project directories (#328)#332
Open
rh42-ic wants to merge 9 commits into
Open
feat: add heuristic cleanup for common project directories (#328)#332rh42-ic wants to merge 9 commits into
rh42-ic wants to merge 9 commits into
Conversation
- Add declarative TOML-based heuristic engine in `etc/heuristics/` - Support common languages: Rust, Node.js, Python, Java, PHP, Dart, Elixir, Zig, macOS - Integrate with TUI: auto-detect project type on directory navigation - Highlight matched build/cache directories in yellow - Add dynamic bottom-right help text (e.g., `clean-rust = X`) - Press `X` to quickly mark matched directories for deletion
- Use `OnceLock` to parse heuristic TOML files only once instead of on every directory change - Avoid blocking the UI thread with filesystem I/O by matching heuristics against the already-loaded in-memory entries - Eliminate string allocations in the render loop by using `OsStr` comparisons instead of `to_string_lossy()`
- Support glob patterns in heuristic `patterns` (e.g., `*.log`) - Make heuristic matching case-insensitive on Windows and macOS - Auto-discover and include TOML files in `etc/heuristics/` via `build.rs` - Re-evaluate heuristics immediately after deleting marked entries
- Centralize matching logic in `Heuristic::is_match` - Fix directory matching flaw for patterns ending with `/` - Use `&'static Heuristic` to avoid unnecessary cloning - Panic on invalid built-in TOML heuristic configs - Simplify UI color logic and remove redundant functions
- Move `prev_view_root` capture before ESC key handling to correctly detect directory changes and trigger `update_heuristics`.
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.
Description
This PR implements an initial prototype of the declarative heuristic engine discussed in #328.
This code is currently a draft and serves as a proof of concept. It requires further discussion, thorough code review, and extensive testing before merging. I am opening this PR now to gather early feedback on the implementation and architectural direction.
Key Changes
etc/heuristics/clean-rust = X)Xto quickly mark matched directories for deletion