Skip to content

Fix: Correct project summary statistics when filtering is active - #2

Merged
GarrickZ2 merged 3 commits into
GarrickZ2:masterfrom
Duo-Huang:fix/project-summary-calculation
May 11, 2026
Merged

GarrickZ2 merged 3 commits into
GarrickZ2:masterfrom
Duo-Huang:fix/project-summary-calculation

Conversation

@Duo-Huang

Copy link
Copy Markdown
Contributor

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 used result.projects for 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 filtered project indices:

  • orphan_count now counts orphans in filtered results
  • active_count now reflects filtered projects
  • selected_count and selected_size now use filtered projects
  • Display count changed from result.projects.len() to filtered.len()

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 #1

claude and others added 2 commits April 25, 2026 12:33
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 GarrickZ2 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

1. PR description / code mismatch (important)

The description states:

selected_count and selected_size now 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.
@Duo-Huang

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed review! Both points addressed in the latest commit.

On point 1 (description mismatch): You're right — selected_count and selected_size intentionally stay global. The Preview tab deletes all selected projects regardless of the active filter (preview.rs uses result.projects.iter().filter(|p| p.selected)), so keeping Selected global ensures the summary always matches what will actually be cleaned. The PR description was wrong; corrected in the commit message.

On point 2 (mixed-scope confusion): Went with the {filtered}/{total} format — when a filter is active the count reads 3/10 projects, making the asymmetry immediately obvious inline. When no filter is active it falls back to 10 projects as before.

@GarrickZ2
GarrickZ2 merged commit 2c4f93b into GarrickZ2:master May 11, 2026
1 of 2 checks passed
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.

Projects and Preview files clean are not matched

3 participants