usage 0.1.1: the tab is named in the window's language, and the tiles fill four across or two by two

magpie.page.titles names the page in zh, zh-TW, ja and de; a magpie that
doesn't know titles still reads title. The tiles were auto-fill, which left
a hole in their row at most widths; now four across, two by two under 640px.

Run: bun test in packages/usage (6 pass). Tried in the magpie sandbox app's
dev UI with the real usage.jsonl, WebKit, dark and light, zh and en, at
900 and 560px.
This commit is contained in:
yetone
2026-10-16 18:13:05 +08:00
parent 29adee2688
commit 3d0a546aa3
4 changed files with 18 additions and 6 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
A page in [magpie](https://usemagpie.ai)'s window with your usage at a glance. It shows calls, errors, tokens and cost for today, 7 days or 30 days, and the models that took them.
Install it from magpie's **Plugins › Discover**, or with `magpie plugin add @magpie-community/page-usage`. It then has a tab, **Usage glance**, under Plugins in the sidebar, in the app and in `magpie web`.
Install it from magpie's **Plugins › Discover**, or with `magpie plugin add @magpie-community/page-usage`. It then has a tab, **Usage glance** (titled in the window's language: 用量速览, 用量速覽, 使用量の概要, Nutzung im Überblick), under Plugins in the sidebar, in the app and in `magpie web`.
## What it reads
@@ -30,4 +30,4 @@ The page saves the period (`today`, `7d`, `30d`) and the model sort (`tokens`, `
bun test packages/usage
```
中文:在 magpie 窗口里加一个「Usage glance」页面,一眼看到今天、7 天或 30 天的调用、错误、token 和费用,以及用到的模型。它只读取声明过的 `usage:summary`,运行在无网络的沙盒 frame 里。
中文:在 magpie 窗口里加一个「用量速览」页面,一眼看到今天、7 天或 30 天的调用、错误、token 和费用,以及用到的模型。它只读取声明过的 `usage:summary`,运行在无网络的沙盒 frame 里。
+7 -2
View File
@@ -1,13 +1,18 @@
{
"name": "@magpie-community/page-usage",
"version": "0.1.0",
"version": "0.1.1",
"description": "A page in magpie's window with your usage at a glance: calls, errors, tokens and cost for today, 7 or 30 days, and the models that took them",
"files": ["page", "README.md"],
"keywords": ["magpie", "magpie-page", "usage", "tokens", "cost"],
"license": "MIT",
"repository": { "type": "git", "url": "git+https://github.com/magpie-community/plugins.git", "directory": "packages/usage" },
"magpie": {
"page": { "title": "Usage glance", "file": "page/index.html", "icon": "page/icon.svg" },
"page": {
"title": "Usage glance",
"titles": { "zh": "用量速览", "zh-TW": "用量速覽", "ja": "使用量の概要", "de": "Nutzung im Überblick" },
"file": "page/index.html",
"icon": "page/icon.svg"
},
"permissions": ["usage:summary"],
"options": { "period": "today", "sort": "tokens" }
}
+3 -1
View File
@@ -19,7 +19,9 @@ h2 { font-size: 13px; font-weight: 600; margin: 0; }
.seg button { font: inherit; color: var(--muted); background: none; border: 0; border-radius: 6px; padding: 3px 10px; cursor: default; }
.seg button[aria-selected="true"] { color: var(--fg); background: var(--bg); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
.seg.small button { padding: 2px 8px; font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 22px; }
/* four across, two by two when narrow: never a row with a hole in it */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
@media (max-width: 640px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.tile .k { color: var(--muted); font-size: 12px; }
.tile .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+6 -1
View File
@@ -37,7 +37,12 @@ test("asks for one read, usage:summary, and nothing else", () => {
test("is a page magpie serves: its files in page/, scripts as files", () => {
expect(pkg.main).toBeUndefined()
expect(pkg.exports).toBeUndefined()
expect(pkg.magpie.page).toEqual({ title: "Usage glance", file: "page/index.html", icon: "page/icon.svg" })
expect(pkg.magpie.page).toEqual({
title: "Usage glance",
titles: { zh: "用量速览", "zh-TW": "用量速覽", ja: "使用量の概要", de: "Nutzung im Überblick" },
file: "page/index.html",
icon: "page/icon.svg",
})
const html = read("index.html")
expect(html).toContain('<script src="_magpie/bridge.js"></script>')
// the policy runs no inline script