LuckymanJC on Discord ticked Google AI Studio in Settings › Allowances in the menu bar, and the macOS menu bar never showed it. The card comes from the magpie-gemini-web plugin's ai-studio provider (AIStudio2API). Its usage reports no allowance: Google AI Studio gives none to read, and the plugin only knows which models its accounts are cooling down on. With nothing cooling, the card holds just two text lines (代理出口, 管理页). quotaOfPlugin marks those Text and Aside, trayWindows has no window left, and trayCardText gives no label, so the menu bar draws nothing. The picker still offered the card because it asked only q.windows?.length. The picker now offers a card with a window that isn't text, or with a balance. That is what trayCardText can draw (withTrayKinds gives the same set its trayKind). While an account is cooling, the card has a used-100 window and is offered and drawn as before. A card ticked earlier stays in the list, under its card's name instead of its provider id, so it can be unticked. Comments in renderTrayUsage were cut to pay for this: app.js is 1,311,353 bytes against 1,311,462 at origin/main, and no budget was raised. Run on mote at this tree (970a86ff3+ this change): - go test ./internal/gui -run 'TestTray|TestCoreScriptBudget': ok (new TestTrayTextOnlyCardShowsNothing) - go test ./internal/provider -run 'TestPluginTextRowIsText|TestAIStudioServiceLinesAreText': ok - node --test tray-text-only (new), tray-inuse, tray-totals, tray-windows, tray-usage-redraw: ok, Chromium and WebKit, en/zh (tray-totals in five languages) - i18n-keys: "a plugin's words are its own" red, and red the same on origin/main970a86ff3in a clean worktree. It is already filed as #5332, #5327, #5482 and #5426. Nothing in this change touches it. - gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet of internal/gui and internal/provider: ok Broken by hand: putting back q.windows?.length makes tray-text-only red ("nothing cooling: its card is text alone, not offered"). Not tried: the real app with the real plugin and a Google account. The plugin's card shape was read from magpie-gemini-web 0.10.0's lib/studio.mjs (usage, poolUsage, accountUsage, serviceWindows) from npm. Reported-by: LuckymanJC
37 lines
1.4 KiB
Go
37 lines
1.4 KiB
Go
package gui
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/yetone/magpie/internal/provider"
|
|
)
|
|
|
|
// A card whose windows are all text (Google AI Studio's plugin with
|
|
// nothing cooling: its proxy and admin page lines) has nothing the menu
|
|
// bar can draw: no label, and no window Settings could pick. Settings'
|
|
// picker leaves such a card out (app.js renderTrayUsage, the
|
|
// tray-text-only GUI test); ticked before, it drew nothing (LuckymanJC on
|
|
// Discord). A cooldown, a reading, is shown.
|
|
func TestTrayTextOnlyCardShowsNothing(t *testing.T) {
|
|
now := time.Now()
|
|
text := []provider.QuotaWindow{
|
|
{Name: "代理出口", Display: "不走代理", Text: true, Aside: true},
|
|
{Name: "管理页", Display: "http://127.0.0.1:5000", Text: true, Aside: true},
|
|
}
|
|
q := provider.SubscriptionQuota{Provider: "ai-studio", Name: "Google AI Studio", User: "a@gmail.com", Windows: text}
|
|
if label, tip := trayCardText("en", q, now, false, false, nil); label != "" || tip != "" {
|
|
t.Fatalf("text only: %q %q", label, tip)
|
|
}
|
|
for _, w := range withTrayKinds([]provider.SubscriptionQuota{q})[0].Windows {
|
|
if w.TrayKind != "" {
|
|
t.Fatalf("%s offered as %q", w.Name, w.TrayKind)
|
|
}
|
|
}
|
|
reset := now.Add(time.Hour)
|
|
q.Windows = append([]provider.QuotaWindow{{Name: "所有模型", Used: 100, ResetsAt: &reset, Display: "冷却中"}}, text...)
|
|
if label, _ := trayCardText("en", q, now, false, false, nil); label != "100%" {
|
|
t.Fatalf("cooling: %q", label)
|
|
}
|
|
}
|