AI Learning Tiers - Toggle Fix
Fixed Tier 1 toggle reverting to OFF issue
AI Learning Tiers - Toggle Fix
Problem
When enabling Tier 1: Development AI in the learning dashboard, it would immediately revert back to OFF.
Root Cause
- Frontend tried to save tier settings to
/api/ai-agents/settings(endpoint doesn't exist) - Every 30 seconds, frontend polled
/api/ai-agents/stats/summaryfor tier stats - Backend returned hardcoded
tier1.active: falsewith comment "managed locally via MCP" - Frontend overwrote local settings with backend response → Toggle reverted to OFF
The Fix
Changed 3 things in ai-learning-dashboard.component.ts:
1. Removed Failed Backend Call
// OLD: Tried to save to non-existent endpoint
await firstValueFrom(
this.http.patch(`${this.API_BASE}/settings`, { [key]: newValue })
);
// NEW: Local-only toggle (no backend call)
this.addEvent({
type: 'sync',
message: `Tier ${tierIndex + 1} ${newValue ? 'enabled' : 'disabled'} (local)`,
tier: tierIndex + 1,
timestamp: new Date(),
success: true,
});
2. Use Local Setting for Tier 1 Status
// OLD: Backend overwrites status
status: stats.tier1?.active ? 'active' : 'inactive',
// NEW: Use local setting
status: this.settings().tier1Enabled ? 'active' : 'inactive',
3. Persist Settings with autoFlashState
// OLD: Lost on page reload
readonly settings = signal({ tier1Enabled: true, ... });
// NEW: Persists across reloads
readonly settings = autoFlashState('ai-learning-dashboard/settings', {
tier1Enabled: true,
tier2Enabled: true,
tier3Enabled: true,
...
});
Result
✅ Tier 1 toggle now works correctly
✅ Settings persist across page reloads
✅ No more "INACTIVE" revert
Architecture Notes
Tier 1: Development AI (Local)
- Managed entirely in frontend
- Settings stored in
autoFlashState(IndexedDB) - No backend persistence needed
- Intended for Cursor/Claude learning (via MCP)
Tier 2: Platform AI (Backend)
- Managed by backend
- Status comes from backend's vector search stats
- Active when embeddings are being generated
- Uses
/api/ai-agents/stats/summaryfor real data
Tier 3: Tenant AI (Tenant Config)
- Would be managed per-tenant in backend
- Not fully implemented yet
- Settings would come from tenant configuration
Testing
- Open AI Learning Dashboard
- Toggle Tier 1: Development AI to ON
- Wait 30+ seconds (stats refresh interval)
- ✅ Should stay ON (not revert to OFF)
- Refresh page
- ✅ Should still be ON (persisted)
Fixed: December 10, 2025
Session: 13
Files Modified:
libs/libs-ai/agent-orchestrator/src/lib/components/ai-learning-dashboard/ai-learning-dashboard.component.ts