mirror of
https://github.com/Routstr/routstrd.git
synced 2026-10-06 12:48:22 +00:00
- Add 'npubs' tab between Clients and Recent (key 7) - Tab is hidden when no clients have ownerNpub set - Groups usage entries by ownerNpub via client-id → npub mapping - Shows truncated npub (first 10 + … + last 6) with full npub on detail line - Displays requests, cost, tokens, avg cost per npub with bar charts - Includes 'Top Models per Npub' sub-section - Tab keys dynamically renumbered (1-7 without npubs, 1-8 with) - Falls back to Clients tab if Npubs becomes unavailable on refresh
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
import type { Tab } from "./types.ts";
|
|
|
|
export const ALL_TABS: Tab[] = [
|
|
{ id: "overview", name: "Overview", key: "1" },
|
|
{ id: "today", name: "Today", key: "2" },
|
|
{ id: "models", name: "Models", key: "3" },
|
|
{ id: "providers", name: "Providers", key: "4" },
|
|
{ id: "tokens", name: "Tokens", key: "5" },
|
|
{ id: "clients", name: "Clients", key: "6" },
|
|
{ id: "npubs", name: "Npubs", key: "7" },
|
|
{ id: "recent", name: "Recent", key: "8" },
|
|
];
|
|
|
|
/**
|
|
* Returns the visible tab list, hiding the Npubs tab when no clients
|
|
* have an ownerNpub. Keys are re-assigned sequentially (1..N).
|
|
*/
|
|
export function getVisibleTabs(hasNpubs: boolean): Tab[] {
|
|
const tabs = ALL_TABS.filter((t) => t.id !== "npubs" || hasNpubs);
|
|
return tabs.map((t, i) => ({ ...t, key: String(i + 1) }));
|
|
}
|
|
|
|
/** Default tab list (no npub data yet). */
|
|
export const TABS: Tab[] = getVisibleTabs(false);
|
|
|
|
export const COLORS = {
|
|
reset: "\x1b[0m",
|
|
bold: "\x1b[1m",
|
|
dim: "\x1b[2m",
|
|
red: "\x1b[31m",
|
|
green: "\x1b[32m",
|
|
yellow: "\x1b[33m",
|
|
blue: "\x1b[34m",
|
|
magenta: "\x1b[35m",
|
|
cyan: "\x1b[36m",
|
|
white: "\x1b[37m",
|
|
bgBlue: "\x1b[44m",
|
|
bgGreen: "\x1b[42m",
|
|
bgYellow: "\x1b[43m",
|
|
bright: "\x1b[1m",
|
|
};
|
|
|
|
export const MODEL_COLORS: Record<string, string> = {
|
|
"gpt-5.4": COLORS.magenta,
|
|
"minimax-m2.7": COLORS.cyan,
|
|
default: COLORS.white,
|
|
};
|
|
|
|
export const CLIENT_COLORS: Record<string, string> = {
|
|
opencode: COLORS.blue,
|
|
openclaw: COLORS.green,
|
|
"pi-agent": COLORS.yellow,
|
|
unknown: COLORS.dim,
|
|
default: COLORS.white,
|
|
};
|