Feat/directory filter tui integration#29
Merged
Conversation
Initial scans (both tree-sitter and Serena) already honor `--filter` / `--filter-regex`, but two TUI re-parse paths previously passed `None` and would inject excluded files back into the tree mid-session: 1. `handle_file_changed` — fires when `notify` reports a modified source file. Now reads `app.filter` and returns early if the changed file's project-relative path does not match. 2. The Serena cache rescan inside `handle_tick` — fires when a `.pkl` modification time changes. Now passes `app.filter.as_deref()` to `scan_project_serena` so the rebuilt tree stays filtered. Both paths share the same filter via a new `App::filter: Option<Arc<PathFilter>>` field, populated in `main()` from the parsed CLI args immediately after `App::new`. The `Arc` is cheap to clone if we ever need to share across threads (none today) and lets borrow callers reach for `as_deref()` to produce `Option<&PathFilter>` to match the existing scan_project signatures. Event-source side needs no changes — agent tool calls targeting excluded files simply have no symbols in the tree to attribute against, so they naturally drop on the floor. 284 lib tests + 37 integration tests still pass. Smoke-tested locally that `--filter src/filter.rs --coverage` still shows only that file. Cargo.lock version bump is the normal regeneration after pulling the 0.16.0 bump from main. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When `--filter` or `--filter-regex` is set, the result is partial by construction. Surface that so readers don't mistake a filtered subset for the whole project: - `CoverageReport` gains an optional `filter: Option<String>` field storing the display form (`"src/parser"` or `"re:^src/.*\.rs$"`). `run_report` populates it from the new `filter` parameter; default is `None` for in-test construction and the existing `CoverageReport::from_project` constructor. - Text formatter prints a `Filter: <display>` line directly after the `Coverage Report (...)` header when set, suppressed otherwise. - JSON formatter adds an optional top-level `filter` field, gated by `skip_serializing_if = "Option::is_none"`. Schema-additive — readers of the existing format see an unchanged object when no filter is active; schema_version stays at 2. - `dump_tree` prints a `Filter: <display>` line under the `Project: ...` header when set. New signature takes `Option<&PathFilter>`; main.rs threads the parsed filter through. - TUI stats panel renders ` Filter: <display>` (muted accent color) immediately below the Session line when `app.filter` is set. Four new tests cover the formatter cases: - text_formatter_renders_filter_line_when_present - text_formatter_omits_filter_line_when_absent - json_formatter_includes_filter_when_present - json_formatter_omits_filter_when_absent (asserts field is absent, not `null`, preserving the additive-schema property) The nine in-test `CoverageReport` struct literals also got `filter: None,` to match the new field. 284 lib tests + 37 integration tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #29 +/- ##
=======================================
Coverage 74.14% 74.14%
=======================================
Files 25 25
Lines 6965 7054 +89
Branches 6965 7054 +89
=======================================
+ Hits 5164 5230 +66
- Misses 1693 1714 +21
- Partials 108 110 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
What changed
Honor the filter on TUI re-parse paths. Initial scans already filtered, but two paths could still inject excluded files mid-session:
notifyfile-watcher →TuiSession::handle_file_changednow readsapp.filterand returns early on non-matching paths.handle_ticknow passesapp.filter.as_deref()toscan_project_serena.Both share a new
App::filter: Option<Arc<PathFilter>>field, set inmain()from the parsed CLI args. The event-source side needs no changes — tool calls targeting excluded files have no symbols to attribute against.Surface the active filter in UI + reports. When a filter is set, the output is partial by construction; readers shouldn't have to guess.
Filter: <display>line under Session.Filter: <display>line under the report header.filterfield, omitted entirely when no filter (additive —schema_versionstays at 2).dump_tree:Filter: <display>line under theProject:header.CoverageReportgainsfilter: Option<String>(display form).run_reportanddump_treegainOption<&PathFilter>parameters;main.rsthreads through.Test plan
coverage::tests:text_formatter_renders_filter_line_when_presenttext_formatter_omits_filter_line_when_absentjson_formatter_includes_filter_when_presentjson_formatter_omits_filter_when_absent(asserts field is absent, notnull)Compatibility
App::filterdefaults toNoneinApp::new.run_report/dump_treesignatures grew anOption<&PathFilter>param.CoverageReportgained one field — existing callers using::from_projectare unaffected; direct struct literals needfilter: None.filterfield appears only when set; existing consumers see no change in the no-filter case.