openclaw/scripts
Tak Hoffman 8a352c8f9d
Web UI: add token usage dashboard (#10072)
* feat(ui): Token Usage dashboard with session analytics

Adds a comprehensive Token Usage view to the dashboard:

Backend:
- Extended session-cost-usage.ts with per-session daily breakdown
- Added date range filtering (startMs/endMs) to API endpoints
- New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints
- Cost breakdown by token type (input/output/cache read/write)

Frontend:
- Two-column layout: Daily chart + breakdown | Sessions list
- Interactive daily bar chart with click-to-filter and shift-click range select
- Session detail panel with usage timeline, conversation logs, context weight
- Filter chips for active day/session selections
- Toggle between tokens/cost view modes (default: cost)
- Responsive design for smaller screens

UX improvements:
- 21-day default date range
- Debounced date input (400ms)
- Session list shows filtered totals when days selected
- Context weight breakdown shows skills, tools, files contribution

* fix(ui): restore gatewayUrl validation and syncUrlWithSessionKey signature

- Restore normalizeGatewayUrl() to validate ws:/wss: protocol
- Restore isTopLevelWindow() guard for iframe security
- Revert syncUrlWithSessionKey signature (host param was unused)

* feat(ui): Token Usage dashboard with session analytics

Adds a comprehensive Token Usage view to the dashboard:

Backend:
- Extended session-cost-usage.ts with per-session daily breakdown
- Added date range filtering (startMs/endMs) to API endpoints
- New sessions.usage, sessions.usage.timeseries, sessions.usage.logs endpoints
- Cost breakdown by token type (input/output/cache read/write)

Frontend:
- Two-column layout: Daily chart + breakdown | Sessions list
- Interactive daily bar chart with click-to-filter and shift-click range select
- Session detail panel with usage timeline, conversation logs, context weight
- Filter chips for active day/session selections
- Toggle between tokens/cost view modes (default: cost)
- Responsive design for smaller screens

UX improvements:
- 21-day default date range
- Debounced date input (400ms)
- Session list shows filtered totals when days selected
- Context weight breakdown shows skills, tools, files contribution

* fix: usage dashboard data + cost handling (#8462) (thanks @mcinteerj)

* Usage: enrich metrics dashboard

* Usage: add latency + model trends

* Gateway: improve usage log parsing

* UI: add usage query helpers

* UI: client-side usage filter + debounce

* Build: harden write-cli-compat timing

* UI: add conversation log filters

* UI: fix usage dashboard lint + state

* Web UI: default usage dates to local day

* Protocol: sync session usage params (#8462) (thanks @mcinteerj, @TakHoffman)

---------

Co-authored-by: Jake McInteer <mcinteerj@gmail.com>
2026-02-05 22:35:46 -06:00
..
docker chore: apply local workspace updates (#9911) 2026-02-05 16:54:44 -05:00
docs-i18n chore: apply local workspace updates (#9911) 2026-02-05 16:54:44 -05:00
e2e fix: stabilize docker e2e flows 2026-02-02 13:11:55 +00:00
pre-commit chore: stabilize prek hooks runner selection (#1720) (thanks @dguido) 2026-01-25 10:55:28 +00:00
repro fix: run cli scripts via node build runner 2026-01-18 18:43:39 +00:00
systemd refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
auth-monitor.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
bench-model.ts chore: apply local workspace updates (#9911) 2026-02-05 16:54:44 -05:00
build-and-run-mac.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
build-docs-list.mjs chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
build_icon.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
bundle-a2ui.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
canvas-a2ui-copy.ts chore: Also format `scripts` and `skills`. 2026-01-31 21:21:25 +09:00
changelog-to-html.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
check-ts-max-loc.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
claude-auth-status.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
clawlog.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
clawtributors-map.json 🤖 Feishu: expand channel support 2026-02-05 12:29:04 -08:00
codesign-mac-app.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
committer chore: block node_modules commits 2026-01-18 22:28:59 +00:00
copy-hook-metadata.ts chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
create-dmg.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
debug-claude-usage.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
docs-list.js chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
firecrawl-compare.ts chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
ios-team-id.sh chore(ios): add team id helper 2025-12-26 18:16:13 +01:00
make_appcast.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
mobile-reauth.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
notarize-mac-artifact.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
package-mac-app.sh fix: Fix Mac app build step. 2026-02-03 22:14:11 +09:00
package-mac-dist.sh chore: add mac dSYM zip to release artifacts 2026-02-03 17:15:02 -08:00
protocol-gen-swift.ts chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
protocol-gen.ts refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
readability-basic-compare.ts chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
release-check.ts chore: prep 2026.2.2 docs/release checks 2026-02-03 16:38:42 -08:00
restart-mac.sh Switch from TypeScript to TypeScript Go. Use `pnpm tsgo` for Typechecks. 2026-01-31 15:33:15 +09:00
run-node.mjs chore: Migrate to tsdown, speed up JS bundling by ~10x (thanks @hyf0). 2026-02-03 20:18:16 +09:00
sandbox-browser-entrypoint.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
sandbox-browser-setup.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
sandbox-common-setup.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
sandbox-setup.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
setup-auth-system.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
sqlite-vec-smoke.mjs chore: Also format `scripts` and `skills`. 2026-01-31 21:21:25 +09:00
sync-labels.ts chore: Also format `scripts` and `skills`. 2026-01-31 21:21:25 +09:00
sync-moonshot-docs.ts Docs: fix Moonshot sync markers (#6789) 2026-02-02 03:38:14 +01:00
sync-plugin-versions.ts chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
termux-auth-widget.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
termux-quick-auth.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
termux-sync-widget.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
test-cleanup-docker.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
test-force.ts chore: Enable "experimentalSortImports" in Oxfmt and reformat all imorts. 2026-02-01 10:03:47 +09:00
test-install-sh-docker.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
test-install-sh-e2e-docker.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
test-live-gateway-models-docker.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
test-live-models-docker.sh refactor: rename to openclaw 2026-01-30 03:16:21 +01:00
test-parallel.mjs chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
test-shell-completion.ts scripts: update test-shell-completion to use shared helpers 2026-02-04 19:51:06 +00:00
ui.js chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
update-clawtributors.ts chore: Enable `typescript/no-explicit-any` rule. 2026-02-02 16:18:09 +09:00
update-clawtributors.types.ts feat: add prek pre-commit hooks and dependabot (#1720) 2026-01-25 10:53:23 +00:00
watch-node.mjs chore: Migrate to tsdown, speed up JS bundling by ~10x (thanks @hyf0). 2026-02-03 20:18:16 +09:00
write-build-info.ts chore: Enable linting in `scripts`. 2026-01-31 21:29:14 +09:00
write-cli-compat.ts Web UI: add token usage dashboard (#10072) 2026-02-05 22:35:46 -06:00
zai-fallback-repro.ts chore: apply local workspace updates (#9911) 2026-02-05 16:54:44 -05:00