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
drop the nav icon main already has, and hold the signed-zero contract
[._.]/ Adam Eivy36a16602ff3a
diff --git a/client/src/lib/navPresentation.js b/client/src/lib/navPresentation.jsindex 38aa93c3a7..b22b412977 100644--- a/client/src/lib/navPresentation.js+++ b/client/src/lib/navPresentation.js@@ -1,5 +1,4 @@import {- CreditCard,Wrench,Home,Package,diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.jsindex 43e0c7ca49..81a433273a 100644--- a/client/src/utils/formatters.js+++ b/client/src/utils/formatters.js@@ -381,7 +381,9 @@ const USD_CENTS = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2, max*/export function formatCount(n, { fallback = '—' } = {}) {const value = roundForDisplay(n, 0);- return value === null ? fallback : GROUPED_INTEGER.format(value);+ // `+ 0` folds the -0 that a negative fraction rounds to (-0.4 → -0), which+ // Intl would render as the nonsense "-0".+ return value === null ? fallback : GROUPED_INTEGER.format(value + 0);}/**@@ -455,13 +457,16 @@ export function formatPercent(value, { decimals = 1, fallback = '—' } = {}) {export function formatUsd(value, { signed = false, trimWhole = false, fallback = '—' } = {}) {const n = value === null || value === undefined ? 0 : Number(value);if (!Number.isFinite(n)) return fallback;- // `+ 0` normalizes -0, which Intl renders with a sign (`-0.00`) where the old- // `toFixed(2)` did not — a rounded-to-zero saving must not read as a loss.- const magnitude = (signed ? Math.abs(n) : n) + 0;+ // Anything under half a cent renders as zero, and Intl signs it (`-$0.00`)+ // where the old `toFixed(2)` did not. A saving that rounds away to nothing+ // must not read as a loss, so snap it onto a true zero and drop the sign with+ // it — `signed && n < 0` alone would still print the minus.+ const raw = signed ? Math.abs(n) : n;+ const magnitude = Math.abs(raw) < 0.005 ? 0 : raw;const body = trimWhole && Number.isInteger(magnitude)? GROUPED_INTEGER.format(magnitude): USD_CENTS.format(magnitude);- return `${signed && n < 0 ? '-' : ''}$${body}`;+ return `${signed && n < 0 && magnitude !== 0 ? '-' : ''}$${body}`;}/**diff --git a/client/src/utils/formatters.test.js b/client/src/utils/formatters.test.jsindex 22325a3cad..0bb65746c5 100644--- a/client/src/utils/formatters.test.js+++ b/client/src/utils/formatters.test.js@@ -136,12 +136,16 @@ describe('formatUsd', () => {expect(formatUsd(12000, { trimWhole: true })).toBe('$12,000');});- // A saving that rounds to zero produces -0, which Intl signs but `toFixed`- // did not — it must not surface as a loss.+ // A saving that rounds away to nothing must not read as a loss. Intl signs a+ // negative zero where `toFixed` did not, and `signed` would print the minus+ // from the ORIGINAL value even once the magnitude has rounded to zero.it('never renders a signed zero', () => {expect(formatUsd(-0)).toBe('$0.00');expect(formatUsd(-0, { trimWhole: true })).toBe('$0');- expect(formatUsd(-0, { signed: true })).toBe('$0.00');+ expect(formatUsd(-0.004)).toBe('$0.00');+ expect(formatUsd(-0.004, { signed: true })).toBe('$0.00');+ // Still a loss once it survives rounding.+ expect(formatUsd(-0.006, { signed: true })).toBe('-$0.01');});});@@ -165,6 +169,17 @@ describe('formatCount', () => {expect(formatCount('')).toBe('—');expect(formatCount(NaN)).toBe('—');expect(formatCount(null, { fallback: '0' })).toBe('0');+ expect(formatCount(' ')).toBe('—');+ expect(formatCount(Infinity)).toBe('—');+ expect(formatCount(-Infinity)).toBe('—');+ // `Number(true)` is 1 — a boolean must not render as a count.+ expect(formatCount(true)).toBe('—');+ });++ // A negative fraction rounds to -0, which Intl renders as "-0".+ it('never renders a signed zero', () => {+ expect(formatCount(-0)).toBe('0');+ expect(formatCount(-0.4)).toBe('0');});});