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: select compatible sequence memory (#3254)
[._.]/ Adam Eivyc13ddf4fc550
diff --git a/client/src/components/meatspace/post/PostSessionLauncher.jsx b/client/src/components/meatspace/post/PostSessionLauncher.jsxindex c56c02bcdc..88bbbce28e 100644--- a/client/src/components/meatspace/post/PostSessionLauncher.jsx+++ b/client/src/components/meatspace/post/PostSessionLauncher.jsx@@ -4,7 +4,7 @@ import { Zap, History, Settings, Play, Brain, BookOpen, Dumbbell, Timer, Radio,import { getProviders, getPostReviewReps, getPostRecommendations, getMorseProgress, getPostProgress, getMemoryItems } from '../../../services/api';import { FormField } from '../../ui/FormField';import { isApiProvider } from '../../../utils/providers';-import { DOMAINS, DRILL_TO_DOMAIN, DRILL_LABELS, computeDomainAverages, computeGoalProgress, isTopicEnabled, memoryItemSupportsDrill, resolveTopicForDrillType } from './constants';+import { DOMAINS, DRILL_TO_DOMAIN, DRILL_LABELS, computeDomainAverages, computeGoalProgress, isTopicEnabled, selectMemoryItemForDrill, resolveTopicForDrillType } from './constants';import { streakGlyph } from '../../../lib/streakGlyph.js';import useUserTimezone from '../../../hooks/useUserTimezone.js';import { todayKeyInTimezone } from '../../../utils/timezone.js';@@ -190,9 +190,14 @@ export default function PostSessionLauncher({ config, recentSessions, stats, sta? DOMAINS.memory.drillTypes.map(type => [type, config.memory?.drillTypes?.[type]]).filter(([type, cfg]) => cfg && cfg.enabled !== false && topicAllowed(type)- && enabledMemoryItems.some(item => memoryItemSupportsDrill(item, type)))+ && selectMemoryItemForDrill(enabledMemoryItems, type)): [];+ const memoryDrillConfig = (type, count) => ({+ count,+ memoryItemId: selectMemoryItemForDrill(enabledMemoryItems, type)?.id,+ });+// Only the fields each cognitive generator reads; extras are harmless.// stimulusMs (n-back) / showMs (digit-span) are forwarded so that manual mode// (Progressive off) actually uses the presentation-speed values the user set@@ -267,10 +272,7 @@ export default function PostSessionLauncher({ config, recentSessions, stats, staconst memoryConfigs = (moduleAllowed('memory') ? enabledMemoryDrills : []).map(([type, cfg]) => ({type,domain: 'memory',- config: {- count: cfg.count,- ...(type === 'memory-element-flash' && { memoryItemId: 'elements-song' }),- },+ config: memoryDrillConfig(type, cfg.count),timeLimitSec: DOMAINS.memory.timeBudgetSec,}));@@ -346,10 +348,10 @@ export default function PostSessionLauncher({ config, recentSessions, stats, sta// Keep the drill short for a balanced 5-minute session.quickConfig = { ...cognitiveDrillConfig(cfg), count: cfg.count ? Math.min(cfg.count, 10) : undefined };} else {- quickConfig = {- count: Math.min(cfg.count || 5, 3),- ...(pick.type === 'memory-element-flash' && { memoryItemId: 'elements-song' }),- }; // Fewer prompts for quick session+ const count = Math.min(cfg.count || 5, 3);+ quickConfig = pick.source === 'memory'+ ? memoryDrillConfig(pick.type, count)+ : { count }; // Fewer prompts for quick session}const drillConfig = {@@ -405,10 +407,9 @@ export default function PostSessionLauncher({ config, recentSessions, stats, sta} else if (source === 'cognitive') {focusConfig = cognitiveDrillConfig(cfg);} else {- focusConfig = {- count: cfg.count || 5,- ...(type === 'memory-element-flash' && { memoryItemId: 'elements-song' }),- };+ focusConfig = source === 'memory'+ ? memoryDrillConfig(type, cfg.count || 5)+ : { count: cfg.count || 5 };}const drillConfig = {type,diff --git a/client/src/components/meatspace/post/PostSessionLauncher.test.jsx b/client/src/components/meatspace/post/PostSessionLauncher.test.jsxindex cc4e705581..db9d258575 100644--- a/client/src/components/meatspace/post/PostSessionLauncher.test.jsx+++ b/client/src/components/meatspace/post/PostSessionLauncher.test.jsx@@ -633,7 +633,11 @@ describe('PostSessionLauncher composed memory drills (issue #3254)', () => {vi.clearAllMocks();getPostRecommendations.mockResolvedValue({ recommendations: [] });getPostReviewReps.mockResolvedValue({ reps: [] });- getMemoryItems.mockResolvedValue([{ id: 'example-memory' }]);+ getMemoryItems.mockResolvedValue([{+ id: 'example-memory',+ content: { lines: [{ text: 'First line' }, { text: 'Second line' }] },+ mastery: { overallPct: 20 },+ }]);});it('adds enabled memory drill types to Full and Quick sessions', async () => {@@ -646,7 +650,7 @@ describe('PostSessionLauncher composed memory drills (issue #3254)', () => {expect.objectContaining({type: 'memory-sequence',domain: 'memory',- config: { count: 4 },+ config: { count: 4, memoryItemId: 'example-memory' },timeLimitSec: 90,}),]));@@ -654,7 +658,11 @@ describe('PostSessionLauncher composed memory drills (issue #3254)', () => {fireEvent.click(screen.getByRole('button', { name: /Quick 5 Min/ }));expect(onStart.mock.calls[1][0]).toEqual(expect.arrayContaining([- expect.objectContaining({ type: 'memory-sequence', domain: 'memory', config: { count: 3 } }),+ expect.objectContaining({+ type: 'memory-sequence',+ domain: 'memory',+ config: { count: 3, memoryItemId: 'example-memory' },+ }),]));});@@ -685,7 +693,11 @@ describe('PostSessionLauncher composed memory drills (issue #3254)', () => {it('omits Element Flash when the built-in elements item is unavailable', async () => {const onStart = vi.fn();- getMemoryItems.mockResolvedValue([{ id: 'example-memory', mastery: { overallPct: 0 } }]);+ getMemoryItems.mockResolvedValue([{+ id: 'example-memory',+ content: { lines: [{ text: 'First line' }, { text: 'Second line' }] },+ mastery: { overallPct: 0 },+ }]);renderWith(memoryConfig({memory: {enabled: true,@@ -702,8 +714,8 @@ describe('PostSessionLauncher composed memory drills (issue #3254)', () => {it('pins Element Flash to the compatible elements item', async () => {const onStart = vi.fn();getMemoryItems.mockResolvedValue([- { id: 'example-memory', mastery: { overallPct: 0 } },- { id: 'elements-song', mastery: { overallPct: 90 } },+ { id: 'example-memory', content: { lines: [{ text: 'First' }, { text: 'Second' }] }, mastery: { overallPct: 0 } },+ { id: 'elements-song', content: { lines: [{ text: 'Hydrogen' }, { text: 'Helium' }] }, mastery: { overallPct: 90 } },]);renderWith(memoryConfig({memory: {@@ -722,4 +734,36 @@ describe('PostSessionLauncher composed memory drills (issue #3254)', () => {}),]));});++ it('omits Sequence Recall when no enabled item has two usable lines', async () => {+ const onStart = vi.fn();+ getMemoryItems.mockResolvedValue([{+ id: 'one-line',+ content: { lines: [{ text: 'Only line' }] },+ mastery: { overallPct: 0 },+ }]);+ renderWith(memoryConfig(), onStart);+ await waitFor(() => expect(getMemoryItems).toHaveBeenCalled());++ fireEvent.click(screen.getByText('Full POST'));+ expect(onStart.mock.calls[0][0].some(d => d.type === 'memory-sequence')).toBe(false);+ });++ it('pins Sequence Recall to a compatible item instead of a lower-mastery one-line item', async () => {+ const onStart = vi.fn();+ getMemoryItems.mockResolvedValue([+ { id: 'one-line', content: { lines: [{ text: 'Only line' }] }, mastery: { overallPct: 0 } },+ { id: 'runnable', content: { lines: [{ text: 'First' }, { text: 'Second' }] }, mastery: { overallPct: 80 } },+ ]);+ renderWith(memoryConfig(), onStart);+ await waitFor(() => expect(getMemoryItems).toHaveBeenCalled());++ fireEvent.click(screen.getByText('Full POST'));+ expect(onStart.mock.calls[0][0]).toEqual(expect.arrayContaining([+ expect.objectContaining({+ type: 'memory-sequence',+ config: { count: 4, memoryItemId: 'runnable' },+ }),+ ]));+ });});diff --git a/client/src/components/meatspace/post/constants.js b/client/src/components/meatspace/post/constants.jsindex 906e8d50ad..db41d704c8 100644--- a/client/src/components/meatspace/post/constants.js+++ b/client/src/components/meatspace/post/constants.js@@ -15,11 +15,27 @@ export const COGNITIVE_DRILL_TYPES = ['n-back', 'digit-span', 'stroop', 'schulte// isn't one of the types PostSessionLauncher offers to pick from yet.export const POST_UNSUPPORTED_DRILL_TYPES = ['memory-fill-blank'];-// Element Flash is backed by the built-in periodic-table item. Other memory-// drills can use any enabled memorized text, but selecting a custom item for-// Element Flash makes the server generator return null.+// The server generators have item-shape requirements: Sequence Recall needs a+// successor line, while Element Flash is backed by the built-in periodic-table+// item. Keep the launcher and Practice Plan preview from advertising a drill+// that would make generation return null.export function memoryItemSupportsDrill(item, drillType) {- return drillType !== 'memory-element-flash' || item?.id === 'elements-song';+ if (drillType === 'memory-sequence') {+ return (item?.content?.lines || [])+ .filter(line => (typeof line === 'string' ? line : line?.text || '').trim())+ .length >= 2;+ }+ if (drillType === 'memory-element-flash') return item?.id === 'elements-song';+ return true;+}++/** Lowest-mastery enabled item that can generate a specific memory drill. */+export function selectMemoryItemForDrill(items, drillType) {+ const compatible = (items || []).filter(item => memoryItemSupportsDrill(item, drillType));+ if (!compatible.length) return null;+ return compatible.reduce((lowest, item) =>+ (item?.mastery?.overallPct ?? 0) < (lowest?.mastery?.overallPct ?? 0) ? item : lowest+ );}// The four wordplay drill types with a dedicated standalone trainerdiff --git a/client/src/components/meatspace/post/constants.test.js b/client/src/components/meatspace/post/constants.test.jsindex cf5c82fcc4..a5df5455b9 100644--- a/client/src/components/meatspace/post/constants.test.js+++ b/client/src/components/meatspace/post/constants.test.js@@ -201,11 +201,20 @@ describe('composedSessionDrillTypes (issue #3252)', () => {};expect(composedSessionDrillTypes(memoryConfig, [- { id: 'elements-song' },- { id: 'example-memory' },+ { id: 'elements-song', content: { lines: [{ text: 'Hydrogen' }, { text: 'Helium' }] } },+ { id: 'example-memory', content: { lines: [{ text: 'First' }, { text: 'Second' }] } },])).toEqual({ memory: ['memory-sequence'] });expect(composedSessionDrillTypes(memoryConfig, [])).toEqual({});});++ it('omits Sequence Recall when enabled items have fewer than two usable lines', () => {+ const config = {+ memory: { enabled: true, drillTypes: { 'memory-sequence': { enabled: true } } },+ };+ expect(composedSessionDrillTypes(config, [+ { id: 'one-line', content: { lines: [{ text: 'Only line' }] } },+ ])).toEqual({});+ });});describe('isTopicEnabled / isMemoryItemEnabled client mirrors', () => {