Skip to content

feat(claude): add cost sub-fields and rate limits#7412

Open
MO2k4 wants to merge 7 commits intoJanDeDobbeleer:mainfrom
MO2k4:feat/claude-cost-ratelimits
Open

feat(claude): add cost sub-fields and rate limits#7412
MO2k4 wants to merge 7 commits intoJanDeDobbeleer:mainfrom
MO2k4:feat/claude-cost-ratelimits

Conversation

@MO2k4
Copy link
Copy Markdown

@MO2k4 MO2k4 commented Mar 23, 2026

Summary

  • Add TotalAPIDurationMS, TotalLinesAdded, TotalLinesRemoved fields to ClaudeCost struct
  • Add ClaudeRateLimits and ClaudeRateLimitWindow structs with nil-safe FiveHourUsage() and SevenDayUsage() helpers returning Percentage
  • Add FormattedDuration() and FormattedAPIDuration() methods for human-readable session/API duration
  • Document all new properties in the Claude segment MDX docs

Test plan

  • All 7 Claude tests pass (TestClaudeSegment, TestClaudeTokenUsagePercent, TestClaudeFormattedCost, TestClaudeFormattedDuration, TestClaudeFormattedAPIDuration, TestClaudeFormattedTokens, TestClaudeRateLimitUsage)
  • Rate limit tests cover nil limits, nil windows, nil percentages, rounding, and capping at 100
  • Duration tests cover zero, seconds-only, minutes+seconds, exact minute
  • Existing test fixture updated with new fields

MO2k4 added 2 commits March 23, 2026 15:36
Replace raw int64 duration fields with a DurationMS custom type
that implements fmt.Stringer for direct use in templates.
Reorder struct fields to reduce pointer bytes and satisfy
the fieldalignment CI check.
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.

2 participants