Repository navigation
Conversation
yetone
left a comment
There was a problem hiding this comment.
Thanks for the board. It renders well on fixture data in Chromium and WebKit. Reviewed at 428613e. A few things block merging.
Blocking
- On magpie desktop the page returns 401.
PLUGIN_MODEkeys offMAGPIE_ADDR(server.mjs:21), which magpie's plugin host doesn't set, soopenPageis false and/asks for a key the frame doesn't have (server.mjs:614-615). Please tell plugin mode apart some other way, and get the page its token through the bridge rather than relaxing auth. - Remote attribution is on by default (
ATTRIBUTION='auto', server.mjs:322). It sends the remote-magpie provider's API key to/v1/magpie/usage/requestsfor up to 40000 rows (server.mjs:361-375). The README calls it optional. Please make it opt-in. - CI goes red. test/server.test.mjs:289 spawns
index.mjsinstead of running-e code, so the child never exits, keeps 3455 and hangsnode --test. test/server.test.mjs:252 imports./index.mjswith no cwd, so it fails under the rootbun test. RootHOME=$(mktemp -d) bun testgives 3 failures in this package. Please also use port 0 andmkdtempinstead of fixed ports and fixed tmp names. - When 3455 is taken, plugin mode binds 3456 while page/index.html and boot.js still point to 3455. The guard at server.mjs:890 never runs because :886 already calls
tryBind(p+1). Separately, any process whose ping answers{service:'magpie-usage'}is reused as the board. - The logo scan reads every sibling package's files and downloads the https icon URLs they declare (server.mjs:728-810). Please use the icons magpie already provides instead.
- The vendored
static/echarts.min.js(sha256 791c7ea0…) doesn't matchecharts@5.5.1/dist/echarts.min.js(e84270bd…), and the custom build entry isn't in the PR. Please use the upstream file, or include a reproducible build.
Please remove or change
- Personal defaults:
REMOTE_PROVIDERS,REMOTE_CALLERS, the merge map in static/index.html, and the Cloudflare analytics allowance in the CSP. - deploy.sh, the Dockerfile, docker-compose.yml and docs/self-hosting.md. They describe one VPS,
vps-init.shis missing,Dockerfile:13's COPY fails, and compose runs with no auth. Origin: nulland arbitrary localhost origins are accepted with CORS (server.mjs:476-496), and the key is accepted in?key=. The page should be the only client.- Please add English strings (the UI is Chinese-only), a
"option":"port"on the service, and drop the fake bridgehello(server.mjs:644).
What I ran (on a macOS test machine, HOME in a temp dir)
node --testin the package: 27 of 28 pass. "plugin mode waits…" fails and leaves a server on 3455.bun scripts/check.mjs page-usage-boardand the fullscripts/check.mjs: pass.scripts/prepack.mjs: pass.- Root
HOME=$(mktemp -d) bun test: 6882 pass, 3 fail, all in page-usage-board. - The service on fixture data with a fake gateway and remote, every fetch logged:
- Without
MAGPIE_ADDR,/returns 401, and the remote key is sent at startup. - With a foreign server on 3455 it binds 3456.
- The logo scan fetched about 25 third-party URLs.
- The Host checks rejected rebinding.
- Without
- Playwright, Chromium and WebKit, at 1280 and 420 and in a sandboxed iframe: renders with no console errors, except that WebKit's framed view blocks
/api/attributionunderconnect-src 'self'.
…n, magpie-sourced logos, reproducible echarts, en i18n - / serves the board on loopback with the token injected (page-usage-tree model): no MAGPIE_ADDR/PLUGIN_MODE env detection, desktop 401 fixed; the page answers loopback Hosts only, and remote binds get 403 on the page + x-dash-key-only APIs - ?key= and the dk cookie removed; tokens are per-boot, server-injected, never in URLs, logs or on disk - port: upward scan removed; ~8s bind-retry then /api/ping BUILD_ID check — same build reuses (after a second liveness confirm), anything else errors loudly; manifest page.service.option="port", boot.js reads magpie.options - remote attribution is opt-in (manifest options.attribution / ATTRIBUTION env, default local); REMOTE_CALLERS/REMOTE_PROVIDERS personal defaults removed - logos: read magpie's own plugin-providers.json (data URIs only) and inject window.QLOGOS; the sibling-package scan and the ~25 third-party downloads are gone — zero network, zero disk writes - CSP without third-party hosts, connect-src lists the loopback explicitly (WebKit sandboxed-frame fix); the fake bridge hello postMessage is dropped - echarts custom build is reproducible now: build/echarts-entry.mjs + scripts/build-echarts.mjs rebuild static/echarts.min.js byte-exact - full en/zh i18n (131 keys, ?lang= or navigator.language) - deploy.sh / vps-init.sh / Dockerfile / docker-compose.yml / docs/docker.md / docs/self-hosting.md removed; tests use mkdtemp + ephemeral ports + -e children and are cwd-independent
|
Thanks for the detailed review — all six blockers and the change list are addressed in 3dbe84b. Blocking
Please remove or change
Verified locally on Node 22/24: |
|
Thanks for the quick turnaround. I re-reviewed at 3dbe84b. Four of the six blockers are fixed, but CI would still go red and a few new problems came in with the rework, so this isn't ready to merge yet. The six blockers
New problems
What I ran (on a macOS test machine, Node 22.22, Bun 1.4.2, HOME in a temp dir)
|
…via bridge, test hardening, pinned devDeps + lockfile
|
Thanks for the re-review — all points addressed (pushed as 6450cbc on the PR branch). Leftover blockers
New problems
echarts claim vs. PR contents devDependencies are pinned exact ( Verification: |
yetone
left a comment
There was a problem hiding this comment.
Thanks. I re-reviewed at 6450cbc. Most of the last round is fixed, but the root test run is still red, and the config dir still misses portable installs.
Blocking
- The root
bun testis still red, with the same failure as last time. The PATH snapshot at test/server.test.mjs:18 doesn't help, because Bun loads each test file only when it reaches it. By then an earlier file has already changedprocess.env.PATH, so the snapshot is the broken value. RootHOME=$(mktemp -d) bun teston macOS (Bun 1.4.2): 6859 pass, 20 skip, 1 fail. Thebeforehook (test/server.test.mjs:103 →startat :44) dies withExecutable not found in $PATH: "node", and the whole server.test.mjs file is lost. It was the only failure in the repo. Please don't spawnnodeby name under Bun. For example, spawnprocess.execPath: that runs server.mjs under Bun, which is also what magpie's plugin host runs it with. - The config dir still misses portable installs.
magpieConfigDir()(server.mjs:27-32) triesMAGPIE_CONFIG_DIR, thenXDG_CONFIG_HOME, then~/.config/magpie. magpie has noMAGPIE_CONFIG_DIR, and a desktop user can't set env for the plugin host, so README.md:96's "portable/XDG installs set this" leaves portable users with an empty board. magpie's own order (appdir.Config()) is the portable data dir first, then XDG, then~/.config/magpie. The plugin host starts with its cwd set to that dir (bunCommand(..., settings.Dir(), "run", js)in internal/plugin/host.go). Soserver()running in the host can takeprocess.cwd(), or read through the gateway's usage APIs as page-usage-tree does. TheROOT/..fallbacks (server.mjs:59-60) don't point at magpie's dir for an installed plugin either. README.md:96 also says XDG is "honoured first", but the code checksMAGPIE_CONFIG_DIRfirst.
Smaller
- scripts/build-echarts.mjs:5-7 still says CI rebuilds the bundle and compares bytes. No workflow does that. Please drop the claim. (I rebuilt it myself with
npm ciand got the same bytes, sha256 791c7ea0….) - static/index.html:308 and :447 (
needKey) still tell the user to append?key=…, which no longer works. - server.mjs:546 and :595 still return Chinese-only errors.
MAGPIE_ADDRof[::1]:<port>fails the check at server.mjs:48 and falls back to 3425.
Verified fixed
- Attribution default: changing it to
remoteby hand turns "attribution stays local unless the user opts in" red. - Gateway: dropping the
MAGPIE_ADDRread by hand turns the gateway test red. - echarts is pinned exactly (5.5.1, esbuild 0.28.2).
- The
helloframes are gone, and so is the client's?key=read. - The theme comes from the bridge.
port: 0gives an ephemeral port.frame-ancestorsis set.- With
Origin: null, the page's HTML is served withoutAccess-Control-Allow-Origin, so a null-origin fetch can't read the injected key./api/*still needsx-dash-key. - The pages escape usage and quota strings before they go into
innerHTML.
What I ran (macOS test machine, Node 22.22, Bun 1.4.2, temp HOME)
bun test packages/page-usage-board: 34 pass.node --testin the package: 34 pass.bun scripts/check.mjs: pass.- Root
HOME=$(mktemp -d) bun test: 1 fail (above). - Hand breaks of the attribution default and the gateway read: red as expected.
- echarts:
npm ciplusnpm run build:echartsin a copy of the package gave identical bytes. - No CI checks ran on this head.
|
Thanks — both blockers and the smaller points are addressed (pushed as 6b2625d on the PR branch). Blocking
Smaller
Verification: |
|
Thanks. I re-reviewed at 6b2625d. Both earlier blockers are fixed in the server. But the new config-dir test is red on macOS, so the root Blocking
Verified fixed
On overlap with magpie's Usage page What I ran (macOS test machine, Node 22.22, Bun 1.4.2, temp HOME outside /tmp)
|
|
Both blockers fixed (pushed as ebb1f29), and the README now leads with what is new. 1. macOS config-dir test — the test now resolves the temp dir first: it compares against 2.
README — it now opens by saying most of the board repeats magpie's Usage page (cards, per-provider/per-model totals, request list) and lists the five things Usage doesn't show: remote attribution by caller key, TTFT p50/p90 per provider, the 7×24 heatmap, the direct-vs-remote split of the last 24 hours, and expiry tiers on the cards — then says everything else is convenience around those. I left the registry Also removed a stale README sentence claiming the board posts a bridge |
Adds
@magpie-community/page-usage-board(page,community: true).Summary (verbatim from registry.json / package.json
magpie.summary)en: A quota card wall with expiry tiers, daily/per-provider charts, 24h cache-hit and token curves, optional remote attribution and account detail. Runs its own zero-dependency local service reading this machine's Magpie usage data; optional remote attribution queries the configured remote magpie.
zh: 额度到期卡片墙 + 每日与 provider 用量图表 + 24 小时缓存命中与 token 曲线,可选远端归因与账号明细。自带零依赖本机服务,读本机 Magpie 用量数据;远端归因会查询所配置的远端 magpie。
Differences from existing packages
usage:summary; this one adds the quota wall with expiry tiers, the 7×24 heatmap, recent-request detail and per-account remote attribution. Complements it rather than replacing it.permissions: []).What it reads (disclosure)
permissions: [], zeromagpie.read).usage.jsonl(no prompts or message bodies) and magpie's local usage/quota API.options.attribution, defaultlocal): when enabled it reads the provider key from the machine's magpie config and queries the configured remote magpie's read-onlyusage/requestsendpoint (rows filtered to the configured callers). The key goes only to that remote magpie.plugin-providers.json(data URIs only, injected into the page): no sibling-package scanning, no third-party download, no disk writes. Brands without one fall back to initial-letter badges./api/ping(service identity + build id) and/api/health(liveness) — no usage data, no tokens; listed indocs/community-submission.md.Engineering facts
x-dash-keyheader only.?lang=ornavigator.language).::wildcard, rewritten-Host page gate), path traversal, malformed requests, the lifecycle contract (import has no side effects,server()awaits listen), build-id-based port reuse, and the registry three-text rule.build/echarts-entry.mjs+scripts/build-echarts.mjs(npm run build:echarts, CI verifies byte-exact) withNOTICE+LICENSES/Apache-2.0.txt.docs/data-semantics.md(the two-accounting-views red lines),docs/community-submission.md(this checklist, maintained as the source of truth for future updates).