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): clarify elements mastery
[._.]/ Adam Eivy25e38a68ef17
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 32480bee60..4884653048 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -50,6 +50,7 @@## POST+- **Elements mastery now tells accuracy and mastery apart.** A single correct flash card can show 100% accuracy while remaining in Learning until it meets the existing mastery gate of three recent checks at 80% or better. The summary count, periodic-table colors, hover tooltip, and selected-element details now all use the same decay-aware rule.- **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.diff --git a/client/src/components/meatspace/post/ElementsSong.jsx b/client/src/components/meatspace/post/ElementsSong.jsxindex 671393bf08..3039a6fe7e 100644--- a/client/src/components/meatspace/post/ElementsSong.jsx+++ b/client/src/components/meatspace/post/ElementsSong.jsx@@ -105,13 +105,40 @@ export default function ElementsSong({ item: itemProp, onBack, loadItemOnMount,// distinguishable from "practiced and scored zero" (the sentinel rule in// CLAUDE.md) — the caller routes those two to different modes.function bucketAccuracy(buckets) {- const attempted = Object.values(buckets || {}).filter(m => (m?.attempts || 0) > 0);+ const attempted = Object.values(buckets || {})+ .map(elementMasteryProgress)+ .filter(progress => progress.attempts > 0);if (attempted.length === 0) return null;- const attempts = attempted.reduce((sum, m) => sum + m.attempts, 0);- const correct = attempted.reduce((sum, m) => sum + (m.correct || 0), 0);+ const attempts = attempted.reduce((sum, progress) => sum + progress.attempts, 0);+ const correct = attempted.reduce((sum, progress) => sum + progress.correct, 0);return attempts > 0 ? correct / attempts : null;}+const ELEMENT_MASTERY_MIN_ATTEMPTS = 3;+const ELEMENT_MASTERY_TARGET_ACCURACY = 0.8;++// Mirror the server's decay-aware mastery gate for every Elements UI surface.+// Recent answers take precedence; cumulative counts remain the legacy fallback.+export function elementMasteryProgress(stat) {+ const hasRecent = Array.isArray(stat?.recent) && stat.recent.length > 0;+ const attempts = hasRecent+ ? stat.recent.length+ : (Number.isFinite(stat?.attempts) ? stat.attempts : 0);+ const correct = hasRecent+ ? stat.recent.reduce((sum, result) => sum + (result ? 1 : 0), 0)+ : (Number.isFinite(stat?.correct) ? stat.correct : 0);+ const accuracy = attempts > 0 ? correct / attempts : 0;++ return {+ accuracy,+ attempts,+ correct,+ hasRecent,+ mastered: attempts >= ELEMENT_MASTERY_MIN_ATTEMPTS+ && accuracy >= ELEMENT_MASTERY_TARGET_ACCURACY,+ };+}+/*** Which practice mode to lead with on the Elements page (issue #3249) — the* surface offers five modes with no ordering, so a "Start here" hint answers@@ -133,6 +160,8 @@ export function recommendedElementsMode(mastery) {function ElementsSongMain({ item, mastery, onSelectMode, onBack }) {const recommendedMode = recommendedElementsMode(mastery);const elementMap = useMemo(() => item.content?.elementMap ?? {}, [item]);+ const masteredElementCount = Object.keys(elementMap)+ .filter(symbol => elementMasteryProgress(mastery.elements?.[symbol]).mastered).length;const songElements = useMemo(() => {const s = new Set();for (const line of item.content?.lines || []) {@@ -200,8 +229,9 @@ function ElementsSongMain({ item, mastery, onSelectMode, onBack }) {</div></div><div className="text-left sm:text-right text-sm text-gray-500">- <div>{Object.keys(mastery.elements || {}).filter(s => { const m = mastery.elements[s]; return m?.attempts >= 3 && m.correct / m.attempts >= 0.8; }).length} / {Object.keys(elementMap).length} elements mastered</div>+ <div>{masteredElementCount} / {Object.keys(elementMap).length} elements mastered</div><div>{Object.keys(elementMap).length} elements in song</div>+ <div className="text-xs text-gray-600">Mastery requires 3 recent checks at 80%+ accuracy</div></div></div>@@ -277,7 +307,7 @@ function ElementsSongMain({ item, mastery, onSelectMode, onBack }) {if (!sym) return <div key={`${ri}-${ci}`} className="w-[30px] sm:w-[36px] h-[30px] sm:h-[36px]" />;const inSong = songElements.has(sym);const m = mastery.elements?.[sym];- const masteryPct = m?.attempts > 0 ? m.correct / m.attempts : 0;+ const progress = elementMasteryProgress(m);const cat = getCategory(sym);const isHovered = hoveredElement === sym;const isSelected = selectedElement === sym;@@ -285,7 +315,7 @@ function ElementsSongMain({ item, mastery, onSelectMode, onBack }) {let bg, borderColor, catBorderStyle;if (tableView === 'mastery') {- bg = !inSong ? 'bg-gray-800/30' : masteryPct >= 0.8 && m?.attempts >= 3 ? 'bg-emerald-600/60' : masteryPct >= 0.5 ? 'bg-amber-600/50' : m?.attempts > 0 ? 'bg-red-600/40' : 'bg-port-border';+ bg = !inSong ? 'bg-gray-800/30' : progress.mastered ? 'bg-emerald-600/60' : progress.accuracy >= 0.5 ? 'bg-amber-600/50' : progress.attempts > 0 ? 'bg-red-600/40' : 'bg-port-border';borderColor = isSelected ? 'border-port-accent' : cat ? cat.border : 'border-transparent';catBorderStyle = cat ? 'border-l-2' : '';} else {@@ -423,8 +453,8 @@ function ElementsSongMain({ item, mastery, onSelectMode, onBack }) {function ElementTooltip({ sym, elementMap, mastery, inSong, category, verses, chunks, pos }) {const info = elementMap[sym];- const m = mastery.elements?.[sym];- const pct = m?.attempts > 0 ? Math.round((m.correct / m.attempts) * 100) : null;+ const progress = elementMasteryProgress(mastery.elements?.[sym]);+ const pct = progress.attempts > 0 ? Math.round(progress.accuracy * 100) : null;const verseLabels = verses.map(v => chunks.find(c => c.id === v)?.label).filter(Boolean);return (@@ -441,10 +471,13 @@ function ElementTooltip({ sym, elementMap, mastery, inSong, category, verses, ch{inSong ? (<><div className="text-gray-500">- Mastery: <span className={`font-mono ${pct != null && pct >= 80 ? 'text-port-success' : pct != null && pct >= 50 ? 'text-port-warning' : pct != null ? 'text-port-error' : 'text-gray-600'}`}>- {pct != null ? `${pct}%` : '—'}+ Status: <span className={`font-medium ${progress.mastered ? 'text-port-success' : progress.attempts > 0 ? 'text-port-warning' : 'text-gray-600'}`}>+ {progress.mastered ? 'Mastered' : progress.attempts > 0 ? 'Learning' : 'Not practiced'}</span>- {m?.attempts > 0 && <span className="text-gray-600 ml-1">({m.correct}/{m.attempts})</span>}+ </div>+ <div className="text-gray-500">+ Accuracy: <span className="font-mono text-gray-300">{pct != null ? `${pct}%` : '—'}</span>+ {progress.attempts > 0 && <span className="text-gray-600 ml-1">({progress.correct}/{progress.attempts}{progress.hasRecent ? ' recent' : ''})</span>}</div>{verseLabels.length > 0 && <div className="text-gray-500">In: {verseLabels.join(', ')}</div>}</>@@ -459,8 +492,8 @@ function ElementTooltip({ sym, elementMap, mastery, inSong, category, verses, chfunction SelectedElementDetail({ sym, elementMap, mastery, inSong, category, verses, chunks, lines, onClear }) {const info = elementMap[sym];- const m = mastery.elements?.[sym];- const pct = m?.attempts > 0 ? Math.round((m.correct / m.attempts) * 100) : null;+ const progress = elementMasteryProgress(mastery.elements?.[sym]);+ const pct = progress.attempts > 0 ? Math.round(progress.accuracy * 100) : null;const verseLabels = verses.map(v => chunks.find(c => c.id === v)?.label).filter(Boolean);const containingLines = lines.filter(l => l.elements?.includes(sym));@@ -481,14 +514,17 @@ function SelectedElementDetail({ sym, elementMap, mastery, inSong, category, ver</div>{inSong ? (<>- <div className="flex items-center gap-4 text-sm">+ <div className="flex flex-wrap items-center gap-4 text-sm"><div>- <span className="text-gray-500">Mastery: </span>- <span className={`font-mono font-medium ${pct != null && pct >= 80 ? 'text-port-success' : pct != null && pct >= 50 ? 'text-port-warning' : pct != null ? 'text-port-error' : 'text-gray-600'}`}>- {pct != null ? `${pct}%` : 'Not practiced'}+ <span className="text-gray-500">Status: </span>+ <span className={`font-medium ${progress.mastered ? 'text-port-success' : progress.attempts > 0 ? 'text-port-warning' : 'text-gray-600'}`}>+ {progress.mastered ? 'Mastered' : progress.attempts > 0 ? 'Learning' : 'Not practiced'}</span></div>- {m?.attempts > 0 && <div className="text-gray-500 text-xs">{m.correct} correct / {m.attempts} attempts</div>}+ <div className="text-gray-500">+ Accuracy: <span className="font-mono text-gray-300">{pct != null ? `${pct}%` : '—'}</span>+ {progress.attempts > 0 && <span className="text-xs ml-1">({progress.correct}/{progress.attempts}{progress.hasRecent ? ' recent' : ''})</span>}+ </div></div>{containingLines.length > 0 && (<div className="space-y-1">@@ -604,11 +640,9 @@ function LearnMode({ item, onBack, onComplete }) {// study deck and the flash quiz surface the least-known elements first.function weakestFirstElements(elementMap, mastery) {return Object.entries(elementMap).sort((a, b) => {- const mA = mastery.elements?.[a[0]];- const mB = mastery.elements?.[b[0]];- const pctA = mA?.attempts > 0 ? mA.correct / mA.attempts : 0;- const pctB = mB?.attempts > 0 ? mB.correct / mB.attempts : 0;- return pctA - pctB;+ const progressA = elementMasteryProgress(mastery.elements?.[a[0]]);+ const progressB = elementMasteryProgress(mastery.elements?.[b[0]]);+ return progressA.accuracy - progressB.accuracy;});}diff --git a/client/src/components/meatspace/post/ElementsSong.test.jsx b/client/src/components/meatspace/post/ElementsSong.test.jsxindex 87a8c3648f..2873fbc95d 100644--- a/client/src/components/meatspace/post/ElementsSong.test.jsx+++ b/client/src/components/meatspace/post/ElementsSong.test.jsx@@ -1,7 +1,7 @@import { useState } from 'react';import { describe, it, expect, vi, beforeEach } from 'vitest';import { render, screen, fireEvent, act } from '@testing-library/react';-import ElementsSong, { recommendedElementsMode } from './ElementsSong';+import ElementsSong, { elementMasteryProgress, recommendedElementsMode } from './ElementsSong';// The Flash Cards study mode (issue #2480) is a flip-to-reveal study surface —// distinct from the Element Flash recall test — that must still advance element@@ -148,6 +148,50 @@ describe('ElementsSong — routed practice modes (issue #3249)', () => {});});+describe('ElementsSong mastery display', () => {+ it('distinguishes one-answer accuracy from confirmed mastery', async () => {+ const learningItem = {+ ...item,+ content: {+ ...item.content,+ lines: [{ text: 'Hydrogen and helium', elements: ['H', 'He'] }],+ chunks: [{ id: 'verse-1', label: 'Verse 1', lineRange: [0, 0] }],+ },+ mastery: {+ overallPct: 0,+ chunks: {},+ elements: { H: { attempts: 1, correct: 1, recent: [1] } },+ },+ };++ render(<ElementsSong item={learningItem} mode={null} onSelectMode={() => {}} onExitMode={() => {}} onBack={() => {}} />);+ await settle();++ expect(screen.getByText('0 / 2 elements mastered')).toBeInTheDocument();+ expect(screen.getByText('Mastery requires 3 recent checks at 80%+ accuracy')).toBeInTheDocument();++ fireEvent.mouseEnter(screen.getByText('H'));+ expect(screen.getAllByText('Learning')).toHaveLength(2); // legend + tooltip status+ expect(screen.getByText('100%')).toBeInTheDocument();+ expect(screen.getByText('(1/1 recent)')).toBeInTheDocument();+ });++ it('uses recent answers for the same decay-aware mastery gate as the server', () => {+ expect(elementMasteryProgress({ attempts: 10, correct: 10, recent: [0, 0, 0] })).toEqual({+ accuracy: 0,+ attempts: 3,+ correct: 0,+ hasRecent: true,+ mastered: false,+ });+ expect(elementMasteryProgress({ attempts: 3, correct: 3 })).toMatchObject({+ accuracy: 1,+ attempts: 3,+ mastered: true,+ });+ });+});+describe('recommendedElementsMode', () => {it('sends a never-practiced user to the study deck first', () => {expect(recommendedElementsMode({ elements: {}, chunks: {} })).toBe('element-study');@@ -158,6 +202,9 @@ describe('recommendedElementsMode', () => {it('sends weak element recall to the recall test', () => {expect(recommendedElementsMode({ elements: { H: { attempts: 10, correct: 3 } } })).toBe('element-flash');+ expect(recommendedElementsMode({+ elements: { H: { attempts: 10, correct: 10, recent: [0, 0, 0] } },+ })).toBe('element-flash');});it('sends solid elements but weak verses to the lyrics drill', () => {