Skip to content
TypeScript

fix(web): Diagnostics memory no longer reads "1024.0 MB" (#28300)

Victor Vogel4c3808a1097c
diff --git a/apps/web/src/components/settings/DiagnosticsSettings.tsx b/apps/web/src/components/settings/DiagnosticsSettings.tsx
index 0fcea4fa5de..66210525d1c 100644
--- a/apps/web/src/components/settings/DiagnosticsSettings.tsx
+++ b/apps/web/src/components/settings/DiagnosticsSettings.tsx
@@ -20,6 +20,7 @@ import type {
import * as DateTime from "effect/DateTime";
import * as Option from "effect/Option";
+import { formatBytes } from "../../lib/formatBytes";
import { cn } from "../../lib/utils";
import { ensureLocalApi } from "../../localApi";
import { useOpenInPreferredEditor } from "../../editorPreferences";
@@ -51,18 +52,6 @@ function formatDuration(value: number): string {
return `${(value / 1_000).toFixed(value >= 10_000 ? 1 : 2).replace(/\.0+$/, "")} s`;
}
-function formatBytes(value: number): string {
- if (value < 1024) return `${value} B`;
- const units = ["KB", "MB", "GB"] as const;
- let unitIndex = -1;
- let next = value;
- do {
- next /= 1024;
- unitIndex += 1;
- } while (next >= 1024 && unitIndex < units.length - 1);
- return `${next.toFixed(next >= 10 ? 1 : 2)} ${units[unitIndex]}`;
-}
-
function RelativeTimeNoWrap(props: { value: DateTime.Utc }) {
const relative = useRelativeTimeState(DateTime.formatIso(props.value));
if (relative.status !== "relative") return null;