usage: a hidden card a menu bar cell showed offers Show in Overview, not Hide again
Found while fixing yuu003348's report (dee1afa40). A card hidden from Usage › Overview still shows when a menu bar cell asks for it (usagePeek), and the "{n} hidden" line leaves it out while it shows. Its menu offered only "Hide from Overview" again, so from that card there was no way back. Now its menu has "Show in Overview" (unhides what of it is hidden) and no Hide items. Translated in zh, zh-TW, ja, de; gui-shell.md says it. Run (mote, node --test, chromium and webkit): - usage-hidden-way-back (now with the peek case, every language and width), usage-cards-hide, usage-count-client, i18n-keys: ok. - usage-agents-hide and tray-cell-click: red as at origin/mainfdfce4d98(#2276/#3414, #4790), same messages. Broken by hand: the new test on dee1afa40's page.js is 32 of 32 red, the peek card's menu reads ['Hide from Overview'], not ['Show in Overview']. Not tried: a real menu bar cell click in the real app. At the pushed head (rebased ond39358f1b, both commits): usage-hidden-way- back, usage-cards-hide, usage-count-client, i18n-keys and claude-quota-onboarding, 100 of 100 ok.
This commit is contained in:
@@ -502,7 +502,7 @@ covers it in both engines, every language and a narrow window.
|
||||
- There are no native `<select>` elements and no colored left-border stripes. State is shown with a dot or a swatch. A dot never says good or failed by colour alone: a failed state's dot is the same box drawn as an x (`--x-mark`, a mask over its red, scaled 1.5 so it reads as heavy as the round dot), since red and green dots read as one colour to a red-green colour-blind reader (coolmantou on Discord). That holds for Test models (`.tdot`), an agent's status line (`.ag-dot`), the check-in (`.ci-dot`), the request ledger (`.led .st .dot`), Routing's tries, steps and preview (`.rt-req`/`.rt-probe`, `.rt-steps`, `.ps-dst`) and a Library server's health (`.lib-health.err`); see `status-dot-shape.test.cjs`.
|
||||
- What the window shows can be selected and copied, its controls can't, as in a Mac app (Outvi V on Discord: nothing could be copied into a bug report). The page is `user-select: none`, and two `:where()` rules after `body` in `app.css` make text content selectable (paragraphs, `pre` and `code`, a detail's values, hints and notes, every error class, a conversation, a request's story on Routing) and keep every control unselectable with what is in it (buttons, labels, tabs, menus, the navigation, grips). Both have no specificity, so a view's own rule still decides, as a list being sorted does; a field stays selectable. See `user-select.test.cjs`.
|
||||
- The Usage page's cards and the tray panel's Allowances tab share one order, `settings.UsageOrder` (`byUsageOrder`). In the panel a balance-only card stands where that order puts it, and balances next to each other share one *Balances* grid (`panelBalances`, #1510); none is gathered after the plans. The panel's *Arrange* (`panelArrange`) moves rows in it and hides subscriptions from that tab alone (`settings.PanelUsageHidden`); both save through `POST /api/usage/arrange`, which changes only the field it is sent, and the Settings save keeps both. Hiding is display only: a menu bar cell's card shows though hidden (`panelPeek`). See `TestUsageArrangePanelHidden`, `panel-arrange.test.cjs` and `panel-balance-order.test.cjs`.
|
||||
- An allowance card can be hidden from Usage › Overview (whqtian_07012 on Discord: StepFun's plan wanted, its balance not). Right-click a card, or press it long on a touch screen (`quotaCardMenus` in `plugins/usage/page.js`), and the app menu offers *Hide from Overview*; an account of a card with several says *Hide this account from Overview*, and a plan card carrying its key's balance (`keyCards`) also offers *Hide its balance from Overview*, which keeps the plan. Each is kept by its tray card id and kind (`cardHideKey`: `stepfun|balance`, `kimi|me@x|plan`) in `settings.UsageCardsHidden` through the same `POST /api/usage/arrange` (`cardsHidden`), and kept by the Settings save. `overviewCards` leaves them out before `keyCards`, so routing, caps, the counting, the Accounts list, the tray panel (which has its own *Arrange*) and the menu bar cells never hear of it; a cell clicked for a hidden card shows it until the page is left (`usagePeek`). A "{n} hidden" line under the cards (`#quotaHid`, `renderQuotaHid`) opens them, each with *Unhide*, and *Show all* from two. The line is drawn in `--muted`, not `--faint`, so it can be read and found (3:1 or more), and while any are hidden every card's menu ends with *Show {n} Hidden*, which opens the line with the keyboard on it and brings it into sight on the menu's click (`openHidden`; yuu003348 on Discord found no way back). See `TestUsageArrangeCardsHidden`, `usage-cards-hide.test.cjs` and `usage-hidden-way-back.test.cjs`.
|
||||
- An allowance card can be hidden from Usage › Overview (whqtian_07012 on Discord: StepFun's plan wanted, its balance not). Right-click a card, or press it long on a touch screen (`quotaCardMenus` in `plugins/usage/page.js`), and the app menu offers *Hide from Overview*; an account of a card with several says *Hide this account from Overview*, and a plan card carrying its key's balance (`keyCards`) also offers *Hide its balance from Overview*, which keeps the plan. Each is kept by its tray card id and kind (`cardHideKey`: `stepfun|balance`, `kimi|me@x|plan`) in `settings.UsageCardsHidden` through the same `POST /api/usage/arrange` (`cardsHidden`), and kept by the Settings save. `overviewCards` leaves them out before `keyCards`, so routing, caps, the counting, the Accounts list, the tray panel (which has its own *Arrange*) and the menu bar cells never hear of it; a cell clicked for a hidden card shows it until the page is left (`usagePeek`). Such a card's menu offers *Show in Overview*, not Hide again, since the "{n} hidden" line leaves it out while it shows. A "{n} hidden" line under the cards (`#quotaHid`, `renderQuotaHid`) opens them, each with *Unhide*, and *Show all* from two. The line is drawn in `--muted`, not `--faint`, so it can be read and found (3:1 or more), and while any are hidden every card's menu ends with *Show {n} Hidden*, which opens the line with the keyboard on it and brings it into sight on the menu's click (`openHidden`; yuu003348 on Discord found no way back). See `TestUsageArrangeCardsHidden`, `usage-cards-hide.test.cjs` and `usage-hidden-way-back.test.cjs`.
|
||||
- A client in the Usage page's Agents list can be hidden from that list (ikunbots on X): its row's "…" button or right-click opens the row menu with *Hide from this list*, saved by client id in `settings.UsageAgentsHidden` through the same `POST /api/usage/arrange` (`agentsHidden`), and kept by the Settings save. The ledger, the totals and the chart still count a hidden client. A "{n} hidden" line under the list opens them, each with *Unhide* (`hideUsageAgent`), and while any are hidden the row menu ends with *Show {n} Hidden*, which opens it as the cards' does (`openHidden`). See `TestUsageArrangeAgentsHidden`, `usage-agents-hide.test.cjs` and `usage-hidden-way-back.test.cjs`.
|
||||
- Usage › Overview's Agents, Models, Accounts and Gateway keys lists each fold under their heading (#2378): the heading is a `.fold` button with its chevron, as on the Gateway page, and the click doesn't move the page (`backToReader`). What is folded is kept per viewer in localStorage `magpie.usageFolded` (`mountUsageFolds`, `showUsageFolds`). The totals leave the cache out, as before, unless the tokens tile's label, a pop-up button (`usageTokensPick`, the app menu), is set to *With cache*: then the tile, the chart and every row's count and share add cache read and written (`usageTokens`), and the tile says the cache's count; kept in localStorage `magpie.usageWithCache`. The Sessions tab counts by the same pick (#2591): its tokens tile carries the same label pop-up and says the cache's count, and the list's rows, the projects and models bars and pickers, the day chart (whose day and week buckets carry the cache's counts), the calendar and the top sessions read `usageTokens` too, the top list ranked again by the count shown (`sessTokens`, `sessSums`, `renderSessChart`, `renderSessTop`); a pick made on that tab refreshes the tab, not the Overview. The per-session median and p90 stay counted in and out (`Stats.Overview`). The Requests tab's total already counts every token (`allTokens`). A token line in parts (the Requests strip's Tokens card, the Overview's and the Sessions tab's tokens tiles) wraps between its counts and keeps each whole (`usageParts`, `.parts`); only a count wider than its card on its own is cut. See `usage-overview-fold.test.cjs` and `sessions-cache-tokens.test.cjs`.
|
||||
- A request's details in the Usage ledger say its tokens at every width (#1839, `ledDetail`): "{i} in · {o} out · {r} cache read · {w} cache creation", 0 said as 0, with how much was written for 5 minutes and for an hour when it says so. A failure that spent nothing has no Tokens row. See `ledger-cache-tokens.test.cjs` and `usage-ledger-detail.test.cjs`.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// kernel adds them to i18n.js's (magpie.strings).
|
||||
magpie.strings({
|
||||
zh: {
|
||||
"Show in Overview": "在概览中显示",
|
||||
"Show {n} Hidden": "显示已隐藏的 {n} 个",
|
||||
"Hide from Overview": "从概览中隐藏",
|
||||
"Hide this account from Overview": "从概览中隐藏这个账号",
|
||||
@@ -241,6 +242,7 @@ magpie.strings({
|
||||
"Sent upstream as {to}, as the agent spoke it": "以 {to} 协议发往上游,与 agent 所用协议相同",
|
||||
},
|
||||
"zh-TW": {
|
||||
"Show in Overview": "在概覽中顯示",
|
||||
"Show {n} Hidden": "顯示已隱藏的 {n} 個",
|
||||
"Hide from Overview": "從概覽中隱藏",
|
||||
"Hide this account from Overview": "從概覽中隱藏這個帳號",
|
||||
@@ -480,6 +482,7 @@ magpie.strings({
|
||||
"Sent upstream as {to}, as the agent spoke it": "以 {to} 協議發往上游,與 agent 所用協議相同",
|
||||
},
|
||||
ja: {
|
||||
"Show in Overview": "概要に表示",
|
||||
"Show {n} Hidden": "非表示の {n} 件を表示",
|
||||
"Hide from Overview": "概要から隠す",
|
||||
"Hide this account from Overview": "このアカウントを概要から隠す",
|
||||
@@ -719,6 +722,7 @@ magpie.strings({
|
||||
"Sent upstream as {to}, as the agent spoke it": "エージェントと同じ {to} で上流へ送信",
|
||||
},
|
||||
de: {
|
||||
"Show in Overview": "In der Übersicht einblenden",
|
||||
"Show {n} Hidden": "{n} ausgeblendete anzeigen",
|
||||
"Hide from Overview": "In der Übersicht ausblenden",
|
||||
"Hide this account from Overview": "Dieses Konto in der Übersicht ausblenden",
|
||||
|
||||
@@ -967,11 +967,15 @@ function quotaCardMenu(target, card, subs) {
|
||||
closeAgentMenu();
|
||||
if (again) return;
|
||||
const one = of.length === 1 && of[0];
|
||||
// a card shown though hidden, a menu bar cell having asked for it
|
||||
// (usagePeek): its way back, not Hide again
|
||||
const hid = hiddenCards(), peeked = of.flatMap(cardHideKeys).filter((k) => hid.has(k));
|
||||
const others = hiddenQuotas().length;
|
||||
openRowMenu(anchor, [
|
||||
{ name: who && subs.length > 1 ? "Hide this account from Overview" : "Hide from Overview", icon: EYE_OFF, run: () => hideQuotaCards(of.flatMap(cardHideKeys), true) },
|
||||
...(peeked.length ? [{ name: "Show in Overview", icon: EYE, run: () => hideQuotaCards(peeked, false) }]
|
||||
: [{ name: who && subs.length > 1 ? "Hide this account from Overview" : "Hide from Overview", icon: EYE_OFF, run: () => hideQuotaCards(of.flatMap(cardHideKeys), true) }]),
|
||||
// a plan's card showing its key's balance: the balance alone
|
||||
...(one?.balanceCard ? [{ name: "Hide its balance from Overview", icon: EYE_OFF, run: () => hideQuotaCards([one.balanceCard + "|balance"], true) }] : []),
|
||||
...(one?.balanceCard && !peeked.length ? [{ name: "Hide its balance from Overview", icon: EYE_OFF, run: () => hideQuotaCards([one.balanceCard + "|balance"], true) }] : []),
|
||||
// the ones hidden already, from the menu that hid them
|
||||
...(others ? [{ name: t("Show {n} Hidden", { n: others }), literal: true, icon: EYE, sep: true, run: (e) => openHidden(e, "quotaHid", () => { quotaHidOpen = true; renderQuotaHid(); }) }] : []),
|
||||
]);
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
// (yuu003348 on Discord: 观测/用量/概览 从概览中隐藏 后 无法取消隐藏). The
|
||||
// menu that hid a card, or an agent, offers "Show {n} Hidden" while some
|
||||
// are, which opens the line under the list with the keyboard on it, each
|
||||
// with Unhide; and the line itself is legible, not the page's faintest
|
||||
// grey. Every language, both engines, a
|
||||
// with Unhide; the line itself is legible, not the page's faintest grey;
|
||||
// and a hidden card a menu bar cell showed (usagePeek) offers "Show in
|
||||
// Overview" in its menu, not Hide again. Every language, both engines, a
|
||||
// wide window, a narrow one and magpie web on a phone; no backend, the API
|
||||
// is faked.
|
||||
const assert = require("node:assert/strict");
|
||||
@@ -90,13 +91,13 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
const errors = [];
|
||||
const saved = { cards: ["stepfun-2|balance"], agents: ["curl"] };
|
||||
const ctx = await browser.newContext({ viewport: { width, height: 700 }, reducedMotion: "reduce", hasTouch: web, isMobile: web && engine === "chromium" });
|
||||
const open = async () => {
|
||||
const open = async (query = "") => {
|
||||
const p = await ctx.newPage();
|
||||
p.setDefaultTimeout(5000);
|
||||
p.setDefaultNavigationTimeout(60000);
|
||||
p.on("pageerror", (e) => errors.push(e.message));
|
||||
await p.route("**/*", server(lang, web, saved));
|
||||
await p.goto("http://magpie.test/?view=usage");
|
||||
await p.goto("http://magpie.test/?view=usage" + query);
|
||||
// the first load of the whole app, on a busy machine
|
||||
await p.locator("#subscriptionUsage .subscription-card").first().waitFor({ timeout: 20000 });
|
||||
await p.locator("#usageAgents .row.stat").first().waitFor({ timeout: 20000 });
|
||||
@@ -126,7 +127,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
return r.top >= v.top - 1 && r.bottom <= v.bottom + 1;
|
||||
});
|
||||
|
||||
const p = await open();
|
||||
let p = await open();
|
||||
assert.deepEqual(await cards(p), ["claude", "stepfun"]);
|
||||
|
||||
// the line is legible: not the page's faintest grey
|
||||
@@ -169,6 +170,18 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.equal(await inSight(p, "#usageAgentsHid"), true);
|
||||
await reader.click(p, p.locator("#usageAgentsHid .us-unhide"));
|
||||
await until(() => saved.agents, []);
|
||||
await p.close();
|
||||
|
||||
// a hidden card a menu bar cell asked for: shown, and its menu has it back
|
||||
saved.cards = ["stepfun-2|balance"];
|
||||
p = await open("&tab=usage&card=stepfun-2");
|
||||
await card(p, "stepfun-2").waitFor();
|
||||
assert.equal(await p.locator("#quotaHid").isHidden(), true, "the one hidden is the one shown");
|
||||
await cardMenu(p, "stepfun-2");
|
||||
assert.deepEqual(await items(p), [w.show]);
|
||||
await p.locator(".row-menu .rm-item").click();
|
||||
await until(() => saved.cards, []);
|
||||
assert.deepEqual(await cards(p), ["claude", "stepfun", "stepfun-2"]);
|
||||
|
||||
const wide = await p.evaluate(() => { const v = document.querySelector("#view-usage"); return [v.scrollWidth, v.clientWidth, document.documentElement.scrollWidth, window.innerWidth]; });
|
||||
assert(wide[0] <= wide[1] + 1 && wide[2] <= wide[3] + 1, "no sideways scroll: " + wide);
|
||||
|
||||
Reference in New Issue
Block a user