diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d86a69..a74019d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ and this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html) ## [Unreleased] +### Fixed + +- **Cache sizes say they are bytes.** The Drivers tab, the engine counters, a driver's status and the + Architecture view's tooltip showed a driver's cache as a bare number, such as `465`. That reads as 465 + queued events, but the engine reports the size in bytes; 465 bytes was two events. They now read + `465 bytes`. **view** beside the size still lists and counts the events. + ## [0.85.0] - 2026-11-02 Needs DirXMLDev 0.62.0. diff --git a/web/src/components/ArchitectureView.tsx b/web/src/components/ArchitectureView.tsx index 71f8ece..b977ebc 100644 --- a/web/src/components/ArchitectureView.tsx +++ b/web/src/components/ArchitectureView.tsx @@ -1,6 +1,7 @@ import { useEffect, useMemo, useRef, useState } from "react"; import { api } from "../api"; import { EnvPicker, useEnvironment } from "../env"; +import { cacheBytes } from "../drivers"; import type { ArchApplication, Architecture, DriverState, Selection } from "../types"; /** @@ -275,7 +276,7 @@ export function ArchitectureView({ revision, onSelect }: { revision: string; onS const midX = (fromX + toX) / 2; const vaultY = Math.min(Math.max(cy, st0.y + 24), st0.y + st0.h - 24); const st = states?.[a.driver]; - const tip = `${a.driver}${a.vaultOnly ? " (serves the vault, no external system)" : ""}\n${a.shimClass ?? "no shim class"}\n${a.counts.policies} policies · ${a.counts.entitlements} entitlements · ${a.counts.resources} resources${a.counts.forms + a.counts.prds > 0 ? ` · ${a.counts.forms} forms · ${a.counts.prds} PRDs` : ""}${st ? `\n${st.state}${st.cacheSize ? ` · cache ${st.cacheSize}` : ""}` : ""}`; + const tip = `${a.driver}${a.vaultOnly ? " (serves the vault, no external system)" : ""}\n${a.shimClass ?? "no shim class"}\n${a.counts.policies} policies · ${a.counts.entitlements} entitlements · ${a.counts.resources} resources${a.counts.forms + a.counts.prds > 0 ? ` · ${a.counts.forms} forms · ${a.counts.prds} PRDs` : ""}${st ? `\n${st.state}${st.cacheSize ? ` · cache ${cacheBytes(st.cacheSize)}` : ""}` : ""}`; return ( diff --git a/web/src/components/VaultView.tsx b/web/src/components/VaultView.tsx index c02412d..57f405b 100644 --- a/web/src/components/VaultView.tsx +++ b/web/src/components/VaultView.tsx @@ -4,6 +4,7 @@ import { Fragment, useEffect, useRef, useState } from "react"; import { ApiError, GIT_CHANGED, api } from "../api"; import { EnvPicker, useEnvironment } from "../env"; import { CachePanel } from "./CachePanel"; +import { cacheBytes } from "../drivers"; import { EventsView } from "./EventsView"; import { TraceViewer } from "./TraceViewer"; import { CaptureSteps, ProductionCheck } from "./ProductionCheck"; @@ -1134,7 +1135,7 @@ function Drivers({ env, onFix, onSelect, onSaved }: { env: string; onFix: () => - {d.cacheSize ?? ""}{" "} + {cacheBytes(d.cacheSize)}{" "} @@ -1228,8 +1229,8 @@ function EngineStrip({ env }: { env: string }) { {data.stats.drivers.map((d) => ( {d.name} - {d.cacheSize} - {d.unprocessedSize} + {cacheBytes(d.cacheSize)} + {cacheBytes(d.unprocessedSize)} {d.reportedEvents} {d.commands} @@ -1326,7 +1327,7 @@ function DriverManagePanel({ env, driver, armed, confirm, onSelect, onClose }: { DN{status.dn} State{status.state} · start option {status.startOption} - Cache{status.cacheSize} · unprocessed {status.unprocessedSize} + Cache{cacheBytes(status.cacheSize)} · unprocessed {cacheBytes(status.unprocessedSize)} Tracelevel {status.traceLevel ?? "-"} · file {status.traceFile || "-"} Named passwords{(status.namedPasswords ?? []).length === 0 ? none : (status.namedPasswords ?? []).join(", ")} diff --git a/web/src/drivers.test.ts b/web/src/drivers.test.ts new file mode 100644 index 0000000..c85c3e0 --- /dev/null +++ b/web/src/drivers.test.ts @@ -0,0 +1,14 @@ +import { describe, expect, it } from "vitest"; +import { cacheBytes } from "./drivers"; + +describe("cacheBytes", () => { + it("gives the engine's cache size its unit", () => { + expect(cacheBytes("465")).toBe("465 bytes"); + expect(cacheBytes(0)).toBe("0 bytes"); + }); + it("leaves what isn't a size alone", () => { + expect(cacheBytes("?")).toBe("?"); + expect(cacheBytes(undefined)).toBe(""); + expect(cacheBytes("")).toBe(""); + }); +}); diff --git a/web/src/drivers.ts b/web/src/drivers.ts index b21ddb7..a2f3561 100644 --- a/web/src/drivers.ts +++ b/web/src/drivers.ts @@ -11,3 +11,12 @@ export function isUserApplication(d: { shimClass?: string | null; forms?: unknow export function userApplicationDrivers(drivers: DriverOutline[]): DriverOutline[] { return drivers.filter(isUserApplication); } + +/** + * A driver's cache size as the engine reports it, with its unit: bytes, not a count of events (viewing the + * cache counts them). 465 bytes was two events on a test vault. Anything that isn't a number shows as it is. + */ +export function cacheBytes(size: string | number | null | undefined): string { + if (size === null || size === undefined || size === "") return ""; + return /^\d+$/.test(String(size)) ? `${size} bytes` : String(size); +}