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

feat(cos): add learning health summary to dashboard

Adam Eivyc01c92f0a3a6
diff --git a/.changelog/v0.12.x.md b/.changelog/v0.12.x.md
index 8cc4da6e81..ae79dd03af 100644
--- a/.changelog/v0.12.x.md
+++ b/.changelog/v0.12.x.md
@@ -71,3 +71,20 @@ This release adds branch management and automated release workflow capabilities
### Runner Config Access Crash
- **Fix**: `server/services/runner.js` was accessing `aiToolkitInstance.config.dataDir` and `aiToolkitInstance.config.hooks`, but the AI Toolkit object returned by `createAIToolkit()` has no `.config` property (config is internal to service closures). This caused a `TypeError: Cannot read properties of undefined (reading 'dataDir')` whenever the PortOS runner shim's `executeCliRun` was invoked.
- **Solution**: Pass `dataDir` and `hooks` explicitly to the runner shim via `setAIToolkit(toolkit, config)` and store them in a local `runnerConfig` variable
+
+## Improvements
+
+### CoS — Learning Health Summary on Dashboard
+- **Learning stat card**: Added a 5th stat card to the CoS main page showing overall task learning success rate with visual health indicators
+- **Quick access**: Clicking the Learning card navigates directly to the Learning tab for detailed analytics
+- **Skipped task alerts**: Shows a warning count when task types have been auto-skipped due to poor performance (<30% success after 5+ attempts)
+- **Status indicators**: Card border changes color based on health — purple for good, yellow for warning states, red for critical (skipped tasks)
+- **Mobile support**: Learning summary displayed as a full-width card at the bottom of the mobile stats grid
+
+**Server changes**:
+- `server/services/taskLearning.js` — Added `getLearningSummary()` function returning lightweight health metrics (healthy/warning/critical/skipped counts, overall success rate)
+- `server/routes/cos.js` — Added `/learning/summary` endpoint
+
+**Client changes**:
+- `client/src/services/api.js` — Added `getCosLearningSummary()` API function
+- `client/src/pages/ChiefOfStaff.jsx` — Added learning summary state, fetches summary with page data, renders clickable Learning stat card in both desktop (5-column grid) and mobile layouts
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index b761361bce..a2f147471a 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback, useMemo } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { useSocket } from '../hooks/useSocket';
import * as api from '../services/api';
-import { Play, Square, Clock, CheckCircle, AlertCircle, Cpu, ChevronDown, ChevronUp } from 'lucide-react';
+import { Play, Square, Clock, CheckCircle, AlertCircle, Cpu, ChevronDown, ChevronUp, Brain } from 'lucide-react';
import toast from 'react-hot-toast';
// Import from modular components
@@ -54,6 +54,7 @@ export default function ChiefOfStaff() {
const [eventLogs, setEventLogs] = useState([]);
const [agentPanelCollapsed, setAgentPanelCollapsed] = useState(false);
const [activeAgentMeta, setActiveAgentMeta] = useState(null);
+ const [learningSummary, setLearningSummary] = useState(null);
const socket = useSocket();
// Derive avatar style from server config, with optional dynamic override
@@ -89,14 +90,15 @@ export default function ChiefOfStaff() {
}, []);
const fetchData = useCallback(async () => {
- const [statusData, tasksData, agentsData, scriptsData, healthData, providersData, appsData] = await Promise.all([
+ const [statusData, tasksData, agentsData, scriptsData, healthData, providersData, appsData, learningSummaryData] = await Promise.all([
api.getCosStatus().catch(() => null),
api.getCosTasks().catch(() => ({ user: null, cos: null })),
api.getCosAgents().catch(() => []),
api.getCosScripts().catch(() => ({ scripts: [] })),
api.getCosHealth().catch(() => null),
api.getProviders().catch(() => ({ providers: [] })),
- api.getApps().catch(() => [])
+ api.getApps().catch(() => []),
+ api.getCosLearningSummary().catch(() => null)
]);
setStatus(statusData);
setTasks(tasksData);
@@ -106,6 +108,7 @@ export default function ChiefOfStaff() {
setProviders(providersData.providers || []);
// Filter out PortOS Autofixer (it's part of PortOS project)
setApps(appsData.filter(a => a.id !== 'portos-autofixer'));
+ setLearningSummary(learningSummaryData);
setLoading(false);
const newState = deriveAgentState(statusData, agentsData, healthData);
@@ -444,7 +447,7 @@ export default function ChiefOfStaff() {
</div>
</div>
- {/* Mobile Stats Grid - 2x2 layout for compact display */}
+ {/* Mobile Stats Grid - shows core stats in compact 2-column layout */}
<div className="flex-1 grid grid-cols-2 gap-1.5 p-2 lg:hidden relative z-10 content-center">
<StatCard
label="Active"
@@ -471,6 +474,33 @@ export default function ChiefOfStaff() {
icon={<AlertCircle className={`w-4 h-4 ${hasIssues ? 'text-port-error' : 'text-gray-500'}`} />}
compact
/>
+ {/* Learning Health - spans 2 columns on mobile for visibility */}
+ <button
+ onClick={() => navigate('/cos/learning')}
+ className={`col-span-2 bg-port-card/80 border rounded px-2 py-1.5 flex items-center gap-2 transition-all ${
+ learningSummary?.status === 'critical' ? 'border-port-error shadow-md shadow-port-error/20' :
+ learningSummary?.status === 'warning' ? 'border-port-warning' :
+ 'border-port-border'
+ }`}
+ >
+ <Brain className={`w-4 h-4 shrink-0 ${
+ learningSummary?.status === 'critical' ? 'text-port-error' :
+ learningSummary?.status === 'warning' ? 'text-port-warning' :
+ learningSummary?.status === 'good' ? 'text-purple-400' :
+ 'text-gray-500'
+ }`} />
+ <div className="flex-1 min-w-0">
+ <div className="text-[10px] text-gray-500">Learning</div>
+ <div className="text-sm font-bold text-white flex items-center gap-2">
+ {learningSummary?.overallSuccessRate != null ? `${learningSummary.overallSuccessRate}% success` : 'No data'}
+ {learningSummary?.skipped > 0 && (
+ <span className="text-[9px] text-port-error font-normal">
+ ({learningSummary.skipped} skipped)
+ </span>
+ )}
+ </div>
+ </div>
+ </button>
</div>
</div>
</div>
@@ -480,7 +510,7 @@ export default function ChiefOfStaff() {
<div className="flex-1 min-h-0 flex flex-col overflow-hidden">
<div className="overflow-y-auto p-3 lg:p-4">
{/* Stats Bar - hidden on mobile for SVG mode (shown in avatar panel instead) */}
- <div className={`grid grid-cols-4 gap-1.5 sm:gap-2 lg:gap-3 mb-3 sm:mb-4 lg:mb-6 ${avatarStyle !== 'ascii' ? 'hidden lg:grid' : ''}`}>
+ <div className={`grid grid-cols-5 gap-1.5 sm:gap-2 lg:gap-3 mb-3 sm:mb-4 lg:mb-6 ${avatarStyle !== 'ascii' ? 'hidden lg:grid' : ''}`}>
<StatCard
label="Active"
value={activeAgentCount}
@@ -506,6 +536,34 @@ export default function ChiefOfStaff() {
icon={<AlertCircle className={`w-3 h-3 sm:w-4 sm:h-4 lg:w-5 lg:h-5 ${hasIssues ? 'text-port-error' : 'text-gray-500'}`} />}
mini
/>
+ {/* Learning Health - clickable to go to Learning tab */}
+ <button
+ onClick={() => navigate('/cos/learning')}
+ className={`bg-port-card border rounded p-1.5 sm:p-2 lg:p-3 transition-all text-left hover:bg-port-card/80 ${
+ learningSummary?.status === 'critical' ? 'border-port-error shadow-md shadow-port-error/20' :
+ learningSummary?.status === 'warning' ? 'border-port-warning shadow-md shadow-port-warning/20' :
+ 'border-port-border hover:border-purple-500/50'
+ }`}
+ title={learningSummary?.statusMessage || 'View learning analytics'}
+ >
+ <div className="flex items-center justify-between mb-0.5">
+ <span className="text-[10px] sm:text-xs text-gray-500 truncate">Learning</span>
+ <Brain className={`w-3 h-3 sm:w-4 sm:h-4 lg:w-5 lg:h-5 shrink-0 ${
+ learningSummary?.status === 'critical' ? 'text-port-error' :
+ learningSummary?.status === 'warning' ? 'text-port-warning' :
+ learningSummary?.status === 'good' ? 'text-purple-400' :
+ 'text-gray-500'
+ }`} />
+ </div>
+ <div className="text-sm sm:text-base lg:text-xl font-bold text-white">
+ {learningSummary?.overallSuccessRate != null ? `${learningSummary.overallSuccessRate}%` : '—'}
+ </div>
+ {learningSummary?.skipped > 0 && (
+ <div className="text-[9px] text-port-error mt-0.5 truncate">
+ {learningSummary.skipped} skipped
+ </div>
+ )}
+ </button>
</div>
{/* Tabs - scrollable on mobile with touch-friendly sizing */}
diff --git a/client/src/services/api.js b/client/src/services/api.js
index 9203f2def4..9afb541df9 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -408,6 +408,7 @@ export const getCosLearning = () => request('/cos/learning');
export const getCosLearningDurations = () => request('/cos/learning/durations');
export const getCosLearningSkipped = () => request('/cos/learning/skipped');
export const getCosLearningPerformance = () => request('/cos/learning/performance');
+export const getCosLearningSummary = () => request('/cos/learning/summary');
export const backfillCosLearning = () => request('/cos/learning/backfill', { method: 'POST' });
export const resetCosTaskTypeLearning = (taskType) => request(`/cos/learning/reset/${encodeURIComponent(taskType)}`, { method: 'POST' });
diff --git a/server/routes/cos.js b/server/routes/cos.js
index 6fe429e5fd..1535c9c06b 100644
--- a/server/routes/cos.js
+++ b/server/routes/cos.js
@@ -382,6 +382,12 @@ router.get('/learning/performance', asyncHandler(async (req, res) => {
res.json(summary);
}));
+// GET /api/cos/learning/summary - Get lightweight learning health summary for dashboard
+router.get('/learning/summary', asyncHandler(async (req, res) => {
+ const summary = await taskLearning.getLearningSummary();
+ res.json(summary);
+}));
+
// GET /api/cos/learning/insights - Get recent learning insights
router.get('/learning/insights', asyncHandler(async (req, res) => {
const limit = parseInt(req.query.limit, 10) || 10;
diff --git a/server/services/taskLearning.js b/server/services/taskLearning.js
index 7f05dff382..2aa96c2474 100644
--- a/server/services/taskLearning.js
+++ b/server/services/taskLearning.js
@@ -1172,3 +1172,66 @@ export async function backfillFromHistory() {
emitLog('info', `Backfilled ${backfilled} completed tasks into learning system`, { backfilled }, '📚 TaskLearning');
return backfilled;
}
+
+/**
+ * Get a lightweight learning health summary for dashboard display
+ * Returns just the key metrics needed for a quick health overview
+ */
+export async function getLearningSummary() {
+ const data = await loadLearningData();
+
+ // Count task types in various health states
+ let healthyCount = 0;
+ let warningCount = 0;
+ let criticalCount = 0;
+ let skippedCount = 0;
+
+ for (const [, metrics] of Object.entries(data.byTaskType)) {
+ if (metrics.completed < 3) continue; // Insufficient data
+
+ if (metrics.successRate >= 70) {
+ healthyCount++;
+ } else if (metrics.successRate >= 40) {
+ warningCount++;
+ } else {
+ criticalCount++;
+ if (metrics.completed >= 5 && metrics.successRate < 30) {
+ skippedCount++;
+ }
+ }
+ }
+
+ const totalTypes = healthyCount + warningCount + criticalCount;
+
+ // Determine overall health status
+ let status = 'good';
+ let statusMessage = 'All task types healthy';
+
+ if (skippedCount > 0) {
+ status = 'critical';
+ statusMessage = `${skippedCount} task type${skippedCount > 1 ? 's' : ''} skipped`;
+ } else if (criticalCount > 0) {
+ status = 'warning';
+ statusMessage = `${criticalCount} need${criticalCount === 1 ? 's' : ''} attention`;
+ } else if (warningCount > 0) {
+ status = 'ok';
+ statusMessage = `${warningCount} underperforming`;
+ } else if (totalTypes === 0) {
+ status = 'none';
+ statusMessage = 'No data yet';
+ }
+
+ return {
+ status,
+ statusMessage,
+ totalTypes,
+ healthy: healthyCount,
+ warning: warningCount,
+ critical: criticalCount,
+ skipped: skippedCount,
+ overallSuccessRate: data.totals.completed > 0
+ ? Math.round((data.totals.succeeded / data.totals.completed) * 100)
+ : null,
+ totalCompleted: data.totals.completed
+ };
+}