feat(stats): redesign the omp stats dashboard

Rewrite the local `omp stats` web UI on the OMP brand palette with a left nav, focused per-section views, a new Projects view, a system-aware light/dark toggle, and flicker-free navigation. Same data, endpoints, and command; the only server change is a 1h time-range bucketing fix in the aggregator.
This commit is contained in:
lycaon
2026-06-16 22:58:46 -06:00
parent e24f789de4
commit 525f4baa64
56 changed files with 5180 additions and 2435 deletions
@@ -0,0 +1,34 @@
import { describe, expect, it } from "bun:test";
import { buildModelPerformanceLookup } from "../src/client/data/view-models";
import type { ModelPerformancePoint } from "../src/shared-types";
const DAY = 24 * 60 * 60 * 1000;
describe("client view models", () => {
it("keeps sparse all-time model performance buckets instead of dropping old points", () => {
const points: ModelPerformancePoint[] = [
{
timestamp: DAY,
model: "gpt-5.5",
provider: "openai-codex",
requests: 1,
avgTtft: 250,
avgTokensPerSecond: 40,
},
{
timestamp: DAY * 10,
model: "gpt-5.5",
provider: "openai-codex",
requests: 2,
avgTtft: 500,
avgTokensPerSecond: 60,
},
];
const series = buildModelPerformanceLookup(points, "all").get("gpt-5.5::openai-codex");
expect(series?.data.map(point => point.timestamp)).toEqual([DAY, DAY * 10]);
expect(series?.data.map(point => point.requests)).toEqual([1, 2]);
expect(series?.data.map(point => point.avgTtftSeconds)).toEqual([0.25, 0.5]);
});
});
@@ -77,14 +77,13 @@ function assistantEntry(opts: {
}
describe("priority service-tier premium-request backfill", () => {
it("derives premium_requests from service_tier_change entries for OpenAI traffic", async () => {
it("derives premium_requests from service_tier_change entries for providers that honor priority", async () => {
await writeSession("--tmp--proj", "01.jsonl", {
lines: [
{ type: "session", version: 1, id: "s1", timestamp: new Date().toISOString(), cwd: "/tmp/proj" },
{ type: "service_tier_change", id: "stc1", timestamp: new Date().toISOString(), serviceTier: "priority" },
assistantEntry({ id: "a1", provider: "openai" }),
assistantEntry({ id: "a2", provider: "openai-codex" }),
// Provider that doesn't honor service_tier — stays at zero.
assistantEntry({ id: "a3", provider: "anthropic" }),
{ type: "service_tier_change", id: "stc2", timestamp: new Date().toISOString(), serviceTier: null },
assistantEntry({ id: "a4", provider: "openai" }),
@@ -95,7 +94,7 @@ describe("priority service-tier premium-request backfill", () => {
const overall = await getOverallStats();
expect(overall.totalRequests).toBe(4);
expect(overall.totalPremiumRequests).toBe(2);
expect(overall.totalPremiumRequests).toBe(3);
});
it("preserves an existing non-zero premiumRequests value (Copilot multiplier) even under priority tier", async () => {