tray: every window a card reports can be picked alone for the menu bar, Cursor's Grok Bot too (CrazyJal on X)
CrazyJal on X (tweet 2116833523604886006): Settings > Usage > Menu bar
windows, Cursor's pill had no choice for the Grok Bot window alone.
Why: the picker offered only the windows the menu bar shows unpicked
(trayWindows), which leaves out every window set aside. The Cursor
plugin reports Grok Bot aside (so it doesn't stop Cursor's models), so
it was never offered. And kinds were only a span ("7d"): Grok Bot and a
weekly plan's Weekly are both 7 days, as are Antigravity's two pools, so
two windows shared one kind, the GUI showed one of them, and picking it
picked both. The plugin reports the window fine; nothing changes there.
Fix (the class, every provider): trayChoices lists every window of a
card that the menu bar can say as a percent (trayCounted): the usual
ones first, then the rest (money aside, one model's window, Grok Bot),
marked TrayExtra and shown only when picked. Every choice has a kind of
its own: a usual window keeps its span's kind where it is the only one
of that span (so existing picks like claude:["5h"] keep working);
another of that span, and every extra, gets its model or name after it
("7d:grok bot", "7d:gemini · 7 days"). Unpicked, every card shows what
it showed before. The Settings pill offers the extras, and drops a pick
only when it is empty or exactly the usual windows.
Run (mote, at this tree, committed then as 0750aa783, on origin/main 15b035eef):
- go test -count=1 ./internal/gui ./internal/provider ./internal/settings:
provider ok, settings ok; gui red only on TestMainWindowCorners,
red the same on origin/main 15b035eef on mote (filed #3949).
- GOOS=windows go vet ./internal/gui ./internal/provider: ok. gofmt -l clean.
- win-run go test ./internal/gui -run 'TestTray|TestWithTrayKinds': ok.
- GUI (Chromium + WebKit, en/zh/zh-TW/ja/de, narrow): tray-windows 20/20;
with i18n-keys, old-webkit, tray-usages, tray-totals, tray-cost,
tray-logos, tray-inuse: every one ok but tray-windows' new subtest
before its names were read through t() (fixed, then 20/20).
- No size budget touched; traywindows.js is loaded only with the menu bar.
Broken by hand: trayChoices without the extras -> TestWithTrayKinds and
TestTrayWindowsPickAside red; the old save rule (v.length < ws.length)
-> tray-windows red in every language.
Not tried: a real Cursor account in the real menu bar (the fixture is the
plugin's own window shape, index.mjs botUsage: aside, 7 days); the Linux
gui package (wsl-run lacks webkitgtk-6.0 headers to build it). A user who
picked "7d" on a card with two 7-day usual windows (Antigravity's pools)
falls back to every window and picks again; that pick was ambiguous before.
Rebased on c0477aa72 (app.js, Providers reset rows; nothing in common)
and run again at the pushed head on mote: go test ./internal/gui -run
'Budget|Tray|Size' ok; tray-windows + i18n-keys (both engines, every
language) 24/24.
This commit is contained in:
@@ -4,12 +4,14 @@
|
||||
// which of a subscription's windows its menu bar card shows, by kind
|
||||
// (settings.TrayWindows, StrikingRaw on X): a pill each for those ticked
|
||||
// with two or more, every window unless some are picked; not on Windows,
|
||||
// whose tooltip says them all
|
||||
// whose tooltip says them all. A window the card shows only when picked
|
||||
// (trayExtra: money aside, one model's, Cursor's Grok Bot, CrazyJal on X)
|
||||
// is offered too; its usual windows ticked alone are no pick at all.
|
||||
window.trayWindowsRow = function trayWindowsRow(s, keep, ids, mac) {
|
||||
const pick = s.trayWindows || {}, box = $("#trayWindowsPick"), subs = [];
|
||||
for (const pid of new Set(ids.filter((id) => !id.startsWith("usage:")).map((id) => id.split("|")[0]))) {
|
||||
const ws = [], q = (quotas || []).find((q) => q.provider === pid);
|
||||
for (const w of q?.windows || []) if (w.trayKind && !ws.some((x) => x.v === w.trayKind)) ws.push({ v: w.trayKind, name: w.name, note: "" });
|
||||
for (const w of q?.windows || []) if (w.trayKind && !ws.some((x) => x.v === w.trayKind)) ws.push({ v: w.trayKind, name: w.name, note: "", extra: !!w.trayExtra });
|
||||
if (ws.length > 1) subs.push([pid, q.name, ws]);
|
||||
}
|
||||
$("#trayWindowsRow").hidden = !subs.length || !mac && document.documentElement.classList.contains("win");
|
||||
@@ -23,7 +25,8 @@ window.trayWindowsRow = function trayWindowsRow(s, keep, ids, mac) {
|
||||
if (b.classList.contains("open")) return closeProtoMenu();
|
||||
openProtoMenu(b, [{ v: "", name: "All windows", note: "" }, ...ws], on, (v) => {
|
||||
const next = { ...pick };
|
||||
if (v.length && v.length < ws.length) next[pid] = v; else delete next[pid];
|
||||
const usual = ws.filter((w) => !w.extra);
|
||||
if (v.length && !(v.length === usual.length && usual.every((w) => v.includes(w.v)))) next[pid] = v; else delete next[pid];
|
||||
savePrefs({ ...keep, trayWindows: next });
|
||||
}, "Shown in the menu bar");
|
||||
};
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
// each ticked subscription with two or more windows the menu bar can show,
|
||||
// a pill picks which of them its card shows, by kind ("5h", "7d"), every
|
||||
// window unless some are picked. The pick is saved by provider, kept when
|
||||
// another setting is saved, and All windows takes it back. Hidden on
|
||||
// another setting is saved, and All windows takes it back. A window the
|
||||
// card shows only when picked (trayExtra: Opus, Cursor's Grok Bot,
|
||||
// CrazyJal on X) is offered too, and can be picked alone. Hidden on
|
||||
// Windows, whose tray shows the tooltip alone, and with no card of two
|
||||
// windows. Every language; narrow too. No backend, the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -17,8 +19,10 @@ const assets = path.resolve(__dirname, "../assets");
|
||||
|
||||
const quotas = [
|
||||
{ provider: "claude", name: "Claude Code", icon: "claude-color", user: "a@b.c", plan: "Pro",
|
||||
windows: [{ name: "5 hours", used: 42, trayKind: "5h" }, { name: "7 days", used: 18, trayKind: "7d" }, { name: "Opus", used: 90 }] },
|
||||
windows: [{ name: "5 hours", used: 42, trayKind: "5h" }, { name: "7 days", used: 18, trayKind: "7d" }, { name: "Opus", used: 90, trayKind: "7d:opus", trayExtra: true }, { name: "Note", used: 0 }] },
|
||||
{ provider: "copilot", name: "Copilot", icon: "githubcopilot", windows: [{ name: "Premium", used: 63, trayKind: "month" }] },
|
||||
{ provider: "cursor", name: "Cursor", icon: "cursor", user: "c@d.e",
|
||||
windows: [{ name: "Weekly", used: 30, trayKind: "7d" }, { name: "Grok Bot", used: 64, trayKind: "7d:grok bot", trayExtra: true }, { name: "Total", used: 30, trayKind: "name:total", trayExtra: true }] },
|
||||
];
|
||||
|
||||
function server(lang, posts, over) {
|
||||
@@ -85,20 +89,21 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await row.waitFor();
|
||||
assert.equal(await row.locator(".name").textContent(), name);
|
||||
// one pill: Claude's, the card with two windows the menu bar can
|
||||
// show (Opus counts one model's use); Copilot has one, totals none
|
||||
// show; Copilot has one, totals none, Cursor isn't ticked
|
||||
const pills = row.locator("#trayWindowsPick button");
|
||||
await page.waitForFunction(() => document.querySelectorAll("#trayWindowsPick button").length === 1);
|
||||
assert.equal((await pills.first().textContent()).trim(), "Claude Code · " + all);
|
||||
assert.equal(await pills.first().evaluate((b) => getComputedStyle(b).borderLeftWidth), "0px");
|
||||
|
||||
// the app's menu: All windows, then each window by its name
|
||||
// the app's menu: All windows, then each window by its name, Opus
|
||||
// (shown only when picked) too
|
||||
await pills.first().click();
|
||||
const menu = page.locator(".proto-menu");
|
||||
await menu.waitFor();
|
||||
assert.equal(await page.locator("select").count(), 0);
|
||||
const items = menu.locator(".pm-item");
|
||||
assert.deepEqual((await items.locator(".pm-name").allTextContents()).map((s) => s.trim()), [all, five, seven]);
|
||||
assert.deepEqual(await items.evaluateAll((bs) => bs.map((b) => b.getAttribute("aria-checked"))), ["true", "false", "false"]);
|
||||
assert.deepEqual((await items.locator(".pm-name").allTextContents()).map((s) => s.trim()), [all, five, seven, "Opus"]);
|
||||
assert.deepEqual(await items.evaluateAll((bs) => bs.map((b) => b.getAttribute("aria-checked"))), ["true", "false", "false", "false"]);
|
||||
await items.nth(1).click();
|
||||
assert.equal(posts.length, 0, "nothing is saved till the menu closes");
|
||||
await page.keyboard.press("Escape");
|
||||
@@ -126,6 +131,42 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
});
|
||||
}
|
||||
|
||||
await t.test("a window shown only when picked, picked alone", async () => {
|
||||
for (const [lang, , all] of LANGS) {
|
||||
const posts = [];
|
||||
const { context, page, errors } = await open(browser, lang, posts, { over: { trayUsages: ["cursor|*"], trayUsage: "cursor|*" } });
|
||||
const pill = page.locator("#trayWindowsPick button");
|
||||
await page.waitForFunction((s) => document.querySelector("#trayWindowsPick button")?.textContent.trim() === s, "Cursor · " + all);
|
||||
// the vendor's window names, in the page's words where it has them
|
||||
const [weekly, total] = await page.evaluate(() => [t("Weekly"), t("Total")]);
|
||||
assert.notEqual(weekly, "", lang);
|
||||
await pill.click();
|
||||
const items = page.locator(".proto-menu .pm-item");
|
||||
await items.first().waitFor();
|
||||
assert.deepEqual((await items.locator(".pm-name").allTextContents()).map((s) => s.trim()), [all, weekly, "Grok Bot", total], lang);
|
||||
await items.nth(2).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await page.waitForFunction(() => document.querySelector("#trayWindowsPick button")?.textContent.trim() === "Cursor · Grok Bot");
|
||||
assert.deepEqual(posts.at(-1).trayWindows, { cursor: ["7d:grok bot"] }, lang);
|
||||
// Weekly with it is a pick too: the card shows Grok Bot only so
|
||||
await pill.click();
|
||||
await items.first().waitFor();
|
||||
await items.nth(1).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await page.waitForFunction((s) => document.querySelector("#trayWindowsPick button")?.textContent.trim() === s, "Cursor · " + weekly + " · Grok Bot");
|
||||
assert.deepEqual(posts.at(-1).trayWindows, { cursor: ["7d", "7d:grok bot"] }, lang);
|
||||
// Weekly alone, its usual window: no pick at all
|
||||
await pill.click();
|
||||
await items.first().waitFor();
|
||||
await items.nth(2).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await page.waitForFunction((s) => document.querySelector("#trayWindowsPick button")?.textContent.trim() === s, "Cursor · " + all);
|
||||
assert.deepEqual(posts.at(-1).trayWindows, {}, lang);
|
||||
assert.deepEqual(errors, []);
|
||||
await context.close();
|
||||
}
|
||||
});
|
||||
|
||||
await t.test("All windows takes a pick back", async () => {
|
||||
const posts = [];
|
||||
const { context, page } = await open(browser, "en", posts, { over: { trayWindows: { claude: ["7d"], codex: ["5h"] } } });
|
||||
|
||||
+88
-12
@@ -145,12 +145,83 @@ func trayWindowKind(w provider.QuotaWindow) string {
|
||||
return "name:" + strings.ToLower(strings.TrimSpace(w.Name))
|
||||
}
|
||||
|
||||
// trayShownKinds are the kinds of ws a card's rows show, as chosen in
|
||||
// Settings (settings.TrayWindows): nil, every window, when none was chosen
|
||||
// or none chosen is among ws now, so a card is never left empty.
|
||||
func trayShownKinds(ws []provider.QuotaWindow, kinds []string) []string {
|
||||
for _, w := range ws {
|
||||
if slices.Contains(kinds, trayWindowKind(w)) {
|
||||
// trayChoice is a window Settings can pick for a card's rows alone, by
|
||||
// its kind, and whether the card shows it only when picked (extra).
|
||||
type trayChoice struct {
|
||||
w provider.QuotaWindow
|
||||
kind string
|
||||
extra bool
|
||||
}
|
||||
|
||||
// trayChoices are every window of a card that the menu bar can say as a
|
||||
// percent, for Settings to pick among (settings.TrayWindows): those it
|
||||
// shows unpicked (trayWindows) first, by how long they run, then the rest
|
||||
// the Usage card has (trayCounted), which it shows only when picked: money
|
||||
// aside, one model's window, Cursor's Grok Bot (CrazyJal on X, which the
|
||||
// picker never offered for being aside). Every choice has a kind of its
|
||||
// own. One shown unpicked keeps its span's kind ("7d") where it is the
|
||||
// only one of that span; another of that span, and every extra one, is
|
||||
// named by its model or name as well ("7d:grok bot"), so a vendor adding a
|
||||
// window never moves a pick onto another.
|
||||
func trayChoices(q provider.SubscriptionQuota) []trayChoice {
|
||||
base := trayWindows(q)
|
||||
var cs []trayChoice
|
||||
n := map[string]int{}
|
||||
for _, w := range base {
|
||||
n[trayWindowKind(w)]++
|
||||
}
|
||||
for _, w := range base {
|
||||
k := trayWindowKind(w)
|
||||
if n[k] > 1 {
|
||||
k = trayNamedKind(k, w)
|
||||
}
|
||||
cs = append(cs, trayChoice{w: w, kind: k})
|
||||
}
|
||||
for _, w := range q.Windows {
|
||||
if !trayCounted(w) || slices.ContainsFunc(base, func(x provider.QuotaWindow) bool { return sameTrayWindow(x, w) }) {
|
||||
continue
|
||||
}
|
||||
cs = append(cs, trayChoice{w: w, kind: trayNamedKind(trayWindowKind(w), w), extra: true})
|
||||
}
|
||||
// a kind twice still (two windows of one name): the later is left out
|
||||
// rather than picked along with the first
|
||||
seen := map[string]bool{}
|
||||
return slices.DeleteFunc(cs, func(c trayChoice) bool {
|
||||
dup := seen[c.kind]
|
||||
seen[c.kind] = true
|
||||
return dup
|
||||
})
|
||||
}
|
||||
|
||||
// trayNamedKind is kind with w's model, or else its pool and name, after
|
||||
// it: "7d:grok bot", "7d:opus"; a kind already of the name alone stays so.
|
||||
func trayNamedKind(kind string, w provider.QuotaWindow) string {
|
||||
if strings.HasPrefix(kind, "name:") {
|
||||
return kind
|
||||
}
|
||||
who := w.Model
|
||||
if who == "" {
|
||||
who = strings.TrimSpace(w.Name)
|
||||
if w.Pool != "" && !strings.HasPrefix(who, w.Pool+" · ") { // trayShared named it so already
|
||||
who = w.Pool + " · " + who
|
||||
}
|
||||
}
|
||||
return kind + ":" + strings.ToLower(strings.TrimSpace(who))
|
||||
}
|
||||
|
||||
// sameTrayWindow is whether a and b are one window, though trayWindows
|
||||
// may have renamed it (with its pool, its family).
|
||||
func sameTrayWindow(a, b provider.QuotaWindow) bool {
|
||||
return a.Model == b.Model && a.Pool == b.Pool && a.Span == b.Span && a.Used == b.Used && a.Aside == b.Aside && a.Family == b.Family
|
||||
}
|
||||
|
||||
// trayShownKinds are the kinds among cs a card's rows show, as chosen in
|
||||
// Settings (settings.TrayWindows): nil, the windows shown unpicked, when
|
||||
// none was chosen or none chosen is among cs now, so a card is never left
|
||||
// empty.
|
||||
func trayShownKinds(cs []trayChoice, kinds []string) []string {
|
||||
for _, c := range cs {
|
||||
if slices.Contains(kinds, c.kind) {
|
||||
return kinds
|
||||
}
|
||||
}
|
||||
@@ -165,12 +236,12 @@ func withTrayKinds(qs []provider.SubscriptionQuota) []provider.SubscriptionQuota
|
||||
for i, q := range qs {
|
||||
if len(q.Windows) > 0 {
|
||||
ws := slices.Clone(q.Windows)
|
||||
for _, w := range trayWindows(q) {
|
||||
for _, c := range trayChoices(q) {
|
||||
// the window as the menu bar has it, named with its pool
|
||||
if j := slices.IndexFunc(ws, func(x provider.QuotaWindow) bool {
|
||||
return x.TrayKind == "" && x.Model == w.Model && x.Pool == w.Pool && x.Span == w.Span && x.Used == w.Used && x.Aside == w.Aside && x.Family == w.Family
|
||||
return x.TrayKind == "" && sameTrayWindow(x, c.w)
|
||||
}); j >= 0 {
|
||||
ws[j].TrayKind = trayWindowKind(w)
|
||||
ws[j].TrayKind, ws[j].TrayExtra = c.kind, c.extra
|
||||
}
|
||||
}
|
||||
q.Windows = ws
|
||||
@@ -210,9 +281,14 @@ func trayCardText(q provider.SubscriptionQuota, now time.Time, left, pace bool,
|
||||
if q.ReadAt != nil && !q.ReadAt.After(now) {
|
||||
readAt = *q.ReadAt
|
||||
}
|
||||
kinds = trayShownKinds(ws, kinds)
|
||||
cs := trayChoices(q)
|
||||
kinds = trayShownKinds(cs, kinds)
|
||||
var short, long []string
|
||||
for _, w := range ws {
|
||||
for _, c := range cs {
|
||||
w, picked := c.w, kinds != nil && slices.Contains(kinds, c.kind)
|
||||
if c.extra && !picked {
|
||||
continue // shown nowhere unless picked
|
||||
}
|
||||
used := math.Max(0, math.Min(100, w.Used))
|
||||
n := int(math.Round(used))
|
||||
word := "used"
|
||||
@@ -226,7 +302,7 @@ func trayCardText(q provider.SubscriptionQuota, now time.Time, left, pace bool,
|
||||
row = pct + " " + trayPace(p, left)
|
||||
paceNote = " · pace " + trayPace(p, left)
|
||||
}
|
||||
if kinds == nil || slices.Contains(kinds, trayWindowKind(w)) {
|
||||
if kinds == nil || picked {
|
||||
short = append(short, row)
|
||||
}
|
||||
tipPct := pct
|
||||
|
||||
@@ -2,6 +2,7 @@ package gui
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -83,18 +84,27 @@ func TestTrayWindowKind(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Settings is told each window the menu bar can show by its kind, and only
|
||||
// those: not one a single model's use counts, nor money aside; the cards
|
||||
// the cache keeps are left as they were.
|
||||
// Settings is told every window the menu bar can say as a percent by a
|
||||
// kind of its own: those it shows unpicked by their span, and one it shows
|
||||
// only when picked (a single model's, money aside) by its model or name
|
||||
// too, marked extra; a row of text gets none. The cards the cache keeps
|
||||
// are left as they were.
|
||||
func TestWithTrayKinds(t *testing.T) {
|
||||
qs := []provider.SubscriptionQuota{{Provider: "claude", Windows: []provider.QuotaWindow{
|
||||
{Name: "5 hours", Span: 5 * time.Hour},
|
||||
{Name: "Opus", Span: 7 * 24 * time.Hour, Model: "opus"},
|
||||
{Name: "Extra", Span: 30 * 24 * time.Hour, Aside: true},
|
||||
{Name: "Extra", Span: 30 * 24 * time.Hour, Aside: true, Used: 3},
|
||||
{Name: "Note", Text: true, Aside: true},
|
||||
}}, {Provider: "deepseek", Balance: "¥5"}}
|
||||
out := withTrayKinds(qs)
|
||||
if ws := out[0].Windows; ws[0].TrayKind != "5h" || ws[1].TrayKind != "" || ws[2].TrayKind != "" {
|
||||
t.Fatalf("kinds: %+v", ws)
|
||||
ws := out[0].Windows
|
||||
for i, want := range []struct {
|
||||
kind string
|
||||
extra bool
|
||||
}{{"5h", false}, {"7d:opus", true}, {"month:extra", true}, {"", false}} {
|
||||
if ws[i].TrayKind != want.kind || ws[i].TrayExtra != want.extra {
|
||||
t.Fatalf("%s: %q extra %v, want %q %v", ws[i].Name, ws[i].TrayKind, ws[i].TrayExtra, want.kind, want.extra)
|
||||
}
|
||||
}
|
||||
if qs[0].Windows[0].TrayKind != "" {
|
||||
t.Fatal("the cache's window was written")
|
||||
@@ -103,3 +113,57 @@ func TestWithTrayKinds(t *testing.T) {
|
||||
t.Fatalf("balance card: %+v", out[1])
|
||||
}
|
||||
}
|
||||
|
||||
// Every window a card reports can be picked alone (CrazyJal on X: Cursor's
|
||||
// Grok Bot wasn't offered). Cursor's plugin reports Grok Bot aside, so it
|
||||
// isn't stopping Cursor's models, with the same 7 days as a weekly plan's
|
||||
// Included window: each gets a kind of its own, Grok Bot alone shows it
|
||||
// alone, and unpicked the card is as it was, Grok Bot left out. Two
|
||||
// windows shown unpicked with one span are told apart by name.
|
||||
func TestTrayWindowsPickAside(t *testing.T) {
|
||||
now := time.Date(2026, 10, 30, 12, 0, 0, 0, time.UTC)
|
||||
week := 7 * 24 * time.Hour
|
||||
cursor := provider.SubscriptionQuota{Provider: "cursor", Name: "Cursor", User: "a@b.c", Windows: []provider.QuotaWindow{
|
||||
{Name: "Weekly", Used: 30, Span: week},
|
||||
{Name: "Grok Bot", Used: 64, Span: week, Aside: true},
|
||||
{Name: "Free usage", Display: "+$5 on us", Aside: true},
|
||||
{Name: "Total", Used: 30, Aside: true},
|
||||
}}
|
||||
out := withTrayKinds([]provider.SubscriptionQuota{cursor})[0].Windows
|
||||
if out[0].TrayKind != "7d" || out[1].TrayKind != "7d:grok bot" || !out[1].TrayExtra || out[2].TrayKind != "" || out[3].TrayKind != "name:total" {
|
||||
t.Fatalf("kinds: %+v", out)
|
||||
}
|
||||
rows := func(pick []string) []string {
|
||||
cells, _, _ := trayCardsView([]provider.SubscriptionQuota{cursor}, now, false, false, map[string][]string{"cursor": pick})
|
||||
return cells[0].Rows
|
||||
}
|
||||
if got := rows(nil); !slices.Equal(got, []string{"30%"}) {
|
||||
t.Fatalf("unpicked: %q", got)
|
||||
}
|
||||
if got := rows([]string{"7d:grok bot"}); !slices.Equal(got, []string{"64%"}) {
|
||||
t.Fatalf("Grok Bot alone: %q", got)
|
||||
}
|
||||
if got := rows([]string{"7d"}); !slices.Equal(got, []string{"30%"}) {
|
||||
t.Fatalf("Weekly alone: %q", got)
|
||||
}
|
||||
if got := rows([]string{"7d", "7d:grok bot"}); !slices.Equal(got, []string{"30%", "64%"}) {
|
||||
t.Fatalf("both: %q", got)
|
||||
}
|
||||
_, _, tip := trayCardsView([]provider.SubscriptionQuota{cursor}, now, false, false, map[string][]string{"cursor": {"7d:grok bot"}})
|
||||
if !strings.Contains(tip, "Grok Bot 64%") {
|
||||
t.Fatalf("tooltip: %q", tip)
|
||||
}
|
||||
|
||||
// two windows shown unpicked, one span: each picked alone
|
||||
two := provider.SubscriptionQuota{Provider: "x", Name: "X", Windows: []provider.QuotaWindow{
|
||||
{Name: "Requests", Used: 10, Span: week},
|
||||
{Name: "Tokens", Used: 20, Span: week},
|
||||
}}
|
||||
if ws := withTrayKinds([]provider.SubscriptionQuota{two})[0].Windows; ws[0].TrayKind != "7d:requests" || ws[1].TrayKind != "7d:tokens" {
|
||||
t.Fatalf("one span twice: %+v", ws)
|
||||
}
|
||||
cells, _, _ := trayCardsView([]provider.SubscriptionQuota{two}, now, false, false, map[string][]string{"x": {"7d:tokens"}})
|
||||
if !slices.Equal(cells[0].Rows, []string{"20%"}) {
|
||||
t.Fatalf("Tokens alone: %q", cells[0].Rows)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,9 @@ func TestTrayAntigravityPools(t *testing.T) {
|
||||
if strings.Contains(tip, "Gemini 2.5 Flash") {
|
||||
t.Errorf("the tooltip lists the models the pools stand for:\n%s", tip)
|
||||
}
|
||||
// Settings is offered the pools' window, and the card's own windows
|
||||
// are left as the cache has them
|
||||
// Settings is offered each pool's window, by its pool as the two have
|
||||
// one span, and each model's window too, which the card shows only
|
||||
// when picked; the card's own windows are left as the cache has them
|
||||
out := withTrayKinds([]provider.SubscriptionQuota{q})
|
||||
var kinds []string
|
||||
for _, w := range out[0].Windows {
|
||||
@@ -70,9 +71,14 @@ func TestTrayAntigravityPools(t *testing.T) {
|
||||
kinds = append(kinds, w.Pool+"="+w.TrayKind)
|
||||
}
|
||||
}
|
||||
if !slices.Equal(kinds, []string{"Gemini=7d", "Claude & GPT=7d"}) {
|
||||
if !slices.Equal(kinds, []string{"=name:claude opus 4.6 (thinking)", "=name:claude sonnet 4.6 (thinking)", "=name:gemini 2.5 flash", "=name:gemini 3 flash",
|
||||
"=name:gemini 3.8 flash (high)", "=name:gpt-oss 120b (medium)", "Gemini=7d:gemini · 7 days", "Claude & GPT=7d:claude & gpt · 7 days"}) {
|
||||
t.Fatalf("kinds %q", kinds)
|
||||
}
|
||||
// the Gemini pool alone
|
||||
if cells, _, _ := trayCardsView([]provider.SubscriptionQuota{q}, now, true, false, map[string][]string{"antigravity": {"7d:gemini · 7 days"}}); !slices.Equal(cells[0].Rows, []string{"94%"}) {
|
||||
t.Fatalf("the Gemini pool alone: %q", cells[0].Rows)
|
||||
}
|
||||
if q.Windows[6].Name != "7 days" || q.Windows[6].TrayKind != "" {
|
||||
t.Fatalf("the cache's window was written: %+v", q.Windows[6])
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ func TestQuotaSpanCarriesEveryWindowField(t *testing.T) {
|
||||
"capId": "the GUI's cap marks (WithCapped)",
|
||||
"startsAt": "the GUI's Pace number (WithWindowStarts)",
|
||||
"trayKind": "the GUI's menu bar picker (gui.withTrayKinds)",
|
||||
"trayExtra": "the GUI's menu bar picker (gui.withTrayKinds)",
|
||||
}
|
||||
names := func(t reflect.Type) map[string]bool {
|
||||
out := map[string]bool{}
|
||||
|
||||
@@ -114,8 +114,13 @@ type QuotaWindow struct {
|
||||
StartsAt *time.Time `json:"startsAt,omitempty"`
|
||||
// TrayKind is, for the GUI only, how Settings names the window among
|
||||
// those the menu bar can show (gui.withTrayKinds): "5h", "7d",
|
||||
// "month"; empty on one the menu bar leaves out.
|
||||
// "month", "7d:grok bot"; empty on one the menu bar can't say as a
|
||||
// percent.
|
||||
TrayKind string `json:"trayKind,omitempty"`
|
||||
// TrayExtra is, for the GUI only, set on a window with a TrayKind that
|
||||
// the menu bar shows only when picked (gui.trayChoices): money aside,
|
||||
// one model's window, Cursor's Grok Bot.
|
||||
TrayExtra bool `json:"trayExtra,omitempty"`
|
||||
// matches further scopes pools whose membership isn't one model word.
|
||||
matches func(string) bool
|
||||
// partial is set on the windows of a reading that may leave some out:
|
||||
|
||||
Reference in New Issue
Block a user