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 (codex): derive POST domain from drill type, not coarse module key

[._.]/ Adam Eivycc6b95d7b738
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0b6ef1afdd..030d5536cb 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -42,7 +42,7 @@
## MeatSpace POST
-- **[issue-1988] POST History is now a responsive analytics dashboard.** The History view (`client/src/components/meatspace/post/PostHistory.jsx`) was a single `max-w-3xl` column that stacked a lone overall-score line chart, a 3-up stat block, and the session table — surfacing only a fraction of what `getPostStats` already computes. It now fills desktop width and surfaces the full stats payload: a 4-up summary of **Sessions / Avg Score / Current Streak / Longest Streak**, a wide **Score Trend** line beside a horizontal **Avg by Domain** bar chart (each domain colored to match its `text-*-400` domain class), and a **Drill Breakdown** card that groups every drill's average into per-domain progress bars — so per-domain and per-drill averages plus streaks are visible without opening a single session. Mobile stays single-column; the 7/30/90/All range selector still drives every panel from one fetch. (Closes #1988)
+- **[issue-1988] POST History is now a responsive analytics dashboard.** The History view (`client/src/components/meatspace/post/PostHistory.jsx`) was a single `max-w-3xl` column that stacked a lone overall-score line chart, a 3-up stat block, and the session table — surfacing only a fraction of what `getPostStats` already computes. It now fills desktop width and surfaces the full stats payload: a 4-up summary of **Sessions / Avg Score / Current Streak / Longest Streak**, a wide **Score Trend** line beside a horizontal **Avg by Domain** bar chart (each domain colored to match its `text-*-400` domain class), and a **Drill Breakdown** card that groups every drill's average into per-domain progress bars — so per-domain and per-drill averages plus streaks are visible without opening a single session. The five training domains (Mental Math / Memory / Wordplay / Verbal Agility / Imagination) are derived from each drill's *type* via `DRILL_TO_DOMAIN`, because the runners persist coarse module keys (`mental-math`, `llm-drills`) rather than domain keys — so all LLM drills split correctly across Wordplay/Verbal/Imagination instead of collapsing into one bucket. Mobile stays single-column; the 7/30/90/All range selector still drives every panel from one fetch. (Closes #1988)
## Creative Director
diff --git a/client/src/components/meatspace/post/PostHistory.jsx b/client/src/components/meatspace/post/PostHistory.jsx
index 1e81f1feb6..ccef28b1a3 100644
--- a/client/src/components/meatspace/post/PostHistory.jsx
+++ b/client/src/components/meatspace/post/PostHistory.jsx
@@ -5,7 +5,7 @@ import {
} from 'recharts';
import { getPostSessions, getPostStats } from '../../../services/api';
import useChartColors from '../../../hooks/useChartColors.js';
-import { LLM_DRILL_TYPES, DRILL_LABELS, DOMAINS } from './constants';
+import { LLM_DRILL_TYPES, DRILL_LABELS, DOMAINS, DRILL_TO_DOMAIN } from './constants';
const RANGES = [
{ label: '7d', days: 7 },
@@ -24,7 +24,7 @@ const DOMAIN_HEX = {
imagination: '#22d3ee' // cyan-400
};
-const domainLabel = (key) => DOMAINS[key]?.label || key;
+const domainLabel = (key) => (key === 'other' ? 'Other' : DOMAINS[key]?.label || key);
const domainHex = (key) => DOMAIN_HEX[key] || '#a3a3a3';
const scoreColorClass = (score) =>
@@ -58,29 +58,35 @@ export default function PostHistory({ onBack }) {
[sessions]
);
- // Per-domain averages (byModule is keyed by domain key → avg score).
- const domainData = useMemo(() => {
- const byModule = stats?.byModule || {};
- return Object.entries(byModule)
- .map(([key, score]) => ({ key, label: domainLabel(key), score }))
- .sort((a, b) => b.score - a.score);
- }, [stats]);
-
- // Per-drill averages grouped by domain (byDrill is keyed by `${module}:${type}`).
- const drillsByDomain = useMemo(() => {
+ // Per-domain averages + per-drill breakdown, both derived from `byDrill`.
+ // getPostStats keys byDrill as `${task.module}:${task.type}`, where task.module
+ // is a COARSE module the runners save (`mental-math`, `llm-drills`, `memory`) —
+ // NOT a DOMAINS key. So the real domain must come from the drill TYPE via
+ // DRILL_TO_DOMAIN, not from the module segment (`byModule` is likewise coarse
+ // and can't be labeled/colored as a domain). The per-domain score is the mean
+ // of that domain's per-drill averages.
+ const { domainData, drillsByDomain } = useMemo(() => {
const byDrill = stats?.byDrill || {};
- const groups = {};
+ const groups = {}; // domainKey -> [{ type, label, score }]
for (const [key, score] of Object.entries(byDrill)) {
- const [module, type] = key.split(':');
- if (!groups[module]) groups[module] = [];
- groups[module].push({ type, label: DRILL_LABELS[type] || type, score });
+ const type = key.slice(key.indexOf(':') + 1);
+ const domain = DRILL_TO_DOMAIN[type] || 'other';
+ if (!groups[domain]) groups[domain] = [];
+ groups[domain].push({ type, label: DRILL_LABELS[type] || type, score });
}
- for (const list of Object.values(groups)) list.sort((a, b) => b.score - a.score);
- // Order domains by their overall average (matching the bar chart order).
- return domainData
- .filter(d => groups[d.key])
- .map(d => ({ key: d.key, label: d.label, drills: groups[d.key] }));
- }, [stats, domainData]);
+ const domainList = Object.entries(groups)
+ .map(([key, drills]) => ({
+ key,
+ label: domainLabel(key),
+ score: Math.round(drills.reduce((a, d) => a + d.score, 0) / drills.length),
+ drills: drills.slice().sort((a, b) => b.score - a.score)
+ }))
+ .sort((a, b) => b.score - a.score);
+ return {
+ domainData: domainList.map(({ key, label, score }) => ({ key, label, score })),
+ drillsByDomain: domainList.map(({ key, label, drills }) => ({ key, label, drills }))
+ };
+ }, [stats]);
const hasStats = stats && stats.sessionCount > 0;
diff --git a/client/src/components/meatspace/post/PostHistory.test.jsx b/client/src/components/meatspace/post/PostHistory.test.jsx
index 7005561907..2cb5c76d86 100644
--- a/client/src/components/meatspace/post/PostHistory.test.jsx
+++ b/client/src/components/meatspace/post/PostHistory.test.jsx
@@ -11,18 +11,21 @@ vi.mock('../../../services/api', () => ({
import PostHistory from './PostHistory';
import { getPostSessions, getPostStats } from '../../../services/api';
+// Runners save COARSE module keys (`mental-math`, `llm-drills`) — not DOMAINS
+// keys — so getPostStats keys byModule/byDrill by those. The dashboard must
+// derive the real domain (Mental Math / Wordplay) from the drill TYPE.
const SESSIONS = [
{
- id: 'a', date: '2026-06-01', score: 72, durationMs: 300000, modules: ['math', 'wordplay'],
+ id: 'a', date: '2026-06-01', score: 72, durationMs: 300000, modules: ['mental-math', 'llm-drills'],
tasks: [
- { module: 'math', type: 'multiplication', score: 80, questions: [{ correct: true }] },
- { module: 'wordplay', type: 'pun-wordplay', score: 64, responses: [{}] },
+ { module: 'mental-math', type: 'multiplication', score: 80, questions: [{ correct: true }] },
+ { module: 'llm-drills', type: 'pun-wordplay', score: 64, responses: [{}] },
],
},
{
- id: 'b', date: '2026-06-02', score: 88, durationMs: 300000, modules: ['math'],
+ id: 'b', date: '2026-06-02', score: 88, durationMs: 300000, modules: ['mental-math'],
tasks: [
- { module: 'math', type: 'multiplication', score: 90, questions: [{ correct: true }] },
+ { module: 'mental-math', type: 'multiplication', score: 90, questions: [{ correct: true }] },
],
},
];
@@ -31,8 +34,8 @@ const STATS = {
days: 30,
sessionCount: 2,
overall: 80,
- byModule: { math: 85, wordplay: 64 },
- byDrill: { 'math:multiplication': 85, 'wordplay:pun-wordplay': 64 },
+ byModule: { 'mental-math': 85, 'llm-drills': 64 },
+ byDrill: { 'mental-math:multiplication': 85, 'llm-drills:pun-wordplay': 64 },
currentStreak: 3,
longestStreak: 5,
};
@@ -62,6 +65,10 @@ describe('PostHistory analytics dashboard', () => {
// Per-drill labels render inside the breakdown.
expect(screen.getByText('Multiplication')).toBeTruthy();
expect(screen.getByText('Pun & Wordplay')).toBeTruthy();
+ // The 'Mental Math' / 'Wordplay' domain labels above can ONLY appear when the
+ // domain is derived from the drill TYPE (multiplication→math, pun-wordplay→
+ // wordplay). The coarse `byModule`/byDrill keys are 'mental-math'/'llm-drills',
+ // so the earlier byModule-keyed implementation would have rendered those raw.
});
it('reloads stats when the range selector changes', async () => {