status page usage

This commit is contained in:
Ian Gulliver
2026-10-16 10:47:53 -07:00
parent a800ac4f56
commit 919e1f8002
7 changed files with 106 additions and 10 deletions
+3
View File
@@ -232,6 +232,9 @@ func codexRateLimit(r codex.RateLimitSnapshot) map[string]any {
if w.ResetsAt != 0 {
window["resetsAt"] = w.ResetsAt
}
if w.WindowDurationMins != 0 {
window["windowMins"] = w.WindowDurationMins
}
windows[name] = window
}
info := map[string]any{"status": status, "unifiedWindows": windows, "planType": r.PlanType}
+18
View File
@@ -779,6 +779,8 @@ func (m *Manager) handle(ctx context.Context, l *live, ev claude.Event) error {
return err
}
addClaudeWindowMins(info.RateLimitInfo)
m.mu.Lock()
m.rateLimits[l.vendor] = info.RateLimitInfo
if info.RateLimitInfo["status"] == "rejected" {
@@ -1037,6 +1039,22 @@ func (m *Manager) event(l *live, actor, kind string, payload map[string]any) api
return ev
}
func addClaudeWindowMins(info map[string]any) {
windows, _ := info["unifiedWindows"].(map[string]any)
for name, w := range windows {
window, ok := w.(map[string]any)
if !ok {
continue
}
switch {
case strings.HasPrefix(name, "five_hour"):
window["windowMins"] = 5 * 60
case strings.HasPrefix(name, "seven_day"):
window["windowMins"] = 7 * 24 * 60
}
}
}
func decode(raw json.RawMessage) (any, error) {
if len(raw) == 0 {
return nil, nil