diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-16 04:25:26 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-16 04:25:26 +0200 |
| commit | f55a1e88ea5948582d0e5a33efea0c5d806e1f4b (patch) | |
| tree | a180dc8c0266c87b0bc8d05a8e9c18d18748d751 /internal/hexaiaction | |
| parent | 7dd1bfa797b462791dc398690f599a2c5e5d1962 (diff) | |
Add Snapshot.ScopeReqs/ScopeRPM and simplify 3 callers
Centralizes the provider+model map traversal and window-minutes guard
that was duplicated in hexaiaction, hexaicli, and lsp.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/hexaiaction')
| -rw-r--r-- | internal/hexaiaction/prompts.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/internal/hexaiaction/prompts.go b/internal/hexaiaction/prompts.go index 61775d4..8cf8c48 100644 --- a/internal/hexaiaction/prompts.go +++ b/internal/hexaiaction/prompts.go @@ -129,20 +129,12 @@ func runOnce(ctx context.Context, client chatDoer, sys, user string, req request if model == "" { model = client.DefaultModel() } - _ = stats.Update(ctx, providerOf(client), model, sent, recv) + provider := providerOf(client) + _ = stats.Update(ctx, provider, model, sent, recv) if snap, err := stats.TakeSnapshot(); err == nil { - minsWin := snap.Window.Minutes() - if minsWin <= 0 { - minsWin = 0.001 - } - scopeReqs := int64(0) - if pe, ok := snap.Providers[providerOf(client)]; ok { - if mc, ok2 := pe.Models[model]; ok2 { - scopeReqs = mc.Reqs - } - } - scopeRPM := float64(scopeReqs) / minsWin - _ = tmux.SetStatus(tmux.FormatGlobalStatusColored(snap.Global.Reqs, snap.RPM, snap.Global.Sent, snap.Global.Recv, providerOf(client), model, scopeRPM, scopeReqs, snap.Window)) + scopeReqs := snap.ScopeReqs(provider, model) + scopeRPM := snap.ScopeRPM(provider, model) + _ = tmux.SetStatus(tmux.FormatGlobalStatusColored(snap.Global.Reqs, snap.RPM, snap.Global.Sent, snap.Global.Recv, provider, model, scopeRPM, scopeReqs, snap.Window)) } return out, nil } |
