Files
magpie/internal/tui/usage_hidden.go
T
yetone 1ab2c39843 tray: the menu bar and panel leave out what Usage's Overview hides (onkashiko on X)
onkashiko on X: a quota hidden in the main window still showed from the
menu bar. 7ea1e6a4b made the tray panel and the TUI leave out Overview-hidden
cards and rows, but two gaps were left:

- The menu bar's cells, its tooltip and Windows' tray figure still showed a
  hidden card and its hidden rows. trayUsageCards now goes through
  trayShown: a cell naming an account takes the card the Overview still
  shows (its balance with its plan hidden), a cell following the account
  in use (`|*`) picks that account among every card as before and is left
  empty while its card is hidden, never moved to another account. Hidden
  rows are left out, a card never left with none. settings.TrayUsages is
  untouched, so the cell comes back with the card.
- POST /api/usage/arrange now wakes the menu bar (onTrayUsage) when
  cardsHidden or windowsHidden is sent, so a hide or unhide reaches it at
  once rather than at the next tick (3 minutes by default).
- The panel hid a card after keyCards had put a key's balance on its plan's
  card, so "Hide its balance from Overview" left the balance on the panel's
  plan card, and a hidden plan took its unhidden balance with it.
  panelPageCut now takes the quotas as read and leaves the hidden out before
  keyCards, as overviewCards does; gone counts a merged card hidden only
  when its plan and balance both are.

The Go hide rule (cardHideKey/usageShown) moved from internal/tui to
internal/provider (ShownQuotas, QuotaCardHidden, QuotaRowsShown,
QuotaHideKey), shared by the TUI and the menu bar. Not changed: Bark's
daily push still warns about a near-limit hidden card (an alert, not a
display). Docs: settings.go comments, docs/subsystems/gui-shell.md.

Run on mica (mote at load 117 on 18 cores), at base ee6352b63:
- go test -count=1 -timeout 45m ./internal/gui ./internal/tui
  ./internal/provider ./internal/settings: all ok.
- go vet of those packages; GOOS=linux go vet -tags nogui and GOOS=windows
  go vet of internal/gui, internal/tui, internal/provider: clean. gofmt -l
  clean.
- GUI (Chromium + WebKit, en/zh/zh-TW/ja/de): panel-hidden-balance (new),
  panel-page-hidden, panel-arrange: 28/28. panel-balance-order,
  usage-rows-hide pass. usage-cards-hide and usage-hidden-way-back are red
  at "de 560" (no sideways scroll), the same 8 on an origin/main
  ee6352b63 copy (#6294, #6295). tray-cell-click "chromium zh/en" is red
  1 run in 3 on origin/main as on this tree (#5215).
Broken by hand: panel-hidden-balance is red on origin/main's assets
(the plan card carries the hidden balance, MiniMax's balance gone);
TestTrayLeavesOutWhatTheOverviewHides is red with trayShown returning
trayPick, TestUsageArrangeWakesTheMenuBar red with the onTrayUsage call
removed.
At the pushed head (rebased on 534b1a334, which adds installdir_windows.go):
GOOS=windows go vet ./internal/gui ./internal/update and go test -run
"TestTray|TestUsageArrange|TestCoreScriptBudget" ./internal/gui: ok.
Not tried: the real menu bar on a Mac or Windows with a real account; no
full go test ./... (a full suite was running on mica).
2026-11-14 19:37:57 +08:00

14 lines
456 B
Go

package tui
import (
"github.com/yetone/magpie/internal/provider"
"github.com/yetone/magpie/internal/settings"
)
// usageShown is the cards the Usage page leaves as the app's Overview does
// (onkashiko on X: a card hidden in the app's window still showed
// elsewhere), provider.ShownQuotas. Only what is shown.
func usageShown(qs []provider.SubscriptionQuota, s settings.Settings) []provider.SubscriptionQuota {
return provider.ShownQuotas(qs, s)
}