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: show unavailable app health when registry reads fail (#8674)

[._.]/ Adam Eivy468eafa69b35
diff --git a/client/src/components/SystemHealthWidget.jsx b/client/src/components/SystemHealthWidget.jsx
index be9167771e..b2b9b041c0 100644
--- a/client/src/components/SystemHealthWidget.jsx
+++ b/client/src/components/SystemHealthWidget.jsx
@@ -230,7 +230,9 @@ const SystemHealthWidget = memo(function SystemHealthWidget({ dashboardState })
<Zap size={14} className="hidden shrink-0 text-amber-400 @2xs:block" />
<span className="truncate text-xs text-gray-500">Services</span>
</div>
- {apps.total > 0 ? (
+ {apps.status === 'unavailable' ? (
+ <div className="text-lg font-bold text-port-warning">Apps unavailable</div>
+ ) : apps.total > 0 ? (
<>
<div className="text-lg @sm:text-xl font-bold text-white">
{apps.online}
diff --git a/client/src/components/SystemHealthWidget.test.jsx b/client/src/components/SystemHealthWidget.test.jsx
index 48de772e7e..9e96a874cb 100644
--- a/client/src/components/SystemHealthWidget.test.jsx
+++ b/client/src/components/SystemHealthWidget.test.jsx
@@ -73,6 +73,23 @@ describe('SystemHealthWidget', () => {
expect(screen.getByRole('link', { name: /Details/ })).toHaveAttribute('href', '/system-resources/overview');
});
+ it('hides unavailable app counts and restores the empty inventory after recovery', () => {
+ const apps = { total: 0, online: 0, stopped: 0, notStarted: 0, unknown: 0, unmanaged: 0, degraded: true, status: 'unavailable' };
+ const warnings = [{ type: 'probe-unavailable', source: 'apps', status: 'unavailable', severity: 'warning', message: 'Apps unavailable', dismissible: false }];
+ const { rerender } = renderWidget({ health: { ...HEALTH, apps, warnings }, refetchHealth: vi.fn() });
+ const card = screen.getByText('Services').parentElement.parentElement;
+ expect(card).toHaveTextContent('Apps unavailable');
+ expect(card).not.toHaveTextContent('No apps');
+ expect(card).not.toHaveTextContent('0');
+ expect(screen.queryByRole('button', { name: /Dismiss warning:/ })).not.toBeInTheDocument();
+
+ rerender(<MemoryRouter><SystemHealthWidget dashboardState={{ health: {
+ ...HEALTH, overallHealth: 'healthy', warnings: [], apps: { ...apps, degraded: false, status: undefined },
+ } }} /></MemoryRouter>);
+ expect(screen.getByText('No apps')).toBeInTheDocument();
+ expect(screen.queryByText('Apps unavailable')).not.toBeInTheDocument();
+ });
+
it('keeps failed disk and CoS probes visible without offering dismissal', () => {
const warnings = [
{ type: 'probe-unavailable', source: 'disk', status: 'unavailable', severity: 'warning', message: 'Disk status unavailable', dismissible: false },
diff --git a/client/src/pages/SystemHealthPage.test.jsx b/client/src/pages/SystemHealthPage.test.jsx
index bd2d8219be..3ecf894bec 100644
--- a/client/src/pages/SystemHealthPage.test.jsx
+++ b/client/src/pages/SystemHealthPage.test.jsx
@@ -93,6 +93,15 @@ describe('SystemHealthPage remediation links', () => {
expect(within(banner).getByRole('link', { name: /Disk usage breakdown/ })).toHaveAttribute('href', '/system-resources/storage');
});
+ it('shows the app probe warning without offering dismissal', async () => {
+ api.getSystemHealth.mockResolvedValue(withWarnings([
+ { type: 'probe-unavailable', source: 'apps', status: 'unavailable', severity: 'warning', message: 'Apps unavailable', dismissible: false },
+ ]));
+ renderPage();
+ expect(await screen.findByText('Apps unavailable')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Dismiss warning: Apps unavailable' })).not.toBeInTheDocument();
+ });
+
it('renders an unavailable disk card when the disk probe fails', async () => {
api.getSystemHealth.mockResolvedValue({
...HEALTH,
diff --git a/server/routes/health.test.js b/server/routes/health.test.js
index 47f637bdd1..eef84b9a4f 100644
--- a/server/routes/health.test.js
+++ b/server/routes/health.test.js
@@ -13,6 +13,7 @@ import { checkGhHealth } from '../services/github.js';
import { getBuildIdentity } from '../lib/buildIdentity.js';
import { getSettingsWithStatus, updateSettingsWith } from '../services/settings.js';
import { statfs } from 'fs/promises';
+import { getAppStatusSummary } from '../services/appProcessStatus.js';
vi.mock('../services/pm2.js', () => ({
listProcesses: vi.fn().mockResolvedValue([]),
@@ -158,6 +159,51 @@ describe('System Health Routes', () => {
expect(response.body).toHaveProperty('overallHealth');
});
+ it('reports an unreadable app aggregate without leaking details, then recovers to a healthy empty registry', async () => {
+ const privateDetail = 'EIO reading /private/example-registry.json';
+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
+ getAppStatusSummary.mockRejectedValueOnce(Object.assign(new Error(privateDetail), { code: 'EIO' }));
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true });
+ getSettingsWithStatus.mockResolvedValueOnce({ corrupt: false, settings: { health: {
+ dismissedWarnings: { 'probe-unavailable': { message: 'Apps unavailable' } }
+ } } });
+
+ try {
+ const response = await request(app).get('/api/system/health/details');
+ expect(response.status).toBe(200);
+ expect(response.body.overallHealth).toBe('warning');
+ expect(response.body.apps).toEqual({ total: 0, online: 0, stopped: 0, notStarted: 0, unknown: 0, unmanaged: 0, degraded: true, status: 'unavailable' });
+ expect(response.body.warnings).toEqual([
+ { type: 'probe-unavailable', source: 'apps', status: 'unavailable', severity: 'warning', message: 'Apps unavailable', dismissible: false }
+ ]);
+ expect(JSON.stringify(response.body)).not.toContain(privateDetail);
+ expect(JSON.stringify(response.body)).not.toContain('EIO');
+ expect(errorSpy).toHaveBeenCalledWith('❌ App health probe failed (operation=getAppStatusSummary, code=EIO)');
+ expect(JSON.stringify(errorSpy.mock.calls)).not.toContain(privateDetail);
+ const dismiss = await request(app).post('/api/system/health/warnings/probe-unavailable/dismiss').send({ message: 'Apps unavailable' });
+ expect(dismiss.status).toBe(400);
+
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true });
+ const recovered = await request(app).get('/api/system/health/details');
+ expect(recovered.body.overallHealth).toBe('healthy');
+ expect(recovered.body.apps.total).toBe(0);
+ expect(recovered.body.apps.status).toBeUndefined();
+ expect(recovered.body.warnings).toEqual([]);
+ } finally {
+ errorSpy.mockRestore();
+ }
+ });
+
+ it('keeps a known per-home PM2 failure distinct from an unavailable app aggregate', async () => {
+ getAppStatusSummary.mockResolvedValueOnce({ total: 2, online: 1, stopped: 0, notStarted: 0, unknown: 1, unmanaged: 0, degraded: true });
+ checkHealth.mockResolvedValueOnce({ connected: true, hasSchema: true });
+ const response = await request(app).get('/api/system/health/details');
+ expect(response.body.overallHealth).toBe('warning');
+ expect(response.body.apps).toMatchObject({ total: 2, online: 1, unknown: 1, degraded: true });
+ expect(response.body.apps.status).toBeUndefined();
+ expect(response.body.warnings).toEqual([{ type: 'apps', severity: 'warning', message: 'App status unavailable for 1 app(s) — PM2 read failed' }]);
+ });
+
it('reports failed disk and CoS probes without exposing their errors or hiding healthy measurements', async () => {
const diskError = 'private disk probe detail';
const cosError = 'private CoS probe detail';
diff --git a/server/services/systemHealthSnapshot.js b/server/services/systemHealthSnapshot.js
index 86c59e2c2c..8df8cf8d17 100644
--- a/server/services/systemHealthSnapshot.js
+++ b/server/services/systemHealthSnapshot.js
@@ -76,7 +76,11 @@ export async function getSystemHealthSnapshot() {
// Gather data in parallel
const [pm2Processes, appStatusSummary, cosStatus, cosPendingTaskIds, cosAgents, self, dbHealth, version, diskStats, memStats, healthSettings, forgeHealth, mediaCapacity, reviewerConfigHealth] = await Promise.all([
listProcessesStrict().catch(() => null),
- getAppStatusSummary().catch(() => ({ total: 0, online: 0, stopped: 0, notStarted: 0, unknown: 0, degraded: false, unmanaged: 0 })),
+ getAppStatusSummary().catch((error) => {
+ const code = typeof error?.code === 'string' && /^[A-Z][A-Z0-9_]{0,31}$/.test(error.code) ? error.code : 'unknown';
+ console.error(`❌ App health probe failed (operation=getAppStatusSummary, code=${code})`);
+ return failedProbe;
+ }),
cos.getStatus().catch((error) => {
console.error('Chief of Staff health probe failed', error);
return failedProbe;
@@ -160,7 +164,10 @@ export async function getSystemHealthSnapshot() {
// App status summary — PM2-managed apps only (Xcode/iOS-native projects
// have no detectable runtime state, so they're tracked under `unmanaged`
// and excluded from the running denominator)
- const appStats = appStatusSummary;
+ // Numeric placeholders preserve older clients' shape, not measurements.
+ const appStats = appStatusSummary === failedProbe
+ ? { total: 0, online: 0, stopped: 0, notStarted: 0, unknown: 0, unmanaged: 0, degraded: true, status: 'unavailable' }
+ : appStatusSummary;
// Determine overall health status. Each condition below records its
// severity on the warning itself rather than mutating `overallHealth`
@@ -217,7 +224,9 @@ export async function getSystemHealthSnapshot() {
// A degraded app summary means PM2 couldn't be read for one or more homes, so
// those apps' online/stopped status is unknown — surface it rather than letting
// the counts silently read as "everything not started."
- if (appStats.degraded) {
+ if (appStatusSummary === failedProbe) {
+ rawWarnings.push({ type: 'probe-unavailable', source: 'apps', status: 'unavailable', severity: 'warning', message: 'Apps unavailable', dismissible: false });
+ } else if (appStats.degraded) {
const unknown = appStats.unknown || 0;
rawWarnings.push({ type: 'apps', severity: 'warning', message: `App status unavailable for ${unknown} app(s) — PM2 read failed` });
}