Chat info: account quota per harness (Claude rate_limit_event, Codex account/rateLimits, OpenCode unsupported)
Usage frames carry optional usage.account {harness, source, plan, as_of,
windows[{id,label,used_percent,resets_at}], unsupported}. Claude Code quota
comes from its rate_limit_event stream lines and the initialize account
(plan), shared across chats on the same account. Codex reads
account/rateLimits/read once per connection (re-read when a chat opens after
5 min) and merges account/rateLimits/updated. OpenCode exposes no quota API
and says so. The app's chat info sheet shows an Account usage section with a
progress bar and reset countdown per window, Material and Cupertino.
This commit is contained in:
@@ -594,6 +594,46 @@ type ChatUsage struct {
|
||||
// RateBasis distinguishes a generation interval from a whole turn (which
|
||||
// can include tools/waits). Never estimate tokens from text/character counts.
|
||||
RateBasis string `json:"rate_basis,omitempty"`
|
||||
// Account is the latest account quota the harness reported (or a note that
|
||||
// it has no quota API). It is account state, not session state: a snapshot
|
||||
// carries the latest value known when it was sent. Nil means unknown.
|
||||
Account *ChatAccountUsage `json:"account,omitempty"`
|
||||
}
|
||||
|
||||
// ChatAccountUsage is a harness account's subscription quota as the harness
|
||||
// itself reported it. Nothing is estimated: windows are only those the
|
||||
// harness named, and Unsupported says the harness exposes no quota at all.
|
||||
type ChatAccountUsage struct {
|
||||
// Harness is the display name ("Claude Code", "Codex", "OpenCode").
|
||||
Harness string `json:"harness"`
|
||||
// Source names the native report, e.g. "rate_limit_event".
|
||||
Source string `json:"source,omitempty"`
|
||||
// Plan is the harness's plan identifier when it reports one ("max", "plus").
|
||||
Plan string `json:"plan,omitempty"`
|
||||
// AsOf is when the server received the report (epoch milliseconds).
|
||||
AsOf int64 `json:"as_of,omitempty"`
|
||||
Windows []ChatQuotaWindow `json:"windows,omitempty"`
|
||||
Unsupported bool `json:"unsupported,omitempty"`
|
||||
}
|
||||
|
||||
// ChatQuotaWindow is one rolling quota window. UsedPercent is 0-100 (it can
|
||||
// exceed 100 when the harness says usage ran past the cap); ResetsAt is epoch
|
||||
// milliseconds, 0 when the harness did not say.
|
||||
type ChatQuotaWindow struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
UsedPercent float64 `json:"used_percent"`
|
||||
ResetsAt int64 `json:"resets_at,omitempty"`
|
||||
}
|
||||
|
||||
// Clone returns a deep copy (nil stays nil).
|
||||
func (a *ChatAccountUsage) Clone() *ChatAccountUsage {
|
||||
if a == nil {
|
||||
return nil
|
||||
}
|
||||
copy := *a
|
||||
copy.Windows = append([]ChatQuotaWindow(nil), a.Windows...)
|
||||
return ©
|
||||
}
|
||||
|
||||
// ChatShell is the state of one shell command the agent started, carried by a
|
||||
|
||||
Reference in New Issue
Block a user