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

fix: correct singular/plural phrasing in drill runner buttons and correlation panels (#7005)

[._.]/ Adam Eivy9d57396ed775
diff --git a/client/src/components/meatspace/ActivityBloodCorrelation.jsx b/client/src/components/meatspace/ActivityBloodCorrelation.jsx
index 1b1248a7db..37ead66df5 100644
--- a/client/src/components/meatspace/ActivityBloodCorrelation.jsx
+++ b/client/src/components/meatspace/ActivityBloodCorrelation.jsx
@@ -2,6 +2,7 @@ import {
ComposedChart, Bar, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer
} from 'recharts';
import useChartColors from '../../hooks/useChartColors.js';
+import { pluralize } from '../../lib/textUtils';
// Blood markers to chart — prefer common ones if available in the test results
const PREFERRED_MARKERS = ['cholesterol', 'glucose', 'ldl', 'hdl', 'triglycerides'];
@@ -54,7 +55,7 @@ export default function ActivityBloodCorrelation({ data, range }) {
<div className="bg-port-card border border-port-border rounded-xl p-6">
<h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider mb-3">Activity vs Blood Work</h3>
<p className="text-gray-400 text-sm">
- Need 14+ days of data for correlations — {dailyData.length} days so far.
+ Need 14+ days of data for correlations — {pluralize(dailyData.length, 'day')} so far.
</p>
</div>
);
diff --git a/client/src/components/meatspace/AlcoholHrvCorrelation.jsx b/client/src/components/meatspace/AlcoholHrvCorrelation.jsx
index 3c19c5a503..381d6b158b 100644
--- a/client/src/components/meatspace/AlcoholHrvCorrelation.jsx
+++ b/client/src/components/meatspace/AlcoholHrvCorrelation.jsx
@@ -3,6 +3,7 @@ import {
ComposedChart, Line, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer
} from 'recharts';
import useChartColors from '../../hooks/useChartColors.js';
+import { pluralize } from '../../lib/textUtils';
const CustomTooltip = ({ active, payload, label, colors }) => {
if (!active || !payload?.length) return null;
@@ -48,7 +49,7 @@ export default function AlcoholHrvCorrelation({ data, range }) {
<h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider">Alcohol vs HRV</h3>
</div>
<p className="text-gray-400 text-sm">
- Need 14+ days of data for correlations — {dailyData.length} days so far.
+ Need 14+ days of data for correlations — {pluralize(dailyData.length, 'day')} so far.
</p>
</div>
);
diff --git a/client/src/components/meatspace/NicotineHealthCorrelation.jsx b/client/src/components/meatspace/NicotineHealthCorrelation.jsx
index 23c27c7cc2..4176a288a4 100644
--- a/client/src/components/meatspace/NicotineHealthCorrelation.jsx
+++ b/client/src/components/meatspace/NicotineHealthCorrelation.jsx
@@ -3,6 +3,7 @@ import {
ComposedChart, Line, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer
} from 'recharts';
import useChartColors from '../../hooks/useChartColors.js';
+import { pluralize } from '../../lib/textUtils';
const CustomTooltip = ({ active, payload, label }) => {
if (!active || !payload?.length) return null;
@@ -50,7 +51,7 @@ export default function NicotineHealthCorrelation({ data, range }) {
<h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider">Nicotine vs Heart Rate</h3>
</div>
<p className="text-gray-400 text-sm">
- Need 14+ days of data for correlations — {dailyData.length} days so far.
+ Need 14+ days of data for correlations — {pluralize(dailyData.length, 'day')} so far.
</p>
</div>
);
diff --git a/client/src/components/meatspace/post/PostLlmDrillRunner.jsx b/client/src/components/meatspace/post/PostLlmDrillRunner.jsx
index e1f983c020..bdd53ef759 100644
--- a/client/src/components/meatspace/post/PostLlmDrillRunner.jsx
+++ b/client/src/components/meatspace/post/PostLlmDrillRunner.jsx
@@ -3,6 +3,7 @@ import { CheckCircle, XCircle } from 'lucide-react';
import ProgressBar from '../../ui/ProgressBar';
import { scorePostLlmDrill } from '../../../services/api';
import { DRILL_LABELS, WORDPLAY_LLM_DRILL_TYPES } from './constants';
+import { pluralize } from '../../../lib/textUtils';
import { AILoadingIndicator, MissedExamplesDisplay, CompoundChainUI, BridgeWordUI, DoubleMeaningUI, IdiomTwistUI, scoreWordplayResponse } from './WordplayDrillUI';
export function combineTrainingScoreResults(scoreResults) {
@@ -800,7 +801,7 @@ function VerbalFluencyUI({ category, items, inputValue, setInputValue, onAddItem
disabled={items.length === 0}
className="w-full px-6 py-2.5 bg-port-success hover:bg-port-success/80 disabled:opacity-50 text-white font-medium rounded-lg transition-colors"
>
- Done — Submit {items.length} items
+ Done — Submit {pluralize(items.length, 'item')}
</button>
<PromptProgress index={questionIndex} total={totalPrompts} />
</>
@@ -927,7 +928,7 @@ function AlternativeUsesUI({ object, items, inputValue, setInputValue, onAddItem
disabled={items.length === 0}
className="w-full px-6 py-2.5 bg-port-success hover:bg-port-success/80 disabled:opacity-50 text-white font-medium rounded-lg transition-colors"
>
- Done — Submit {items.length} uses
+ Done — Submit {pluralize(items.length, 'use')}
</button>
<PromptProgress index={questionIndex} total={totalPrompts} />
</>
diff --git a/client/src/components/meatspace/post/PostLlmDrillRunner.test.jsx b/client/src/components/meatspace/post/PostLlmDrillRunner.test.jsx
index 4c06af36fe..ccebab4e06 100644
--- a/client/src/components/meatspace/post/PostLlmDrillRunner.test.jsx
+++ b/client/src/components/meatspace/post/PostLlmDrillRunner.test.jsx
@@ -143,7 +143,7 @@ describe('PostLlmDrillRunner — training-mode scoring path', () => {
const input = screen.getByPlaceholderText(/other half/i);
fireEvent.change(input, { target: { value: 'firehouse' } });
fireEvent.click(screen.getByText('Add'));
- fireEvent.click(screen.getByText(/Done — Submit 1 compounds/));
+ fireEvent.click(screen.getByText(/Done — Submit 1 compound\b/));
await waitFor(() => expect(screen.getByText('88')).toBeInTheDocument());
expect(scorePostLlmDrill).toHaveBeenCalledWith(
@@ -191,7 +191,7 @@ describe('PostLlmDrillRunner — training-mode scoring path', () => {
fireEvent.change(screen.getByPlaceholderText(/other half/i), { target: { value: 'firehouse' } });
fireEvent.click(screen.getByText('Add'));
- fireEvent.click(screen.getByText(/Done — Submit 1 compounds/));
+ fireEvent.click(screen.getByText(/Done — Submit 1 compound\b/));
await screen.findByText('88');
fireEvent.click(screen.getByText('Next'));
diff --git a/client/src/components/meatspace/post/WordplayDrillUI.jsx b/client/src/components/meatspace/post/WordplayDrillUI.jsx
index ce3251a898..21eeea33d2 100644
--- a/client/src/components/meatspace/post/WordplayDrillUI.jsx
+++ b/client/src/components/meatspace/post/WordplayDrillUI.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
import { Loader } from 'lucide-react';
import { scorePostLlmDrill } from '../../../services/api';
import { getDifficultyColor } from './constants';
+import { pluralize } from '../../../lib/textUtils';
// Shared scoring core for the four wordplay drill types (compound-chain,
// bridge-word, double-meaning, idiom-twist) — used by BOTH the standalone
@@ -161,7 +162,7 @@ export function CompoundChainUI({ challenge, items, inputValue, setInputValue, o
disabled={items.length === 0}
className="w-full px-6 py-2.5 bg-port-success hover:bg-port-success/80 disabled:opacity-50 text-white font-medium rounded-lg transition-colors"
>
- Done — Submit {items.length} compounds
+ Done — Submit {pluralize(items.length, 'compound')}
</button>
<ProgressBar index={questionIndex} total={totalPrompts} />
</>
diff --git a/client/src/components/meatspace/post/WordplayTrainer.test.jsx b/client/src/components/meatspace/post/WordplayTrainer.test.jsx
index 2d81ba7b0e..03f0583bab 100644
--- a/client/src/components/meatspace/post/WordplayTrainer.test.jsx
+++ b/client/src/components/meatspace/post/WordplayTrainer.test.jsx
@@ -134,7 +134,7 @@ describe('WordplayTrainer — training-log persistence (issue #2097)', () => {
fireEvent.change(input, { target: { value: 'firehouse' } });
fireEvent.click(screen.getByText('Add'));
- fireEvent.click(screen.getByText(/Done — Submit 1 compounds/));
+ fireEvent.click(screen.getByText(/Done — Submit 1 compound\b/));
// Scoring resolves (score: 85 >= 70 correct threshold) — "See Results" is
// the last-question label for handleNext.
@@ -182,7 +182,7 @@ describe('WordplayTrainer — training-log persistence (issue #2097)', () => {
await waitFor(() => expect(screen.getByText('fire')).toBeInTheDocument(), { timeout: GENERATED_DRILL_TIMEOUT });
fireEvent.change(screen.getByPlaceholderText(/other half/i), { target: { value: 'firehouse' } });
fireEvent.click(screen.getByText('Add'));
- fireEvent.click(screen.getByText(/Done — Submit 1 compounds/));
+ fireEvent.click(screen.getByText(/Done — Submit 1 compound\b/));
fireEvent.click(await screen.findByText('See Results'));
await waitFor(() => expect(submitTrainingEntry).toHaveBeenCalledTimes(1));
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index ba0a3314ad..def65d48e4 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -233,7 +233,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `terminalDictation.js` | Voice-dictation/IME bridge for the Shell's xterm.js terminal. Apple dictation streams progressively refined guesses and *replaces* what it already typed; xterm forwards each insertion and drops the matching deletions, so the PTY accumulates a garble (`determin` + `determine` + `determines`…). `attachDictationBridge(terminal, sendData)` binds capture-phase listeners on `terminal.element` — ahead of xterm's own textarea listeners, which it stops — and forwards a diff instead: `TERMINAL_DEL` (`0x7f`) per dropped character, then the added text. `sendData` returns `false` to report a dropped send, which leaves the mirror where the PTY actually is. Paths that reach the PTY some other way (a keystroke xterm handles itself, paste, blur, composition end, screen-reader mode) resync the mirror without emitting. `planFieldEdit(mirror, next, floor)` → `{ data, committed }` is the pure core: `floor` is the prefix we did not write and must never rewind through, and `committed` (what the PTY holds afterward, which is *not* the field's value when the floor blocked a rewind) is what the caller must track. The prefix scan never splits a surrogate pair — cutting between the halves of an astral character would send a lone surrogate that serializes to `U+FFFD`. Wired in `useShellSession`; the test suite pins the seam against a real `Terminal`. |
| `terminalScroll.js` | Scrolling the Shell terminal by touch, wheel, and page controls. xterm 6 binds **no touch handlers at all**, and a TUI’s ALTERNATE screen buffer has no terminal scrollback, so `scrollLines()` clamps to a no-op there. Normal shell scrollback uses `scrollLines()`; alternate-screen wheel gestures are captured before xterm’s mouse listener and translated to standard PageUp/PageDown input, which OpenCode supports for its message viewport, while apps that explicitly enable terminal mouse tracking keep xterm’s native wheel path. `attachTerminalTouchScroll(terminal)` (→ detach fn) reserves one-finger panning while preserving pinch zoom and adds bounded flick momentum to normal shell scrollback; mouse-aware apps receive row-granular wheel events at the touch coordinates, and only apps without wheel support fall back to page keys. `attachTerminalWheelScroll(terminal)` handles native wheel input, and `scrollTerminalPage(terminal, direction)` powers the `SCROLL_KEYS` buttons. `measureTerminalGeometry(terminal)` takes one layout read per gesture; `planTouchScrollSteps(accumPx, rowHeightPx)` is the pure sub-row-remainder core. Wired in `useShellSession`. |
| `terminalTheme.js` | Pure xterm.js palette builder for the Shell terminal. `buildTerminalTheme({ bg, fg, accent, card, error, success, warning }, mode)` assembles the xterm `theme` object — base ANSI colors from the active theme's CSS vars, the rest from mode-tuned literals (`ANSI_NIGHT` bright/pastel for dark backgrounds, `ANSI_DAY` darkened/saturated so colored CLI output stays legible on daytime themes). `parseCssColorToHex(raw, fallback)` normalizes both the `15 15 15` triple form and the `rgb(7 7 7 / 0.86)` function form (used by `--port-terminal-*` tokens) to `#rrggbb`, dropping alpha. No DOM reads — `Shell.jsx` resolves CSS vars and re-applies on theme switch. |
-| `textUtils.js` | `escapeRegExp(value)`, `countWords(text)`, `isStr(v)` and `isNonBlankStr(v)` re-exported from `server/lib/textUtils.js` — the two members the bundle has callers for (the Writers Room editor and exercise panel and the autobiography tab count words with the same `\S+` rule the server stores). Named exports rather than `export *`, so the file stays the list of what the browser actually uses. |
+| `textUtils.js` | `escapeRegExp(value)`, `countWords(text)`, `isStr(v)` and `isNonBlankStr(v)` re-exported from `server/lib/textUtils.js` — the two members the bundle has callers for (the Writers Room editor and exercise panel and the autobiography tab count words with the same `\S+` rule the server stores). Named exports rather than `export *`, so the file stays the list of what the browser actually uses. Also `pluralize(count, singular, pluralForm?)` — the shared "N item/items" phrasing helper for singular/plural counts. |
| `threejsAnimation.js` | Pure pose evaluator for the declarative clip contract in `server/lib/threejsModel.js`, used by the Three.js Models preview transport. `evaluateThreejsClipPose(clip, timeSeconds)` → `{ timeSeconds, pose, activeSequenceIds, activePartIds }` where `pose` is a null-prototype partId → `{ position?, rotationDegrees?, scale?, opacity?, visible? }` map: each part+channel resolves from the one sequence that owns the instant (the window containing it, else the most recent behind it, else the next ahead), `visible` steps at the window's end rather than interpolating, and a part no sequence drives is absent so the spec renders as authored. `collectThreejsCues(clip, from, to)` returns the data-only sound cues a play loop crossed in the half-open `[from, to)` interval — a scrub calls it never, which is what makes scrubbing silent. `listThreejsClips` / `listThreejsCues` / `resolveThreejsClip` / `getThreejsClipDuration` read a spec that may have no `animation` key at all. |
| `threejsEnvironment.js` | Image-based lighting for the procedural sculpt spec, used by the Three.js Models preview. `spec.lights` are punctual — they light a surface but give it nothing to REFLECT, so `metalness`, `transmission`, `clearcoat` and `iridescence` read off an environment or read off nothing, and a plausible conductor renders near-black without one. `createSculptEnvironmentTarget(renderer, preset)` builds a preset locally from three's own primitives and prefilters it through `PMREMGenerator` — `neutral` is three's bundled `RoomEnvironment`, `studio` a dark shell with three emissive softbox panels plus a floor bounce — returning null for `none`; the caller owns the render TARGET and disposes it (disposing only `.texture` leaks the framebuffer behind it). `THREEJS_RENDER_PROFILE` mirrors the server's colour-space/tone-map/exposure contract so the preview renders at what the export stamps on the model. Deliberately NOT drei's `<Environment preset=…>`, which fetches an HDR from a CDN: rendering a local model makes no outbound request. `resolveSculptEnvironment(spec)` is the client mirror of `resolveThreejsEnvironment` in `server/lib/threejsModel.js`, reading a spec with no `environment` key as the `none` it was actually authored against. |
| `threejsExplode.js` | Disassembly + part-picking maths for the procedural sculpt spec, shared by the Three.js Models preview so explode and the picker agree on what "a part" is. `computeExplodeLayout(parts, amount)` → `{ offsets, meshOffsets, unitIds, growth }`: separation is a layout **scale about the model centre** (≈2× at full explode) plus a base clearance for parts sitting at the centre — never a uniform outward push, which slides the arrangement without opening gaps — where `offsets` add to a unit's own `position` and `meshOffsets` apply to a group around a container's own geometry (moving its group instead would drag its child units along), and `growth` measures how much the layout actually grew so the camera re-fits on real change. `buildPartSelectionIndex(parts)` → `{ owners, ancestry, names }` for click resolution, subtree highlight, and the selection label. All maps are null-prototype — part ids are provider-authored and `idSchema` accepts `toString`. `isReliefPart` / `isContainerPart` expose the shared part definition: a part flagged `explodeWithParent` is surface relief that rides its parent and resolves selection up to it (unless it has no parent to ride), every other geometry-bearing part is both a movable unit and a selectable component, a part whose descendants carry geometry is additionally descended through, and a part with no geometry in its subtree moves nothing. |
diff --git a/client/src/lib/textUtils.js b/client/src/lib/textUtils.js
index 5ac74e62cb..2d75dc4a54 100644
--- a/client/src/lib/textUtils.js
+++ b/client/src/lib/textUtils.js
@@ -12,3 +12,10 @@
* client is unchanged.
*/
export { countWords, escapeRegExp, isStr, isNonBlankStr } from '../../../server/lib/textUtils.js';
+
+/**
+ * `pluralize(1, 'item')` → "1 item"; `pluralize(2, 'item')` → "2 items".
+ * Pass a third arg for an irregular plural: `pluralize(1, 'person', 'people')`.
+ */
+export const pluralize = (count, singular, pluralForm = `${singular}s`) =>
+ `${count} ${count === 1 ? singular : pluralForm}`;
diff --git a/client/src/lib/textUtils.test.js b/client/src/lib/textUtils.test.js
new file mode 100644
index 0000000000..07034b523d
--- /dev/null
+++ b/client/src/lib/textUtils.test.js
@@ -0,0 +1,18 @@
+import { describe, it, expect } from 'vitest';
+import { pluralize } from './textUtils.js';
+
+describe('pluralize', () => {
+ it('uses the singular form for a count of 1', () => {
+ expect(pluralize(1, 'item')).toBe('1 item');
+ });
+
+ it('appends "s" by default for any other count', () => {
+ expect(pluralize(0, 'item')).toBe('0 items');
+ expect(pluralize(2, 'item')).toBe('2 items');
+ });
+
+ it('uses an explicit irregular plural form when given one', () => {
+ expect(pluralize(1, 'person', 'people')).toBe('1 person');
+ expect(pluralize(3, 'person', 'people')).toBe('3 people');
+ });
+});
diff --git a/client/src/pages/WorkspaceContexts.jsx b/client/src/pages/WorkspaceContexts.jsx
index e3cf47d871..7353f20ba0 100644
--- a/client/src/pages/WorkspaceContexts.jsx
+++ b/client/src/pages/WorkspaceContexts.jsx
@@ -8,6 +8,7 @@ import toast from '../components/ui/Toast';
import { useAsyncAction } from '../hooks/useAsyncAction';
import { timeAgo } from '../utils/formatters';
import PageSkeleton from '../components/ui/PageSkeleton';
+import { pluralize } from '../lib/textUtils';
import {
listWorkspaceContexts, getWorkspaceContext, saveWorkspaceContext,
restoreWorkspaceContext, deleteWorkspaceContext
@@ -17,11 +18,11 @@ import {
// its working context — git branch, in-repo shell sessions, scoped tasks.
// Deep-linkable: /workspace-contexts (list) and /workspace-contexts/:appId.
-function StatChip({ icon: Icon, label, value }) {
+function StatChip({ icon: Icon, singular, value }) {
return (
<div className="flex items-center gap-1.5 text-xs text-gray-400">
<Icon size={13} />
- <span>{value} {label}</span>
+ <span>{pluralize(value, singular)}</span>
</div>
);
}
@@ -180,8 +181,8 @@ function ContextDetail({ appId }) {
: <span className="text-port-warning flex items-center gap-1 text-xs"><AlertCircle size={12} /> branch changed</span>)}
</div>
<div className="flex items-center gap-4 text-xs text-gray-500">
- <span>{ctx.saved.shellSessionIds?.length || 0} shell(s)</span>
- <span>{ctx.saved.taskIds?.length || 0} task(s)</span>
+ <span>{pluralize(ctx.saved.shellSessionIds?.length || 0, 'shell')}</span>
+ <span>{pluralize(ctx.saved.taskIds?.length || 0, 'task')}</span>
</div>
</div>
)}
@@ -236,8 +237,8 @@ function ContextList() {
<FolderGit2 size={16} /> {row.appName}
</div>
<div className="flex flex-wrap gap-x-4 gap-y-1 mb-2">
- <StatChip icon={SquareTerminal} label="shell(s)" value={row.shellSessionCount} />
- <StatChip icon={ListChecks} label="task(s)" value={row.taskCount} />
+ <StatChip icon={SquareTerminal} singular="shell" value={row.shellSessionCount} />
+ <StatChip icon={ListChecks} singular="task" value={row.taskCount} />
</div>
<div className="text-xs text-gray-500">
{row.savedAt