feat(tui): Add Monthly tab for model-by-month usage tracking#354
Open
kang-heewon wants to merge 5 commits intojunhoyeo:mainfrom
Open
feat(tui): Add Monthly tab for model-by-month usage tracking#354kang-heewon wants to merge 5 commits intojunhoyeo:mainfrom
kang-heewon wants to merge 5 commits intojunhoyeo:mainfrom
Conversation
- Add MonthlyModelUsage struct with month, model, provider, client, tokens, cost, message_count - Add monthly_models and total_months fields to UsageData - Implement monthly aggregation in aggregate_messages() with GroupBy support - Sort monthly_models by month desc, cost desc, model asc
- Add Monthly variant to Tab enum (between Daily and Stats) - Update Tab::all(), as_str(), short_name(), next(), prev() - Add get_sorted_monthly() with Date/Cost/Tokens sorting - Add Monthly branch to get_current_list_len() - Add monthly module stub to ui/mod.rs - Import MonthlyModelUsage in app.rs
- Full Month ร Model table with responsive columns - Provider/Client columns in full width mode - Sort indicator (โฒ/โผ) for Date/Cost/Tokens - Current month highlight (Yellow + Bold) - Monthly average row at bottom (AVG/MO) - Scrollbar and selection/striped styling - Empty state message
- Add Monthly count label to footer (n entries) - Change tokscale monthly CLI to open Monthly tab instead of Daily
- Update test_tab_all: expect 6 tabs with Monthly - Update test_tab_next/prev: include Monthly navigation - Update test_tab_as_str/short_name: add Monthly assertions - Update test_handle_key_tab_switch/backtab_switch: full tab cycle
Contributor
|
@kang-heewon is attempting to deploy a commit to the Inevitable Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
There was a problem hiding this comment.
2 issues found across 7 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid โ if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/tokscale-cli/src/tui/cache.rs">
<violation number="1" location="crates/tokscale-cli/src/tui/cache.rs:335">
P2: Monthly usage data is never serialized/deserialized in the cache; the new fields are always reset to empty/zero, so cached loads render an empty Monthly tab.</violation>
</file>
<file name="crates/tokscale-cli/src/tui/ui/monthly.rs">
<violation number="1" location="crates/tokscale-cli/src/tui/ui/monthly.rs:259">
P3: Scrollbar is drawn over the full inner block (`area.inner(...)`) even when the AVG/MO footer row is reserved, so it overlaps/mismatches the footer; it should use `table_area` for the scrollbar height.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| models: u.models.into_iter().map(|m| m.into()).collect(), | ||
| agents: u.agents.into_iter().map(|a| a.into()).collect(), | ||
| daily: daily?, | ||
| monthly_models: Vec::new(), |
Contributor
There was a problem hiding this comment.
P2: Monthly usage data is never serialized/deserialized in the cache; the new fields are always reset to empty/zero, so cached loads render an empty Monthly tab.
Prompt for AI agents
Check if this issue is valid โ if so, understand the root cause and fix it. At crates/tokscale-cli/src/tui/cache.rs, line 335:
<comment>Monthly usage data is never serialized/deserialized in the cache; the new fields are always reset to empty/zero, so cached loads render an empty Monthly tab.</comment>
<file context>
@@ -332,6 +332,8 @@ impl TryFrom<CachedUsageData> for UsageData {
models: u.models.into_iter().map(|m| m.into()).collect(),
agents: u.agents.into_iter().map(|a| a.into()).collect(),
daily: daily?,
+ monthly_models: Vec::new(),
+ total_months: 0,
graph: graph.transpose()?,
</file context>
|
|
||
| frame.render_stateful_widget( | ||
| scrollbar, | ||
| area.inner(Margin { |
Contributor
There was a problem hiding this comment.
P3: Scrollbar is drawn over the full inner block (area.inner(...)) even when the AVG/MO footer row is reserved, so it overlaps/mismatches the footer; it should use table_area for the scrollbar height.
Prompt for AI agents
Check if this issue is valid โ if so, understand the root cause and fix it. At crates/tokscale-cli/src/tui/ui/monthly.rs, line 259:
<comment>Scrollbar is drawn over the full inner block (`area.inner(...)`) even when the AVG/MO footer row is reserved, so it overlaps/mismatches the footer; it should use `table_area` for the scrollbar height.</comment>
<file context>
@@ -0,0 +1,282 @@
+
+ frame.render_stateful_widget(
+ scrollbar,
+ area.inner(Margin {
+ horizontal: 0,
+ vertical: 1,
</file context>
Suggested change
| area.inner(Margin { | |
| table_area.inner(Margin { | |
| horizontal: 0, | |
| vertical: 1, | |
| }), |
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.
Summary
tokscale monthlyCLI โ Monthly ํญ ๋ฆฌ๋ค์ด๋ ํธChanges
MonthlyModelUsagestruct ๋ฐmonthly_models/total_monthsํ๋ ์ถ๊ฐaggregate_messages()์ monthly ์ง๊ณ ๋ก์ง ์ถ๊ฐ (GroupBy ์ง์)Tab::Monthlyvariant ๋ฐget_sorted_monthly()ํจ์ ์ถ๊ฐmonthly.rsUI ๋ชจ๋ ์์ฑ (daily.rs ํจํด ๊ธฐ๋ฐ)Test plan
cargo clippy --package tokscale-cli๊ฒฝ๊ณ ์์cargo build --package tokscale-cli์ฑ๊ณตcargo test --package tokscale-cliTab ๊ด๋ จ ํ ์คํธ ํต๊ณผNotes
test_data_loader_*,test_handle_key_increase_decrease_refresh)๋ main ๋ธ๋์น์์๋ ์คํจํ๋ ๊ธฐ์กด ์ด์์ ๋๋ค.Summary by cubic
Adds a Monthly tab to the TUI for model-by-month usage tracking with sorting, scrolling, and an AVG/MO row. Monthly data is now aggregated during load, and
tokscale monthlyopens this tab.DataLoaderwithMonthlyModelUsage, plusmonthly_modelsandtotal_months.Tab::Monthlywith Date/Cost/Tokens sorting, selection, scroll, and footer count.monthlyUI: responsive columns (Month/Model/Provider/Client/Tokens/Cost), current month highlight, AVG/MO row, scrollbar, empty state.tokscale monthlynow redirects to the Monthly tab.Written for commit 81c06eb. Summary will update on new commits.