Skip to content

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

Merged
JanDeDobbeleer merged 7 commits intoJanDeDobbeleer:nextfrom
MO2k4:feat/claude-cost-ratelimits
Apr 10, 2026
Merged

feat(claude): add cost sub-fields and rate limits#7412
JanDeDobbeleer merged 7 commits intoJanDeDobbeleer:nextfrom
MO2k4:feat/claude-cost-ratelimits

Conversation

@MO2k4
Copy link
Copy Markdown
Contributor

@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

Comment thread src/segments/claude.go Outdated
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.
@AbdelrahmanHafez
Copy link
Copy Markdown
Contributor

Can't wait to see this go live, let me know if I can help with anything.

@JanDeDobbeleer JanDeDobbeleer changed the base branch from main to next April 10, 2026 07:28
@JanDeDobbeleer JanDeDobbeleer enabled auto-merge (rebase) April 10, 2026 07:29
@JanDeDobbeleer JanDeDobbeleer disabled auto-merge April 10, 2026 07:29
@JanDeDobbeleer JanDeDobbeleer enabled auto-merge (squash) April 10, 2026 07:29
@JanDeDobbeleer JanDeDobbeleer merged commit 83b2dbe into JanDeDobbeleer:next Apr 10, 2026
9 checks passed
@JanDeDobbeleer
Copy link
Copy Markdown
Owner

@all-contributors please add @MO2k4 for code,doc

This is pure magic 🪄! @holopin-bot @MO2k4 wizard

@holopin-bot
Copy link
Copy Markdown

holopin-bot Bot commented Apr 10, 2026

Congratulations @MO2k4, the maintainer of this repository has issued you a badge! Here it is: https://holopin.io/claim/cmnslbmhm0001l4046ue9h3pz

This badge can only be claimed by you, so make sure that your GitHub account is linked to your Holopin account. You can manage those preferences here: https://holopin.io/account.
Or if you're new to Holopin, you can simply sign up with GitHub, which will do the trick!

@allcontributors
Copy link
Copy Markdown
Contributor

@JanDeDobbeleer

I've put up a pull request to add @MO2k4! 🎉

@MO2k4 MO2k4 deleted the feat/claude-cost-ratelimits branch April 10, 2026 07:37
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