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-1995]): make POST Morse modes & reference tabs deep-linkable via URL

[._.]/ Adam Eivycb5a23f21754
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 76cad2b521..4ff65fd70d 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -23,6 +23,7 @@
- **[issue-1990] The POST launcher now shows your progress at a glance — streak, trend, and weakest-domain focus.** The Power On Self Test launcher (`PostSessionLauncher.jsx`) previously surfaced only "Today's Status" plus the last three raw scores, even though the server already computes rich analytics that never reached it. It now loads `GET /post/stats` (30-day and 7-day windows) alongside the config/session fetch and renders a compact analytics strip above the fold: a **current streak** card with the same 🔥/⚡/✨ glyphs as the dashboard Daily POST widget (plus your best streak), a **7-day average** card with a trend arrow showing how the last week compares to your 30-day baseline, and a **weakest-domain callout** ("Lowest domain this month: Verbal Agility — 62 avg") derived from per-drill averages mapped to their training domain. A one-click **Practice \<domain\>** button starts a focused session running every enabled drill in your weakest domain — and it always targets a domain you actually have drills enabled for, so it can't dead-end. Everything degrades gracefully with no history (the strip simply doesn't render), and all existing launcher behavior — Full POST, Quick 5 Min, the Test/Train toggle, and condition tags — is unchanged. Extracted the shared `domainLabel` / `computeDomainAverages` helpers into `constants.js` (now reused by History). (`client/src/components/meatspace/post/PostSessionLauncher.jsx`, `constants.js`, `PostTab.jsx`, Closes #1990)
- **[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)
- **[issue-1989] POST Memory surfaces are now responsive.** The Memory Builder, Practice, and Session Results screens were all pinned to a single narrow `max-w-2xl` column that wasted desktop width. **Memory Builder** (`MemoryBuilder.jsx`) now renders its saved items as a responsive card grid (`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`) — each card lays out the item icon, title, line/chunk meta, and mastery badge above a full-width Practice button (with an aria-labeled delete for non-built-ins), while the create form and description stay in a readable `max-w-2xl` column above the grid. **Memory Practice** (`MemoryPractice.jsx`) widens the reading-oriented screens to `max-w-4xl` — the practice-mode picker (now a two-column card grid), Learn progressive-reveal, and Speed Run — while the active-recall focus steps (Sequence, Fill-in-the-Blank, Spaced Repetition) stay at a comfortable `max-w-2xl` for readability. **Session Results** (`PostSessionResults.jsx`) widens to `max-w-4xl` and lays the per-drill breakdown out in two columns on desktop. Layout-only: create/edit/delete, practice submission, mastery display, and score/breakdown rendering are unchanged; every surface collapses to a single column on mobile. (Closes #1989)
+- **[issue-1995] POST Morse modes and reference tabs are now deep-linkable via the URL.** The Morse trainer kept its mode (Copy/Send) and reference view (Tree/Length/List) in local `useState`, so — unlike every other routed POST sub-page — those views weren't bookmarkable, shareable, reload-safe, or reachable from ⌘K / voice. The selected mode now lives in the `/post/morse/:mode` route segment (Copy → `/post/morse/copy`, Send → `/post/morse/send`) and the reference tab in a `?ref=tree|length|list` search param (via the shared `useDrawerTab` hook) — so the exact drill + reference you're looking at is the single source of truth in the URL and survives reload/share. A stale or deleted deep link degrades gracefully: an unknown `:mode` segment falls back to the mode-picker grid (not a blank panel) and an unknown `?ref` value falls back to the Tree view. New `NAV_COMMANDS` entries (`nav.post.morse.copy` / `.send` / `.tree` / `.length` / `.list`) make "morse send", "morse tree", etc. reachable from the ⌘K palette and voice navigation. (`client/src/components/meatspace/post/MorseTrainer.jsx`, `client/src/components/meatspace/tabs/PostTab.jsx`, `server/lib/navManifest.js`, Closes #1995)
- **[issue-1992] Opt-in adaptive difficulty for mental-math POST drills.** Math drill params (`steps` / `maxDigits` / `maxExponent` / estimation `tolerancePct`) were fixed values from config that never responded to how you were doing. A new **Adaptive difficulty** toggle in the Drill Configuration screen (default OFF, so existing installs are unchanged) makes each math drill nudge its primary difficulty knob from your recent scored performance: sustained high accuracy (≥90% over enough sessions) bumps it one step harder, repeated misses (≤50%) ease it back, all clamped to safe min/max bounds — and it won't move until it has enough scored samples to trust. The adjustment is a pure, unit-tested policy (`server/lib/postAdaptive.js`) applied server-side at drill-generation time, so manual config still wins whenever Adaptive is off. It's fully transparent: each math drill card shows the effective difficulty (e.g. "Adaptive: max digits 2 → 3 (harder · 94% recent)") via a new `GET /post/adaptive-preview` endpoint, so it's never a black box. (`server/lib/postAdaptive.js`, `server/services/meatspacePost.js`, `client/src/components/meatspace/post/PostDrillConfig.jsx`, Closes #1992)
## Media Generation
diff --git a/client/src/components/meatspace/post/MorseTrainer.jsx b/client/src/components/meatspace/post/MorseTrainer.jsx
index 43e613db1a..ab6bd634f2 100644
--- a/client/src/components/meatspace/post/MorseTrainer.jsx
+++ b/client/src/components/meatspace/post/MorseTrainer.jsx
@@ -1,5 +1,6 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import { ArrowLeft, Radio, Headphones, Hand, CheckCircle, XCircle, Play, RefreshCw, Volume2, GitBranch, List as ListIcon, Ruler, Eraser } from 'lucide-react';
+import useDrawerTab from '../../../hooks/useDrawerTab';
const MORSE_TABLE = {
A: '.-', B: '-...', C: '-.-.', D: '-..', E: '.', F: '..-.',
@@ -46,7 +47,7 @@ const DEFAULT_PREFS = { wpm: 18, effectiveWpm: 18, hz: 700, kochLevel: 2, bestAc
const RAMP_SEC = 0.005;
const TONE_GAIN = 0.25;
-const MODES = [
+export const MODES = [
{
id: 'copy',
label: 'Copy',
@@ -314,9 +315,15 @@ function useKeyingDecoder({ unitMs, hz, ensureCtx, enabled = false }) {
return { pattern, decoded, pressing, beginPress, endPress, clear };
}
-export default function MorseTrainer({ onBack }) {
+// Valid `:mode` subroute segments. Anything else (stale/deleted deep link)
+// falls through to the mode grid rather than a blank panel.
+export const MORSE_MODE_IDS = MODES.map((m) => m.id);
+
+// `mode` is the routed `:mode` segment (`/post/morse/:mode`), validated by the
+// caller (PostTab) to one of MORSE_MODE_IDS or null — the URL is the single
+// source of truth for which drill is open, so there is no local mode state.
+export default function MorseTrainer({ mode = null, onSelectMode, onExitMode, onBack }) {
const [prefs, setPrefs] = useState(loadPrefs);
- const [mode, setMode] = useState(null);
const ensureCtx = useAudioContext();
const unitMs = 1.2 / prefs.wpm * 1000;
const keying = useKeyingDecoder({ unitMs, hz: prefs.hz, ensureCtx, enabled: mode === 'send' });
@@ -354,12 +361,12 @@ export default function MorseTrainer({ onBack }) {
<div className="grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_24rem] gap-6">
<div className="space-y-6 min-w-0 max-w-2xl">
<SettingsPanel prefs={prefs} updatePrefs={updatePrefs} onResetProgress={resetProgress} />
- {!mode && <ModeGrid onPick={setMode} />}
+ {!mode && <ModeGrid onPick={onSelectMode} />}
{mode === 'copy' && (
- <CopyDrill prefs={prefs} updatePrefs={updatePrefs} ensureCtx={ensureCtx} onExit={() => setMode(null)} />
+ <CopyDrill prefs={prefs} updatePrefs={updatePrefs} ensureCtx={ensureCtx} onExit={onExitMode} />
)}
{mode === 'send' && (
- <SendDrill keying={keying} onExit={() => setMode(null)} />
+ <SendDrill keying={keying} onExit={onExitMode} />
)}
</div>
<ReferenceWidget keying={keying} mode={mode} />
@@ -441,8 +448,12 @@ const REFERENCE_VIEWS = [
{ id: 'list', label: 'List', icon: ListIcon },
];
+const REFERENCE_VIEW_IDS = REFERENCE_VIEWS.map((v) => v.id);
+
function ReferenceWidget({ keying, mode }) {
- const [view, setView] = useState('tree');
+ // Reference tab lives in the `?ref=` search param so it's deep-linkable and
+ // survives reload/share; a stale value degrades to 'tree'.
+ const [view, setView] = useDrawerTab('ref', 'tree', REFERENCE_VIEW_IDS);
// Only show the in-progress key path in Send mode — in Copy mode the right
// widget is a passive cheat-sheet, not live feedback for the user.
const currentPath = mode === 'send' ? keying.pattern : '';
diff --git a/client/src/components/meatspace/post/MorseTrainer.test.jsx b/client/src/components/meatspace/post/MorseTrainer.test.jsx
new file mode 100644
index 0000000000..e248e258ab
--- /dev/null
+++ b/client/src/components/meatspace/post/MorseTrainer.test.jsx
@@ -0,0 +1,66 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
+import MorseTrainer, { MODES, MORSE_MODE_IDS } from './MorseTrainer';
+
+// Surfaces the live URL (path + search) so tests can assert the reference tab
+// is encoded in the query string — the "URL is the source of truth" contract.
+function LocationProbe() {
+ const loc = useLocation();
+ return <div data-testid="loc">{loc.pathname}{loc.search}</div>;
+}
+
+function renderMorse(props = {}, { route = '/post/morse' } = {}) {
+ return render(
+ <MemoryRouter initialEntries={[route]}>
+ <Routes>
+ <Route
+ path="/post/morse"
+ element={<><MorseTrainer {...props} /><LocationProbe /></>}
+ />
+ </Routes>
+ </MemoryRouter>,
+ );
+}
+
+describe('MorseTrainer deep-linking', () => {
+ it('exports the routed mode ids', () => {
+ expect(MORSE_MODE_IDS).toEqual(['copy', 'send']);
+ expect(MODES.map((m) => m.id)).toEqual(MORSE_MODE_IDS);
+ });
+
+ it('shows the mode grid and routes on pick (mode=null)', () => {
+ const onSelectMode = vi.fn();
+ renderMorse({ mode: null, onSelectMode });
+ // Both mode cards render as pickable entries.
+ fireEvent.click(screen.getByText('Copy'));
+ expect(onSelectMode).toHaveBeenCalledWith('copy');
+ fireEvent.click(screen.getByText('Send'));
+ expect(onSelectMode).toHaveBeenCalledWith('send');
+ });
+
+ it('defaults the reference tab to tree with no ?ref param', () => {
+ renderMorse({ mode: null, onSelectMode: vi.fn() });
+ // Tree view legend is unique to the tree reference.
+ expect(screen.getByText('start')).toBeInTheDocument();
+ });
+
+ it('reads the reference tab from the ?ref search param', () => {
+ renderMorse({ mode: null, onSelectMode: vi.fn() }, { route: '/post/morse?ref=length' });
+ // Length view groups by symbol count.
+ expect(screen.getByText('1 symbol')).toBeInTheDocument();
+ });
+
+ it('encodes the selected reference tab in the URL', () => {
+ renderMorse({ mode: null, onSelectMode: vi.fn() });
+ // Exact name — a loose /List/ also matches the "Listen to Morse" mode card.
+ fireEvent.click(screen.getByRole('button', { name: 'List' }));
+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse?ref=list');
+ });
+
+ it('drops the ?ref param when returning to the default tree tab', () => {
+ renderMorse({ mode: null, onSelectMode: vi.fn() }, { route: '/post/morse?ref=list' });
+ fireEvent.click(screen.getByRole('button', { name: 'Tree' }));
+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse');
+ });
+});
diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsx
index 460c59ccb5..6184ab02bd 100644
--- a/client/src/components/meatspace/tabs/PostTab.jsx
+++ b/client/src/components/meatspace/tabs/PostTab.jsx
@@ -13,7 +13,7 @@ import MemoryBuilder from '../post/MemoryBuilder';
import ElementsSong from '../post/ElementsSong';
import DrillTransition from '../post/DrillTransition';
import WordplayTrainer from '../post/WordplayTrainer';
-import MorseTrainer from '../post/MorseTrainer';
+import MorseTrainer, { MORSE_MODE_IDS } from '../post/MorseTrainer';
import { LLM_DRILL_TYPES } from '../post/constants';
export default function PostTab({ tab = 'launcher', subtab }) {
@@ -157,8 +157,19 @@ export default function PostTab({ tab = 'launcher', subtab }) {
);
case 'wordplay':
return <WordplayTrainer config={config} onConfigUpdate={setConfig} onBack={() => navigate('/post/launcher')} />;
- case 'morse':
- return <MorseTrainer onBack={() => navigate('/post/launcher')} />;
+ case 'morse': {
+ // The `:mode` sub-route (copy/send) is the source of truth; an unknown
+ // segment degrades to the mode grid instead of a blank panel.
+ const morseMode = MORSE_MODE_IDS.includes(subtab) ? subtab : null;
+ return (
+ <MorseTrainer
+ mode={morseMode}
+ onSelectMode={(id) => navigate(`/post/morse/${id}`)}
+ onExitMode={() => navigate('/post/morse')}
+ onBack={() => navigate('/post/launcher')}
+ />
+ );
+ }
case 'memory':
if (subtab === 'elements') {
return (
diff --git a/server/lib/navManifest.js b/server/lib/navManifest.js
index 523c97deee..d8f8a391e3 100644
--- a/server/lib/navManifest.js
+++ b/server/lib/navManifest.js
@@ -154,6 +154,11 @@ export const NAV_COMMANDS = [
{ 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.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.send', path: '/post/morse/send', label: 'Morse Send', section: 'POST', aliases: ['morse-send', 'morse send', 'send-morse', 'morse-key', 'keying'], keywords: ['cw', 'key', 'straight key', 'transmit', 'dit', 'dah', 'spacebar'] },
+ { id: 'nav.post.morse.tree', path: '/post/morse?ref=tree', label: 'Morse Tree', section: 'POST', aliases: ['morse-tree', 'morse tree', 'morse-chart', 'dichotomic'], keywords: ['cw', 'binary tree', 'chart', 'reference', 'dit dah'] },
+ { id: 'nav.post.morse.length', path: '/post/morse?ref=length', label: 'Morse Length', section: 'POST', aliases: ['morse-length', 'morse length', 'morse-by-length'], keywords: ['cw', 'reference', 'symbol length', 'chart'] },
+ { id: 'nav.post.morse.list', path: '/post/morse?ref=list', label: 'Morse List', section: 'POST', aliases: ['morse-list', 'morse list', 'morse-table', 'morse-alphabet'], keywords: ['cw', 'reference', 'alphabet', 'table', 'chart'] },
{ id: 'nav.post.wordplay', path: '/post/wordplay', label: 'Wordplay', section: 'POST', aliases: ['post-wordplay'] },
{ id: 'nav.settings.ai-assignments', path: '/settings/ai-assignments', label: 'AI Assignments', section: 'Settings', aliases: ['ai-assignments', 'assignments', 'settings-ai-assignments', 'ai-inventory'], keywords: ['provider', 'model', 'pin', 'inventory', 'migration', 'llm'] },
diff --git a/server/lib/navManifest.test.js b/server/lib/navManifest.test.js
index 0fe03e96fa..f59f54f5ac 100644
--- a/server/lib/navManifest.test.js
+++ b/server/lib/navManifest.test.js
@@ -33,7 +33,11 @@ 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' },
- { prefix: '/post', file: 'client/src/components/meatspace/tabs/PostTab.jsx', kind: 'switch', switchVar: 'tab' },
+ // 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.
+ { 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' }] },
];
// Pull the inner text of `export const <constName> = [ … ];` (requiring `export`
@@ -67,11 +71,21 @@ function extractSwitchTabs(src, switchVar) {
return [def[1], ...extractSwitchCases(src, switchVar)];
}
+// The `id:` values of an exported const array (`kind: 'ids'` shape), used to
+// pull routed sub-page ids (e.g. morse's copy/send MODES) out of another file.
+function extractConstIds(filePath, constName) {
+ const src = fs.readFileSync(filePath, 'utf8');
+ const block = extractConstArrayBlock(src, constName);
+ return [...block.matchAll(/id:\s*['"]([^'"]+)['"]/g)].map((m) => m[1]);
+}
+
// The set of absolute tab paths a page serves under its own prefix.
-function extractTabPaths(filePath, { kind, constName, switchVar, prefix }) {
+function extractTabPaths(filePath, { kind, constName, switchVar, prefix, nestedIdSources }) {
const src = fs.readFileSync(filePath, 'utf8');
+ const nested = (nestedIdSources || []).flatMap(({ parent, file, constName: c }) =>
+ extractConstIds(path.join(REPO_ROOT, file), c).map((id) => `${prefix}/${parent}/${id}`));
if (kind === 'switch') {
- return extractSwitchTabs(src, switchVar).map((id) => `${prefix}/${id}`);
+ return [...extractSwitchTabs(src, switchVar).map((id) => `${prefix}/${id}`), ...nested];
}
const block = extractConstArrayBlock(src, constName);
if (kind === 'ids') {