From f55a1e88ea5948582d0e5a33efea0c5d806e1f4b Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Mon, 16 Mar 2026 04:25:26 +0200 Subject: 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 --- internal/hexaiaction/prompts.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'internal/hexaiaction') 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 } -- cgit v1.2.3