Skip to content

fix: correct TuiStats size comment, revert cost_cents to u32#132

Merged
mike1858 merged 1 commit intoPiebald-AI:mainfrom
Sewer56:fix/tuistats-size-comment
Mar 15, 2026
Merged

fix: correct TuiStats size comment, revert cost_cents to u32#132
mike1858 merged 1 commit intoPiebald-AI:mainfrom
Sewer56:fix/tuistats-size-comment

Conversation

@Sewer56
Copy link
Contributor

@Sewer56 Sewer56 commented Mar 15, 2026

Summary

  • Updates the outdated comment (24 → 40 bytes)
  • Reverts cost_cents from u64 back to u32, saving 8 bytes

Fixes comment oversight from #130.

Details

TuiStats is now 40 bytes instead of 48 bytes. While TuiStats does aggregate totals per session/day, a u32 for cost_cents supports up to $43M per day - far beyond realistic usage. For comparison: the user from #129 spent $177K over 3 months.

Ref: #129 (comment)

Summary by CodeRabbit

Release Notes

  • Refactor
    • Optimized internal cost calculation and storage to improve memory efficiency while maintaining consistent cost tracking functionality.

TuiStats is now 40 bytes instead of 48 bytes. The cost_cents does not
need widening - it wastes 8 bytes once padding is accounted for.
TuiStats only aggregates for Session/Message/Day.

u32 for cost_cents supports up to $43M per day, which is more than
sufficient (current usage: $177K over 3 months).
@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

📝 Walkthrough

Walkthrough

The cost_cents field in the TuiStats struct was changed from u64 to u32, reducing the stored numeric type. All related conversions, method implementations, and field assignments were updated across three files to use the new type while maintaining calculation correctness through explicit casting where needed.

Changes

Cohort / File(s) Summary
Core Type Definition
src/types.rs
Updated TuiStats struct with cost_cents field changed from u64 to u32. All related methods (set_cost, add_cost, From<&Stats> implementation, AddAssign, SubAssign) updated to cast and use u32 for cost operations.
Conversion and Casting
src/contribution_cache/single_message.rs
Adjusted cast in PackedStatsDate::to_tui_stats conversion from u64 to u32 to align with updated TuiStats.cost_cents type.
TUI Rendering Logic
src/tui.rs
Changed best_cost_cents local variable from u64 to u32 in draw_daily_stats_table. Added explicit u64 casts during cost accumulation in three functions to handle aggregation with the new smaller field type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through memory lanes,
Where bytes once danced in sixty-fours,
Now thirty-twos claim lesser reigns,
The struct grows lighter than before—
Optimization bounds in spacious bounds! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main changes: correcting a size comment and reverting cost_cents to u32, matching the primary objectives of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 87.50% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aac344ca-504a-424a-9dff-92179a7bd20b

📥 Commits

Reviewing files that changed from the base of the PR and between 730b9bd and c307ac8.

📒 Files selected for processing (3)
  • src/contribution_cache/single_message.rs
  • src/tui.rs
  • src/types.rs

@mike1858 mike1858 merged commit 6610d71 into Piebald-AI:main Mar 15, 2026
6 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.

3 participants