Repository navigation
feat(settings): add local model usage dashboard - #393
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
在「设置 → 用量统计 / Usage」集中展示 Universal-Code 自身的 Token、输入/输出/缓存、已记录费用、模型占比、最近会话、趋势和活动热图。支持今日、近 30 天、全部历史与会话跳转;沿用 Mono 字体和现有主题,中英文即时切换,窄屏改为单列。页面打开时每分钟刷新。活动热图使用正方形格子;鼠标悬停、点击或键盘选中时显示白色边框、日期和 Token 浮层,窄屏下浮层保持在图表范围内。
新增只读
GET /api/v1/usage,从持久化终态回执汇总主代理、子代理、并行调用和上下文压缩。排除尚未发出的调用及未启动就取消的分片,保留失败消耗与旧版 fanout Token。Token 按调用完成时间、费用按实际结算时间划分;缓存是输入的子集。金额仅包含已定价的实际结算,缺失用量和费用分别显示覆盖情况。无数据库迁移,使用现有读取权限。下面是实际浏览器截图,数值为用于展示完整图表的演示数据。
390px 窄屏截图
Validation
go test ./internal/store ./internal/httpapi -run '^TestUsageStatistics' -count=1go test ./internal/httpapi -run '^TestOpenAPI' -count=1go run ./cmd/protocolregistry -check、go run ./cmd/surfacechecknpm run build、npm run typecheck、npm run check:api、git diff --check本地运行上述定向验证;全量测试和
go vet ./...由 CI 执行。覆盖了四类回执的调用身份、历史 fanout、跨日结算及读取授权;生成的 OpenAPI/TypeScript 文件通过生成一致性检查,未作为手工源码逐行审阅。修复 Windows 固定 PowerShell 命令首次查找模块时扫描过慢的问题:从
$PSHOME下的确定路径显式加载所需的两个系统模块,保留原有受限令牌、Job 和超时。现有 native 测试增加目录输出的名称、长度和属性校验。Surface governance
Audit
docs/usage.md的入口、口径、未知值和截图说明。