Expose local codebase token estimates and apparent disk size in the project dashboard. - Add a bounded, cached, symlink-safe codebase metrics service and project API. - Display token and disk indicators across Command Center overview states. - Add formatting, route, UI, and metric calibration coverage with a minor changeset. Files changed: .changeset/fn-8133-codebase-metrics.md | 7 + docs/dashboard-guide.md | 2 +- .../dashboard/app/__tests__/api-projects.test.ts | 12 ++ packages/dashboard/app/api/legacy.ts | 14 ++ .../components/command-center/CommandCenter.css | 5 + .../components/command-center/CommandCenter.tsx | 65 +++++++-- .../CommandCenter.mobile-chart-layout.test.ts | 4 + .../__tests__/CommandCenter.test.tsx | 10 ++ .../__tests__/SystemStatsArea.test.tsx | 8 + .../command-center/areas/SystemStatsArea.tsx | 8 +- .../app/utils/__tests__/formatBytes.test.ts | 18 +++ packages/dashboard/app/utils/formatBytes.ts | 11 ++ .../src/lib/__tests__/codebase-metrics.test.ts | 62 ++++++++ .../lib/__tests__/fixtures/token-corpus/README.md | 17 +++ .../fixtures/token-corpus/calibration/component.ts | 1 + .../fixtures/token-corpus/calibration/config.json | 1 + .../lib/__tests__/fixtures/token-corpus/example.ts | 1 + .../lib/__tests__/fixtures/token-corpus/notes.md | 3 + .../fixtures/token-corpus/reference-counts.json | 9 ++ .../__tests__/fixtures/token-corpus/settings.json | 1 + .../lib/__tests__/fixtures/token-corpus/view.tsx | 1 + packages/dashboard/src/lib/codebase-metrics.ts | 161 +++++++++++++++++++++ .../__tests__/codebase-metrics-route.test.ts | 34 +++++ .../src/routes/register-project-routes.ts | 19 +++ 24 files changed, 456 insertions(+), 18 deletions(-) Fusion-Task-Id: FN-8133 Fusion-Task-Lineage: d591636b-d4b8-469e-8788-c4516eeb8405 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
19 lines
678 B
TypeScript
19 lines
678 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { formatBytes } from "../formatBytes";
|
|
|
|
describe("formatBytes", () => {
|
|
it("formats byte-unit boundaries with granular local sizes", () => {
|
|
expect(formatBytes(0)).toBe("0 B");
|
|
expect(formatBytes(512)).toBe("512 B");
|
|
expect(formatBytes(1024)).toBe("1 KB");
|
|
expect(formatBytes(1024 * 1024)).toBe("1 MB");
|
|
expect(formatBytes(1024 * 1024 * 1024)).toBe("1.00 GB");
|
|
});
|
|
|
|
it("marks negative and non-finite measurements unavailable", () => {
|
|
expect(formatBytes(-1)).toBe("—");
|
|
expect(formatBytes(Number.NaN)).toBe("—");
|
|
expect(formatBytes(Number.POSITIVE_INFINITY)).toBe("—");
|
|
});
|
|
});
|