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(cos): name the health issue and make the Issues tile open Health

Adam Eivy8bf705e2de0a
diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.js
index 29be2f2f45..eef7082561 100644
--- a/client/src/components/cos/constants.js
+++ b/client/src/components/cos/constants.js
@@ -193,6 +193,33 @@ export const STATE_MESSAGES = {
ideating: "Analyzing options...",
};
+// A health issue is the ONLY thing that flips an idle-but-running CoS into
+// `investigating`, so the status bubble has to say *which* issue. Falling back
+// to the generic STATE_MESSAGES line left the avatar parked on "Investigating
+// issue..." with zero agents running and the detail reachable only by guessing
+// at the Health tab. Returns null when there is nothing to report so callers
+// can fall back to their own default. Issue shape mirrors the server's
+// `runHealthCheck` (`{ type, category, message }` — server/services/cosHealthMonitor.js).
+export const summarizeHealthIssues = (issues) => {
+ if (!Array.isArray(issues) || issues.length === 0) return null;
+ const messages = issues.map((issue) => issue?.message).filter(Boolean);
+ // A message-less issue still has to read as an issue — `null` means "nothing
+ // to report", so callers that already know the list is non-empty never need a
+ // fallback of their own.
+ if (messages.length === 0) return `${issues.length} health issue${issues.length > 1 ? 's' : ''} detected`;
+ if (messages.length === 1) return messages[0];
+ return `${messages.length} health issues: ${messages.join(' · ')}`;
+};
+
+// StatCard tone for the Issues tile. `error`-type issues mean something is
+// broken; a warning-only check (e.g. a memory-hungry process) stays amber
+// rather than screaming red — matching how HealthTab colors the same list.
+// 'default' (not null) so a zero-issue tile keeps its explicit gray icon.
+export const healthIssueTone = (issues) => {
+ if (!Array.isArray(issues) || issues.length === 0) return 'default';
+ return issues.some((issue) => issue?.type === 'error') ? 'critical' : 'warning';
+};
+
// Agent option toggles for task metadata (useWorktree, openPR, simplify, requireApproval).
export const AGENT_OPTIONS = [
{ field: 'requireApproval', label: 'Require approval', shortLabel: 'Apr', description: 'Queue as awaiting-approve and do not auto-run — including Run Now — until you approve. Off (default): Run Now starts immediately; scheduled runs still follow the confidence and safety gates.' },
diff --git a/client/src/components/cos/constants.test.js b/client/src/components/cos/constants.test.js
index 66563fb130..f9e0e99172 100644
--- a/client/src/components/cos/constants.test.js
+++ b/client/src/components/cos/constants.test.js
@@ -13,7 +13,9 @@ import {
MUSE_ROOT_MOTION_CLIPS,
resolveMuseMotion,
MODEL_CAPABLE_CLI_REVIEWERS,
- reviewerLabel
+ reviewerLabel,
+ summarizeHealthIssues,
+ healthIssueTone
} from './constants';
// These mirror the server's domainBudgets/domainAutonomy helpers so the UI's
@@ -217,4 +219,46 @@ describe('reviewerLabel', () => {
expect(reviewerLabel('@octocat')).toBe('@octocat');
});
});
+
+// A warning-level health issue put the CoS avatar in `investigating` while the
+// status bubble showed the generic "Investigating issue..." and the Issues tile
+// was an inert number. Both helpers exist so the UI can name the issue and color
+// the tile by severity.
+describe('summarizeHealthIssues', () => {
+ it('returns null when there is nothing to report', () => {
+ expect(summarizeHealthIssues([])).toBeNull();
+ expect(summarizeHealthIssues(null)).toBeNull();
+ expect(summarizeHealthIssues(undefined)).toBeNull();
+ });
+
+ it('names the single issue verbatim', () => {
+ expect(summarizeHealthIssues([{ type: 'warning', category: 'memory', message: 'High memory usage in: example-app (900MB)' }]))
+ .toBe('High memory usage in: example-app (900MB)');
+ });
+
+ it('counts and joins multiple issues', () => {
+ expect(summarizeHealthIssues([{ message: 'a' }, { message: 'b' }])).toBe('2 health issues: a \u00b7 b');
+ });
+
+ it('still reads as an issue when the payload carries no message', () => {
+ expect(summarizeHealthIssues([{ type: 'error' }])).toBe('1 health issue detected');
+ expect(summarizeHealthIssues([{ type: 'error' }, {}])).toBe('2 health issues detected');
+ });
+});
+
+describe('healthIssueTone', () => {
+ it('stays neutral with no issues', () => {
+ expect(healthIssueTone([])).toBe('default');
+ expect(healthIssueTone(null)).toBe('default');
+ });
+
+ it('keeps warning-only checks amber rather than red', () => {
+ expect(healthIssueTone([{ type: 'warning' }, { type: 'warning' }])).toBe('warning');
+ });
+
+ it('escalates to critical when any issue is an error', () => {
+ expect(healthIssueTone([{ type: 'warning' }, { type: 'error' }])).toBe('critical');
+ });
+});
+
// @vitest-environment node
diff --git a/client/src/components/cos/index.js b/client/src/components/cos/index.js
index 53d13f4822..f2f890ca50 100644
--- a/client/src/components/cos/index.js
+++ b/client/src/components/cos/index.js
@@ -1,5 +1,5 @@
// Constants
-export { TABS, AGENT_STATES, STATE_MESSAGES, MEMORY_TYPES, MEMORY_TYPE_COLORS } from './constants';
+export { TABS, AGENT_STATES, STATE_MESSAGES, MEMORY_TYPES, MEMORY_TYPE_COLORS, summarizeHealthIssues, healthIssueTone } from './constants';
// Avatar/Character Components
// The five three.js *CoSAvatar variants are intentionally NOT re-exported:
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index a219c4fdff..a2f7f28080 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -16,6 +16,8 @@ import PageSkeleton from '../components/ui/PageSkeleton';
import {
TABS,
STATE_MESSAGES,
+ summarizeHealthIssues,
+ healthIssueTone,
CoSCharacter,
StateLabel,
TerminalCoSPanel,
@@ -198,10 +200,13 @@ export default function ChiefOfStaff() {
const newState = deriveAgentState(statusData, agentsData, healthData);
setAgentState(newState);
- // Use default state message - real messages come from socket events
+ // Default state message — richer messages come from socket events. The one
+ // state whose default is useless is `investigating`: only a health issue
+ // gets us here, so name it rather than saying "Investigating issue..." next
+ // to an Active count of 0 with no agent to inspect.
setStatusMessage(statusData?.paused
? `Paused${statusData.pauseReason ? ` — ${statusData.pauseReason}` : ''}`
- : STATE_MESSAGES[newState]);
+ : (newState === 'investigating' && summarizeHealthIssues(healthData?.issues)) || STATE_MESSAGES[newState]);
// Set active agent metadata for dynamic avatar (use first running agent)
const runningAgent = agentsData.find(a => a.status === 'running');
@@ -362,7 +367,7 @@ export default function ChiefOfStaff() {
// (see the note by the redirect effect). Banner refreshes on the next poll.
if (data.issues?.length > 0) {
setAgentState('investigating');
- setStatusMessage(`Health check: ${data.issues.length} issue${data.issues.length > 1 ? 's' : ''} found`);
+ setStatusMessage(summarizeHealthIssues(data.issues));
setSpeaking(true);
setTimeout(() => setSpeaking(false), 2000);
}
@@ -531,7 +536,7 @@ export default function ChiefOfStaff() {
// count refreshes on the next fetchData poll instead (see the note above).
toast.success('Health check complete');
if (result.issues?.length > 0) {
- setStatusMessage(`Health: ${result.issues.length} issue${result.issues.length > 1 ? 's' : ''} detected`);
+ setStatusMessage(summarizeHealthIssues(result.issues));
} else {
setAgentState('sleeping');
setStatusMessage("Health check passed - all systems OK");
@@ -545,10 +550,6 @@ export default function ChiefOfStaff() {
agents.filter(a => a.status === 'running').length,
[agents]
);
- const hasIssues = useMemo(() =>
- (health?.issues?.length || 0) > 0,
- [health?.issues?.length]
- );
// Memoize pending task count
const pendingTaskCount = useMemo(() =>
@@ -600,6 +601,20 @@ export default function ChiefOfStaff() {
onClick: () => navigate('/cos/learning'),
};
+ // The Issues tile is the only place the UI admits CoS found something wrong,
+ // so it has to click through to the detail. Without that, a warning-level
+ // health issue parked the avatar on "Investigating" with Active 0, no agent
+ // to open, and the offending message reachable only by guessing at the Health
+ // tab. `title` surfaces the same summary on hover/touch-and-hold.
+ const healthIssues = health?.issues || [];
+ const issuesStatProps = {
+ label: 'Issues',
+ value: healthIssues.length,
+ tone: healthIssueTone(healthIssues),
+ title: summarizeHealthIssues(healthIssues) || 'No issues detected — view system health',
+ onClick: () => navigate('/cos/health'),
+ };
+
// Compact stats card grid — rendered both inside the desktop CoS sidebar and
// the mobile compressed header so the metrics always live "inside" CoS.
const statsGridCards = (
@@ -624,9 +639,8 @@ export default function ChiefOfStaff() {
compact
/>
<StatCard
- label="Issues"
- value={health?.issues?.length || 0}
- icon={<AlertCircle className={`w-4 h-4 ${hasIssues ? 'text-port-error' : 'text-gray-500'}`} />}
+ {...issuesStatProps}
+ icon={<AlertCircle className="w-4 h-4" />}
compact
/>
<StatCard
@@ -816,7 +830,7 @@ export default function ChiefOfStaff() {
<StatCard label="Active" value={activeAgentCount} icon={<Cpu className="w-4 h-4 text-port-accent" />} active={activeAgentCount > 0} compact />
<StatCard label="Pending" value={pendingTaskCount} icon={<Clock className="w-4 h-4 text-port-warning" />} compact />
<StatCard label="Done" value={status?.stats?.tasksCompleted || 0} icon={<CheckCircle className="w-4 h-4 text-port-success" />} compact />
- <StatCard label="Issues" value={health?.issues?.length || 0} icon={<AlertCircle className={`w-4 h-4 ${hasIssues ? 'text-port-error' : 'text-gray-500'}`} />} compact />
+ <StatCard {...issuesStatProps} icon={<AlertCircle className="w-4 h-4" />} compact />
</div>
</div>
)}
@@ -960,9 +974,8 @@ export default function ChiefOfStaff() {
mini
/>
<StatCard
- label="Issues"
- value={health?.issues?.length || 0}
- 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'}`} />}
+ {...issuesStatProps}
+ icon={<AlertCircle className="w-3 h-3 sm:w-4 sm:h-4 lg:w-5 lg:h-5" />}
mini
/>
{/* Learning Health - clickable to go to Learning tab */}
diff --git a/client/src/pages/ChiefOfStaff.test.jsx b/client/src/pages/ChiefOfStaff.test.jsx
index 9997306378..ecfebba51d 100644
--- a/client/src/pages/ChiefOfStaff.test.jsx
+++ b/client/src/pages/ChiefOfStaff.test.jsx
@@ -576,3 +576,82 @@ describe('ChiefOfStaff stale queue-read guard', () => {
expect(screen.getByText('FRESH in-progress copy')).toBeInTheDocument();
});
});
+
+// A single warning-level health issue parked the avatar on "Investigating
+// issue..." with Active 0. Nothing on screen said what was being investigated,
+// and the Issues tile was an inert <div> holding the number 1, so the detail was
+// reachable only by guessing at the Health tab.
+describe('ChiefOfStaff Issues card', () => {
+ const memoryWarning = {
+ type: 'warning',
+ category: 'memory',
+ message: 'High memory usage in: example-app (900MB)',
+ };
+
+ const renderWithIssues = (issues) => {
+ api.getCosStatus.mockResolvedValue({ running: true, config, stats: {} });
+ api.getCosHealth.mockResolvedValue({ lastCheck: '2026-01-01T00:00:00.000Z', issues });
+ return render(
+ <MemoryRouter initialEntries={['/cos/config']}>
+ <Routes>
+ <Route path="/cos/:tab" element={<ChiefOfStaff />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+ };
+
+ // Same "never index a match list" rule as the Learning card above: the page
+ // paints the Issues tile in up to four places (desktop sidebar, mobile grid,
+ // the compressed header, and the Tailwind-`hidden` ascii `mini` bar, all still
+ // in the jsdom tree). Hold every variant to the contract.
+ const issueCards = async () => {
+ const cards = await screen.findAllByRole('button', { name: /^Issues:/ });
+ expect(cards.length).toBeGreaterThan(0);
+ return cards;
+ };
+
+ it('names the health issue in the status bubble instead of the generic investigating line', async () => {
+ renderWithIssues([memoryWarning]);
+
+ expect(await screen.findByText(memoryWarning.message)).toBeInTheDocument();
+ expect(screen.queryByText('Investigating issue...')).not.toBeInTheDocument();
+ });
+
+ it('summarizes the count when more than one issue is open', async () => {
+ renderWithIssues([memoryWarning, { type: 'error', category: 'processes', message: 'example-app failed to auto-restart' }]);
+
+ expect(await screen.findByText(/^2 health issues: /)).toBeInTheDocument();
+ });
+
+ it('makes every Issues tile a button that carries the issue summary', async () => {
+ renderWithIssues([memoryWarning]);
+
+ for (const card of await issueCards()) {
+ expect(card).toHaveAttribute('title', memoryWarning.message);
+ expect(within(card).getByText('1')).toBeInTheDocument();
+ }
+ });
+
+ it('opens the Health tab when the tile is clicked', async () => {
+ renderWithIssues([memoryWarning]);
+ const cards = await issueCards();
+
+ // Clicking the first is enough: the assertion above pins every variant to
+ // the same props object, and the click swaps the route out from under the
+ // rest of the list.
+ fireEvent.click(cards[0]);
+
+ const panel = await screen.findByRole('tabpanel');
+ expect(panel).toHaveAttribute('id', 'tabpanel-health');
+ expect(within(panel).getByText(memoryWarning.message)).toBeInTheDocument();
+ });
+
+ it('stays a click-through to Health when there are no issues at all', async () => {
+ renderWithIssues([]);
+
+ for (const card of await issueCards()) {
+ expect(card).toHaveAttribute('title', 'No issues detected — view system health');
+ expect(within(card).getByText('0')).toBeInTheDocument();
+ }
+ });
+});
diff --git a/server/routes/cosInsightRoutes.js b/server/routes/cosInsightRoutes.js
index 23bb6beca5..81c5415326 100644
--- a/server/routes/cosInsightRoutes.js
+++ b/server/routes/cosInsightRoutes.js
@@ -100,13 +100,19 @@ router.get('/actionable-insights', asyncHandler(async (req, res) => {
// 3. Health issues
const healthIssues = healthCheck?.issues || [];
if (healthIssues.length > 0) {
- const criticalIssues = healthIssues.filter(i => i.severity === 'critical');
+ // `type`, not `severity` — runHealthCheck stamps issues `error`/`warning`
+ // and never writes a `severity` field, so the old check matched nothing and
+ // a process that failed to auto-restart banner'd at `medium` alongside a
+ // memory warning.
+ const criticalIssues = healthIssues.filter(i => i.type === 'error');
insights.push({
type: 'health',
priority: criticalIssues.length > 0 ? 'critical' : 'medium',
icon: 'AlertTriangle',
title: `${healthIssues.length} system health issue${healthIssues.length > 1 ? 's' : ''}`,
- description: healthIssues[0]?.message || 'System health issue detected',
+ // Lead with the error when there is one — otherwise a red `critical`
+ // banner can describe an unrelated warning that merely sorted first.
+ description: (criticalIssues[0] || healthIssues[0])?.message || 'System health issue detected',
action: { label: 'Check Health', route: '/cos/health' },
count: healthIssues.length
});
diff --git a/server/routes/cosInsightRoutes.test.js b/server/routes/cosInsightRoutes.test.js
index 25bd66fa18..ae61478e9a 100644
--- a/server/routes/cosInsightRoutes.test.js
+++ b/server/routes/cosInsightRoutes.test.js
@@ -156,6 +156,53 @@ describe('CoS Insight Routes', () => {
}));
});
+ // The health insight filtered on a `severity` field runHealthCheck never
+ // writes, so a PM2 process that failed to auto-restart banner'd at the same
+ // muted `medium` priority as a memory warning.
+ it('raises the health insight to critical for an error-type issue', async () => {
+ cos.getAllTasks.mockResolvedValue({ user: null, cos: null });
+ taskLearning.getLearningInsights.mockResolvedValue({ skippedTypes: [] });
+ cos.getPendingAgentFeedbackCount.mockResolvedValue(0);
+ productivity.getOptimalTimeInfo.mockResolvedValue({ hasData: false });
+ cos.runHealthCheck.mockResolvedValue({
+ issues: [
+ { type: 'warning', category: 'memory', message: 'High memory usage in: example-app (900MB)' },
+ { type: 'error', category: 'processes', message: 'example-app failed to auto-restart' }
+ ]
+ });
+
+ const response = await request(app).get('/api/cos/actionable-insights');
+
+ expect(response.status).toBe(200);
+ expect(response.body.insights).toContainEqual(expect.objectContaining({
+ type: 'health',
+ priority: 'critical',
+ count: 2,
+ // …and it describes the error, not the warning that happened to sort first.
+ description: 'example-app failed to auto-restart',
+ action: { label: 'Check Health', route: '/cos/health' }
+ }));
+ });
+
+ it('keeps a warning-only health check at medium priority', async () => {
+ cos.getAllTasks.mockResolvedValue({ user: null, cos: null });
+ taskLearning.getLearningInsights.mockResolvedValue({ skippedTypes: [] });
+ cos.getPendingAgentFeedbackCount.mockResolvedValue(0);
+ productivity.getOptimalTimeInfo.mockResolvedValue({ hasData: false });
+ cos.runHealthCheck.mockResolvedValue({
+ issues: [{ type: 'warning', category: 'memory', message: 'High memory usage in: example-app (900MB)' }]
+ });
+
+ const response = await request(app).get('/api/cos/actionable-insights');
+
+ expect(response.status).toBe(200);
+ expect(response.body.insights).toContainEqual(expect.objectContaining({
+ type: 'health',
+ priority: 'medium',
+ description: 'High memory usage in: example-app (900MB)'
+ }));
+ });
+
it('should handle errors gracefully in parallel calls', async () => {
cos.getAllTasks.mockRejectedValue(new Error('fail'));
taskLearning.getLearningInsights.mockRejectedValue(new Error('fail'));