Repository navigation
Fix: Correct project summary statistics when filtering is active - #2
Conversation
When filtering projects, the summary stats (orphan count, active count, selected count) were calculated from all projects instead of the filtered projects. This caused a mismatch between the Projects tab and Preview tab. Changes: - Use filtered project indices instead of all projects for summary stats - Display filtered project count instead of total project count - Ensures consistency when searching/filtering projects Fixes GarrickZ2#1
selected_count and selected_size should reflect all selected projects regardless of the active filter, consistent with how Preview tab calculates what will be cleaned. orphan_count, active_count, and display count remain filter-scoped (from PR GarrickZ2#2). Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
GarrickZ2
left a comment
There was a problem hiding this comment.
1. PR description / code mismatch (important)
The description states:
selected_countandselected_sizenow use filtered projects
But in the diff, selected_count (line 215) and selected_size (lines 216-221) still iterate over result.projects.iter() — only orphan_count, active_count, and the displayed total were switched to filtered.
Please clarify the intent:
- If keeping Selected global is intentional (which I'd lean toward — the Preview tab deletes everything selected regardless of whether the filter currently hides it), then update the PR description to remove those two bullets, and consider adding a brief comment explaining why Selected stays global while orphan/active follow the filter.
- If Selected really should follow the filter, then lines 215-221 need the same treatment. Otherwise, when a filter is active, "Selected: X" in this summary will disagree with the Preview tab — which contradicts the stated goal of making the two views consistent.
2. Mixed-scope summary line is confusing
With the current change, when a filter is active the summary reads:
```
{} projects ({} orphan, {} active) | Selected: {} ({})
```
The left half reflects the filtered view, but the right half (Selected) is global. Users may misread it. Two options:
- Show both counts when filtered, e.g. `{filtered}/{total} projects (...)`.
- Append a ` (filtered)` marker when a filter is active to signal that the left half is a subset.
When a search filter narrows the project list, the summary left half (project count, orphan, active) reflects the filtered view while Selected stays global — because the Preview tab deletes all selected projects regardless of whether the filter hides them. Without a visual cue this mixed scope is confusing. Now the count reads "3/10 projects" when filtered and "10 projects" when not, making the asymmetry immediately obvious. Also removes incorrect PR description bullets that claimed selected_count and selected_size were changed to use filtered indices — they intentionally remain global.
|
Thanks for the detailed review! Both points addressed in the latest commit. On point 1 (description mismatch): You're right — On point 2 (mixed-scope confusion): Went with the |
Problem
When filtering projects in the Projects tab, the summary statistics (orphan count, active count, selected count) were calculated from all projects instead of the filtered projects. This caused a mismatch between the Projects tab and the Preview tab.
Root Cause
In
src/ui/projects.rs, the summary statistics usedresult.projectsfor all calculations, even though the table displayed only the filtered projects. This inconsistency was confusing to users.Solution
Changed the summary calculations to use the
filteredproject indices:orphan_countnow counts orphans in filtered resultsactive_countnow reflects filtered projectsselected_countandselected_sizenow use filtered projectsresult.projects.len()tofiltered.len()Changes
Fixes #1