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

refactor(issue-4028): dedupe capitalize helper into shared formatters

[._.]/ Adam Eivydf1aaf9d64e4
diff --git a/client/src/lib/clinicianReport.js b/client/src/lib/clinicianReport.js
index e0c2dc952a..48093805b6 100644
--- a/client/src/lib/clinicianReport.js
+++ b/client/src/lib/clinicianReport.js
@@ -8,7 +8,7 @@
*/
import { REFERENCE_RANGES, getBloodValueStatus } from '../components/meatspace/constants.js';
-import { formatDateTime } from '../utils/formatters';
+import { formatDateTime, capitalize } from '../utils/formatters';
// Blood-marker category grouping — canonical source for the marker→category map.
// BloodTestCard imports getCategoryForKey from here so the on-screen tab grouping
@@ -133,10 +133,6 @@ export function buildLifestyleModel(config) {
return rows;
}
-function capitalize(s) {
- return typeof s === 'string' && s.length ? s[0].toUpperCase() + s.slice(1) : s;
-}
-
/**
* Build the full clinician report model from blood tests + lifestyle config.
* `tests` is the raw array from the Blood tab (oldest-first); the report shows
diff --git a/client/src/lib/tabNotation.js b/client/src/lib/tabNotation.js
index f3116953ae..9927e2f2f8 100644
--- a/client/src/lib/tabNotation.js
+++ b/client/src/lib/tabNotation.js
@@ -30,6 +30,8 @@
// values populate meta, renderers hide the raw line
// 'text' — everything else (incl. non-meta {directive} lines)
+import { capitalize } from '../utils/formatters.js';
+
// ---------------------------------------------------------------------------
// Chord tokens
// ---------------------------------------------------------------------------
@@ -197,8 +199,6 @@ const WORD_SECTION_RE =
/^\s*(intro|verse|chorus|pre[- ]?chorus|bridge|outro|solo|interlude|instrumental|refrain|coda)(\s+\d+)?\s*:?\s*$/i;
const META_ALIASES = { t: 'title', subtitle: 'artist', st: 'artist' };
-const capitalize = (s) => (s ? s[0].toUpperCase() + s.slice(1) : s);
-
// Short ChordPro section codes → [start|end, kind].
const CHORDPRO_SHORT = {
soc: ['start', 'chorus'], eoc: ['end', 'chorus'],
diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.js
index eab4ccb5dc..9b1f8ce4cf 100644
--- a/client/src/utils/formatters.js
+++ b/client/src/utils/formatters.js
@@ -666,3 +666,14 @@ export function clamp(n, min, max) {
return Math.min(max, Math.max(min, n));
}
+/**
+ * Capitalize the first character of a string, leaving the rest untouched
+ * (e.g. "female" → "Female"). Non-strings and empty strings pass through
+ * unchanged rather than throwing.
+ * @param {string} s
+ * @returns {string}
+ */
+export function capitalize(s) {
+ return typeof s === 'string' && s.length ? s[0].toUpperCase() + s.slice(1) : s;
+}
+