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

Merge remote-tracking branch 'origin/main' into next/issue-1997

Adam Eivyc28a28138be6
diff --cc .changelog/NEXT.md
index 3deec05ad7,340322a3dd..8d3af2f19c
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@@ -27,7 -28,8 +28,9 @@@
- **[issue-1991] POST memory items now resurface on a spaced-repetition schedule.** Memory items (songs, poems, speeches, sequences) tracked mastery but had no review cadence — practice was entirely user-initiated, with nothing telling you *what to review today*. Each item now carries a lightweight SM-2-inspired schedule (ease, interval, next-review date): finishing a practice session reschedules the item automatically — a strong, mostly-correct session pushes the next review further out, while a miss-heavy session resets it to "due now" so it comes back around immediately. The Memory Builder gains a **Due Today (N)** banner listing what's ready for review with a one-click **Review Next**, plus a small "Due" badge on each item that's ready; the count updates the moment you finish practicing. Existing items keep working unchanged — a migration stamps every pre-existing item with a "due now" default so nothing gets stranded — and a new `GET /post/memory-items/due` endpoint lists due items most-overdue first.
- **[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)
- **[issue-1993] New deterministic cognitive drills — N-Back, Digit Span, and Stroop.** POST spanned math, LLM, and memory drills but was missing classic non-LLM cognitive-training exercises. A new **Cognitive** domain adds three provider-free drills: **N-Back** (1/2/3-back working-memory matching), **Digit Span** (forward/backward sequence recall), and **Stroop** (name the ink color, not the word — attention/inhibition). Each is configurable in the Drill Configuration screen, playable in both Test and Train modes via a dedicated interactive runner, scored, and saved to your training history alongside every other drill — with **zero AI provider calls**. Scoring is recomputed server-side from the generated drill (never trusting the client) using a shared 80% accuracy + 20% speed blend, and the drills are picked up by Full POST and Quick 5 Min automatically. (Closes #1993)
+- **[issue-1997] Morse Trainer now logs practice to your POST training streak, plus a new Head Copy mode.** Completing a Copy or Send round previously only updated the trainer's own `localStorage` prefs (Koch level, best round) — it never touched POST's training log, so Morse practice was invisible to the rest of the app. Every completed round/check now logs to the same training log other POST training-mode drills use, and the Settings panel shows your training streak plus Morse-specific sessions-logged/accuracy right next to the existing Koch-level readout. Also ships a new **Head Copy** mode alongside Copy and Send: identical Koch-progression practice, but with the on-screen morse-code hints and reference cheat sheet hidden, so you're copying purely from memory. Deep-linkable at `/post/morse/head-copy` and reachable from ⌘K/voice nav like the existing modes. Existing Copy/Send behavior and prefs are unchanged. (`client/src/components/meatspace/post/MorseTrainer.jsx`, `server/lib/postValidation.js`, `server/lib/navManifest.js`, Closes #1997)
+ - **[issue-1994] Optional daily reminder for your POST session.** POST is meant to be a daily habit, but nothing ever nudged you to actually do it. A new **Daily Reminder** toggle in the Drill Configuration screen — off by default — lets you pick a time of day; if you haven't completed a session by then, you'll get a single in-app notification reminding you, and it stays silent once you've already practiced that day. Turning it off stops all nudges immediately. No AI calls are involved, and changing the time takes effect right away without a restart. (Closes #1994)
+ - **[issue-2008] Cognitive drills (N-Back, Digit Span, Stroop) no longer show a "Time Limit" field that did nothing.** These three drills are self-paced/stimulus-driven and never counted down against it, unlike Mental Math and Wit & Memory drills, which genuinely do enforce their time limit. The dead field is removed from the Drill Configuration screen and drill summaries, along with the unreachable `stimulusMs`/`showMs` config pass-through (no UI ever set them — the drills always used their built-in pacing anyway). No behavior change to how the drills actually play. (Closes #2008)
## Media Generation
diff --cc client/src/components/meatspace/post/MorseTrainer.jsx
index 96f85f9bd6,4123866f61..365a2cdd18
--- a/client/src/components/meatspace/post/MorseTrainer.jsx
+++ b/client/src/components/meatspace/post/MorseTrainer.jsx
@@@ -1,9 -1,8 +1,9 @@@
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 { ArrowLeft, Radio, Headphones, Hand, EyeOff, CheckCircle, XCircle, Play, RefreshCw, Volume2, GitBranch, List as ListIcon, Ruler, Eraser } from 'lucide-react';
import useDrawerTab from '../../../hooks/useDrawerTab';
+import { submitTrainingEntry, getTrainingStats } from '../../../services/api';
- const MORSE_TABLE = {
+ export const MORSE_TABLE = {
A: '.-', B: '-...', C: '-.-.', D: '-..', E: '.', F: '..-.',
G: '--.', H: '....', I: '..', J: '.---', K: '-.-', L: '.-..',
M: '--', N: '-.', O: '---', P: '.--.', Q: '--.-', R: '.-.',
diff --cc client/src/components/meatspace/post/MorseTrainer.test.jsx
index fa9b11f72a,8f6fc817e7..5db382682a
--- a/client/src/components/meatspace/post/MorseTrainer.test.jsx
+++ b/client/src/components/meatspace/post/MorseTrainer.test.jsx
@@@ -1,20 -1,7 +1,20 @@@
-import { describe, it, expect, vi } from 'vitest';
-import { render, screen, fireEvent } from '@testing-library/react';
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
+
+// Stub the training-log API so mount-time fetches (refreshTrainingStats) and
+// round-completion writes (logTraining) never hit the network — mirrors the
+// mocking convention used by PostDrillConfig.test.jsx / PostHistory.test.jsx.
+vi.mock('../../../services/api', () => ({
+ submitTrainingEntry: vi.fn(() => Promise.resolve({})),
+ getTrainingStats: vi.fn(() => Promise.resolve({
+ currentStreak: 3,
+ byDrill: { 'morse:morse-copy': { practiceCount: 4, accuracy: 80, totalMs: 1000, daysActive: 2 } },
+ })),
+}));
+
- import MorseTrainer, { MODES, MORSE_MODE_IDS } from './MorseTrainer';
+ import MorseTrainer, { MODES, MORSE_MODE_IDS, MORSE_TABLE, isNodeOnPath } from './MorseTrainer';
+import { submitTrainingEntry, getTrainingStats } from '../../../services/api';
// 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.
@@@ -85,39 -65,62 +85,99 @@@ describe('MorseTrainer deep-linking', (
});
});
+describe('MorseTrainer head-copy mode', () => {
+ beforeEach(() => {
+ submitTrainingEntry.mockClear();
+ getTrainingStats.mockClear();
+ });
+
+ it('hides the reference cheat sheet and explains the audio-only rules', () => {
+ renderMorse({ mode: 'head-copy', onSelectMode: vi.fn(), onExitMode: vi.fn() });
+ // The Tree/Length/List reference tabs only render via ReferenceWidget,
+ // which head-copy mode suppresses entirely.
+ expect(screen.queryByRole('button', { name: 'Tree' })).not.toBeInTheDocument();
+ expect(screen.getByText(/No code hints on the results screen/)).toBeInTheDocument();
+ });
+
+ it('keeps the reference widget visible in plain copy mode (unchanged behavior)', () => {
+ renderMorse({ mode: 'copy', onSelectMode: vi.fn(), onExitMode: vi.fn() });
+ expect(screen.getByRole('button', { name: 'Tree' })).toBeInTheDocument();
+ });
+});
+
+describe('MorseTrainer training log integration', () => {
+ beforeEach(() => {
+ submitTrainingEntry.mockClear();
+ getTrainingStats.mockClear();
+ });
+
+ it('fetches 30-day training stats on mount and renders the streak summary', async () => {
+ const { container } = renderMorse({ mode: null, onSelectMode: vi.fn() });
+ expect(getTrainingStats).toHaveBeenCalledWith(30);
+ await waitFor(() => {
+ expect(container.textContent).toContain('Training streak: 3d');
+ });
+ expect(container.textContent).toContain('Morse logged: 4');
+ expect(container.textContent).toContain('80% avg');
+ });
+});
++
+ describe('MorseTrainer Tree reference view', () => {
+ it('renders a labeled, reachable node for all 41 characters', () => {
+ const { container } = renderMorse({ mode: null, onSelectMode: vi.fn() });
+ // Every node (including the root) carries its own morse code (or 'start'
+ // for the root) as its `title` — the most reliable way to pick each tree
+ // node out individually, since letter text alone can collide with other
+ // on-screen content (e.g. mode-card labels).
+ const chars = Object.keys(MORSE_TABLE);
+ for (const ch of chars) {
+ const code = MORSE_TABLE[ch];
+ const node = container.querySelector(`[title="${code}"]`);
+ expect(node, `expected a tree node for "${ch}" (${code})`).toBeTruthy();
+ expect(node.textContent).toBe(ch);
+ }
+ });
+
+ it('centers the start node roughly under "start", not pinned to one edge', () => {
+ const { container } = renderMorse({ mode: null, onSelectMode: vi.fn() });
+ const root = container.querySelector('[title="start"]');
+ expect(root).toBeTruthy();
+ expect(root.textContent).toBe('·');
+ // Regression guard for the reported bug: the root previously rendered
+ // displaced toward the DIT side. Its computed x-slot should sit near the
+ // horizontal middle of the tree's total width, not near either edge.
+ const treeContainer = root.closest('.relative.mx-auto');
+ const totalWidth = parseFloat(treeContainer.style.width);
+ const rootLeft = parseFloat(root.style.left);
+ expect(rootLeft).toBeGreaterThan(totalWidth * 0.3);
+ expect(rootLeft).toBeLessThan(totalWidth * 0.7);
+ });
+ });
+
+ describe('isNodeOnPath (live keying highlight gate)', () => {
+ // Root's placeholder char is '·' (truthy) and its code is '' — an idle/empty
+ // currentPath must not make it read as "matched", or the reference tree lights
+ // up the root before the user has keyed anything.
+ const root = { char: '·', code: '' };
+ const e = { char: 'E', code: '.' };
+ const i = { char: 'I', code: '..' };
+ const t = { char: 'T', code: '-' };
+
+ it('does not match or highlight the root when currentPath is empty', () => {
+ expect(isNodeOnPath(root, '')).toEqual({ matched: false, onPath: false });
+ });
+
+ it('matches a node whose code equals the current keyed path', () => {
+ expect(isNodeOnPath(i, '..')).toEqual({ matched: true, onPath: false });
+ });
+
+ it('marks an ancestor of the current path as onPath but not matched', () => {
+ // 'e' ('.') is a prefix of the in-progress path '..' but is not the
+ // fully-keyed node itself.
+ expect(isNodeOnPath(e, '..')).toEqual({ matched: false, onPath: true });
+ });
+
+ it('does not flag a node unrelated to the current path', () => {
+ expect(isNodeOnPath(t, '..')).toEqual({ matched: false, onPath: false });
+ });
+ });