Skip to content

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

address review: unsigned -0, sibling counts, and a nav icon main is missing

[._.]/ Adam Eivy928de54aff09
diff --git a/AGENTS.md b/AGENTS.md
index 0decb2ac29..152f2855db 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -136,7 +136,7 @@ If a close match exists, **extend it or use it**. Only add a new module when non
- `useLockToggle` (`client/src/hooks/useLockToggle.js`) — optimistic-PATCH lock toggle for any new lock button.
- `useSseProgress` (`client/src/hooks/useSseProgress.js`) — generic JSON-frame EventSource subscriber; build new progress hooks on it.
- `formatBytes` / `formatTimecode` / `formatDateShort` / `formatDurationMs` / `timeAgo` (`client/src/utils/formatters.js`) — never re-define formatters inside components.
-- `formatCount` / `formatUsd` (`client/src/utils/formatters.js`) — thousands-grouped, en-US-pinned (`2,762`, `$4,610.09`). **Never render a raw integer or a bare `.toLocaleString()` for a user-facing count or amount** — an unseparated `4610` is read at the wrong order of magnitude, and the browser locale disagrees with the `$` beside it. `formatCount` gives `—` for a count that was never measured; pass `{ fallback: '0' }` where a measured zero is meant.
+- `formatCount` / `formatUsd` (`client/src/utils/formatters.js`) — thousands-grouped, en-US-pinned (`2,762`, `$4,610.09`). Reach for these rather than rendering a raw integer or a bare `.toLocaleString()` for a user-facing count or amount — an unseparated `4610` is read at the wrong order of magnitude, and the browser locale disagrees with the `$` beside it. A **measured** zero already renders `0`; `formatCount` gives `—` only for a value that is missing or unparseable, so pass `{ fallback: '0' }` just where an ABSENT count should still read as zero. Converging the ~80 remaining `.toLocaleString()` renders and adding the guard that enforces this is tracked in #7433, so expect to still find both spellings in the tree.
### Maintenance rule (WHEN adding a public module)
diff --git a/client/src/components/calendar/ReviewTab.jsx b/client/src/components/calendar/ReviewTab.jsx
index 42c1901fa5..403e0b5514 100644
--- a/client/src/components/calendar/ReviewTab.jsx
+++ b/client/src/components/calendar/ReviewTab.jsx
@@ -157,7 +157,7 @@ export default function ReviewTab({ accounts = [] }) {
)}
{review.progressEntries?.length > 0 && (
<span className="text-port-accent">
- {formatCount(review.progressEntries.reduce((sum, e) => sum + (e.durationMinutes || 0), 0))}min logged
+ {review.progressEntries.reduce((sum, e) => sum + (e.durationMinutes || 0), 0)}min logged
</span>
)}
</div>
diff --git a/client/src/components/cos/PersistentMindRuntimePanel.jsx b/client/src/components/cos/PersistentMindRuntimePanel.jsx
index 67878fc37f..deb6d58654 100644
--- a/client/src/components/cos/PersistentMindRuntimePanel.jsx
+++ b/client/src/components/cos/PersistentMindRuntimePanel.jsx
@@ -2,7 +2,6 @@ import { AlertTriangle, Brain, Cpu, Gauge } from 'lucide-react';
import { describeMindTurnProgress, mindTurnHeadline } from '../../lib/mindTurnProgress.js';
import { formatBytes, formatCount, timeUntil } from '../../utils/formatters.js';
-
const RESIDENCY_STATES = {
loaded: 'Loaded in memory',
'not-loaded': 'Not loaded',
diff --git a/client/src/components/cos/tabs/AgentsTab.jsx b/client/src/components/cos/tabs/AgentsTab.jsx
index 62c4b3d1e5..cf96aeb6f9 100644
--- a/client/src/components/cos/tabs/AgentsTab.jsx
+++ b/client/src/components/cos/tabs/AgentsTab.jsx
@@ -448,7 +448,7 @@ export default function AgentsTab({ agents, onRefresh, liveOutputs, providers, p
) : (
<>
<ChevronDown size={14} />
- Load older agents ({remainingCount} remaining)
+ Load older agents ({formatCount(remainingCount)} remaining)
</>
)}
</button>
diff --git a/client/src/components/messages/IMessageTab.jsx b/client/src/components/messages/IMessageTab.jsx
index a24c999e1c..2f81c8fe81 100644
--- a/client/src/components/messages/IMessageTab.jsx
+++ b/client/src/components/messages/IMessageTab.jsx
@@ -626,10 +626,10 @@ export default function IMessageTab() {
{formatCount(stats?.eventCount, { fallback: '0' })} events
</span>
<span className="rounded border border-port-border bg-port-card px-2 py-1">
- {stats?.conversationCount ?? 0} conversations
+ {formatCount(stats?.conversationCount, { fallback: '0' })} conversations
</span>
<span className="rounded border border-port-border bg-port-card px-2 py-1">
- {stats?.blockedCount ?? 0} blocked
+ {formatCount(stats?.blockedCount, { fallback: '0' })} blocked
</span>
{stats?.earliestAt && (
<span className="rounded border border-port-border bg-port-card px-2 py-1">
diff --git a/client/src/components/universe/UniverseCanonSection.jsx b/client/src/components/universe/UniverseCanonSection.jsx
index 0ab27c2a8e..6f5130a151 100644
--- a/client/src/components/universe/UniverseCanonSection.jsx
+++ b/client/src/components/universe/UniverseCanonSection.jsx
@@ -1190,7 +1190,7 @@ function KindSection() {
<div>
<div className="flex flex-wrap items-center gap-1.5 mb-2">
<span className="text-[10px] text-gray-500 mr-auto shrink-0">
- {filtered ? `${all.length} / ${totalCount}` : all.length} {all.length === 1 ? kind.singular : kind.label.toLowerCase()}
+ {filtered ? `${formatCount(all.length)} / ${formatCount(totalCount)}` : formatCount(all.length)} {all.length === 1 ? kind.singular : kind.label.toLowerCase()}
</span>
{controls}
</div>
@@ -1206,7 +1206,7 @@ function KindSection() {
<Icon size={14} className="text-gray-400" />
<h3 className="text-sm font-semibold text-white">{kind.label}</h3>
<span className="text-[10px] text-gray-500">
- {filtered ? `${all.length} / ${totalCount}` : all.length}
+ {filtered ? `${formatCount(all.length)} / ${formatCount(totalCount)}` : formatCount(all.length)}
</span>
<div className="ml-auto flex flex-wrap items-center gap-1.5">
{controls}
diff --git a/client/src/components/writers-room/ExercisePanel.jsx b/client/src/components/writers-room/ExercisePanel.jsx
index e1b42cccd9..347eaa3812 100644
--- a/client/src/components/writers-room/ExercisePanel.jsx
+++ b/client/src/components/writers-room/ExercisePanel.jsx
@@ -92,7 +92,7 @@ export default function ExercisePanel({ activeWork, onClose, editorDirty = false
return null;
});
if (!result) return;
- toast.success(`Logged ${wordsAdded} words`);
+ toast.success(`Logged ${formatCount(wordsAdded)} words`);
} else {
const result = await discardWritersRoomExercise(active.id, { silent: true }).catch((err) => {
toast.error(`Discard failed: ${err.message}`);
diff --git a/client/src/lib/navPresentation.js b/client/src/lib/navPresentation.js
index b22b412977..38aa93c3a7 100644
--- a/client/src/lib/navPresentation.js
+++ b/client/src/lib/navPresentation.js
@@ -1,4 +1,5 @@
import {
+ CreditCard,
Wrench,
Home,
Package,
diff --git a/client/src/pages/Loops.jsx b/client/src/pages/Loops.jsx
index 62b20aeb54..18ae6ce530 100644
--- a/client/src/pages/Loops.jsx
+++ b/client/src/pages/Loops.jsx
@@ -398,7 +398,7 @@ export default function Loops() {
</p>
</div>
<div className="flex items-center gap-3 text-xs text-gray-400">
- {runningCount > 0 && <span className="text-port-success">{runningCount} active</span>}
+ {runningCount > 0 && <span className="text-port-success">{formatCount(runningCount)} active</span>}
<span>{formatCount(loops.length)} total</span>
<button onClick={fetchLoops} className="min-h-[44px] min-w-[44px] inline-flex items-center justify-center p-1 rounded hover:bg-port-border" title="Refresh" aria-label="Refresh">
<RefreshCw size={14} />
diff --git a/client/src/pages/Timeline.jsx b/client/src/pages/Timeline.jsx
index 28eb8a77fa..cb57f09d55 100644
--- a/client/src/pages/Timeline.jsx
+++ b/client/src/pages/Timeline.jsx
@@ -244,7 +244,7 @@ export default function Timeline() {
<span className="rounded bg-port-card px-2 py-1 border border-port-border">{formatCount(counts.total)} events</span>
{Object.entries(counts.bySource).map(([source, n]) => (
<span key={source} className="rounded bg-port-card px-2 py-1 border border-port-border">
- {source}: {n}
+ {source}: {formatCount(n)}
</span>
))}
</div>
diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.js
index 2e2b7ae577..43e0c7ca49 100644
--- a/client/src/utils/formatters.js
+++ b/client/src/utils/formatters.js
@@ -362,9 +362,10 @@ export function formatCompactCountOrDash(n) {
// Grouping is pinned to en-US rather than the browser locale. The UI is
// English-only, and `$` is a US currency mark — rendering "$4.610,09" next to
// English copy reads as a typo, not as localization. Counts use the same
-// separator so a total and its cost line up. The DATE helpers above stay on the
-// browser locale on purpose: a date carries no currency anchor, so there is
-// nothing for its separators to contradict.
+// separator so a total and its cost line up — `formatAgeDays` above formats its
+// day count through the same instance for that reason. The date/time DISPLAY
+// helpers keep the browser locale on purpose: a rendered date carries no
+// currency anchor, so there is nothing for its separators to contradict.
const GROUPED_INTEGER = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 });
const USD_CENTS = new Intl.NumberFormat('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
@@ -454,7 +455,9 @@ 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;
- const magnitude = signed ? Math.abs(n) : n;
+ // `+ 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;
const body = trimWhole && Number.isInteger(magnitude)
? GROUPED_INTEGER.format(magnitude)
: USD_CENTS.format(magnitude);
diff --git a/client/src/utils/formatters.test.js b/client/src/utils/formatters.test.js
index 7eb63e9b64..22325a3cad 100644
--- a/client/src/utils/formatters.test.js
+++ b/client/src/utils/formatters.test.js
@@ -135,6 +135,14 @@ describe('formatUsd', () => {
expect(formatUsd(-4610.09, { signed: true })).toBe('-$4,610.09');
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.
+ 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');
+ });
});
describe('formatCount', () => {