feat(tui): filter usage by model - #218
Conversation
Add an interactive model filter that recalculates aggregate usage and session visibility. Show per-period and total model shares using tokens with a message-count fallback. Signed-off-by: jimyag <git@jimyag.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe TUI adds case-insensitive model filtering with editable input, cancellation, persistent application, recalculated statistics, and filtered sessions. Aggregate rows display usage shares from visible-period statistics. Tests cover filtering, fallback data, percentages, and rendering. ChangesModel filtering and usage display
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant run_app
participant UiState
participant filter_analyzer_view_by_model
User->>run_app: press f
run_app->>UiState: activate filter editing
User->>run_app: edit or apply model text
run_app->>filter_analyzer_view_by_model: apply model filter
filter_analyzer_view_by_model-->>UiState: return filtered statistics
UiState-->>User: redraw filtered views and usage shares
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/tui.rs`:
- Around line 1514-1525: Update the non-empty model-filter branch in the
help_text construction to append the existing estimated-pricing note whenever
has_estimated_models is true, matching the behavior of the unfiltered help
branch while preserving the current filter controls and base_help_text.
- Around line 267-305: Update the DailyStats filtering logic around filtered_day
to preserve user_messages if it is consumed downstream, and handle days where
model_stats is incomplete relative to models without silently zeroing totals.
Inspect user_messages usages and the data-building paths, then apply the
established fallback behavior for matched models (at minimum preserving
message-count totals) while retaining accurate model_stats-derived metrics when
available. Ensure the reconstructed filtered_day and downstream totals remain
consistent for cached and current data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 30232248-c9dc-42f2-b0d9-12edd4978ca4
📒 Files selected for processing (2)
src/tui.rssrc/tui/tests.rs
Keep message totals and attributable stats when per-model details are incomplete. Preserve estimated-pricing guidance while a model filter is active. Signed-off-by: jimyag <git@jimyag.com>
mike1858
left a comment
There was a problem hiding this comment.
Cool, this is amazing! Thank you for all of your PRs by the way - they're very useful, and the screenshots you attach help me understand the feature better and review faster 👍
Signed-off-by: jimyag <git@jimyag.com> # Conflicts: # src/tui.rs # src/tui/tests.rs
|
@jimyag Due to merging one of the other PRs, you have some new merge conflicts. Will you please fix them? |
|
Thank you! I’m glad the PRs have been useful, and I’ll keep including screenshots where they help make the behavior easier to review. I really appreciate your time and feedback! 🙏 |

Summary
Add an interactive TUI model filter and show each model's usage share for the selected period.
Key changes
fto edit a case-insensitive, partial model-name filter; useEnterto apply,Escto cancel, andCtrl+Uto clear.Validation
cargo build --quietcargo test --quiet(401 passed)cargo clippy --quiet -- -D warningscargo doc --quietcargo fmt --all --quietgit diff --checkNotes
Summary by CodeRabbit
New Features
fkey.Bug Fixes