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([issue-2100]): filter recs to runnable drills; wire Morse WPM goal metric (codex review)
Adam Eivy52e4044ef2ec
diff --git a/client/src/components/meatspace/post/PostSessionLauncher.jsx b/client/src/components/meatspace/post/PostSessionLauncher.jsxindex ba8e8e4171..12ca316292 100644--- a/client/src/components/meatspace/post/PostSessionLauncher.jsx+++ b/client/src/components/meatspace/post/PostSessionLauncher.jsx@@ -1,7 +1,7 @@import { useState, useEffect } from 'react';import { Link } from 'react-router-dom';import { Zap, History, Settings, Play, Brain, BookOpen, Dumbbell, Timer, Radio, Target, TrendingUp, TrendingDown, Minus, Compass, ArrowRight, Layers } from 'lucide-react';-import { getProviders, getPostReviewReps, getPostRecommendations } from '../../../services/api';+import { getProviders, getPostReviewReps, getPostRecommendations, getMorseProgress } from '../../../services/api';import { FormField } from '../../ui/FormField';import { isApiProvider } from '../../../utils/providers';import { DOMAINS, DRILL_TO_DOMAIN, DRILL_LABELS, computeDomainAverages, computeGoalProgress } from './constants';@@ -79,6 +79,9 @@ 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([]);+ // 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);useEffect(() => {getProviders().then(p => setProviders((p || []).filter(pr => pr.enabled && isApiProvider(pr)))).catch(err => console.warn('⚠️ Failed to load providers: ' + err.message));@@ -86,6 +89,21 @@ export default function PostSessionLauncher({ config, recentSessions, stats, stagetPostRecommendations().then(r => setRecommendations(r?.recommendations || [])).catch(() => setRecommendations([]));}, []);+ // Only fetch Morse progress when a Morse WPM goal exists — avoids an extra+ // request on the common path. Effective WPM prefers the Farnsworth setting.+ useEffect(() => {+ if (!config?.goals?.morseWpmTarget) { setMorseWpm(null); return; }+ let cancelled = false;+ getMorseProgress(30, { silent: true })+ .then(m => {+ if (cancelled) return;+ const wpm = m?.settings?.farnsworthWpm ?? m?.settings?.wpm ?? null;+ setMorseWpm(typeof wpm === 'number' ? wpm : null);+ })+ .catch(() => { if (!cancelled) setMorseWpm(null); });+ return () => { cancelled = true; };+ }, [config?.goals?.morseWpmTarget]);+if (!config) {return <div className="text-gray-500">Loading configuration...</div>;}@@ -363,7 +381,7 @@ export default function PostSessionLauncher({ config, recentSessions, stats, staconst todaysSessions = (recentSessions || []).filter(s => s.date === today);const todayMinutes = Math.round(todaysSessions.reduce((sum, s) => sum + (s.durationMs || 0), 0) / 60000);const weekSessions = statsWeek?.sessionCount ?? 0;- const goalRows = computeGoalProgress(config.goals, { todayMinutes, weekSessions, currentStreak });+ const goalRows = computeGoalProgress(config.goals, { todayMinutes, weekSessions, currentStreak, morseWpm });return (<div className="space-y-6 max-w-6xl mx-auto">diff --git a/client/src/components/meatspace/post/PostSessionLauncher.test.jsx b/client/src/components/meatspace/post/PostSessionLauncher.test.jsxindex 2f2544f469..f3a0c592b6 100644--- a/client/src/components/meatspace/post/PostSessionLauncher.test.jsx+++ b/client/src/components/meatspace/post/PostSessionLauncher.test.jsx@@ -8,10 +8,11 @@ vi.mock('../../../services/api', () => ({getProviders: vi.fn().mockResolvedValue([]),getPostReviewReps: vi.fn().mockResolvedValue({ reps: [] }),getPostRecommendations: vi.fn().mockResolvedValue({ recommendations: [] }),+ getMorseProgress: vi.fn().mockResolvedValue({ settings: { wpm: 18, farnsworthWpm: 12 } }),}));import PostSessionLauncher, { buildCleanTags, cognitiveSummary, interleaveByDomain } from './PostSessionLauncher';-import { getPostRecommendations } from '../../../services/api';+import { getPostRecommendations, getMorseProgress } from '../../../services/api';// Pure-function tests for PostSessionLauncher's pre-submit helpers (issue// #2102 gap #10). Both were lifted from component-body closures to module@@ -139,6 +140,7 @@ describe('PostSessionLauncher render (issue #2100)', () => {beforeEach(() => {vi.clearAllMocks();getPostRecommendations.mockResolvedValue({ recommendations: [] });+ getMorseProgress.mockResolvedValue({ settings: { wpm: 18, farnsworthWpm: 12 } });});it('renders the "Up next" panel with working deep links', async () => {@@ -160,6 +162,13 @@ describe('PostSessionLauncher render (issue #2100)', () => {expect(screen.getByText(/4\/10/)).toBeTruthy();});+ it('renders a Morse WPM goal by fetching current Morse speed', async () => {+ renderLauncher({ config: { ...baseConfig, goals: { morseWpmTarget: 20 } } });+ await waitFor(() => expect(getMorseProgress).toHaveBeenCalled());+ // Effective WPM prefers Farnsworth (12) → "12/20".+ await waitFor(() => expect(screen.getByText(/12\/20/)).toBeTruthy());+ });+it('hides the goals panel when no goals are set', async () => {renderLauncher({ config: { ...baseConfig, goals: {} } });await waitFor(() => expect(getPostRecommendations).toHaveBeenCalled());diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.jsindex f1394c7887..58d41cd7b9 100644--- a/server/services/meatspacePost.js+++ b/server/services/meatspacePost.js@@ -988,7 +988,7 @@ export function composePostRecommendations({kind: 'weak-skill',title: `Shore up ${DRILL_LABEL(weakestSkill.type)}`,detail: `Weakest skill lately — ${Math.round((weakestSkill.accuracy || 0) * 100)}% accuracy`,- deepLink: '/post/launcher',+ deepLink: weakestSkill.deepLink || '/post/launcher',drillType: weakestSkill.type,});}@@ -1023,13 +1023,42 @@ export function composePostRecommendations({return recs.slice(0, Math.max(1, limit)).map((r, i) => ({ ...r, priority: i }));}+// Coarse module → config key for the enabled-drill lookup.+const MODULE_CONFIG_KEY = { 'mental-math': 'mentalMath', 'llm-drills': 'llmDrills', cognitive: 'cognitive' };++/**+ * Whether a recommended drill can actually be run under the current config+ * (issue #2100 review): a weak-skill / stalled rec deep-links into a session,+ * so recommending a drill the user has since disabled — or a module they've+ * removed from Session Composition — would be a dead end. Memory practice runs+ * from its own tab, so it's always runnable regardless of session composition.+ * Pure — exported for unit tests.+ */+export function isRecDrillRunnable(config, module, type) {+ if (module === 'memory') return true;+ const sm = Array.isArray(config?.sessionModules) ? config.sessionModules : null;+ // null = legacy/absent → all modules allowed; an explicit array must include it.+ if (sm !== null && !sm.includes(module)) return false;+ const key = MODULE_CONFIG_KEY[module];+ if (!key) return true; // unknown module — don't filter it out+ // An absent module/drill entry means "default" (enabled) — getPostConfig+ // deep-merges the enabled-by-default config, so only an EXPLICIT `false`+ // disables it.+ const mod = config?.[key];+ if (mod && mod.enabled === false) return false;+ const dt = mod?.drillTypes?.[type];+ return !dt || dt.enabled !== false;+}+/*** Gather the recommendation signals and compose the ordered "Up next" list* (issue #2100). Reads due memory items, due skill re-verifications, recent- * stats (weakest skill), and the resolved ladders (stalled progressions).+ * stats (weakest skill), and the resolved ladders (stalled progressions), then+ * filters the config-dependent ones (weakest/stalled) to drills the current+ * config can actually run.*/export async function getPostRecommendations({ limit = RECOMMENDATION_LIMIT } = {}) {- const [dueMemoryItems, dueReviews, stats, mulProgress, cogProgress, morse, sessions] = await Promise.all([+ const [dueMemoryItems, dueReviews, stats, mulProgress, cogProgress, morse, sessions, config] = await Promise.all([getDueMemoryItems(),getDueReviews(new Date(), Infinity),getPostStats(MASTERY_DEFAULTS.windowDays),@@ -1037,14 +1066,26 @@ export async function getPostRecommendations({ limit = RECOMMENDATION_LIMIT } =getCognitiveProgress(),getMorseProgress(MASTERY_DEFAULTS.windowDays),getPostSessions(),+ getPostConfig(),]);- const weakestSkill = weakestSkillFromStats(stats);+ // Weakest skill — drop it unless the drill is currently runnable; a memory+ // weak-skill deep-links to its own tab rather than a composed session.+ let weakestSkill = weakestSkillFromStats(stats);+ if (weakestSkill) {+ weakestSkill = isRecDrillRunnable(config, weakestSkill.module, weakestSkill.type)+ ? { ...weakestSkill, deepLink: weakestSkill.module === 'memory' ? '/post/memory' : '/post/launcher' }+ : null;+ }++ // Stalled progressions — keep Morse (runs from its own tab) and any ladder+ // whose drill is still runnable under the current config.const stalled = stalledProgressions(mulProgress, cogProgress, {kochLevel: morse?.kochLevel,kochLevelSet: morse?.kochLevelSet,maxKochLevel: MAX_KOCH_LEVEL,- });+ }).filter(s => s.drillType === 'morse-copy'+ || isRecDrillRunnable(config, s.drillType === 'multiplication' ? 'mental-math' : 'cognitive', s.drillType));return {recommendations: composePostRecommendations({diff --git a/server/services/meatspacePostRecommendations.test.js b/server/services/meatspacePostRecommendations.test.jsindex 0428675719..33e8228fa8 100644--- a/server/services/meatspacePostRecommendations.test.js+++ b/server/services/meatspacePostRecommendations.test.js@@ -29,6 +29,7 @@ import {stalledProgressions,getPostRecommendations,updatePostConfig,+ isRecDrillRunnable,} from './meatspacePost.js';import { atomicWrite } from '../lib/fileUtils.js';@@ -132,6 +133,43 @@ describe('stalledProgressions', () => {});});+describe('isRecDrillRunnable (issue #2100)', () => {+ it('memory is always runnable (its own tab)', () => {+ expect(isRecDrillRunnable({ sessionModules: [] }, 'memory', 'memory-sequence')).toBe(true);+ });++ it('false when the module is excluded from session composition', () => {+ expect(isRecDrillRunnable({ sessionModules: ['mental-math'] }, 'cognitive', 'n-back')).toBe(false);+ });++ it('null/absent sessionModules means all modules allowed', () => {+ expect(isRecDrillRunnable({}, 'cognitive', 'n-back')).toBe(true);+ });++ it('false when the module or the specific drill is disabled', () => {+ expect(isRecDrillRunnable({ cognitive: { enabled: false } }, 'cognitive', 'n-back')).toBe(false);+ expect(isRecDrillRunnable({ cognitive: { enabled: true, drillTypes: { 'n-back': { enabled: false } } } }, 'cognitive', 'n-back')).toBe(false);+ });++ it('true when the module and drill are both enabled and allowed', () => {+ expect(isRecDrillRunnable({ sessionModules: ['cognitive'], cognitive: { enabled: true, drillTypes: { 'n-back': { enabled: true } } } }, 'cognitive', 'n-back')).toBe(true);+ });+});++describe('getPostRecommendations config filtering (issue #2100)', () => {+ it('drops a weakest-skill rec for a drill excluded from session composition', async () => {+ // History makes n-back the weakest skill, but the config excludes cognitive+ // from composition — so it must not surface as a runnable recommendation.+ state.config = { sessionModules: ['mental-math'] };+ state.sessions = [{+ date: new Date().toISOString().split('T')[0], durationMs: 60000, score: 40,+ tasks: [{ module: 'cognitive', type: 'n-back', score: 40, accuracy: 0.4, completion: 1, questions: [{ answered: 'match', correct: false }] }],+ }];+ const { recommendations } = await getPostRecommendations();+ expect(recommendations.some(r => r.kind === 'weak-skill')).toBe(false);+ });+});+describe('updatePostConfig goals (issue #2100)', () => {it('replaces the goals block wholesale so a goal can be cleared', async () => {state.config = { goals: { streakTarget: 5, dailyMinutes: 20 } };