feat: show daily key usage in dashboard

This commit is contained in:
2026-07-27 03:39:10 +08:00
parent 69f72c09b5
commit 42b2e63a97
5 changed files with 99 additions and 16 deletions
+11 -6
View File
@@ -81,20 +81,25 @@ Environment variables override the config file:
## Unified Dashboard
`shusub2` opens a single dashboard with Accounts, Logs, and Errors tables
stacked vertically. Press `a`, `l`, or `e` to focus a table, `/` to filter all
three tables, and `r` to refresh all data. The two-line detail area follows the
selected row.
`shusub2` opens a single dashboard with Accounts, Keys, Logs, and Errors
tables stacked vertically. Press `a`, `k`, `l`, or `e` to focus a table, `/` to
filter all four tables, and `r` to refresh all data. The two-line detail area
follows the selected row.
The dashboard uses compact columns sized to fit an 80-column terminal without
horizontal scrolling:
```text
ACCOUNT | Group | Today | Daily | 5h | 7d | Avail
KEY | Today | Tokens | Req
LOG KEY | Account | Model | Cost | Latency | Time
ERR | Status | Account | Model | Phase | Type | Time
```
The Keys table shows today's usage sorted by actual cost, including key name,
tokens, and request count. It uses the same admin API key as Logs and Errors;
without that token the table is hidden and the summary remains compact.
Use `--accounts`, `--logs`, or `--errors` to start a dedicated full-table view.
The corresponding `--once` form still prints only that data set.
@@ -205,8 +210,8 @@ Configuration:
The dashboard reads `/api/tui/accounts` and can optionally read `sub2api-status`
`/api/status` for channel monitor health. The Accounts table does not need SSH,
database access, API keys, OAuth credentials, or plaintext env files. The
Logs and Errors tables authenticate to the Sub2API admin APIs with
database access, API keys, OAuth credentials, or plaintext env files. The Keys,
Logs, and Errors tables authenticate to the Sub2API admin APIs with
an admin API key stored only in `~/.config/shusub2/logs-token` (0600) or
`SHUSUB2_LOGS_TOKEN`.