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([issue-2101]): POST nav/config/a11y polish — Morse in sidebar, presets, keyboard rows, pausable transitions

Adam Eivyc4a4ca6bef7a
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 894946cf08..975ce98216 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -6,6 +6,7 @@
## MeatSpace POST
+- **[issue-2101] POST config & UX polish: Morse in the sidebar, config presets, keyboard-accessible history, pausable transitions.** Morse is now a full nav entry under the POST sidebar section (previously reachable only via the launcher or ⌘K). The drill config page gained one-click presets — "Balanced daily", "Math focus", "Cognitive focus", and "Everything (local-only)" — plus per-group "Enable all / Disable all" buttons on the Mental Math, Cognitive, and LLM sections (bulk-enabling LLM drills is blocked until you've picked an AI provider). History session rows now expand/collapse with the keyboard (Enter/Space), not just a mouse click. The inter-drill transition screen gained a Pause/Resume control and pauses its 3-second auto-advance countdown while you're hovering or focused on it, so you're never yanked into the next drill mid-read.
- **Multiplication drills now ramp up instead of starting hard.** The mental-math multiplication drill used to open at a fixed 2-digit × 2-digit difficulty (e.g. `566 × 191`) for everyone. It now climbs a mastery-gated ladder — `1×1` → `1×2` → `1×1×1` → `2×2` → … — starting at single-digit × single-digit and advancing to the next rung only after you answer a level quickly *and* accurately (≥90% correct within a per-rung speed target). The drill header and the config page show your current rung and per-level mastery. On by default; turn off "Progressive difficulty" on the Multiplication card to go back to the manual Max Digits setting.
- **Morse trainer audio now works on mobile Safari.** iOS Safari starts the Web Audio context suspended and only unlocks it once `resume()` fully settles. The trainer fired `resume()` without awaiting it, so the first tones were scheduled against a still-suspended clock and never sounded on iPhone/iPad. It now awaits the resume before scheduling any tone (matching the app's other audio modules), so Copy, Head Copy, and Send-mode keying all produce sound on mobile Safari.
- **The Elements Song trainer is now mobile-friendly and speed-readable.** The periodic-table memorization view no longer overflows off the right edge of a phone screen: the mastery summary, search box, and Mastery/Category toggle now stack and stretch to full width on small screens, the periodic table uses smaller cells (with a scroll-hint fade so it's clear the grid pans horizontally), and the header shrinks to fit. It also gained a **Rapid Read** practice mode that RSVP-flashes the lyrics one word at a time (reusing the app's speed reader) — run the whole song from the Practice list, or tap the gauge icon on any verse to speed-read just that section.
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 037c3d3da7..8bec717685 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -69,6 +69,7 @@ import {
FileInput,
FilePen,
MessageCircle,
+ Radio,
Swords,
HardDrive,
Layers,
@@ -327,6 +328,7 @@ const navItems = [
{ to: '/post/history', label: 'History', icon: History },
{ to: '/post/launcher', label: 'Launcher', icon: Play },
{ to: '/post/memory', label: 'Memory', icon: Brain },
+ { to: '/post/morse', label: 'Morse', icon: Radio },
{ to: '/post/wordplay', label: 'Wordplay', icon: MessageCircle },
],
},
diff --git a/client/src/components/meatspace/post/DrillTransition.jsx b/client/src/components/meatspace/post/DrillTransition.jsx
index baa78db65f..5e9a093f97 100644
--- a/client/src/components/meatspace/post/DrillTransition.jsx
+++ b/client/src/components/meatspace/post/DrillTransition.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
-import { ChevronRight, Calculator, BookOpen, MessageCircle, Mic, Sparkles } from 'lucide-react';
+import { ChevronRight, Calculator, BookOpen, MessageCircle, Mic, Sparkles, Pause, Play } from 'lucide-react';
import { DOMAINS, DRILL_TO_DOMAIN, DRILL_LABELS } from './constants';
const DOMAIN_ICONS = {
@@ -12,23 +12,41 @@ const DOMAIN_ICONS = {
export default function DrillTransition({ nextDrillType, drillIndex, drillCount, completedResults, onContinue }) {
const [countdown, setCountdown] = useState(3);
+ // Explicit user pause (Pause/Resume button) vs. transient hover/focus pause —
+ // tracked separately so releasing hover/focus doesn't silently un-pause a
+ // deliberate Pause click. Either one halts the countdown.
+ const [manuallyPaused, setManuallyPaused] = useState(false);
+ const [hovering, setHovering] = useState(false);
+ const paused = manuallyPaused || hovering;
const domainKey = DRILL_TO_DOMAIN[nextDrillType];
const domain = domainKey ? DOMAINS[domainKey] : null;
const Icon = domainKey ? DOMAIN_ICONS[domainKey] : ChevronRight;
- // Auto-advance after 3 seconds
+ // Auto-advance after 3 seconds, unless paused (manually or via hover/focus).
useEffect(() => {
+ if (paused) return;
if (countdown <= 0) {
onContinue();
return;
}
const timer = setTimeout(() => setCountdown(c => c - 1), 1000);
return () => clearTimeout(timer);
- }, [countdown, onContinue]);
+ }, [countdown, paused, onContinue]);
return (
- <div className="max-w-lg mx-auto space-y-8">
+ <div
+ className="max-w-lg mx-auto space-y-8"
+ onMouseEnter={() => setHovering(true)}
+ onMouseLeave={() => setHovering(false)}
+ onFocus={() => setHovering(true)}
+ onBlur={(e) => {
+ // Only clear hover-pause once focus has left the whole transition card,
+ // not just the individual button — a Tab between the Pause and Continue
+ // buttons shouldn't flicker the countdown back on mid-transition.
+ if (!e.currentTarget.contains(e.relatedTarget)) setHovering(false);
+ }}
+ >
{/* Completed domains summary */}
{completedResults.length > 0 && (
<div className="flex justify-center gap-3">
@@ -74,13 +92,30 @@ export default function DrillTransition({ nextDrillType, drillIndex, drillCount,
))}
</div>
- {/* Continue button with countdown */}
- <button
- onClick={onContinue}
- className="w-full px-6 py-3 bg-port-accent hover:bg-port-accent/80 text-white font-medium rounded-lg transition-colors"
- >
- Continue {countdown > 0 ? `(${countdown})` : ''}
- </button>
+ {/* Pause/Resume + Continue now controls */}
+ <div className="flex items-center gap-2">
+ <button
+ type="button"
+ onClick={() => setManuallyPaused(p => !p)}
+ aria-pressed={manuallyPaused}
+ className="flex items-center gap-1.5 px-4 py-3 bg-port-card border border-port-border hover:border-port-accent text-gray-300 text-sm font-medium rounded-lg transition-colors shrink-0"
+ >
+ {manuallyPaused ? <Play size={16} /> : <Pause size={16} />}
+ {manuallyPaused ? 'Resume' : 'Pause'}
+ </button>
+ <button
+ type="button"
+ onClick={onContinue}
+ className="flex-1 px-6 py-3 bg-port-accent hover:bg-port-accent/80 text-white font-medium rounded-lg transition-colors"
+ >
+ Continue now {!paused && countdown > 0 ? `(${countdown})` : ''}
+ </button>
+ </div>
+ {paused && (
+ <p className="text-center text-xs text-gray-500">
+ {manuallyPaused ? 'Paused' : 'Paused — hover or focus'} · auto-advance stopped
+ </p>
+ )}
</div>
);
}
diff --git a/client/src/components/meatspace/post/DrillTransition.test.jsx b/client/src/components/meatspace/post/DrillTransition.test.jsx
new file mode 100644
index 0000000000..25625ae71b
--- /dev/null
+++ b/client/src/components/meatspace/post/DrillTransition.test.jsx
@@ -0,0 +1,98 @@
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
+import { render, screen, fireEvent, act } from '@testing-library/react';
+import DrillTransition from './DrillTransition';
+
+const baseProps = {
+ nextDrillType: 'multiplication',
+ drillIndex: 1,
+ drillCount: 3,
+ completedResults: [{ type: 'doubling-chain', score: 90 }],
+};
+
+// The countdown reschedules a new 1000ms setTimeout from each re-render, so a
+// single bulk `advanceTimersByTime(3000)` races the timer queue against
+// React's flush. Ticking one second at a time (each wrapped in its own act())
+// lets each render settle before the component's effect arms the next timer.
+async function tickSeconds(n) {
+ for (let i = 0; i < n; i++) {
+ await act(async () => {
+ vi.advanceTimersByTime(1000);
+ });
+ }
+}
+
+describe('DrillTransition', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ });
+
+ afterEach(() => {
+ vi.useRealTimers();
+ });
+
+ it('auto-advances after the 3s countdown by default', async () => {
+ const onContinue = vi.fn();
+ render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ expect(onContinue).not.toHaveBeenCalled();
+ await tickSeconds(3);
+ expect(onContinue).toHaveBeenCalledTimes(1);
+ });
+
+ it('"Continue now" advances immediately without waiting for the countdown', () => {
+ const onContinue = vi.fn();
+ render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ fireEvent.click(screen.getByRole('button', { name: /Continue now/ }));
+ expect(onContinue).toHaveBeenCalledTimes(1);
+ });
+
+ it('clicking Pause stops the auto-advance countdown', async () => {
+ const onContinue = vi.fn();
+ render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Pause' }));
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ expect(screen.getByText(/auto-advance stopped/)).toBeTruthy();
+ });
+
+ it('clicking Resume after Pause lets the countdown continue', async () => {
+ const onContinue = vi.fn();
+ render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ fireEvent.click(screen.getByRole('button', { name: 'Pause' }));
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole('button', { name: 'Resume' }));
+ await tickSeconds(3);
+ expect(onContinue).toHaveBeenCalledTimes(1);
+ });
+
+ it('hovering the card pauses the countdown, and un-hovering resumes it', async () => {
+ const onContinue = vi.fn();
+ const { container } = render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ const card = container.firstChild;
+ fireEvent.mouseEnter(card);
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ fireEvent.mouseLeave(card);
+ await tickSeconds(3);
+ expect(onContinue).toHaveBeenCalledTimes(1);
+ });
+
+ it('focusing an element inside the card pauses the countdown', async () => {
+ const onContinue = vi.fn();
+ render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ fireEvent.focus(screen.getByRole('button', { name: 'Pause' }));
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ });
+
+ it('a manual Pause survives hover ending — countdown stays stopped', async () => {
+ const onContinue = vi.fn();
+ const { container } = render(<DrillTransition {...baseProps} onContinue={onContinue} />);
+ const card = container.firstChild;
+ fireEvent.mouseEnter(card);
+ fireEvent.click(screen.getByRole('button', { name: 'Pause' }));
+ fireEvent.mouseLeave(card);
+ await tickSeconds(5);
+ expect(onContinue).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsx
index 4511944462..32a4dcbab1 100644
--- a/client/src/components/meatspace/post/PostDrillConfig.jsx
+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx
@@ -79,6 +79,8 @@ const DRILL_META = {
}
};
+const MATH_TYPES = Object.keys(DRILL_META);
+
// LLM drill config meta for all 14 generatable types.
// `defaults.count` mirrors the server (`server/services/meatspacePostLlm.js`,
// `config.count || N`); `defaults.timeLimitSec` follows the DEFAULT_CONFIG
@@ -113,6 +115,8 @@ const LLM_DRILL_META = {
'reframe': { label: 'Reframe', desc: 'Reframe a frustrating situation positively or humorously', fields: llmFields(), defaults: { enabled: false, count: 3, timeLimitSec: 180 } }
};
+const LLM_TYPES = Object.keys(LLM_DRILL_META);
+
// Seed state for every LLM drill type so a card's toggle reflects real,
// persistable state. Without this, a type absent from the saved config renders
// as enabled (via the `enabled !== false` convention) but never enters
@@ -215,6 +219,8 @@ const COGNITIVE_DRILL_META = {
},
};
+const COGNITIVE_TYPES = Object.keys(COGNITIVE_DRILL_META);
+
// String-valued cognitive config keys must NOT be coerced to Number on edit.
const COGNITIVE_STRING_FIELDS = new Set(['direction', 'mode']);
@@ -240,6 +246,64 @@ const LLM_DRILL_GROUPS = [
const CARD_GRID = 'grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4';
+// Batch-set `enabled` across a domain's drill-type map, preserving every other
+// per-type field (count, timeLimitSec, etc). Used by both presets and the
+// per-group "Enable all / Disable all" buttons.
+function setEnabledMap(current, allTypes, enabledTypes) {
+ const out = { ...current };
+ for (const type of allTypes) {
+ out[type] = { ...out[type], enabled: enabledTypes.has(type) };
+ }
+ return out;
+}
+
+// Config presets — batch-set the enabled flags across domains so a first
+// session doesn't require clicking through ~25 individual cards. None of
+// these presets touch LLM drills (the "Everything" preset is explicitly
+// local-only) — enabling LLM drills in bulk is handled separately by the
+// LLM group's "Enable all" button, which is gated on a provider being chosen.
+const PRESETS = [
+ {
+ id: 'balanced',
+ label: 'Balanced daily',
+ apply: ({ setDrillTypes, setCognitiveDrillTypes, setCognitiveEnabled, setLlmEnabled }) => {
+ setDrillTypes(prev => setEnabledMap(prev, MATH_TYPES, new Set(['multiplication', 'estimation'])));
+ setCognitiveDrillTypes(prev => setEnabledMap(prev, COGNITIVE_TYPES, new Set(['n-back', 'stroop'])));
+ setCognitiveEnabled(true);
+ setLlmEnabled(false);
+ },
+ },
+ {
+ id: 'math-focus',
+ label: 'Math focus',
+ apply: ({ setDrillTypes, setCognitiveEnabled, setLlmEnabled }) => {
+ setDrillTypes(prev => setEnabledMap(prev, MATH_TYPES, new Set(MATH_TYPES)));
+ setCognitiveEnabled(false);
+ setLlmEnabled(false);
+ },
+ },
+ {
+ id: 'cognitive-focus',
+ label: 'Cognitive focus',
+ apply: ({ setDrillTypes, setCognitiveDrillTypes, setCognitiveEnabled, setLlmEnabled }) => {
+ setDrillTypes(prev => setEnabledMap(prev, MATH_TYPES, new Set()));
+ setCognitiveDrillTypes(prev => setEnabledMap(prev, COGNITIVE_TYPES, new Set(COGNITIVE_TYPES)));
+ setCognitiveEnabled(true);
+ setLlmEnabled(false);
+ },
+ },
+ {
+ id: 'everything',
+ label: 'Everything (local-only)',
+ apply: ({ setDrillTypes, setCognitiveDrillTypes, setCognitiveEnabled, setLlmEnabled }) => {
+ setDrillTypes(prev => setEnabledMap(prev, MATH_TYPES, new Set(MATH_TYPES)));
+ setCognitiveDrillTypes(prev => setEnabledMap(prev, COGNITIVE_TYPES, new Set(COGNITIVE_TYPES)));
+ setCognitiveEnabled(true);
+ setLlmEnabled(false);
+ },
+ },
+];
+
function AdaptiveBadge({ info }) {
const status = describeAdaptive(info);
if (!status) return null;
@@ -285,6 +349,32 @@ function ProgressiveBadge({ info }) {
);
}
+// Per-group "Enable all / Disable all" — a lighter-weight bulk action than the
+// top-level presets, scoped to one domain's own card grid.
+function GroupBulkToggle({ groupLabel, onEnableAll, onDisableAll }) {
+ return (
+ <div className="flex items-center gap-2 text-xs">
+ <button
+ type="button"
+ onClick={onEnableAll}
+ className="text-port-accent hover:underline"
+ aria-label={`Enable all ${groupLabel}`}
+ >
+ Enable all
+ </button>
+ <span className="text-gray-600">/</span>
+ <button
+ type="button"
+ onClick={onDisableAll}
+ className="text-gray-400 hover:underline"
+ aria-label={`Disable all ${groupLabel}`}
+ >
+ Disable all
+ </button>
+ </div>
+ );
+}
+
function DrillCard({ meta, drillConfig, enabled, accent, onToggle, onUpdateField, adaptiveInfo, progressive, onToggleProgressive, progressInfo }) {
const supportsProgressive = typeof progressive === 'boolean';
const hideMaxDigits = supportsProgressive && progressive;
@@ -501,6 +591,32 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
}));
}
+ function applyPreset(id) {
+ const preset = PRESETS.find(p => p.id === id);
+ if (!preset) return;
+ preset.apply({ setDrillTypes, setCognitiveDrillTypes, setCognitiveEnabled, setLlmEnabled });
+ toast.success(`Preset "${preset.label}" applied — click Save to persist`);
+ }
+
+ function setAllMathEnabled(enabled) {
+ setDrillTypes(prev => setEnabledMap(prev, MATH_TYPES, enabled ? new Set(MATH_TYPES) : new Set()));
+ }
+
+ function setAllCognitiveEnabled(enabled) {
+ setCognitiveDrillTypes(prev => setEnabledMap(prev, COGNITIVE_TYPES, enabled ? new Set(COGNITIVE_TYPES) : new Set()));
+ }
+
+ // Never bulk-enable LLM drills without a chosen provider — respects the
+ // AI-provider consent posture (no silent expansion into a provider the
+ // user hasn't picked). Disabling never calls a provider, so it's unguarded.
+ function setAllLlmEnabled(enabled) {
+ if (enabled && !llmProviderId) {
+ toast.error('Pick an AI provider above before enabling all LLM drills');
+ return;
+ }
+ setLlmDrillTypes(prev => setEnabledMap(prev, LLM_TYPES, enabled ? new Set(LLM_TYPES) : new Set()));
+ }
+
const selectedProvider = providers.find(p => p.id === llmProviderId);
const availableModels = filterSelectableModels(selectedProvider?.models);
@@ -550,6 +666,21 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
</button>
</div>
+ {/* Presets — batch-set flags across domains; a subsequent Save persists them */}
+ <div className="flex flex-wrap items-center gap-2 p-3 bg-port-card border border-port-border rounded-lg">
+ <span className="text-xs text-gray-500 uppercase tracking-wider mr-1">Presets</span>
+ {PRESETS.map(preset => (
+ <button
+ key={preset.id}
+ type="button"
+ onClick={() => applyPreset(preset.id)}
+ className="px-3 py-1.5 text-xs font-medium text-white bg-port-bg border border-port-border rounded-full hover:border-port-accent transition-colors"
+ >
+ {preset.label}
+ </button>
+ ))}
+ </div>
+
{/* Daily Reminder Section — opt-in, off by default; no LLM calls */}
<div className="p-4 bg-port-card border border-port-border rounded-lg space-y-3">
<div className="flex items-center justify-between">
@@ -594,7 +725,14 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
{/* Mental Math Section */}
<div className="space-y-3">
<div className="flex items-center justify-between">
- <h3 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Mental Math</h3>
+ <div className="flex items-center gap-3">
+ <h3 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Mental Math</h3>
+ <GroupBulkToggle
+ groupLabel="Mental Math drills"
+ onEnableAll={() => setAllMathEnabled(true)}
+ onDisableAll={() => setAllMathEnabled(false)}
+ />
+ </div>
<div className="flex items-center gap-2">
<span className="text-xs text-gray-400">Adaptive difficulty</span>
<button
@@ -643,9 +781,16 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
{/* Cognitive Drills Section (deterministic — no provider) */}
<div className="flex items-center justify-between pt-2">
- <div className="flex items-center gap-2">
- <Brain size={16} className="text-rose-400" />
- <h3 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Cognitive (deterministic)</h3>
+ <div className="flex items-center gap-3">
+ <div className="flex items-center gap-2">
+ <Brain size={16} className="text-rose-400" />
+ <h3 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Cognitive (deterministic)</h3>
+ </div>
+ <GroupBulkToggle
+ groupLabel="Cognitive drills"
+ onEnableAll={() => setAllCognitiveEnabled(true)}
+ onDisableAll={() => setAllCognitiveEnabled(false)}
+ />
</div>
<button
type="button"
@@ -684,9 +829,16 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
{/* LLM Drills Section */}
<div className="flex items-center justify-between pt-2">
- <div className="flex items-center gap-2">
- <Brain size={16} className="text-port-accent-2" />
- <h3 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Wit &amp; Memory (LLM)</h3>
+ <div className="flex items-center gap-3">
+ <div className="flex items-center gap-2">
+ <Brain size={16} className="text-port-accent-2" />
+ <h3 className="text-sm font-medium text-gray-500 uppercase tracking-wider">Wit &amp; Memory (LLM)</h3>
+ </div>
+ <GroupBulkToggle
+ groupLabel="LLM drills"
+ onEnableAll={() => setAllLlmEnabled(true)}
+ onDisableAll={() => setAllLlmEnabled(false)}
+ />
</div>
<button
type="button"
diff --git a/client/src/components/meatspace/post/PostDrillConfig.test.jsx b/client/src/components/meatspace/post/PostDrillConfig.test.jsx
index 19be611662..5a327ab0b8 100644
--- a/client/src/components/meatspace/post/PostDrillConfig.test.jsx
+++ b/client/src/components/meatspace/post/PostDrillConfig.test.jsx
@@ -243,4 +243,109 @@ describe('PostDrillConfig', () => {
expect(screen.getByRole('switch', { name: 'Daily reminder' }).getAttribute('aria-checked')).toBe('true');
expect(screen.getByLabelText('Remind me at').value).toBe('20:15');
});
+
+ describe('presets', () => {
+ it('"Balanced daily" enables 2 math + 2 cognitive drills, turns cognitive on, and turns LLM off', async () => {
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByText('Balanced daily'));
+ expect(screen.getByRole('switch', { name: 'Multiplication' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Estimation' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Doubling Chain' }).getAttribute('aria-checked')).toBe('false');
+ expect(screen.getByRole('switch', { name: 'N-Back' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Stroop' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Digit Span' }).getAttribute('aria-checked')).toBe('false');
+ expect(screen.getByRole('switch', { name: 'Cognitive drills' }).getAttribute('aria-checked')).toBe('true');
+ // LLM section collapses once its domain toggle is switched off by the preset.
+ expect(screen.getByRole('switch', { name: 'Wit & Memory (LLM) drills' }).getAttribute('aria-checked')).toBe('false');
+ expect(screen.queryByText('AI Provider')).toBeNull();
+
+ fireEvent.click(screen.getByText('Save'));
+ await waitFor(() => expect(updatePostConfig).toHaveBeenCalled());
+ const payload = updatePostConfig.mock.calls[0][0];
+ expect(payload.mentalMath.drillTypes.multiplication.enabled).toBe(true);
+ expect(payload.mentalMath.drillTypes.estimation.enabled).toBe(true);
+ expect(payload.mentalMath.drillTypes['doubling-chain'].enabled).toBe(false);
+ expect(payload.cognitive.enabled).toBe(true);
+ expect(payload.cognitive.drillTypes['n-back'].enabled).toBe(true);
+ expect(payload.cognitive.drillTypes['stroop'].enabled).toBe(true);
+ expect(payload.cognitive.drillTypes['digit-span'].enabled).toBe(false);
+ expect(payload.llmDrills.enabled).toBe(false);
+ });
+
+ it('"Math focus" enables every math drill and turns cognitive + LLM off', () => {
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByText('Math focus'));
+ for (const label of ['Doubling Chain', 'Serial Subtraction', 'Multiplication', 'Powers', 'Estimation']) {
+ expect(screen.getByRole('switch', { name: label }).getAttribute('aria-checked')).toBe('true');
+ }
+ expect(screen.getByRole('switch', { name: 'Cognitive drills' }).getAttribute('aria-checked')).toBe('false');
+ expect(screen.getByRole('switch', { name: 'Wit & Memory (LLM) drills' }).getAttribute('aria-checked')).toBe('false');
+ });
+
+ it('"Cognitive focus" disables all math drills and enables every cognitive drill', () => {
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByText('Cognitive focus'));
+ expect(screen.getByRole('switch', { name: 'Multiplication' }).getAttribute('aria-checked')).toBe('false');
+ expect(screen.getByRole('switch', { name: 'Cognitive drills' }).getAttribute('aria-checked')).toBe('true');
+ for (const label of ['N-Back', 'Digit Span', 'Stroop', 'Schulte Table', 'Mental Rotation', 'Reaction Time']) {
+ expect(screen.getByRole('switch', { name: label }).getAttribute('aria-checked')).toBe('true');
+ }
+ expect(screen.getByRole('switch', { name: 'Wit & Memory (LLM) drills' }).getAttribute('aria-checked')).toBe('false');
+ });
+
+ it('"Everything (local-only)" enables every math + cognitive drill but never LLM', () => {
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByText('Everything (local-only)'));
+ expect(screen.getByRole('switch', { name: 'Powers' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Mental Rotation' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Cognitive drills' }).getAttribute('aria-checked')).toBe('true');
+ expect(screen.getByRole('switch', { name: 'Wit & Memory (LLM) drills' }).getAttribute('aria-checked')).toBe('false');
+ });
+ });
+
+ describe('per-group enable/disable-all', () => {
+ it('Mental Math "Enable all" / "Disable all" toggle every math drill', () => {
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByLabelText('Enable all Mental Math drills'));
+ for (const label of ['Doubling Chain', 'Serial Subtraction', 'Multiplication', 'Powers', 'Estimation']) {
+ expect(screen.getByRole('switch', { name: label }).getAttribute('aria-checked')).toBe('true');
+ }
+ fireEvent.click(screen.getByLabelText('Disable all Mental Math drills'));
+ for (const label of ['Doubling Chain', 'Serial Subtraction', 'Multiplication', 'Powers', 'Estimation']) {
+ expect(screen.getByRole('switch', { name: label }).getAttribute('aria-checked')).toBe('false');
+ }
+ });
+
+ it('Cognitive "Enable all" / "Disable all" toggle every cognitive drill', () => {
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByLabelText('Enable all Cognitive drills'));
+ expect(screen.getByRole('switch', { name: 'Digit Span' }).getAttribute('aria-checked')).toBe('true');
+ fireEvent.click(screen.getByLabelText('Disable all Cognitive drills'));
+ expect(screen.getByRole('switch', { name: 'Digit Span' }).getAttribute('aria-checked')).toBe('false');
+ });
+
+ it('LLM "Enable all" is blocked without a chosen provider — no toggles flip, an error toast fires', async () => {
+ const toastModule = await import('../../ui/Toast');
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ fireEvent.click(screen.getByLabelText('Enable all LLM drills'));
+ // Untouched drills stay at their config-seeded (opt-in-disabled) state.
+ expect(screen.getByRole('switch', { name: 'Reframe' }).getAttribute('aria-checked')).toBe('false');
+ expect(toastModule.default.error).toHaveBeenCalled();
+ });
+
+ it('LLM "Enable all" enables every LLM drill once a provider is chosen', async () => {
+ getProviders.mockResolvedValue({
+ providers: [{ id: 'prov-1', name: 'Test Provider', type: 'api', enabled: true, models: [] }],
+ });
+ render(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
+ await waitFor(() => expect(getProviders).toHaveBeenCalled());
+ const providerSelect = screen.getByLabelText('Provider');
+ await waitFor(() => expect(providerSelect.querySelectorAll('option')).toHaveLength(2));
+ fireEvent.change(providerSelect, { target: { value: 'prov-1' } });
+ fireEvent.click(screen.getByLabelText('Enable all LLM drills'));
+ expect(screen.getByRole('switch', { name: 'Reframe' }).getAttribute('aria-checked')).toBe('true');
+ fireEvent.click(screen.getByLabelText('Disable all LLM drills'));
+ expect(screen.getByRole('switch', { name: 'Reframe' }).getAttribute('aria-checked')).toBe('false');
+ });
+ });
});
diff --git a/client/src/components/meatspace/post/PostHistory.jsx b/client/src/components/meatspace/post/PostHistory.jsx
index b7bd3a2589..484cad9135 100644
--- a/client/src/components/meatspace/post/PostHistory.jsx
+++ b/client/src/components/meatspace/post/PostHistory.jsx
@@ -241,11 +241,22 @@ export default function PostHistory({ onBack }) {
const expanded = expandedId === s.id;
const durationMin = Math.round((s.durationMs || 0) / 60000);
+ const toggleExpanded = () => setExpandedId(expanded ? null : s.id);
+
const rows = [
<tr
key={s.id}
- onClick={() => setExpandedId(expanded ? null : s.id)}
- className="border-b border-port-border/50 hover:bg-port-bg/50 cursor-pointer"
+ role="button"
+ tabIndex={0}
+ aria-expanded={expanded}
+ aria-label={`Session ${s.date}, score ${s.score}. ${expanded ? 'Collapse' : 'Expand'} details.`}
+ onClick={toggleExpanded}
+ onKeyDown={(e) => {
+ if (e.key !== 'Enter' && e.key !== ' ') return;
+ e.preventDefault();
+ toggleExpanded();
+ }}
+ className="border-b border-port-border/50 hover:bg-port-bg/50 cursor-pointer focus:outline-none focus:ring-2 focus:ring-port-accent focus:ring-inset"
>
<td className="px-4 py-2 text-gray-500">
{expanded ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
diff --git a/client/src/components/meatspace/post/PostHistory.test.jsx b/client/src/components/meatspace/post/PostHistory.test.jsx
index 2cb5c76d86..d93c412f86 100644
--- a/client/src/components/meatspace/post/PostHistory.test.jsx
+++ b/client/src/components/meatspace/post/PostHistory.test.jsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
-import { render, screen, waitFor, fireEvent } from '@testing-library/react';
+import { render, screen, waitFor, fireEvent, within } from '@testing-library/react';
vi.mock('../../../services/api', () => ({
getPostSessions: vi.fn(),
@@ -85,4 +85,53 @@ describe('PostHistory analytics dashboard', () => {
await waitFor(() => expect(screen.getByText('No sessions found for this range.')).toBeTruthy());
expect(screen.queryByText('Drill Breakdown')).toBeNull();
});
+
+ describe('session row keyboard accessibility', () => {
+ it('exposes a collapsed session row as a disclosure control with aria-expanded=false', async () => {
+ render(<PostHistory onBack={() => {}} />);
+ await waitFor(() => expect(screen.getByText('2026-06-01')).toBeTruthy());
+ const row = screen.getByRole('button', { name: /Session 2026-06-01/ });
+ expect(row).toHaveAttribute('aria-expanded', 'false');
+ expect(row).toHaveAttribute('tabindex', '0');
+ });
+
+ it('expands a row via a click, flipping aria-expanded and revealing task detail', async () => {
+ render(<PostHistory onBack={() => {}} />);
+ await waitFor(() => expect(screen.getByText('2026-06-01')).toBeTruthy());
+ const table = screen.getByRole('table');
+ expect(within(table).queryByText('Multiplication')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: /Session 2026-06-01/ }));
+ expect(screen.getByRole('button', { name: /Session 2026-06-01/ })).toHaveAttribute('aria-expanded', 'true');
+ expect(within(table).getByText('Multiplication')).toBeTruthy();
+ });
+
+ it('expands and collapses a row via the Enter key, without scrolling the page (default prevented)', async () => {
+ render(<PostHistory onBack={() => {}} />);
+ await waitFor(() => expect(screen.getByText('2026-06-01')).toBeTruthy());
+ const table = screen.getByRole('table');
+ const row = screen.getByRole('button', { name: /Session 2026-06-01/ });
+ fireEvent.keyDown(row, { key: 'Enter' });
+ expect(screen.getByRole('button', { name: /Session 2026-06-01/ })).toHaveAttribute('aria-expanded', 'true');
+ expect(within(table).getByText('Multiplication')).toBeTruthy();
+ fireEvent.keyDown(screen.getByRole('button', { name: /Session 2026-06-01/ }), { key: 'Enter' });
+ expect(screen.getByRole('button', { name: /Session 2026-06-01/ })).toHaveAttribute('aria-expanded', 'false');
+ expect(within(table).queryByText('Multiplication')).toBeNull();
+ });
+
+ it('expands a row via the Space key', async () => {
+ render(<PostHistory onBack={() => {}} />);
+ await waitFor(() => expect(screen.getByText('2026-06-01')).toBeTruthy());
+ const row = screen.getByRole('button', { name: /Session 2026-06-01/ });
+ fireEvent.keyDown(row, { key: ' ' });
+ expect(screen.getByRole('button', { name: /Session 2026-06-01/ })).toHaveAttribute('aria-expanded', 'true');
+ });
+
+ it('ignores unrelated keys — a row does not expand on an arbitrary keypress', async () => {
+ render(<PostHistory onBack={() => {}} />);
+ await waitFor(() => expect(screen.getByText('2026-06-01')).toBeTruthy());
+ const row = screen.getByRole('button', { name: /Session 2026-06-01/ });
+ fireEvent.keyDown(row, { key: 'a' });
+ expect(row).toHaveAttribute('aria-expanded', 'false');
+ });
+ });
});