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

fix: gate memory composition on runnable drills (#3254)

[._.]/ Adam Eivy216048ca6c80
diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsx
index 28aa4c5e27..18d0f8dff1 100644
--- a/client/src/components/meatspace/post/PostDrillConfig.jsx
+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx
@@ -4,7 +4,7 @@ import { updatePostConfig, getProviders, getPostAdaptivePreview, getPostMultipli
import toast from '../../ui/Toast';
import { FormField } from '../../ui/FormField';
import { filterSelectableModels, enabledApiProviderFilter } from '../../../utils/providers';
-import { GOAL_DEFS, POST_TOPICS, MODULE_LABELS } from './constants';
+import { GOAL_DEFS, POST_TOPICS, MODULE_LABELS, composedSessionDrillTypes } from './constants';
// Modules a Full/Quick composed session can draw from (issue #2100), DERIVED
// from the shared topic registry so the list has one owner (issue #3252): a
@@ -571,8 +571,14 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
.catch(() => setMemoryItemsState({ status: 'error', items: [] }));
}, []);
- const hasEnabledMemoryItem = memoryItemsState.status === 'ready'
- && memoryItemsState.items.some(item => config?.memory?.items?.[item.id]?.enabled !== false);
+ // Force Memory through the same topic/module/drill/item compatibility chain
+ // as the launcher while ignoring its current Session Composition membership:
+ // this predicate decides whether that membership may be added in the first place.
+ const hasRunnableMemoryDrill = memoryItemsState.status === 'ready'
+ && !!composedSessionDrillTypes(
+ { ...config, sessionModules: ['memory'] },
+ memoryItemsState.items,
+ ).memory?.length;
// Load the effective-difficulty preview when Adaptive is on, so each math card
// can show what a session would actually use. Reflects saved config + recent
@@ -892,12 +898,12 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {
<div className="flex flex-wrap gap-2">
{SESSION_MODULE_OPTIONS.map(opt => {
const on = sessionModules.includes(opt.id);
- const memoryUnavailable = opt.id === 'memory' && !hasEnabledMemoryItem;
+ const memoryUnavailable = opt.id === 'memory' && !hasRunnableMemoryDrill;
const unavailableReason = memoryItemsState.status === 'loading'
? 'Checking memory items…'
: memoryItemsState.status === 'error'
? 'Memory items could not be loaded.'
- : 'Add or enable a memory item in Practice Plan first.';
+ : 'Enable Memory, a runnable drill, and an item in Practice Plan first.';
return (
<div key={opt.id} className="flex flex-col gap-1">
<button
diff --git a/client/src/components/meatspace/post/PostDrillConfig.test.jsx b/client/src/components/meatspace/post/PostDrillConfig.test.jsx
index 9434fb8c1c..a6dd6f191b 100644
--- a/client/src/components/meatspace/post/PostDrillConfig.test.jsx
+++ b/client/src/components/meatspace/post/PostDrillConfig.test.jsx
@@ -29,6 +29,11 @@ const NEWLY_EXPOSED_TYPES = ALL_LLM_TYPES.filter(t => !LEGACY_ENABLED_TYPES.incl
// Mirrors the server DEFAULT_CONFIG: only the 5 legacy LLM drills ship enabled.
const config = {
mentalMath: { drillTypes: { 'multiplication': { enabled: true, count: 10 } } },
+ memory: {
+ enabled: true,
+ drillTypes: { 'memory-sequence': { enabled: true, count: 4 } },
+ items: {},
+ },
llmDrills: {
enabled: true,
providerId: null,
@@ -83,7 +88,10 @@ beforeEach(() => {
thresholds: { minSamples: 3, targetAccuracy: 0.85 }, windowDays: 30,
},
});
- getMemoryItems.mockResolvedValue([{ id: 'example-memory' }]);
+ getMemoryItems.mockResolvedValue([{
+ id: 'example-memory',
+ content: { lines: [{ text: 'First' }, { text: 'Second' }] },
+ }]);
});
// Render + settle the mount-effect fetches (providers, adaptive preview,
@@ -158,7 +166,26 @@ describe('PostDrillConfig', () => {
await renderConfig(<PostDrillConfig config={config} onSaved={vi.fn()} onBack={vi.fn()} />);
const memory = await screen.findByRole('checkbox', { name: 'Memory' });
expect(memory.disabled).toBe(true);
- expect(screen.getByText('Add or enable a memory item in Practice Plan first.')).toBeTruthy();
+ expect(screen.getByText('Enable Memory, a runnable drill, and an item in Practice Plan first.')).toBeTruthy();
+ });
+
+ it('disables Memory composition when its topic or every runnable drill is off', async () => {
+ const topicOff = {
+ ...config,
+ topics: { memory: { enabled: false } },
+ };
+ const { unmount } = await renderConfig(
+ <PostDrillConfig config={topicOff} onSaved={vi.fn()} onBack={vi.fn()} />,
+ );
+ expect((await screen.findByRole('checkbox', { name: 'Memory' })).disabled).toBe(true);
+ unmount();
+
+ const drillsOff = {
+ ...config,
+ memory: { ...config.memory, drillTypes: { 'memory-sequence': { enabled: false } } },
+ };
+ await renderConfig(<PostDrillConfig config={drillsOff} onSaved={vi.fn()} onBack={vi.fn()} />);
+ expect((await screen.findByRole('checkbox', { name: 'Memory' })).disabled).toBe(true);
});
it('clears a previously-set goal to an empty goals patch on save', async () => {