Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
usage: the allowance cards come in the Providers page's order (Zhenbao TONG on Discord)
yetone5c557c793cc8
diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.jsindex 66d9b02be..9da7754f1 100644--- a/internal/gui/assets/app.js+++ b/internal/gui/assets/app.js@@ -15669,8 +15669,9 @@ function usageAcctFold(q, open) {// The Usage page's cards in the order they were dragged to (settings// usageOrder, by provider id), as the Agents page's rows are; one it doesn't-// name keeps magpie's own order after them. The tray panel's Usage tab-// follows it too.+// name keeps the order magpie sends them in after them, the Providers+// page's (provider.InProviderOrder). The tray panel's Usage tab follows it+// too.function byUsageOrder(list) {const order = state.settings?.usageOrder || [];const rank = (q) => { const i = order.indexOf(q.provider); return i < 0 ? order.length : i; };diff --git a/internal/gui/usage.go b/internal/gui/usage.goindex 5a23cf2c1..77a9725d3 100644--- a/internal/gui/usage.go+++ b/internal/gui/usage.go@@ -187,7 +187,7 @@ func usageRoutes(mux *http.ServeMux, w Windows) {defer cancel()// a WorkBuddy (China) account's card says how its daily check-in// went (#694)- qs := provider.WithCheckins(provider.Quotas(ctx))+ qs := provider.InProviderOrder(provider.WithCheckins(provider.Quotas(ctx)))// and what each window holds whole, by what magpie routed in itqs = usage.WithWindowHolds(qs, usage.Clock())// and when each began, for its Pace number (fflake33)@@ -211,7 +211,7 @@ func usageRoutes(mux *http.ServeMux, w Windows) {ctx, cancel := context.WithTimeout(r.Context(), 30*time.Second)defer cancel()provider.RefreshUsage(ctx, id, r.URL.Query().Get("user"))- writeJSON(rw, provider.WithWindowStarts(usage.WithWindowHolds(provider.WithCheckins(provider.Quotas(ctx)), usage.Clock()), usage.Clock()))+ writeJSON(rw, provider.WithWindowStarts(usage.WithWindowHolds(provider.InProviderOrder(provider.WithCheckins(provider.Quotas(ctx))), usage.Clock()), usage.Clock()))})// WorkBuddy's daily check-in pressed now, from the Usage card, for// each account not in yet today, as `magpie accounts checkin` does; thediff --git a/internal/provider/quotas.go b/internal/provider/quotas.goindex bad34b17e..06435b08e 100644--- a/internal/provider/quotas.go+++ b/internal/provider/quotas.go@@ -16,6 +16,28 @@ func Quotas(ctx context.Context) []SubscriptionQuota {return cardsServed(subs, plans, balances, LastServed())}+// InProviderOrder is qs in the order the user put the providers in on the+// Providers page (SetOrder), each provider's cards as they came; a card of+// no provider here (a remote magpie's) after them all. The window's Usage+// page and the tray panel's Allowances tab draw them so, where the user+// hasn't arranged the cards themselves (Zhenbao TONG on Discord: the+// providers moved in the window, the tray kept its own order).+func InProviderOrder(qs []SubscriptionQuota) []SubscriptionQuota {+ at := map[string]int{}+ for i, p := range All() {+ at[p.ID] = i+ }+ rank := func(q SubscriptionQuota) int {+ if i, ok := at[q.Provider]; ok {+ return i+ }+ return len(at)+ }+ out := slices.Clone(qs)+ slices.SortStableFunc(out, func(a, b SubscriptionQuota) int { return rank(a) - rank(b) })+ return out+}+// Allotted is Quotas without the keys' balances: the accounts and plans// whose allowance runs out and starts again, which is what magpie quota// wait waits on; no key's balance is asked for.diff --git a/internal/provider/quotas_order_test.go b/internal/provider/quotas_order_test.gonew file mode 100644index 000000000..7d4a4c3ba--- /dev/null+++ b/internal/provider/quotas_order_test.go@@ -0,0 +1,47 @@+package provider++import (+ "slices"+ "testing"+)++// Zhenbao TONG on Discord: the providers moved on the window's Providers+// page, and the tray panel's Allowances tab kept its own order. The cards+// come in the providers' order now, each provider's as they came, and a+// card of no provider here (a remote magpie's) after them.+func TestQuotaCardsInProviderOrder(t *testing.T) {+ t.Setenv("HOME", t.TempDir())+ t.Setenv("USERPROFILE", t.TempDir())+ t.Setenv("XDG_CONFIG_HOME", t.TempDir())+ t.Setenv("XDG_CACHE_HOME", t.TempDir())+ for _, id := range []string{"a", "b", "c"} {+ if err := Save(Provider{ID: id, Name: id, Key: "sk-" + id, Chat: "https://" + id + ".example.com/v1", Models: []string{"m"}}); err != nil {+ t.Fatal(err)+ }+ }+ // as Quotas has them: subscriptions, then plans, then balances+ qs := []SubscriptionQuota{+ {Provider: "a", User: "a1"}, {Provider: "remote:x", User: "r"}, {Provider: "c", User: "c1"},+ {Provider: "b", Plan: "pro"}, {Provider: "a", User: "a2"}, {Provider: "c", Balance: "$1"},+ }+ cards := func(qs []SubscriptionQuota) []string {+ var out []string+ for _, q := range qs {+ out = append(out, q.Provider+"/"+q.User+q.Plan+q.Balance)+ }+ return out+ }+ if got, want := cards(InProviderOrder(qs)), []string{"a/a1", "a/a2", "b/pro", "c/c1", "c/$1", "remote:x/r"}; !slices.Equal(got, want) {+ t.Fatalf("as added: %v, want %v", got, want)+ }+ if err := SetOrder([]string{"c", "a", "b"}); err != nil {+ t.Fatal(err)+ }+ if got, want := cards(InProviderOrder(qs)), []string{"c/c1", "c/$1", "a/a1", "a/a2", "b/pro", "remote:x/r"}; !slices.Equal(got, want) {+ t.Fatalf("after SetOrder(c, a, b): %v, want %v", got, want)+ }+ // the cache's own array is left as it was+ if qs[0].User != "a1" || qs[1].User != "r" {+ t.Fatalf("Quotas' list was sorted in place: %v", cards(qs))+ }+}diff --git a/internal/tui/pages.go b/internal/tui/pages.goindex 62580a20a..4323f6b54 100644--- a/internal/tui/pages.go+++ b/internal/tui/pages.go@@ -834,7 +834,7 @@ func quotasCmd() tea.Msg {defer cancel()// a WorkBuddy (China) account's line says how its daily check-in went,// as its card in the app does- return quotaMsg(provider.WithCheckins(provider.Quotas(ctx)))+ return quotaMsg(provider.InProviderOrder(provider.WithCheckins(provider.Quotas(ctx))))}// checkinMsg is what came of c, WorkBuddy's daily check-in pressed now.