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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(post): continue the daily training routine
[._.]/ Adam Eivye5590bcce69b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 2054b21436..32480bee60 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -50,6 +50,7 @@## POST+- **Finishing a lesson now keeps the daily brain-training routine moving.** Memory lessons, scored POST assessments, standalone Wordplay rounds, and Morse practice now end with an explicit choice to save/finish for now or save and continue. Continue asks the existing recommendation engine for the next scheduled activity and opens it directly even when the routine crosses from memory into math, cognitive training, wordplay, or Morse. The Memory Builder's own "Review Next" button also starts the due practice mode instead of reopening the item's mode menu.- **The session launcher can show which AI provider a run will use again.** The launcher read the provider list as if the server returned a bare array, but it returns an object wrapping one. The mismatch threw on every mount, was swallowed into a console warning, and left the list permanently empty — so the Wit & Memory panel never showed the provider a drill was about to use unless one had been pinned explicitly.- **[issue-3253] Powers practice now teaches a fast mental path before raising the difficulty.** New sessions begin with recall-friendly powers of two, unlock named techniques through speed-and-accuracy mastery, never generate a pair without a documented method, and show the worked steps after a miss and in session review. Manual base and exponent controls remain available when Progressive is switched off.- **[issue-3254] Memory drills can now join Full and Quick POST sessions.** Memory remains off in Session Composition by default, but users with an enabled memorized item can opt in to interleave recall work with their daily session; empty or fully-disabled item pools are explained and never produce a broken mid-session drill.diff --git a/client/src/components/meatspace/post/ElementsSong.jsx b/client/src/components/meatspace/post/ElementsSong.jsxindex 6b3a2d3ffb..671393bf08 100644--- a/client/src/components/meatspace/post/ElementsSong.jsx+++ b/client/src/components/meatspace/post/ElementsSong.jsx@@ -3,6 +3,7 @@ import { ChevronLeft, ChevronRight, BookOpen, Zap, Target, Check, X, SkipForwardimport { submitMemoryPractice, getMemoryMastery, getMemoryItem } from '../../../services/api';import { RapidReaderModal } from '../../RapidReader';import { clickableProps } from '../../../lib/a11yKeyboard';+import PostCompletionActions from './PostCompletionActions';// Standard periodic table layout: [row][col] = symbol or nullconst PERIODIC_TABLE = [@@ -58,7 +59,7 @@ export const PRACTICE_MODES = [// picker, mirroring MorseTrainer's MORSE_MODE_IDS (issue #3249).export const ELEMENTS_MODE_IDS = PRACTICE_MODES.map(m => m.id);-export default function ElementsSong({ item: itemProp, onBack, loadItemOnMount, mode, onSelectMode, onExitMode }) {+export default function ElementsSong({ item: itemProp, onBack, loadItemOnMount, mode, onSelectMode, onExitMode, onContinue }) {const [loadedItem, setLoadedItem] = useState(null);const item = itemProp || loadedItem;const [mastery, setMastery] = useState(item?.mastery || { overallPct: 0, chunks: {}, elements: {} });@@ -76,9 +77,10 @@ export default function ElementsSong({ item: itemProp, onBack, loadItemOnMount,getMemoryMastery(item.id).then(m => { if (m) setMastery(m); }).catch(err => console.warn('⚠️ Failed to load mastery: ' + err.message));}, [item?.id]);- function handlePracticeComplete(newMastery) {+ function handlePracticeComplete(newMastery, continueDaily = false) {if (newMastery) setMastery(newMastery);- onExitMode();+ if (continueDaily) onContinue();+ else onExitMode();}if (!item) {@@ -511,10 +513,31 @@ function SelectedElementDetail({ sym, elementMap, mastery, inSong, category, verfunction LearnMode({ item, onBack, onComplete }) {const [currentChunk, setCurrentChunk] = useState(0);const [revealedLines, setRevealedLines] = useState(1);+ const [complete, setComplete] = useState(false);const chunks = item.content?.chunks || [];const chunk = chunks[currentChunk];const lines = chunk ? item.content.lines.slice(chunk.lineRange[0], chunk.lineRange[1] + 1) : [];+ function save(continueDaily) {+ return submitMemoryPractice(item.id, {+ mode: 'learn', chunkId: null,+ results: [{ correct: true }],+ totalMs: 0,+ }).then(r => onComplete(r?.mastery, continueDaily));+ }++ if (complete) {+ return (+ <div className="space-y-6 max-w-2xl">+ <h2 className="text-xl font-bold text-white">Lesson Complete</h2>+ <div className="bg-port-card border border-port-border rounded-lg p-6 text-center text-gray-300">+ You finished every verse in The Elements Song.+ </div>+ <PostCompletionActions onSave={() => save(false)} onContinue={() => save(true)} />+ </div>+ );+ }+return (<div className="space-y-6 max-w-2xl"><div className="flex items-center gap-3">@@ -566,13 +589,7 @@ function LearnMode({ item, onBack, onComplete }) {</button>) : (<button- onClick={() => {- submitMemoryPractice(item.id, {- mode: 'learn', chunkId: null,- results: [{ correct: true }],- totalMs: 0,- }).then(r => onComplete(r?.mastery)).catch(err => { console.warn('⚠️ Failed to record practice: ' + err.message); onComplete(null); });- }}+ onClick={() => setComplete(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} /> Complete@@ -619,6 +636,14 @@ function ElementStudyMode({ item, mastery, onBack, onComplete }) {const [results, setResults] = useState([]);const [startTime] = useState(Date.now());+ function save(continueDaily) {+ return 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, continueDaily));+ }+if (!cards.length) {return (<div className="space-y-6 max-w-2xl">@@ -666,18 +691,7 @@ function ElementStudyMode({ item, mastery, onBack, onComplete }) {</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>+ <PostCompletionActions onSave={() => save(false)} onContinue={() => save(true)} /></div>);}@@ -787,6 +801,14 @@ function ElementFlashMode({ item, mastery, onBack, onComplete }) {const [startTime] = useState(Date.now());const inputRef = useRef(null);+ function save(continueDaily) {+ return submitMemoryPractice(item.id, {+ mode: 'element-flash', chunkId: null,+ results: results.map(r => ({ correct: r.correct, element: r.element, expected: r.expected, answered: r.answered })),+ totalMs: Date.now() - startTime,+ }).then(r => onComplete(r?.mastery, continueDaily));+ }+useEffect(() => { inputRef.current?.focus(); }, [idx]);const next = useCallback(() => {@@ -846,18 +868,7 @@ function ElementFlashMode({ item, mastery, onBack, onComplete }) {</div></div>)}- <button- onClick={() => {- submitMemoryPractice(item.id, {- mode: 'element-flash', chunkId: null,- results: results.map(r => ({ correct: r.correct, element: r.element, expected: r.expected, answered: r.answered })),- 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>+ <PostCompletionActions onSave={() => save(false)} onContinue={() => save(true)} /></div>);}@@ -947,6 +958,14 @@ function FillBlankMode({ item, onBack, onComplete }) {const [startTime] = useState(Date.now());const inputRef = useRef(null);+ function save(continueDaily) {+ return submitMemoryPractice(item.id, {+ mode: 'fill-blank', chunkId: null,+ results: results.map(r => ({ correct: r.correct, expected: r.expected, answered: r.answered })),+ totalMs: Date.now() - startTime,+ }).then(r => onComplete(r?.mastery, continueDaily));+ }+useEffect(() => { inputRef.current?.focus(); }, [idx]);if (idx >= lines.length) {@@ -966,18 +985,7 @@ function FillBlankMode({ item, onBack, onComplete }) {<div className={`text-5xl font-bold font-mono ${scoreColor} mb-2`}>{pct}%</div><div className="text-gray-400 text-sm">{correct} of {results.length} lines correct</div></div>- <button- onClick={() => {- submitMemoryPractice(item.id, {- mode: 'fill-blank', chunkId: null,- results: results.map(r => ({ correct: r.correct, expected: r.expected, answered: r.answered })),- 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>+ <PostCompletionActions onSave={() => save(false)} onContinue={() => save(true)} /></div>);}diff --git a/client/src/components/meatspace/post/ElementsSong.test.jsx b/client/src/components/meatspace/post/ElementsSong.test.jsxindex 3df89c0796..87a8c3648f 100644--- a/client/src/components/meatspace/post/ElementsSong.test.jsx+++ b/client/src/components/meatspace/post/ElementsSong.test.jsx@@ -83,7 +83,7 @@ describe('ElementsSong — Flash Cards study mode', () => {}// Completion screen → persist the study reps.- fireEvent.click(screen.getByText('Save & Return'));+ fireEvent.click(screen.getByText('Save Progress'));await settle();expect(submitMemoryPractice).toHaveBeenCalledTimes(1);@@ -96,6 +96,24 @@ describe('ElementsSong — Flash Cards study mode', () => {expect(payload.results.every((r) => r.element === 'H' || r.element === 'He')).toBe(true);expect(payload.results.filter((r) => r.correct)).toHaveLength(1);});++ it('saves the deck before continuing the daily routine', async () => {+ const onContinue = vi.fn();+ render(<RoutedElementsSong item={item} onBack={() => {}} onContinue={onContinue} />);+ await settle();++ fireEvent.click(screen.getByText('Flash Cards'));+ for (let i = 0; i < 2; i++) {+ fireEvent.click(screen.getByRole('button', { name: 'Reveal' }));+ fireEvent.click(screen.getByText('Got It'));+ }++ fireEvent.click(screen.getByText("Continue Today's Routine"));+ await settle();++ expect(submitMemoryPractice).toHaveBeenCalledTimes(1);+ expect(onContinue).toHaveBeenCalledTimes(1);+ });});describe('ElementsSong — routed practice modes (issue #3249)', () => {diff --git a/client/src/components/meatspace/post/MemoryBuilder.jsx b/client/src/components/meatspace/post/MemoryBuilder.jsxindex 4d9d6a504a..e10474e670 100644--- a/client/src/components/meatspace/post/MemoryBuilder.jsx+++ b/client/src/components/meatspace/post/MemoryBuilder.jsx@@ -36,7 +36,7 @@ function mostOverdueFirst(a, b) {// Practice selection is URL-driven (`/post/memory/:itemId`), so this component// only ever renders the list — `onSelectItem` navigates (issue #3249).-export default function MemoryBuilder({ onBack, onSelectItem }) {+export default function MemoryBuilder({ onBack, onSelectItem, onReviewItem = onSelectItem }) {const [items, setItems] = useState([]);const [creating, setCreating] = useState(false);@@ -150,7 +150,7 @@ export default function MemoryBuilder({ onBack, onSelectItem }) {</div></div><button- onClick={() => onSelectItem(dueItems[0])}+ onClick={() => onReviewItem(dueItems[0])}className="shrink-0 flex items-center gap-1.5 px-3 py-1.5 text-sm bg-emerald-600 hover:bg-emerald-500 text-white rounded-lg transition-colors"><BookOpen size={14} />diff --git a/client/src/components/meatspace/post/MemoryPractice.jsx b/client/src/components/meatspace/post/MemoryPractice.jsxindex fae90e0302..dc699e9fd6 100644--- a/client/src/components/meatspace/post/MemoryPractice.jsx+++ b/client/src/components/meatspace/post/MemoryPractice.jsx@@ -1,6 +1,7 @@import { useState, useRef, useEffect, useMemo } from 'react';import { ChevronLeft, Check, X, SkipForward, RotateCcw, Target, ChevronDown, Loader } from 'lucide-react';import { submitMemoryPractice, getChunkMastery, getMemoryItem } from '../../../services/api';+import PostCompletionActions from './PostCompletionActions';const MODES = [{ id: 'learn', label: 'Learn', desc: 'Progressive reveal — read and absorb line by line' },@@ -22,7 +23,7 @@ export const MEMORY_PRACTICE_MODE_IDS = MODES.map(m => m.id);* fetched. An id that doesn't resolve renders a not-found fallback rather than a* blank panel, per the deep-link contract in CLAUDE.md.*/-export default function MemoryPractice({ itemId, item: seedItem, mode, onSelectMode, onExitMode, onBack }) {+export default function MemoryPractice({ itemId, item: seedItem, mode, onSelectMode, onExitMode, onBack, onContinue }) {const [loadedItem, setLoadedItem] = useState(null);const [notFound, setNotFound] = useState(false);const item = seedItem || loadedItem;@@ -79,6 +80,7 @@ export default function MemoryPractice({ itemId, item: seedItem, mode, onSelectMonSelectMode={onSelectMode}onExitMode={onExitMode}onBack={onBack}+ onContinue={onContinue}/>);}@@ -86,7 +88,7 @@ export default function MemoryPractice({ itemId, item: seedItem, mode, onSelectM// The practice runner itself. `mode` is URL-driven; PostTab keys this component// on it, so every mode entry (and every return to the picker) mounts fresh —// no manual per-run state reset is needed.-function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack }) {+function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack, onContinue }) {const [results, setResults] = useState([]);const [currentIdx, setCurrentIdx] = useState(0);const [answer, setAnswer] = useState('');@@ -132,17 +134,14 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack })// Drive terminal transitions from an effect, never during render. The render// fallbacks below (chunk exhausted, line exhausted, sequence exhausted) return null- // for a frame while this effect saves results, advances the chunk, or marks the- // session done — firing setState + an async submitMemoryPractice() POST inside the- // render body is fragile under StrictMode/concurrent rendering. Normal per-answer- // flow still runs through advanceSpaced / nextSequenceQuestion.+ // for a frame while this effect advances or marks the session done. Spaced+ // chunks persist as they advance; other modes wait for the completion choice.useEffect(() => {if (done) return;if (mode === 'spaced') {if (!chunkMastery || chunkMastery.length === 0) return;const currentChunk = chunkMastery[spacedChunkIdx];if (!currentChunk) {- savePractice('spaced', results);setDone(true);return;}@@ -236,19 +235,17 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack })</div>)}- <div className="flex gap-3">+ <div className="space-y-3">+ <PostCompletionActions+ onSave={() => saveAndExit(false)}+ onContinue={() => saveAndExit(true)}+ /><buttononClick={onExitMode}- 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:text-white transition-colors"+ className="w-full flex items-center justify-center gap-2 px-4 py-2.5 text-gray-400 hover:text-white transition-colors"><RotateCcw size={16} />- Try Again- </button>- <button- onClick={onBack}- className="flex-1 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"- >- Done+ Practice Again</button></div></div>@@ -442,7 +439,7 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack })</button>) : (<button- onClick={() => { setDone(true); setResults([{ correct: true, expected: 'learn mode', answered: 'learn mode' }]); savePractice('learn', [{ correct: true }]); }}+ onClick={() => { setDone(true); setResults([{ correct: true, expected: 'learn mode', answered: 'learn mode' }]); }}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} />@@ -640,7 +637,7 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack }){results.length === lines.length && (<button- onClick={() => { savePractice('speed-run', results); setDone(true); }}+ onClick={() => setDone(true)}className="w-full 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} />@@ -672,7 +669,6 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack })}function finishSequence() {- savePractice('sequence', results);setDone(true);}@@ -684,7 +680,6 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack })function nextFillBlank() {if (currentIdx + 1 >= lines.length) {- savePractice('fill-blank', results);setDone(true);} else {setCurrentIdx(prev => prev + 1);@@ -748,6 +743,14 @@ function MemoryPracticeRunner({ item, mode, onSelectMode, onExitMode, onBack })totalMs: Date.now() - startTime,}).catch(err => console.warn(`⚠️ Failed to save practice results: ${err.message}`));}++ async function saveAndExit(continueDaily) {+ // Spaced repetition persists each completed chunk as the user advances;+ // every other mode waits for this explicit completion choice.+ if (mode !== 'spaced') await savePractice(mode, results);+ if (continueDaily) onContinue();+ else onBack();+ }}/**diff --git a/client/src/components/meatspace/post/MemoryPractice.test.jsx b/client/src/components/meatspace/post/MemoryPractice.test.jsxindex 3a8ba7f9af..b01b32a2de 100644--- a/client/src/components/meatspace/post/MemoryPractice.test.jsx+++ b/client/src/components/meatspace/post/MemoryPractice.test.jsx@@ -1,5 +1,6 @@-import { describe, it, expect } from 'vitest';-import {+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';+import MemoryPractice, {fuzzyMatch,generateHint,findChunkForLine,@@ -8,6 +9,20 @@ import {checkSpacedAnswer,} from './MemoryPractice';+const { submitMemoryPractice } = vi.hoisted(() => ({+ submitMemoryPractice: vi.fn(),+}));++vi.mock('../../../services/api', () => ({+ submitMemoryPractice,+ getChunkMastery: vi.fn(),+ getMemoryItem: vi.fn(),+}));++beforeEach(() => {+ vi.clearAllMocks();+});+// Pure-function tests for MemoryPractice's correctness scorers (issue #2102// gap #2). These decide whether a memorization drill answer counts as// correct — a silent regression here would mis-grade every spaced-repetition@@ -175,3 +190,40 @@ describe('findChunkForLine', () => {expect(findChunkForLine({ content: {} }, 0)).toBeNull();});});++describe('MemoryPractice daily routine actions', () => {+ it('waits for progress to save before continuing from a completed lesson', async () => {+ let resolveSave;+ submitMemoryPractice.mockImplementation(() => new Promise(resolve => { resolveSave = resolve; }));+ const onContinue = vi.fn();+ const item = {+ id: 'example-memory',+ title: 'Example Memory',+ content: {+ lines: [{ text: 'An example line.' }],+ chunks: [{ id: 'example-chunk', label: 'Example Chunk', lineRange: [0, 0] }],+ },+ };++ render(+ <MemoryPractice+ itemId={item.id}+ item={item}+ mode="learn"+ onSelectMode={() => {}}+ onExitMode={() => {}}+ onBack={() => {}}+ onContinue={onContinue}+ />+ );++ fireEvent.click(screen.getByText('Complete'));+ fireEvent.click(screen.getByText("Continue Today's Routine"));++ expect(submitMemoryPractice).toHaveBeenCalledTimes(1);+ expect(onContinue).not.toHaveBeenCalled();++ await act(async () => resolveSave({ mastery: {} }));+ await waitFor(() => expect(onContinue).toHaveBeenCalledTimes(1));+ });+});diff --git a/client/src/components/meatspace/post/MorseTrainer.jsx b/client/src/components/meatspace/post/MorseTrainer.jsxindex 516a9a2ff7..688506c716 100644--- a/client/src/components/meatspace/post/MorseTrainer.jsx+++ b/client/src/components/meatspace/post/MorseTrainer.jsx@@ -5,6 +5,7 @@ import { submitTrainingEntry, getTrainingStats, submitMorseRound, getMorseProgreimport MorseProgressPanel from './MorseProgressPanel';import { streakGlyph } from '../../../lib/streakGlyph.js';import { safeReadJsonStorage, safeWriteStorage } from '../../../lib/safeStorage';+import PostCompletionActions from './PostCompletionActions';export const MORSE_TABLE = {A: '.-', B: '-...', C: '-.-.', D: '-..', E: '.', F: '..-.',@@ -413,7 +414,7 @@ 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 }) {+export default function MorseTrainer({ mode = null, onSelectMode, onExitMode, onBack, onContinue }) {const [prefs, setPrefs] = useState(loadPrefs);const [trainingStats, setTrainingStats] = useState(null);// Bumped after each round submit so the progress panel refetches its trends /@@ -478,7 +479,7 @@ export default function MorseTrainer({ mode = null, onSelectMode, onExitMode, on// Fire-and-forget per-round submit (server persists per-item sent→guessed// results for the trends + confusion matrix). Refreshes the panel on success.const submitRound = useCallback((round) => {- submitMorseRound(round, { silent: true })+ return submitMorseRound(round, { silent: true }).then(() => setProgressRefresh((n) => n + 1)).catch(() => {});}, []);@@ -507,7 +508,7 @@ export default function MorseTrainer({ mode = null, onSelectMode, onExitMode, on// usePostSession.js training-mode pattern (silent — a failed background log// shouldn't interrupt practice). Refreshes the displayed stats on success.const logTraining = useCallback((patch) => {- submitTrainingEntry({ module: TRAINING_MODULE, ...patch })+ return submitTrainingEntry({ module: TRAINING_MODULE, ...patch }).then(() => refreshTrainingStats()).catch(() => {});}, [refreshTrainingStats]);@@ -534,13 +535,13 @@ export default function MorseTrainer({ mode = null, onSelectMode, onExitMode, on<SettingsPanel prefs={prefs} updatePrefs={updatePrefs} onResetProgress={resetProgress} trainingStats={trainingStats} />{!mode && <ModeGrid onPick={onSelectMode} />}{mode === 'copy' && (- <CopyDrill prefs={prefs} updatePrefs={updatePrefs} ensureCtx={ensureCtx} onExit={onExitMode} onSessionComplete={logTraining} onRoundSubmit={submitRound} />+ <CopyDrill prefs={prefs} updatePrefs={updatePrefs} ensureCtx={ensureCtx} onExit={onExitMode} onContinue={onContinue} onSessionComplete={logTraining} onRoundSubmit={submitRound} />)}{mode === 'head-copy' && (- <CopyDrill prefs={prefs} updatePrefs={updatePrefs} ensureCtx={ensureCtx} onExit={onExitMode} onSessionComplete={logTraining} onRoundSubmit={submitRound} headCopy />+ <CopyDrill prefs={prefs} updatePrefs={updatePrefs} ensureCtx={ensureCtx} onExit={onExitMode} onContinue={onContinue} onSessionComplete={logTraining} onRoundSubmit={submitRound} headCopy />)}{mode === 'send' && (- <SendDrill keying={keying} onExit={onExitMode} onSessionComplete={logTraining} onRoundSubmit={submitRound} />+ <SendDrill keying={keying} onExit={onExitMode} onContinue={onContinue} onSessionComplete={logTraining} onRoundSubmit={submitRound} />)}{!mode && <MorseProgressPanel refreshKey={progressRefresh} />}</div>@@ -875,7 +876,7 @@ export function resultsToItems(results) {return items;}-function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, onRoundSubmit, headCopy = false }) {+function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onContinue, onSessionComplete, onRoundSubmit, headCopy = false }) {const [prompt, setPrompt] = useState('');const [input, setInput] = useState('');const [results, setResults] = useState([]);@@ -887,6 +888,7 @@ function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, o// Set when a prompt finishes playing; drives per-question responseMs (time from// "audio done" to the user's submit) recorded per character in the round.const questionStartRef = useRef(0);+ const saveRef = useRef(Promise.resolve());// Re-entrancy guard. On the first play of a session `ensureCtx()` awaits the// iOS audio-unlock, and `prompt`/`playing` aren't set until after it — so the// Start Round / New Round button stays live during that window. A second tap@@ -951,7 +953,7 @@ function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, oupdatePrefs(patch);setDone(true);const durationMs = roundStartRef.current ? Date.now() - roundStartRef.current : 0;- onSessionComplete?.({+ const trainingSave = onSessionComplete?.({drillType: headCopy ? 'morse-head-copy' : 'morse-copy',questionCount: rs.length,correctCount,@@ -960,7 +962,7 @@ function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, o// Persist the round server-side with per-character sent→guessed pairs (each// prompt/guess is aligned positionally so a 5-char group yields 5 items) —// the raw material for the confusion matrix and per-character mastery.- onRoundSubmit?.({+ const roundSave = onRoundSubmit?.({mode: headCopy ? 'head-copy' : 'copy',kochLevel: prefs.kochLevel,wpm: prefs.wpm,@@ -968,6 +970,7 @@ function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, odurationMs,items: resultsToItems(rs),});+ saveRef.current = Promise.all([trainingSave, roundSave]);}function onKey(e) {@@ -1003,12 +1006,14 @@ function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, o</div>))}</div>- <div className="flex gap-3">- <button onClick={startRound} className="flex-1 px-4 py-2.5 bg-port-accent hover:bg-port-accent/80 text-white font-medium rounded-lg transition-colors">- New Round- </button>- <button onClick={onExit} className="flex-1 px-4 py-2.5 bg-port-card border border-port-border hover:border-port-accent text-white font-medium rounded-lg transition-colors">- Pick Mode+ <PostCompletionActions+ saveLabel="Finish for Now"+ onSave={() => saveRef.current.then(onExit)}+ onContinue={() => saveRef.current.then(onContinue)}+ />+ <div className="flex justify-center">+ <button onClick={startRound} className="px-4 py-2 text-sm text-gray-400 hover:text-white transition-colors">+ Practice Again</button></div></div>@@ -1102,10 +1107,11 @@ function CopyDrill({ prefs, updatePrefs, ensureCtx, onExit, onSessionComplete, o);}-function SendDrill({ keying, onExit, onSessionComplete, onRoundSubmit }) {+function SendDrill({ keying, onExit, onContinue, onSessionComplete, onRoundSubmit }) {const [prompt, setPrompt] = useState(() => pickSendPrompt());const [feedback, setFeedback] = useState(null);const promptStartRef = useRef(Date.now());+ const saveRef = useRef(Promise.resolve());// Drop any stale keying state from a prior session so "Your sending" starts empty.const { clear: clearKeying } = keying;@@ -1119,7 +1125,7 @@ function SendDrill({ keying, onExit, onSessionComplete, onRoundSubmit }) {const correct = got === target;setFeedback({ correct, decoded: got, target });const durationMs = Date.now() - promptStartRef.current;- onSessionComplete?.({+ const trainingSave = onSessionComplete?.({drillType: 'morse-send',questionCount: 1,correctCount: correct ? 1 : 0,@@ -1155,7 +1161,10 @@ function SendDrill({ keying, onExit, onSessionComplete, onRoundSubmit }) {items.push({ sent: '', guessed: ' ', correct: false, responseMs: 0 });}if (items.length > 0) {- onRoundSubmit?.({ mode: 'send', durationMs, items });+ const roundSave = onRoundSubmit?.({ mode: 'send', durationMs, items });+ saveRef.current = Promise.all([trainingSave, roundSave]);+ } else {+ saveRef.current = Promise.resolve(trainingSave);}}@@ -1199,14 +1208,14 @@ function SendDrill({ keying, onExit, onSessionComplete, onRoundSubmit }) {vs target <span className="font-mono text-port-accent">{feedback.target}</span></div></div>- <div className="flex gap-3">- <button onClick={nextPrompt} className="flex-1 px-4 py-2.5 bg-port-accent hover:bg-port-accent/80 text-white font-medium rounded-lg transition-colors">- Next Prompt- </button>- <button onClick={onExit} className="flex-1 px-4 py-2.5 bg-port-card border border-port-border hover:border-port-accent text-white font-medium rounded-lg transition-colors">- Pick Mode- </button>- </div>+ <PostCompletionActions+ saveLabel="Finish for Now"+ onSave={() => saveRef.current.then(onExit)}+ onContinue={() => saveRef.current.then(onContinue)}+ />+ <button onClick={nextPrompt} className="w-full px-4 py-2 text-sm text-gray-400 hover:text-white transition-colors">+ Practice Another Prompt+ </button></div>) : (<div className="flex gap-3">diff --git a/client/src/components/meatspace/post/MorseTrainer.test.jsx b/client/src/components/meatspace/post/MorseTrainer.test.jsxindex 9ad3490640..bc36b89115 100644--- a/client/src/components/meatspace/post/MorseTrainer.test.jsx+++ b/client/src/components/meatspace/post/MorseTrainer.test.jsx@@ -164,6 +164,18 @@ describe('MorseTrainer training log integration', () => {expect(container.textContent).toContain('80% avg');});+ it('waits for a Send result to save before continuing the daily routine', async () => {+ const onContinue = vi.fn();+ await renderMorse({ mode: 'send', onContinue, onExitMode: vi.fn(), onBack: vi.fn() });++ fireEvent.click(screen.getByText('Check'));+ fireEvent.click(screen.getByText("Continue Today's Routine"));++ await waitFor(() => expect(submitTrainingEntry).toHaveBeenCalled());+ await waitFor(() => expect(submitMorseRound).toHaveBeenCalled());+ await waitFor(() => expect(onContinue).toHaveBeenCalledTimes(1));+ });+describe('round completion', () => {// Scoped to just this test — install/teardown live in beforeEach/afterEach// (not inline in the test body) so a failed assertion above the cleanupdiff --git a/client/src/components/meatspace/post/PostCompletionActions.jsx b/client/src/components/meatspace/post/PostCompletionActions.jsxnew file mode 100644index 0000000000..5c7603e384--- /dev/null+++ b/client/src/components/meatspace/post/PostCompletionActions.jsx@@ -0,0 +1,46 @@+import { useState } from 'react';+import { ArrowRight, Save } from 'lucide-react';++/**+ * Shared completion fork for every POST lesson: stop after persisting progress,+ * or persist and immediately continue into the next daily recommendation.+ */+export default function PostCompletionActions({+ onSave,+ onContinue,+ saveLabel = 'Save Progress',+ continueLabel = "Continue Today's Routine",+}) {+ const [pending, setPending] = useState(null);++ function run(kind, action) {+ if (pending || !action) return;+ setPending(kind);+ Promise.resolve(action())+ .catch(() => {})+ .finally(() => setPending(null));+ }++ return (+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-3">+ <button+ type="button"+ onClick={() => run('save', onSave)}+ disabled={Boolean(pending)}+ className="flex items-center justify-center gap-2 px-4 py-2.5 bg-port-card border border-port-border hover:border-port-accent disabled:opacity-50 text-white rounded-lg transition-colors"+ >+ <Save size={16} />+ {pending === 'save' ? 'Saving...' : saveLabel}+ </button>+ <button+ type="button"+ onClick={() => run('continue', onContinue)}+ disabled={Boolean(pending)}+ className="flex items-center justify-center gap-2 px-4 py-2.5 bg-port-accent hover:bg-port-accent/80 disabled:opacity-50 text-white rounded-lg transition-colors"+ >+ {pending === 'continue' ? 'Saving...' : continueLabel}+ <ArrowRight size={16} />+ </button>+ </div>+ );+}diff --git a/client/src/components/meatspace/post/PostSessionLauncher.jsx b/client/src/components/meatspace/post/PostSessionLauncher.jsxindex daa117392c..7c03b44066 100644--- a/client/src/components/meatspace/post/PostSessionLauncher.jsx+++ b/client/src/components/meatspace/post/PostSessionLauncher.jsx@@ -1,4 +1,4 @@-import { useState, useEffect } from 'react';+import { useState, useEffect, useRef } from 'react';import { Link } from 'react-router-dom';import { Zap, History, Settings, Play, Brain, BookOpen, Dumbbell, Timer, Radio, Target, TrendingUp, TrendingDown, Minus, Compass, ArrowRight, ChevronRight, Layers } from 'lucide-react';import { getPostReviewReps, getPostRecommendations, getMorseProgress, getPostProgress, getMemoryItems } from '../../../services/api';@@ -69,7 +69,34 @@ export function buildCleanTags(tags) {return cleanTags;}-export default function PostSessionLauncher({ config, recentSessions, stats, statsWeek, onStart, onViewHistory, onViewConfig, onViewMemory, onViewMorse }) {+function AutoStartRecommendation({ action, onConsumed, onNavigate }) {+ const startedRef = useRef(false);++ useEffect(() => {+ if (startedRef.current) return;+ startedRef.current = true;+ onConsumed();+ if (action?.to) onNavigate(action.to);+ else action?.onClick?.();+ }, [action, onConsumed, onNavigate]);++ return <div className="text-center text-gray-400 py-12">Starting your next lesson...</div>;+}++export default function PostSessionLauncher({+ config,+ recentSessions,+ stats,+ statsWeek,+ onStart,+ onViewHistory,+ onViewConfig,+ onViewMemory,+ onViewMorse,+ autoStartRecommendationId,+ onAutoStartConsumed,+ onNavigate,+}) {// Resolve "today" in the user's CONFIGURED timezone so client-side day matching// (completed-today, today's minutes) agrees with the server, which stamps and// windows POST records on the configured local day (issue #2681). Deriving it@@ -101,6 +128,7 @@ export default function PostSessionLauncher({ config, recentSessions, stats, sta// failure silently degrades to an empty list (the panel hides). The top// recommendation also biases the Quick session's drill picks.const [recommendations, setRecommendations] = useState([]);+ const [recommendationsLoaded, setRecommendationsLoaded] = useState(false);// Current effective Morse WPM — fetched only when a Morse WPM goal is set, so// that goal can render progress (issue #2100). null when unset/unavailable.const [morseWpm, setMorseWpm] = useState(null);@@ -115,7 +143,10 @@ export default function PostSessionLauncher({ config, recentSessions, stats, stauseEffect(() => {getPostReviewReps(5).then(r => setReviewReps(r?.reps || [])).catch(() => setReviewReps([]));- getPostRecommendations().then(r => setRecommendations(r?.recommendations || [])).catch(() => setRecommendations([]));+ getPostRecommendations()+ .then(r => setRecommendations(r?.recommendations || []))+ .catch(() => setRecommendations([]))+ .finally(() => setRecommendationsLoaded(true));getMemoryItems({ silent: true }).then(items => setMemoryItemsState({ status: 'ready', items: Array.isArray(items) ? items : [] })).catch(() => setMemoryItemsState({ status: 'error', items: [] }));@@ -580,6 +611,19 @@ export default function PostSessionLauncher({ config, recentSessions, stats, staconst weekSessions = statsWeek?.sessionCount ?? 0;const goalRows = computeGoalProgress(config.goals, { todayMinutes, weekSessions, currentStreak, morseWpm });+ // A default/full recommendation may include memory drills, so wait until the+ // item pool is known before deciding whether its session is runnable.+ if (autoStartRecommendationId && recommendationsLoaded && memoryItemsState.status !== 'loading') {+ const recommendation = recommendations.find(rec => rec.id === autoStartRecommendationId) || topRec;+ return (+ <AutoStartRecommendation+ action={recAction(recommendation)}+ onConsumed={onAutoStartConsumed}+ onNavigate={onNavigate}+ />+ );+ }+return (<div className="space-y-6 max-w-6xl mx-auto">{/* Header */}diff --git a/client/src/components/meatspace/post/PostSessionLauncher.test.jsx b/client/src/components/meatspace/post/PostSessionLauncher.test.jsxindex a0a5e02138..50dcb03d4a 100644--- a/client/src/components/meatspace/post/PostSessionLauncher.test.jsx+++ b/client/src/components/meatspace/post/PostSessionLauncher.test.jsx@@ -203,6 +203,25 @@ describe('PostSessionLauncher render (issue #2100)', () => {expect(drills.map(d => d.type)).toEqual(['multiplication']);});+ it('auto-starts the requested recommendation when continuing a daily routine', async () => {+ const onStart = vi.fn();+ const onAutoStartConsumed = vi.fn();+ getPostRecommendations.mockResolvedValue({ recommendations: [+ { id: 'weak-skill:mm', kind: 'weak-skill', title: 'Shore up Multiplication', detail: 'x', deepLink: '/post/launcher', drillType: 'multiplication', priority: 0 },+ ] });++ renderLauncher({+ onStart,+ autoStartRecommendationId: 'weak-skill:mm',+ onAutoStartConsumed,+ onNavigate: vi.fn(),+ });++ await waitFor(() => expect(onStart).toHaveBeenCalledTimes(1));+ expect(onStart.mock.calls[0][0].map(d => d.type)).toEqual(['multiplication']);+ expect(onAutoStartConsumed).toHaveBeenCalledTimes(1);+ });+it('launches a review rep (with markers) for a skill-review recommendation', async () => {const onStart = vi.fn();getPostReviewReps.mockResolvedValue({ reps: [diff --git a/client/src/components/meatspace/post/PostSessionResults.jsx b/client/src/components/meatspace/post/PostSessionResults.jsxindex ca92169c43..57eab4dcde 100644--- a/client/src/components/meatspace/post/PostSessionResults.jsx+++ b/client/src/components/meatspace/post/PostSessionResults.jsx@@ -1,29 +1,26 @@-import { Save, ArrowLeft, Dumbbell } from 'lucide-react';+import { ArrowLeft } from 'lucide-react';import PostSessionSummary from './PostSessionSummary';+import PostCompletionActions from './PostCompletionActions';export default function PostSessionResults({ session, tags = {}, onSaved, onBack }) {const { drillResults, sessionScore, state, saveSession, isTraining } = session;- async function handleSave() {+ async function handleSave(continueDaily) {const savedSession = await saveSession(tags);- if (savedSession) onSaved(savedSession);+ if (savedSession) onSaved(savedSession, { continueDaily });}return (<div className="max-w-4xl mx-auto space-y-6"><PostSessionSummary drillResults={drillResults} sessionScore={sessionScore} isTraining={isTraining} />- {/* Save Button */}+ {/* Every completed assessment offers the same explicit daily-routine fork. */}{state === 'complete' && (- <button- onClick={handleSave}- className={`w-full flex items-center justify-center gap-2 px-6 py-3 ${- isTraining ? 'bg-port-accent-2 hover:bg-port-accent-2/80 text-port-on-accent-2' : 'bg-port-success hover:bg-port-success/80 text-white'- } font-medium rounded-lg transition-colors`}- >- {isTraining ? <Dumbbell size={18} /> : <Save size={18} />}- {isTraining ? 'Log Training' : 'Save Session'}- </button>+ <PostCompletionActions+ saveLabel={isTraining ? 'Log Training' : 'Save Session'}+ onSave={() => handleSave(false)}+ onContinue={() => handleSave(true)}+ />)}{state === 'saving' && (diff --git a/client/src/components/meatspace/post/PostSessionResults.test.jsx b/client/src/components/meatspace/post/PostSessionResults.test.jsxindex dae5e583cb..1e505eaab6 100644--- a/client/src/components/meatspace/post/PostSessionResults.test.jsx+++ b/client/src/components/meatspace/post/PostSessionResults.test.jsx@@ -1,5 +1,5 @@import { describe, it, expect, vi } from 'vitest';-import { render, screen, fireEvent, within } from '@testing-library/react';+import { render, screen, fireEvent, within, act } from '@testing-library/react';import PostSessionResults from './PostSessionResults';// Issue #2093 — the drill-breakdown expansion previously only ever showed@@ -90,3 +90,26 @@ describe('PostSessionResults drill breakdown', () => {expect(container.querySelector('table')).not.toBeInTheDocument();});});++describe('PostSessionResults daily routine actions', () => {+ it('saves before requesting the next scheduled lesson', async () => {+ const saved = { id: 'session-example' };+ const saveSession = vi.fn().mockResolvedValue(saved);+ const onSaved = vi.fn();+ render(+ <PostSessionResults+ session={makeSession({ saveSession })}+ tags={{}}+ onSaved={onSaved}+ onBack={() => {}}+ />+ );++ await act(async () => {+ fireEvent.click(screen.getByText("Continue Today's Routine"));+ });++ expect(saveSession).toHaveBeenCalledWith({});+ expect(onSaved).toHaveBeenCalledWith(saved, { continueDaily: true });+ });+});diff --git a/client/src/components/meatspace/post/WordplayTrainer.jsx b/client/src/components/meatspace/post/WordplayTrainer.jsxindex 90f4ffd566..56aaf35063 100644--- a/client/src/components/meatspace/post/WordplayTrainer.jsx+++ b/client/src/components/meatspace/post/WordplayTrainer.jsx@@ -10,6 +10,7 @@ import Modal from '../../ui/Modal';import toast from '../../ui/Toast';import { AILoadingIndicator, MissedExamplesDisplay, CompoundChainUI, BridgeWordUI, DoubleMeaningUI, IdiomTwistUI, ProgressBar, scoreWordplayResponse } from './WordplayDrillUI';import { countLlmCorrect, LLM_TRAINING_CORRECT_THRESHOLD } from './constants';+import PostCompletionActions from './PostCompletionActions';// Coarse module bucket for training-log entries — matches the module// PostLlmDrillRunner's in-session runner logs LLM/wordplay drills under@@ -60,7 +61,7 @@ const GAME_MODES = [},];-export default function WordplayTrainer({ onBack, config, onConfigUpdate, mode = null, onSelectMode, onExitMode }) {+export default function WordplayTrainer({ onBack, onContinue, config, onConfigUpdate, mode = null, onSelectMode, onExitMode }) {// Selected mode is driven by the `/post/wordplay/:mode` URL param (source of// truth), not local state — deep-linkable and refresh-safe like MorseTrainer.// An unknown segment degrades to the mode grid instead of a blank screen.@@ -87,6 +88,7 @@ export default function WordplayTrainer({ onBack, config, onConfigUpdate, mode =// log one training-log entry with the whole round's elapsed time (matches// MorseTrainer's roundStartRef → totalMs contract).const roundStartRef = useRef(Date.now());+ const roundSaveRef = useRef(Promise.resolve());// Cache-fill consent: PortOS never issues background LLM calls a user// hasn't asked for. A mode whose drill cache is cold (0 cached) prompts@@ -367,7 +369,7 @@ export default function WordplayTrainer({ onBack, config, onConfigUpdate, mode =// `results` (issue #2114) — the drill cache means these prompts are// reusable, so a future progress dashboard can trend which individual// wordplay prompts get missed rather than only the round aggregate.- submitTrainingEntry({+ roundSaveRef.current = submitTrainingEntry({module: TRAINING_MODULE,drillType: selectedMode,questionCount: results.length,@@ -497,18 +499,17 @@ export default function WordplayTrainer({ onBack, config, onConfigUpdate, mode =</div>))}</div>- <div className="flex gap-3">+ <PostCompletionActions+ saveLabel="Finish for Now"+ onSave={() => roundSaveRef.current.then(onBack)}+ onContinue={() => roundSaveRef.current.then(onContinue)}+ />+ <div className="flex justify-center"><buttononClick={() => startMode(selectedMode)}- className="flex-1 px-4 py-2.5 bg-port-accent hover:bg-port-accent/80 text-white font-medium rounded-lg transition-colors"+ className="px-4 py-2 text-sm text-gray-400 hover:text-white transition-colors">- Play Again- </button>- <button- onClick={handleBackToModes}- className="flex-1 px-4 py-2.5 bg-port-card border border-port-border hover:border-port-accent text-white font-medium rounded-lg transition-colors"- >- Pick Mode+ Practice Again</button></div></div>@@ -709,4 +710,3 @@ function CacheFillConsentModal({</Modal>);}-diff --git a/client/src/components/meatspace/post/WordplayTrainer.test.jsx b/client/src/components/meatspace/post/WordplayTrainer.test.jsxindex f05872fe15..54f9102c3a 100644--- a/client/src/components/meatspace/post/WordplayTrainer.test.jsx+++ b/client/src/components/meatspace/post/WordplayTrainer.test.jsx@@ -55,6 +55,7 @@ beforeEach(() => {describe('WordplayTrainer — training-log persistence (issue #2097)', () => {it('submits a training entry on round completion, with correctCount derived from the scored responses', async () => {+ const onContinue = vi.fn();generatePostDrill.mockResolvedValue({type: 'compound-chain',challenges: [{ rootWord: 'fire', position: 'prefix', minExpected: 1 }],@@ -63,7 +64,7 @@ describe('WordplayTrainer — training-log persistence (issue #2097)', () => {evaluation: { scores: [{ score: 85, feedback: 'Nice compounds!' }] },});- render(<TrainerHarness onBack={() => {}} config={{}} onConfigUpdate={() => {}} />);+ render(<TrainerHarness onBack={() => {}} onContinue={onContinue} config={{}} onConfigUpdate={() => {}} />);fireEvent.click(await screen.findByText('Compound Chain'));@@ -101,6 +102,9 @@ describe('WordplayTrainer — training-log persistence (issue #2097)', () => {feedback: 'Nice compounds!',correct: true,});++ fireEvent.click(screen.getByText("Continue Today's Routine"));+ await waitFor(() => expect(onContinue).toHaveBeenCalledTimes(1));});it('does not wedge on a permanent spinner after leaving a mode mid-generation then picking another (issue #2098)', async () => {diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsxindex f18c1fd03a..79f23d408f 100644--- a/client/src/components/meatspace/tabs/PostTab.jsx+++ b/client/src/components/meatspace/tabs/PostTab.jsx@@ -1,7 +1,7 @@import { useState, useEffect } from 'react';import { useNavigate, useLocation } from 'react-router-dom';import { Loader } from 'lucide-react';-import { getPostConfig, getPostSessions, getPostStats } from '../../../services/api';+import { getPostConfig, getPostRecommendations, getPostSessions, getPostStats } from '../../../services/api';import { usePostSession } from '../../../hooks/usePostSession';import PostSessionLauncher from '../post/PostSessionLauncher';import PostDrillRunner from '../post/PostDrillRunner';@@ -83,12 +83,27 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {if (started) navigate('/post/session/run');}- // Save success → jump to the deep-linkable results URL for this session, so it- // is shareable/bookmarkable/reachable from History. The run id === session id.- async function handleSaved(savedSession) {+ // Save success either continues the daily recommendation chain or opens the+ // deep-linkable saved result. The run id === session id.+ async function continueDailyRoutine() {+ const result = await getPostRecommendations(1).catch(() => null);+ const recommendation = result?.recommendations?.[0];+ if (!recommendation) {+ navigate('/post/launcher');+ return;+ }+ if (recommendation.deepLink && recommendation.deepLink !== '/post/launcher') {+ navigate(recommendation.deepLink);+ return;+ }+ navigate(`/post/launcher?continue=${encodeURIComponent(recommendation.id)}`);+ }++ async function handleSaved(savedSession, { continueDaily = false } = {}) {await loadData();session.reset();- if (savedSession?.id) navigate(`/post/session/${savedSession.id}`);+ if (continueDaily) await continueDailyRoutine();+ else if (savedSession?.id) navigate(`/post/session/${savedSession.id}`);else navigate('/post/launcher');}@@ -233,6 +248,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {onSelectMode={(id) => navigate(`/post/wordplay/${id}`)}onExitMode={() => navigate('/post/wordplay')}onBack={() => navigate('/post/launcher')}+ onContinue={continueDailyRoutine}/>);case 'morse': {@@ -249,6 +265,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {onSelectMode={(id) => navigate(`/post/morse/${id}${location.search}`)}onExitMode={() => navigate(`/post/morse${location.search}`)}onBack={() => navigate('/post/launcher')}+ onContinue={continueDailyRoutine}/>);}@@ -266,6 +283,10 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {if (item.id === 'elements-song') { setElementsItem(item); navigate('/post/memory/elements'); }else { setMemoryItem(item); navigate(`/post/memory/${item.id}`); }}}+ onReviewItem={(item) => {+ if (item.id === 'elements-song') navigate('/post/memory/elements/element-flash');+ else navigate(`/post/memory/${item.id}/spaced`);+ }}/>);}@@ -278,6 +299,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {onSelectMode={(id) => navigate(`/post/memory/elements/${id}`)}onExitMode={() => navigate('/post/memory/elements')}onBack={() => { setElementsItem(null); navigate('/post/memory'); }}+ onContinue={continueDailyRoutine}loadItemOnMount={!elementsItem}/>);@@ -296,6 +318,7 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {onSelectMode={(id) => navigate(`/post/memory/${subtab}/${id}`)}onExitMode={() => navigate(`/post/memory/${subtab}`)}onBack={() => { setMemoryItem(null); navigate('/post/memory'); }}+ onContinue={continueDailyRoutine}/>);}@@ -311,6 +334,9 @@ export default function PostTab({ tab = 'launcher', subtab, mode }) {onViewConfig={() => navigate('/post/config')}onViewMemory={() => navigate('/post/memory')}onViewMorse={() => navigate('/post/morse')}+ autoStartRecommendationId={new URLSearchParams(location.search).get('continue')}+ onAutoStartConsumed={() => navigate('/post/launcher', { replace: true })}+ onNavigate={navigate}/>);}diff --git a/client/src/components/meatspace/tabs/PostTab.test.jsx b/client/src/components/meatspace/tabs/PostTab.test.jsxindex 227482ef4d..4bb3c5282a 100644--- a/client/src/components/meatspace/tabs/PostTab.test.jsx+++ b/client/src/components/meatspace/tabs/PostTab.test.jsx@@ -13,6 +13,7 @@ const settle = () => act(async () => {});// any of this data — it's the pure routing surface under test here.vi.mock('../../../services/api', () => ({getPostConfig: () => Promise.resolve(null),+ getPostRecommendations,getPostSessions: () => Promise.resolve([]),getPostStats: () => Promise.resolve(null),// MorseTrainer (rendered by the 'morse' tab) fetches/logs training stats on@@ -43,7 +44,7 @@ vi.mock('../../RapidReader', () => ({ RapidReaderModal: () => null }));// Hoisted so the api mock factory (which vitest lifts above imports) can close// over it — a plain `const` declared below would be in the TDZ at mock time.-const { MEMORY_ITEM, ELEMENTS_ITEM } = vi.hoisted(() => ({+const { MEMORY_ITEM, ELEMENTS_ITEM, getPostRecommendations } = vi.hoisted(() => ({MEMORY_ITEM: {id: 'raven',title: 'The Raven',@@ -64,6 +65,7 @@ const { MEMORY_ITEM, ELEMENTS_ITEM } = vi.hoisted(() => ({content: { lines: [], chunks: [], elementMap: { H: { name: 'Hydrogen', atomicNumber: 1 } } },mastery: { overallPct: 0, chunks: {}, elements: {} },},+ getPostRecommendations: vi.fn().mockResolvedValue({ recommendations: [] }),}));vi.mock('../../../hooks/usePostSession', () => ({@@ -112,13 +114,13 @@ describe('PostTab morse deep-linking', () => {</MemoryRouter>,);await settle();- // Check surfaces the send-drill feedback, whose "Pick Mode" button exits the- // mode back to the grid; ?ref=length must not reset to tree on the way out.+ // Check surfaces the send-drill feedback, whose "Finish for Now" action exits+ // the mode back to the grid; ?ref=length must not reset to tree on the way out.fireEvent.click(screen.getByText('Check'));// Check submits the round + training entry — settle those writes before// navigating away so their state updates stay act-wrapped.await settle();- fireEvent.click(screen.getByText('Pick Mode'));+ fireEvent.click(screen.getByText('Finish for Now'));await settle();expect(screen.getByTestId('loc').textContent).toBe('/post/morse?ref=length');});@@ -145,6 +147,16 @@ describe('PostTab memory deep-linking (issue #3249)', () => {expect(screen.getByText('Memory Builder')).toBeInTheDocument();});+ it('starts Review Next inside the due practice mode instead of reopening the item menu', async () => {+ renderMemory('/post/memory');+ await settle();++ fireEvent.click(screen.getByText('Review Next'));+ await settle();++ expect(screen.getByTestId('loc').textContent).toBe('/post/memory/raven/spaced');+ });+it('loads an item practice mode straight from the URL on a cold load', async () => {renderMemory('/post/memory/raven/spaced', { subtab: 'raven', mode: 'spaced' });await settle();@@ -195,4 +207,26 @@ describe('PostTab memory deep-linking (issue #3249)', () => {await settle();expect(screen.getByText('Periodic Table')).toBeInTheDocument();});++ it('continues from a saved Elements lesson to the next cross-domain recommendation', async () => {+ getPostRecommendations.mockResolvedValueOnce({ recommendations: [{+ id: 'stalled:morse-copy',+ kind: 'stalled-progression',+ title: 'Morse: keep climbing',+ deepLink: '/post/morse/copy',+ drillType: 'morse-copy',+ priority: 0,+ }] });+ renderMemory('/post/memory/elements/element-study', { subtab: 'elements', mode: 'element-study' });+ await settle();++ fireEvent.click(screen.getByRole('button', { name: 'Reveal' }));+ fireEvent.click(screen.getByText('Got It'));+ await settle();+ fireEvent.click(screen.getByText("Continue Today's Routine"));+ await settle();++ expect(getPostRecommendations).toHaveBeenCalledWith(1);+ expect(screen.getByTestId('loc').textContent).toBe('/post/morse/copy');+ });});