Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(formatters): make parseSizeGb internal helper (#4026)
[._.]/ Adam Eivy96985b3e5ae1
diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex f5e6880cd7..72574fb59e 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -22,7 +22,7 @@ grep -i "what you want to do" client/src/utils/README.md| Module | Purpose ||---|---|-| `formatters` | Date/time/duration/byte/word formatters (`clamp`, `formatBytes`, `formatCompactCount`, `timeAgo`, `formatTimecode`, `formatDurationMs`, `formatDateShort`, `parseTimeoutMs`, `formatCooldown`, `parseSizeGb`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. **Never write `new Date(x).toLocaleDateString()` inline** — pick the helper for the shape you want: `formatDateNumeric` ("3/5/2026", compact cells), `formatDateShort` ("Mar 5, 2026"), `formatDate` ("March 5, 2026"), `formatDateFull` ("Saturday, March 5, 2026"), `formatWeekdayDate` ("Monday, Mar 5", `{ weekday, year }`), `formatMonthDay` ("Mar 5"), `formatMonthYear` ("March 2026"), `formatWeekdayShort` ("Mon"), `formatWeekdayTime` ("Mon, 7:00 AM"), `formatTimeOfDay` ("1:30 PM"), `formatTimeOfDaySeconds` ("1:30:45 PM", log/queue rows), `formatClockTime` ("02:30:45 PM"; `{ seconds, hour12, timeZone }`), `formatDateTime`. All of them anchor a bare `YYYY-MM-DD` at LOCAL midnight (a naive `new Date('2026-03-05')` is UTC midnight and renders as the previous day west of Greenwich) and take a fallback instead of rendering the literal "Invalid Date". |+| `formatters` | Date/time/duration/byte/word formatters (`clamp`, `formatBytes`, `formatCompactCount`, `timeAgo`, `formatTimecode`, `formatDurationMs`, `formatDateShort`, `parseTimeoutMs`, `formatCooldown`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. **Never write `new Date(x).toLocaleDateString()` inline** — pick the helper for the shape you want: `formatDateNumeric` ("3/5/2026", compact cells), `formatDateShort` ("Mar 5, 2026"), `formatDate` ("March 5, 2026"), `formatDateFull` ("Saturday, March 5, 2026"), `formatWeekdayDate` ("Monday, Mar 5", `{ weekday, year }`), `formatMonthDay` ("Mar 5"), `formatMonthYear` ("March 2026"), `formatWeekdayShort` ("Mon"), `formatWeekdayTime` ("Mon, 7:00 AM"), `formatTimeOfDay` ("1:30 PM"), `formatTimeOfDaySeconds` ("1:30:45 PM", log/queue rows), `formatClockTime` ("02:30:45 PM"; `{ seconds, hour12, timeZone }`), `formatDateTime`. All of them anchor a bare `YYYY-MM-DD` at LOCAL midnight (a naive `new Date('2026-03-05')` is UTC midnight and renders as the previous day west of Greenwich) and take a fallback instead of rendering the literal "Invalid Date". || `cronHelpers` | Cron preset list, `isCronExpression` detection, and `describeCron` human-readable rendering. || `markdownText` | `markdownToPlainText(md)` — flatten markdown source to one plain-text string for a clamped preview: strips heading/list/blockquote/fence markers, unwraps emphasis, inline code and links, images → `[alt]`, collapses blank-line runs. Use whenever a card previews arbitrary agent-authored markdown — `line-clamp-N` does not clamp a subtree of block elements, and foreign `##` headings would otherwise join the page's heading outline. Underscore emphasis is word-boundary gated and `__…__` needs interior whitespace, so stack frames and user-agent strings (`10_15_7`, `__init__`) are never silently rewritten. `dropsMarkupWhenFlattened(md)` — did the flatten lose actual markup, as opposed to only normalizing whitespace? Gates a "Show more" disclosure so a short-but-lossy body stays reachable without putting a toggle on every body that merely lost a trailing newline. || `timeWindow` | Time-of-day window math (`isInTimeWindow`, `timeStringToMinutes`) and morning-layout auto-switch helpers (`pickActiveLayoutId`, `recordManualLayoutPick`). |diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.jsindex b334e65d0d..eab4ccb5dc 100644--- a/client/src/utils/formatters.js+++ b/client/src/utils/formatters.js@@ -633,7 +633,7 @@ export function formatCooldown(ms) {* @param {string|null|undefined} sizeStr - Human-readable size string* @returns {number|null} Size in GB, or null when unparseable*/-export function parseSizeGb(sizeStr) {+function parseSizeGb(sizeStr) {const match = /([\d.]+)\s*(TB|GB|MB|KB)/i.exec(String(sizeStr || ''));if (!match) return null;const val = parseFloat(match[1]);diff --git a/client/src/utils/formatters.test.js b/client/src/utils/formatters.test.jsindex f6d80cdb35..412310d2c3 100644--- a/client/src/utils/formatters.test.js+++ b/client/src/utils/formatters.test.js@@ -1,7 +1,7 @@import { describe, it, expect } from 'vitest';import {clamp, formatContextLength, formatDurationMin, formatDurationMs, formatEventDateTime, timeAgo,- formatCooldown, parseSizeGb, recommendedRamGb, parseTimeoutMs, formatDurationSec, middleTruncate,+ formatCooldown, recommendedRamGb, parseTimeoutMs, formatDurationSec, middleTruncate,formatWeight, formatPercent, formatUsd, formatBytes,formatDateNumeric, formatTimeOfDaySeconds, formatClockTime, formatWeekdayDate,formatMonthDay, formatMonthYear, formatWeekdayShort, formatWeekdayTime, formatDateFull, formatDateShort, formatDateTime,@@ -290,30 +290,6 @@ describe('formatCooldown', () => {});});-describe('parseSizeGb', () => {- it('parses GB strings', () => {- expect(parseSizeGb('4.7 GB')).toBeCloseTo(4.7);- expect(parseSizeGb('1GB')).toBe(1);- });-- it('parses MB strings (converts to fractional GB)', () => {- const result = parseSizeGb('512 MB');- expect(result).toBeCloseTo(0.5);- });-- it('parses TB strings (converts to large GB)', () => {- const result = parseSizeGb('2 TB');- expect(result).toBeCloseTo(2048);- });-- it('returns null for garbage input', () => {- expect(parseSizeGb('not a size')).toBeNull();- expect(parseSizeGb('')).toBeNull();- expect(parseSizeGb(null)).toBeNull();- expect(parseSizeGb(undefined)).toBeNull();- });-});-describe('recommendedRamGb', () => {it('uses exact bytes when provided', () => {// 4 GB in bytes: 4 * 1024^3 = 4294967296; + 20% overhead = 4.8 → ceil = 5@@ -323,11 +299,19 @@ describe('recommendedRamGb', () => {it('falls back to size string when bytes are null', () => {// 4.7 GB string: 4.7 * 1.2 = 5.64 → ceil = 6expect(recommendedRamGb(null, '4.7 GB')).toBe(6);+ // 1 GB string: 1 * 1.2 = 1.2 → ceil = 2+ expect(recommendedRamGb(null, '1GB')).toBe(2);+ // 512 MB string: 0.5 * 1.2 = 0.6 → ceil = 1 (floor)+ expect(recommendedRamGb(null, '512 MB')).toBe(1);+ // 2 TB string: 2048 * 1.2 = 2457.6 → ceil = 2458+ expect(recommendedRamGb(null, '2 TB')).toBe(2458);});- it('returns null when both inputs are absent', () => {+ it('returns null when both inputs are absent or unparseable', () => {expect(recommendedRamGb(null, null)).toBeNull();expect(recommendedRamGb(undefined, undefined)).toBeNull();+ expect(recommendedRamGb(null, 'not a size')).toBeNull();+ expect(recommendedRamGb(null, '')).toBeNull();});it('enforces a 1 GB floor for tiny models', () => {