Skip to content

feat: update mcode-usage-monitor to 1.3.0 and add a usage-query skill - #12

Open
yanhy2000 wants to merge 3 commits into
MiniMax-AI:mainfrom
yanhy2000:update-mcode-usage-monitor-1.3.0
Open

yanhy2000 wants to merge 3 commits into
MiniMax-AI:mainfrom
yanhy2000:update-mcode-usage-monitor-1.3.0

Conversation

@yanhy2000

@yanhy2000 yanhy2000 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Updates plugins/yanhy2000/mcode-usage-monitor/ from 1.2.0 to 1.3.0. Plugin ID, package layout, data sources and privacy behaviour are unchanged.

What changed

Filtering

  • The model and session lists now cross-filter each other: each list narrows to what the other side selected, and shows its full range list when the other side is set to all. This stops a session from looking like it used several models at once.
  • A selection that the other filter temporarily hides is kept instead of being dropped, and the dropdown reports how many are hidden.
  • Select-all is dimmed only when everything is selected, invert is always available, and selecting nothing is allowed (the page then shows zero data).

Interface

  • Icon-only header controls (theme, refresh interval, manual refresh). Every card can be collapsed and expanded, and the layout editor reorders or removes both the KPI tiles and the cards, remembering the arrangement.
  • The model comparison card gained an empty state; the recent-calls table escapes its values; toasts no longer cover the header icons; Esc closes dropdown panels.

Agent skill (new)

  • The package now ships one Agent skill, skills/usage-query/. It teaches the Agent to locate and run the bundled data backend (miniapp/node/api.py), so usage questions — "how many tokens did this chat use?", "which model do I use most?" — can be answered directly without opening the dashboard first. It documents the parameters, the JSON field map, the counting rules, and failure handling, and points back to the dashboard when charts or hands-on filtering are wanted.
  • exampleQueries was rewritten to cover four entry points: opening the dashboard, this conversation's usage, a specific time range, and a per-model question.
  • README.md / README.zh-CN.md document the skill and add it to the verified list.

Robustness

  • Dropdown panels are no longer rebuilt by auto-refresh while open, so a click in progress is not lost.
  • Data loading is decoupled from the chart library: KPI tiles and the table render immediately, charts follow once ECharts is ready (bounded wait).
  • fetch has an in-flight guard and a 35 s abort, so slow queries no longer pile up and a hung connection cannot block refresh.
  • Preferences are written atomically and serialized; the query cache has a size cap; keep-alive timeouts are raised to avoid a 5 s idle-close race.
  • Python is probed as python then py -3, and a missing SQLite JSON1 extension is reported together with its SQLite version.
  • Snapshot fallback no longer leaks temporary directories; unused payload fields were removed.

Test environment

  • MiniMax Code desktop 3.1.0 on Windows (10.0.26200, x64), Python 3.10.10 / SQLite 3.39.4, Node.js 24.18. The dashboard and the bundled skill were re-tested on this release.
  • npm run validate on this branch: 0 errors, 2 warnings (explained below).
  • Backend: cross-filtering verified against /api/data — selecting models narrows the session list to the sessions that used them while the model list stays complete, selecting sessions narrows the model list the same way, per-session totals match a single-session query, and the explicit empty selection returns zero rows.
  • Frontend, in a browser: hidden selections survive later checkbox changes and the hidden-count hint appears; a dropdown stays interactive across an auto-refresh; Esc closes panels; the model comparison empty state renders; the footer shows the version injected from plugin.json; prefs.json stays valid after repeated filter changes.
  • Agent skill: verified end to end on this machine by asking usage questions in a conversation — the Agent finds the backend, runs the documented command, and answers from the JSON. The field names in SKILL.md were checked against the real payload (today: 881 calls, 16 sessions, 147.1M tokens, 97.8% cache hit rate).
  • Preview image regenerated from a synthetic local database (a fabricated runtime-state.sqlite plus fabricated messages.jsonl files, injected through MINIMAX_DATA_DIR). It contains no real session records, project names or personal data.
  • Diff checked before pushing: no secrets, no real data, no local paths.

Not verified: macOS and Linux; the py -3 probe fallback (the primary python command is available here); a Python build without the SQLite JSON1 extension; and the keep-alive / fetch-abort fixes are preventive — they were not reproduced under sustained load.

Warnings

npm run validate reports two README_HEADING_MISSING warnings:

warning README_HEADING_MISSING README.md should contain the heading "## Tested environment"
warning README_HEADING_MISSING README.md should contain the heading "## Data & access"

This package's README has used ## Data access and counting and ## Source and verification since 1.1.0 and carries the same information. The headings were left as they are to keep the README stable across releases; happy to rename them to the example's wording if you prefer.


中文摘要:mcode-usage-monitor 由 1.2.0 更新至 1.3.0。模型与会话筛选改为互相牵制(各侧只列出另一侧所选范围内出现过的项),被另一侧暂时隐藏的已选项不再丢失;顶栏改为图标按钮并加入编辑布局;新增内置技能 usage-query,Agent 可直接调用包内数据后端回答用量问题,不必先打开看板,示例问法同步覆盖打开看板 / 本对话用量 / 时间范围 / 模型维度四类;同时修复下拉被自动刷新打断、取数依赖图表库、请求堆积、偏好写入非原子等问题。插件 ID、数据来源与隐私行为不变,预览图已用合成数据重新生成。已在 Windows 桌面端 3.1.0 正式版实测(看板与内置技能均通过);macOS/Linux 与部分防御性改动未验证。


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

- Cross-filter the model and session lists: each list narrows to what the
  other side selected, and shows the full range list when the other side is
  set to all
- Keep selections that the other filter temporarily hides, and report how
  many are hidden inside the dropdown
- Pause dropdown rebuilding while a panel is open, so auto refresh no longer
  interrupts a click in progress
- Decouple data loading from ECharts: KPI tiles and tables render right away
  and charts are drawn once the library is ready (bounded wait)
- Add an in-flight guard with a 35s abort, so slow queries stop piling up and
  a hung connection cannot block refresh
- Fix the snapshot fallback leaking temporary directories; drop the unused
  ledger payload and dead response fields
- Write the preferences file atomically and serialize read-modify-write; cap
  the query cache; lengthen keep-alive timeouts; probe python/py -3
- Probe the SQLite JSON1 extension at startup and report an actionable error
- Add an empty state to the model comparison card, escape recent-call table
  values, keep toasts from covering the header icons, close dropdowns on Esc
Regenerated from the synthetic local database: 515M tokens, 16 sessions and
5 models, showing the 1.3.0 icon-only header and the layout editing entry.
Same capture spec as before: 642 CSS px wide at 2x, light theme, last 24 hours.
- skills/usage-query/SKILL.md: how to locate and run the bundled data backend
  (miniapp/node/api.py) to query local token usage, plus the JSON field map,
  counting rules and failure handling; it points back to the dashboard for charts
  and hands-on filtering
- plugin.json: declare the skill, and rewrite exampleQueries to cover opening the
  dashboard, this conversation's usage, a specific time range, and a per-model
  question
- README.md / README.zh-CN.md: document the skill and add "the Agent answers usage
  questions from the data backend" to the verified list
- Version stays 1.3.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant