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

feat: add Flash Cards study mode to Elements Song (#2480)

Adam Eivyaa1cf6913b12
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index ce78f7ad4b..ac814ceed0 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -79,3 +79,5 @@
- **PortOS now installs a service worker for offline app-shell loading and low-bandwidth caching** — the modern replacement for the long-deprecated AppCache manifest. After the first online visit, the built app shell (`index.html`) and the content-hashed JS/CSS chunks are cached, so the UI loads instantly on repeat visits, keeps rendering when the server is briefly unreachable (flaky Tailnet links), and stops re-pulling megabytes of vendor JS on every navigation over a slow connection. Google Fonts and static public assets (icons, textures, manifest) are cached too. Real-time and large/dynamic routes — `/api/*`, `/socket.io/*`, and `/data/*` media — are **never** cached, so live data and streamed assets always hit the network (HTTP Range preserved for `/data`). Navigations stay network-first so a fresh build is always picked up when online, and the existing build-id / stale-chunk-reload machinery still handles "the server rebuilt while a tab was open." The worker registers only in a production **secure context** (HTTPS, or `localhost`) — it is a progressive enhancement that silently no-ops over a plain-HTTP Tailnet hostname and in the Vite dev server (where it also tears down any stale worker). Implemented as a hand-rolled worker (`client/public/sw.js`) with no new dependency; registration lives in `client/src/lib/registerServiceWorker.js`. The PWA manifest gained explicit `id`/`scope` for a deterministic installed-app identity.
- **A daily self-diagnostics job now surfaces CoS self-healing failures into a single GitHub monitoring issue (#2464).** The Layered Intelligence loop can only improve if failures are actually observed, but a category quietly stuck failing (e.g. `self-improve:claim-issue`'s claim-work at a ~30% failure rate, or `layered-intelligence` failing its first run) had no automated pulse — the numbers lived only in the Learning tab. A new deterministic `type: 'script'` autonomous job (`job-self-diagnostics`, `scriptHandler: 'self-diagnostics'`, daily at 05:00, disabled by default) reads the task-learning per-category metrics (`data/cos/learning.json` `byTaskType`), and for every category with recorded failures records a structured single-line log entry (slug, failed/total, success rate, `lastCompleted`, avg/max duration) and aggregates them — ordered by impact (most failures first, then lowest success rate) — into ONE persistent GitHub summary issue. It reuses an existing open issue marked `monitoring` (matched by an embedded dedup slug marker) rather than filing a fresh duplicate each cycle, refreshes its body in place, and toggles a `needs attention` label on while failures exist / off once the categories recover. The issue read distinguishes a failed `gh` call (skip, don't file) from an empty list (`ok:true`), so a transient CLI blip can't defeat dedup. No LLM calls — a pure metrics-read + `gh` write, cold-bootstrap-safe and a sanctioned scheduled automation. The new default job self-installs on existing installs via the additive `mergeWithDefaults` boot merge (no migration needed).
+
+- **The Elements Song page gains a Flash Cards study mode so you can learn name↔symbol pairings before being tested (#2480).** The `/post/memory/elements` surface previously only *tested* element mappings (the Element Flash recall quiz) or let you *browse* the periodic table — a user who didn't already know the pairings had nowhere to learn them, unlike Morse (copy vs head-copy) and MemoryPractice (learn vs recall) which both have an explicit study→test split. A new **Flash Cards** mode draws the weakest-mastered elements first, shows one face (name, or symbol + atomic number) and flips to reveal the full pairing, then lets you self-rate *Got It* / *Study Again*. Study reps advance element mastery through the same `submitMemoryPractice` path the recall quiz uses (`mode: 'element-study'`), so studying counts toward the same per-element mastery the periodic-table heatmap shows. The elements page is also now reachable from ⌘K / voice nav (a new `nav.post.memory.elements` manifest entry) — it had no entry before. `element-study` is a standalone practice mode (like `learn`), not a POST-session drill type, so it's intentionally not offered in the balanced-session drill picker (the server has no session generator for it); no migration needed (additive enum value + label).
diff --git a/client/src/components/meatspace/post/ElementsSong.jsx b/client/src/components/meatspace/post/ElementsSong.jsx
index 67c328f1de..f71f7cb00d 100644
--- a/client/src/components/meatspace/post/ElementsSong.jsx
+++ b/client/src/components/meatspace/post/ElementsSong.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect, useRef, useMemo } from 'react';
-import { ChevronLeft, ChevronRight, BookOpen, Zap, Target, Check, X, SkipForward, Loader, Search, Eye, BarChart3, Gauge } from 'lucide-react';
+import { ChevronLeft, ChevronRight, BookOpen, Zap, Target, Check, X, SkipForward, Loader, Search, Eye, BarChart3, Gauge, Layers, RotateCw } from 'lucide-react';
import { submitMemoryPractice, getMemoryMastery, getMemoryItem } from '../../../services/api';
import { RapidReaderModal } from '../../RapidReader';
@@ -42,6 +42,9 @@ const ROW_LABELS = [null, null, null, null, null, null, null, 'Lanthanides', 'Ac
const PRACTICE_MODES = [
{ id: 'learn', label: 'Learn Lyrics', icon: BookOpen, desc: 'Read through the song verse by verse' },
+ // Study (flip-to-reveal) before the recall test, mirroring the study→test
+ // split of Morse (copy vs head-copy) and MemoryPractice (learn vs recall).
+ { id: 'element-study', label: 'Flash Cards', icon: Layers, desc: 'Study element name ↔ symbol pairings' },
{ id: 'element-flash', label: 'Element Flash', icon: Zap, desc: 'Name elements from symbols or vice versa' },
{ id: 'fill-blank', label: 'Fill the Lyrics', icon: Target, desc: 'Fill in missing element names from the lyrics' },
];
@@ -80,6 +83,7 @@ export default function ElementsSong({ item: itemProp, onBack, loadItemOnMount }
}
if (mode === 'learn') return <LearnMode item={item} onBack={() => setMode(null)} onComplete={handlePracticeComplete} />;
+ if (mode === 'element-study') return <ElementStudyMode item={item} mastery={mastery} onBack={() => setMode(null)} onComplete={handlePracticeComplete} />;
if (mode === 'element-flash') return <ElementFlashMode item={item} mastery={mastery} onBack={() => setMode(null)} onComplete={handlePracticeComplete} />;
if (mode === 'fill-blank') return <FillBlankMode item={item} onBack={() => setMode(null)} onComplete={handlePracticeComplete} />;
@@ -524,6 +528,183 @@ function LearnMode({ item, onBack, onComplete }) {
);
}
+// Element [symbol, info] entries ordered weakest-mastery-first, so both the
+// study deck and the flash quiz surface the least-known elements first.
+function weakestFirstElements(elementMap, mastery) {
+ return Object.entries(elementMap).sort((a, b) => {
+ const mA = mastery.elements?.[a[0]];
+ const mB = mastery.elements?.[b[0]];
+ const pctA = mA?.attempts > 0 ? mA.correct / mA.attempts : 0;
+ const pctB = mB?.attempts > 0 ? mB.correct / mB.attempts : 0;
+ return pctA - pctB;
+ });
+}
+
+// =============================================================================
+// ELEMENT STUDY MODE (flash cards — flip to reveal, self-rate)
+// =============================================================================
+
+function ElementStudyMode({ item, mastery, onBack, onComplete }) {
+ const elementMap = item.content?.elementMap || {};
+
+ // Build the study deck once per item/mastery. Without memoization the
+ // Math.random() front-side pick below re-runs on every render (e.g. each flip),
+ // flipping which face shows mid-card — same footgun ElementFlashMode guards.
+ const cards = useMemo(() => {
+ return weakestFirstElements(elementMap, mastery).slice(0, 20).map(([symbol, info]) => ({
+ symbol,
+ info,
+ // Fixed per-card front face so a flip doesn't swap which side is hidden.
+ showSymbolFront: Math.random() > 0.5,
+ }));
+ }, [elementMap, mastery]);
+
+ const [idx, setIdx] = useState(0);
+ const [flipped, setFlipped] = useState(false);
+ const [results, setResults] = useState([]);
+ const [startTime] = useState(Date.now());
+
+ if (!cards.length) {
+ return (
+ <div className="space-y-6 max-w-2xl">
+ <div className="flex items-center gap-3">
+ <button aria-label="Back" onClick={onBack} className="text-gray-400 hover:text-white transition-colors">
+ <ChevronLeft size={20} />
+ </button>
+ <h2 className="text-lg font-bold text-white">Flash Cards</h2>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-500 text-sm">
+ No elements available to study yet.
+ </div>
+ </div>
+ );
+ }
+
+ if (idx >= cards.length) {
+ const known = results.filter(r => r.correct).length;
+ const pct = Math.round((known / results.length) * 100);
+ const scoreColor = pct >= 80 ? 'text-port-success' : pct >= 50 ? 'text-port-warning' : 'text-port-error';
+
+ return (
+ <div className="space-y-6 max-w-2xl">
+ <div className="flex items-center gap-3">
+ <button aria-label="Back" onClick={onBack} className="text-gray-400 hover:text-white transition-colors">
+ <ChevronLeft size={20} />
+ </button>
+ <h2 className="text-xl font-bold text-white">Flash Cards Complete</h2>
+ </div>
+ <div className="bg-port-card border border-port-border rounded-lg p-6 text-center">
+ <div className={`text-5xl font-bold font-mono ${scoreColor} mb-2`}>{pct}%</div>
+ <div className="text-gray-400 text-sm">{known} of {results.length} marked known</div>
+ </div>
+ {results.filter(r => !r.correct).length > 0 && (
+ <div className="bg-port-card border border-port-border rounded-lg p-4">
+ <h3 className="text-sm font-medium text-gray-400 mb-3">Keep studying</h3>
+ <div className="grid grid-cols-2 gap-2">
+ {results.filter(r => !r.correct).map((r, i) => (
+ <div key={i} className="text-xs bg-port-bg rounded p-2">
+ <span className="text-port-warning font-mono">{r.symbol}</span>
+ <span className="text-gray-500 mx-1">&rarr;</span>
+ <span className="text-gray-300">{r.name}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ )}
+ <button
+ onClick={() => {
+ submitMemoryPractice(item.id, {
+ mode: 'element-study', chunkId: null,
+ results: results.map(r => ({ correct: r.correct, element: r.element })),
+ totalMs: Date.now() - startTime,
+ }).then(r => onComplete(r?.mastery)).catch(err => { console.warn('⚠️ Failed to record practice: ' + err.message); onComplete(null); });
+ }}
+ className="w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors"
+ >
+ Save & Return
+ </button>
+ </div>
+ );
+ }
+
+ const card = cards[idx];
+ const info = card.info;
+ const frontLabel = card.showSymbolFront ? 'What element?' : 'What symbol?';
+
+ function rate(known) {
+ setResults(prev => [...prev, { correct: known, element: card.symbol, symbol: card.symbol, name: info.name }]);
+ setIdx(prev => prev + 1);
+ setFlipped(false);
+ }
+
+ return (
+ <div className="space-y-6 max-w-2xl">
+ <div className="flex items-center gap-3">
+ <button aria-label="Back" onClick={onBack} className="text-gray-400 hover:text-white transition-colors">
+ <ChevronLeft size={20} />
+ </button>
+ <h2 className="text-lg font-bold text-white">Flash Cards</h2>
+ <span className="text-gray-500 text-sm ml-auto">{idx + 1} / {cards.length}</span>
+ </div>
+
+ <div className="w-full h-1.5 bg-port-border rounded-full overflow-hidden">
+ <div className="h-full bg-emerald-500 rounded-full transition-all" style={{ width: `${((idx + 1) / cards.length) * 100}%` }} />
+ </div>
+
+ {/* The card: tap the front to flip; the back shows the full pairing. */}
+ {flipped ? (
+ <div className="bg-port-card border border-emerald-500/40 rounded-lg p-8 text-center">
+ <div className="text-[11px] text-gray-600 mb-1">{info.atomicNumber}</div>
+ <div className="text-5xl font-bold font-mono text-white mb-2">{card.symbol}</div>
+ <div className="text-xl text-emerald-400">{info.name}</div>
+ </div>
+ ) : (
+ <button
+ type="button"
+ onClick={() => setFlipped(true)}
+ className="w-full bg-port-card border border-port-border rounded-lg p-8 text-center hover:border-port-accent/50 transition-colors"
+ >
+ {card.showSymbolFront ? (
+ <>
+ <div className="text-[11px] text-gray-600 mb-1">{info.atomicNumber}</div>
+ <div className="text-5xl font-bold font-mono text-white">{card.symbol}</div>
+ </>
+ ) : (
+ <div className="text-4xl font-bold text-white">{info.name}</div>
+ )}
+ <div className="mt-4 flex items-center justify-center gap-1.5 text-gray-500 text-sm">
+ <RotateCw size={14} /> Tap to reveal — {frontLabel}
+ </div>
+ </button>
+ )}
+
+ {flipped ? (
+ <div className="flex gap-3">
+ <button
+ onClick={() => rate(false)}
+ className="flex-1 flex items-center justify-center gap-2 px-4 py-2.5 bg-port-card border border-port-border rounded-lg text-gray-300 hover:border-port-warning/50 hover:text-port-warning transition-colors"
+ >
+ <RotateCw size={16} /> Study Again
+ </button>
+ <button
+ onClick={() => rate(true)}
+ className="flex-1 flex items-center justify-center gap-2 px-4 py-2.5 bg-port-success hover:bg-port-success/80 text-white rounded-lg transition-colors"
+ >
+ <Check size={16} /> Got It
+ </button>
+ </div>
+ ) : (
+ <button
+ onClick={() => setFlipped(true)}
+ className="w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors"
+ >
+ Reveal
+ </button>
+ )}
+ </div>
+ );
+}
+
// =============================================================================
// ELEMENT FLASH MODE
// =============================================================================
@@ -535,16 +716,8 @@ function ElementFlashMode({ item, mastery, onBack, onComplete }) {
// shuffle below re-runs on every render (e.g. each keystroke), reshuffling the
// deck and swapping the current question mid-answer.
const questions = useMemo(() => {
- const allElements = Object.entries(elementMap);
- // Prioritize weak elements
- const sorted = [...allElements].sort((a, b) => {
- const mA = mastery.elements?.[a[0]];
- const mB = mastery.elements?.[b[0]];
- const pctA = mA?.attempts > 0 ? mA.correct / mA.attempts : 0;
- const pctB = mB?.attempts > 0 ? mB.correct / mB.attempts : 0;
- return pctA - pctB;
- });
- return sorted.slice(0, 15).sort(() => Math.random() - 0.5).map(([symbol, info]) => {
+ // Prioritize weak elements, then shuffle the weakest slice for quiz variety.
+ return weakestFirstElements(elementMap, mastery).slice(0, 15).sort(() => Math.random() - 0.5).map(([symbol, info]) => {
const askSymbol = Math.random() > 0.5;
return askSymbol
? { prompt: info.name, expected: symbol, element: symbol, label: 'What symbol?' }
diff --git a/client/src/components/meatspace/post/ElementsSong.test.jsx b/client/src/components/meatspace/post/ElementsSong.test.jsx
new file mode 100644
index 0000000000..93d68770ac
--- /dev/null
+++ b/client/src/components/meatspace/post/ElementsSong.test.jsx
@@ -0,0 +1,83 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, fireEvent, act } from '@testing-library/react';
+import ElementsSong from './ElementsSong';
+
+// The Flash Cards study mode (issue #2480) is a flip-to-reveal study surface —
+// distinct from the Element Flash recall test — that must still advance element
+// mastery through the shared submitMemoryPractice path. These tests pin that
+// contract: the mode is offered, a card flips + self-rates, and completing the
+// deck submits `mode: 'element-study'` with element-tagged results.
+
+const submitMemoryPractice = vi.fn(() => Promise.resolve({ mastery: { overallPct: 10, chunks: {}, elements: {} } }));
+
+vi.mock('../../../services/api', () => ({
+ submitMemoryPractice: (...args) => submitMemoryPractice(...args),
+ getMemoryMastery: () => Promise.resolve(null),
+ getMemoryItem: () => Promise.resolve(null),
+}));
+
+// The RapidReader modal pulls in browser-only APIs; the study flow never opens
+// it, so stub it out to keep the render lightweight.
+vi.mock('../../RapidReader', () => ({ RapidReaderModal: () => null }));
+
+const item = {
+ id: 'elements-song',
+ title: 'The Elements Song',
+ content: {
+ lines: [],
+ chunks: [],
+ elementMap: {
+ H: { name: 'Hydrogen', atomicNumber: 1 },
+ He: { name: 'Helium', atomicNumber: 2 },
+ },
+ },
+ mastery: { overallPct: 0, chunks: {}, elements: {} },
+};
+
+const settle = () => act(async () => {});
+
+beforeEach(() => submitMemoryPractice.mockClear());
+
+describe('ElementsSong — Flash Cards study mode', () => {
+ it('offers a Flash Cards study mode alongside the recall test', async () => {
+ render(<ElementsSong item={item} onBack={() => {}} />);
+ await settle();
+ expect(screen.getByText('Flash Cards')).toBeInTheDocument();
+ expect(screen.getByText('Study element name ↔ symbol pairings')).toBeInTheDocument();
+ // The recall test is still present — study augments, it doesn't replace.
+ expect(screen.getByText('Element Flash')).toBeInTheDocument();
+ });
+
+ it('flips a card to reveal the pairing, then self-rates through the deck and submits element-study mastery', async () => {
+ render(<ElementsSong item={item} onBack={() => {}} />);
+ await settle();
+
+ fireEvent.click(screen.getByText('Flash Cards'));
+ await settle();
+
+ // Two elements → a 2-card deck. Reveal + rate each card.
+ for (let i = 0; i < 2; i++) {
+ // Reveal the hidden face (the explicit Reveal button under the card).
+ fireEvent.click(screen.getByRole('button', { name: 'Reveal' }));
+ await settle();
+ // Self-rate: mark the first known, the second not-known, so the submitted
+ // results carry a mix of correct flags.
+ fireEvent.click(screen.getByText(i === 0 ? 'Got It' : 'Study Again'));
+ await settle();
+ }
+
+ // Completion screen → persist the study reps.
+ fireEvent.click(screen.getByText('Save & Return'));
+ await settle();
+
+ expect(submitMemoryPractice).toHaveBeenCalledTimes(1);
+ const [id, payload] = submitMemoryPractice.mock.calls[0];
+ expect(id).toBe('elements-song');
+ expect(payload.mode).toBe('element-study');
+ expect(payload.results).toHaveLength(2);
+ // Every result is element-tagged (drives per-element mastery server-side) and
+ // exactly one was marked known.
+ expect(payload.results.every((r) => r.element === 'H' || r.element === 'He')).toBe(true);
+ expect(payload.results.filter((r) => r.correct)).toHaveLength(1);
+ });
+});
diff --git a/client/src/components/meatspace/post/constants.js b/client/src/components/meatspace/post/constants.js
index 9ee810ef9e..ea4dfb8886 100644
--- a/client/src/components/meatspace/post/constants.js
+++ b/client/src/components/meatspace/post/constants.js
@@ -112,6 +112,10 @@ export const DRILL_LABELS = {
'memory-fill-blank': 'Memory Fill Blank',
'memory-sequence': 'Memory Sequence',
'memory-element-flash': 'Element Flash',
+ // Standalone flash-card study mode (ElementsSong.jsx). Label only — NOT added
+ // to MEMORY_DRILL_TYPES / DOMAINS.memory.drillTypes because it isn't a POST
+ // session drill (the server has no memory-element-study generator).
+ 'memory-element-study': 'Element Study',
'what-if': 'What If?',
'alternative-uses': 'Alternative Uses',
'story-prompt': 'Story Prompt',
diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsx
index 790587524a..70c9766cd5 100644
--- a/client/src/components/meatspace/tabs/PostTab.jsx
+++ b/client/src/components/meatspace/tabs/PostTab.jsx
@@ -28,6 +28,15 @@ import { LLM_DRILL_TYPES, COGNITIVE_DRILL_TYPES } from '../post/constants';
const RUN_SUBROUTE = 'run';
const isRunSubroute = (subtab) => subtab === RUN_SUBROUTE;
+// Routed memory sub-pages (`/post/memory/:subtab`). The Elements Song study
+// surface is the only one today; kept as a const so the guard below and the
+// nav-manifest contract test (server/lib/navManifest.test.js) share one source
+// of truth for which `/post/memory/*` deep links resolve to a real page.
+export const MEMORY_SUBROUTES = [
+ { id: 'elements', label: 'Elements' },
+];
+const MEMORY_SUBROUTE_IDS = MEMORY_SUBROUTES.map((s) => s.id);
+
export default function PostTab({ tab = 'launcher', subtab }) {
const navigate = useNavigate();
const location = useLocation();
@@ -222,7 +231,7 @@ export default function PostTab({ tab = 'launcher', subtab }) {
);
}
case 'memory':
- if (subtab === 'elements') {
+ if (MEMORY_SUBROUTE_IDS.includes(subtab)) {
return (
<ElementsSong
item={elementsItem}
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index a3b154683b..21e067a0ca 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -165,6 +165,7 @@ export const NAV_COMMANDS = [
{ id: 'nav.post.config', path: '/post/config', label: 'Config', section: 'POST', aliases: ['post-config'] },
{ id: 'nav.post.history', path: '/post/history', label: 'History', section: 'POST', aliases: ['post-history'] },
{ id: 'nav.post.memory', path: '/post/memory', label: 'Memory', section: 'POST', aliases: ['post-memory'] },
+ { id: 'nav.post.memory.elements', path: '/post/memory/elements', label: 'Elements', section: 'POST', aliases: ['post-elements', 'elements', 'periodic-table', 'elements-song'], keywords: ['periodic table', 'chemistry', 'symbols', 'flash cards', 'tom lehrer', 'atomic number'] },
{ id: 'nav.post.morse', path: '/post/morse', label: 'Morse', section: 'POST', aliases: ['post-morse', 'morse', 'morse-code'], keywords: ['cw', 'ham', 'radio', 'koch', 'cognitive'] },
{ id: 'nav.post.morse.copy', path: '/post/morse/copy', label: 'Morse Copy', section: 'POST', aliases: ['morse-copy', 'morse copy', 'copy-morse', 'morse-listen'], keywords: ['cw', 'koch', 'listen', 'decode', 'receive', 'ear'] },
{ id: 'nav.post.morse.head-copy', path: '/post/morse/head-copy', label: 'Morse Head Copy', section: 'POST', aliases: ['morse-head-copy', 'morse head copy', 'head-copy', 'head copy'], keywords: ['cw', 'koch', 'audio only', 'no reference', 'memory', 'recall'] },
diff --git a/server/lib/navManifest.test.js b/server/lib/navManifest.test.js
index 0ef94f24d5..b7acb9bc5f 100644
--- a/server/lib/navManifest.test.js
+++ b/server/lib/navManifest.test.js
@@ -34,11 +34,15 @@ const TABBED_PAGES = [
{ prefix: '/wiki', file: 'client/src/pages/Wiki.jsx', kind: 'ids', constName: 'TABS' },
{ prefix: '/settings', file: 'client/src/components/settings/SettingsTabsHeader.jsx', kind: 'links', constName: 'TABS' },
{ prefix: '/sharing', file: 'client/src/pages/Sharing.jsx', kind: 'links', constName: 'SECTIONS' },
- // POST's morse tab has routed `:mode` sub-pages (/post/morse/copy|send) that
- // aren't top-level switch cases — declare their source so the guard covers
- // them in both directions (nav ↔ real mode). Adding a MODE flows automatically.
+ // POST's morse tab has routed `:mode` sub-pages (/post/morse/copy|send) and the
+ // memory tab has the Elements study sub-page (/post/memory/elements) — none are
+ // top-level switch cases, so declare their sources so the guard covers them in
+ // both directions (nav ↔ real sub-page). Adding an entry flows automatically.
{ prefix: '/post', file: 'client/src/components/meatspace/tabs/PostTab.jsx', kind: 'switch', switchVar: 'tab',
- nestedIdSources: [{ parent: 'morse', file: 'client/src/components/meatspace/post/MorseTrainer.jsx', constName: 'MODES' }] },
+ nestedIdSources: [
+ { parent: 'morse', file: 'client/src/components/meatspace/post/MorseTrainer.jsx', constName: 'MODES' },
+ { parent: 'memory', file: 'client/src/components/meatspace/tabs/PostTab.jsx', constName: 'MEMORY_SUBROUTES' },
+ ] },
];
// Pull the inner text of `export const <constName> = [ … ];` (requiring `export`
diff --git a/server/lib/postValidation.js b/server/lib/postValidation.js
index c65b5e5eeb..d524e49636 100644
--- a/server/lib/postValidation.js
+++ b/server/lib/postValidation.js
@@ -354,7 +354,10 @@ const practiceResultSchema = z.object({
});
export const memoryPracticeSchema = z.object({
- mode: z.enum(['fill-blank', 'sequence', 'element-flash', 'learn', 'speed-run']),
+ // `element-study` is the standalone flash-card study mode (ElementsSong.jsx) —
+ // logged like `learn`; it advances element mastery via results[].element but
+ // is NOT a POST-session drill type (no server generator, see generateMemoryDrill).
+ mode: z.enum(['fill-blank', 'sequence', 'element-flash', 'element-study', 'learn', 'speed-run']),
chunkId: z.string().nullable().optional(),
results: z.array(practiceResultSchema).min(1),
totalMs: z.number().min(0).optional(),