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(schedule): report unavailable app schedule inputs (#11525)

[._.]/79096d4019f8
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsx
index cf5cf72c35..78c88303ee 100644
--- a/client/src/components/cos/tabs/ScheduleTab.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.jsx
@@ -45,6 +45,7 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr
const [searchParams, setSearchParams] = useSearchParams();
const [schedule, setSchedule] = useState(null);
const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
const label = searchParams.get('label') || '';
const setLabel = next => {
@@ -84,8 +85,14 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr
}, [searchParams, setSearchParams]);
const fetchSchedule = useCallback(async () => {
- const data = await api.getCosSchedule().catch(() => null);
- setSchedule(current => data || current);
+ const data = await api.getCosSchedule({ silent: true }).catch(err => {
+ setError(err?.message || 'Failed to load task schedule');
+ return null;
+ });
+ if (data) {
+ setSchedule(data);
+ setError(null);
+ }
setLoading(false);
return data;
}, []);
@@ -157,6 +164,7 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr
<div className="text-center py-8 text-gray-500">
<AlertCircle className="w-12 h-12 mx-auto mb-3 opacity-50" />
<p>Failed to load task schedule</p>
+ <button type="button" onClick={fetchSchedule} className="mt-3 underline">Retry</button>
</div>
);
}
@@ -187,6 +195,12 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr
</button>
</div>
+ {error && (
+ <Banner tone="error" icon={AlertCircle} title="Schedule unavailable — showing the last loaded schedule">
+ {error}
+ </Banner>
+ )}
+
{improvementDisabled && (
<Banner size="md" icon={AlertCircle} title="Improvement is disabled">
<div className="text-xs text-port-warning/80 mt-1">
diff --git a/client/src/components/cos/tabs/ScheduleTab.test.jsx b/client/src/components/cos/tabs/ScheduleTab.test.jsx
index d6e96309de..2fc5e02247 100644
--- a/client/src/components/cos/tabs/ScheduleTab.test.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.test.jsx
@@ -81,6 +81,39 @@ describe('mergeUpdatedTaskInterval', () => {
});
describe('ScheduleTab on-demand feedback', () => {
+ it('retains the last schedule on a failed refresh, shows the failure, and recovers', async () => {
+ const user = userEvent.setup();
+ api.getCodeReviewDefaults.mockResolvedValue({});
+ const schedule = { tasks: { review: { type: 'on-demand', enabled: true, displayName: 'Example Review' } } };
+ api.getCosSchedule
+ .mockResolvedValueOnce(schedule)
+ .mockRejectedValueOnce(new Error('app cadence unavailable'))
+ .mockResolvedValueOnce({ ...schedule, tasks: { review: { ...schedule.tasks.review, displayName: 'Recovered Review' } } });
+ render(<MemoryRouter><ScheduleTab apps={[]} providers={[]} /></MemoryRouter>);
+ expect(await screen.findByText('Example Review')).toBeVisible();
+
+ await user.click(screen.getByRole('button', { name: 'Refresh' }));
+ expect(await screen.findByRole('alert')).toHaveTextContent('Schedule unavailable — showing the last loaded schedule');
+ expect(screen.getByRole('alert')).toHaveTextContent('app cadence unavailable');
+ expect(screen.getByText('Example Review')).toBeVisible();
+
+ await user.click(screen.getByRole('button', { name: 'Refresh' }));
+ expect(await screen.findByText('Recovered Review')).toBeVisible();
+ expect(screen.queryByRole('alert')).not.toBeInTheDocument();
+ expect(api.getCosSchedule).toHaveBeenLastCalledWith({ silent: true });
+ });
+
+ it('allows an initial unavailable schedule to be retried successfully with an empty schedule', async () => {
+ const user = userEvent.setup();
+ api.getCodeReviewDefaults.mockResolvedValue({});
+ api.getCosSchedule.mockRejectedValueOnce(new Error('app registry unavailable')).mockResolvedValueOnce({ tasks: {} });
+ render(<MemoryRouter><ScheduleTab apps={[]} providers={[]} /></MemoryRouter>);
+ expect(await screen.findByText('Failed to load task schedule')).toBeVisible();
+ await user.click(screen.getByRole('button', { name: 'Retry' }));
+ expect(await screen.findByText('Task Schedule')).toBeVisible();
+ expect(screen.queryByText('Failed to load task schedule')).not.toBeInTheDocument();
+ });
+
it('names the selected app and paints the returned request before the refresh settles', async () => {
const user = userEvent.setup();
const request = {
diff --git a/client/src/components/cos/tabs/WorkflowTab.appSchedules.test.jsx b/client/src/components/cos/tabs/WorkflowTab.appSchedules.test.jsx
index a860fa9f9d..541474c902 100644
--- a/client/src/components/cos/tabs/WorkflowTab.appSchedules.test.jsx
+++ b/client/src/components/cos/tabs/WorkflowTab.appSchedules.test.jsx
@@ -6,7 +6,7 @@
*/
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
-import { render, screen, cleanup, act, within } from '@testing-library/react';
+import { render, screen, cleanup, act, within, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
const api = {
@@ -67,6 +67,20 @@ beforeEach(() => vi.clearAllMocks());
afterEach(cleanup);
describe('WorkflowTab per-app schedules', () => {
+ it('keeps the last app schedule visible when refresh fails and clears the error after recovery', async () => {
+ await render_(APP_SCHEDULED);
+ api.getCosWorkflow.mockRejectedValueOnce(new Error('app registry unavailable'));
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Refresh' })); });
+ expect(screen.getByText('app registry unavailable')).toBeVisible();
+ expect(screen.getByText('1 app · at 07:00')).toBeVisible();
+
+ api.getCosWorkflow.mockResolvedValueOnce(graph({ appSchedules: [], occurrences: [] }));
+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Refresh' })); });
+ expect(screen.queryByText('app registry unavailable')).not.toBeInTheDocument();
+ expect(screen.getByText('Unpinned runner queue')).toBeVisible();
+ expect(api.getCosWorkflow).toHaveBeenLastCalledWith(168, { silent: true });
+ });
+
it('gives an app-scheduled task a timeline track instead of the unpinned queue', async () => {
await render_(APP_SCHEDULED);
diff --git a/client/src/components/cos/tabs/WorkflowTab.jsx b/client/src/components/cos/tabs/WorkflowTab.jsx
index ee084eac7d..6a106c5109 100644
--- a/client/src/components/cos/tabs/WorkflowTab.jsx
+++ b/client/src/components/cos/tabs/WorkflowTab.jsx
@@ -350,7 +350,7 @@ export default function WorkflowTab({ apps, providers, providersLoaded }) {
const fetchGraph = useCallback(async () => {
const generation = ++fetchGeneration.current;
setLoading(true);
- const data = await api.getCosWorkflow(hours).catch(err => {
+ const data = await api.getCosWorkflow(hours, { silent: true }).catch(err => {
if (generation === fetchGeneration.current) setError(err?.message || 'Failed to load schedule');
return null;
});
diff --git a/client/src/components/cos/tabs/WorkflowTab.timeline.test.jsx b/client/src/components/cos/tabs/WorkflowTab.timeline.test.jsx
index 444cefd2b0..b314a4c8b8 100644
--- a/client/src/components/cos/tabs/WorkflowTab.timeline.test.jsx
+++ b/client/src/components/cos/tabs/WorkflowTab.timeline.test.jsx
@@ -76,7 +76,7 @@ describe('WorkflowTab timeline defaults and layout', () => {
);
});
- expect(api.getCosWorkflow).toHaveBeenCalledWith(168);
+ expect(api.getCosWorkflow).toHaveBeenCalledWith(168, { silent: true });
const sevenDaysBtn = screen.getByRole('button', { name: '7 days' });
expect(sevenDaysBtn.className).toContain('text-port-accent');
const twentyFourHoursBtn = screen.getByRole('button', { name: '24 hours' });
diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.js
index f718149112..60bddf9465 100644
--- a/client/src/services/apiAgents.js
+++ b/client/src/services/apiAgents.js
@@ -419,7 +419,7 @@ export const triggerCosJob = (id, { formValues = null, ...options } = {}) => req
export const deleteCosJob = (id, options = {}) => request(`/cos/jobs/${id}`, { method: 'DELETE', ...options });
// Workflow visualizer — canonical scheduled-task ordering across tasks + jobs
-export const getCosWorkflow = (hours = 168) => request(`/cos/workflow?hours=${hours}`);
+export const getCosWorkflow = (hours = 168, options) => request(`/cos/workflow?hours=${hours}`, options);
// Feature Agents
export const getFeatureAgents = () => request('/feature-agents');
diff --git a/server/routes/cosScheduleRoutes.test.js b/server/routes/cosScheduleRoutes.test.js
index c62430cd75..a6565e1496 100644
--- a/server/routes/cosScheduleRoutes.test.js
+++ b/server/routes/cosScheduleRoutes.test.js
@@ -70,6 +70,19 @@ describe('CoS Schedule Routes', () => {
});
describe('GET /api/cos/schedule', () => {
+ it('surfaces unavailable schedule inputs as errors and recovers on the next read', async () => {
+ taskSchedule.getScheduleStatus
+ .mockRejectedValueOnce(new Error('app registry unavailable'))
+ .mockRejectedValueOnce(new Error('app cadence unavailable'))
+ .mockResolvedValueOnce({ tasks: {}, onDemandRequests: [] });
+
+ expect((await request(app).get('/api/cos/schedule')).status).toBe(500);
+ expect((await request(app).get('/api/cos/schedule')).status).toBe(500);
+ const recovered = await request(app).get('/api/cos/schedule');
+ expect(recovered.status).toBe(200);
+ expect(recovered.body).toEqual({ tasks: {}, onDemandRequests: [] });
+ });
+
it('should return schedule status', async () => {
taskSchedule.getScheduleStatus.mockResolvedValue({ tasks: [], enabled: true });
diff --git a/server/services/taskSchedule.js b/server/services/taskSchedule.js
index 0bb89a25dc..24affae41c 100644
--- a/server/services/taskSchedule.js
+++ b/server/services/taskSchedule.js
@@ -1360,7 +1360,7 @@ async function resolveHiddenAppSchedules(taskType, interval, activeApps, allOver
if (candidates.length === 0) return [];
const checks = await mapWithConcurrency(candidates, 8, ({ app }) =>
- shouldRunTask(taskType, app.id, { featureEnabled, schedule }).catch(() => null));
+ shouldRunTask(taskType, app.id, { featureEnabled, schedule }));
return candidates.map(({ app, cronExpression }, i) => ({
appId: app.id,
appName: app.name || app.id,
@@ -1390,7 +1390,7 @@ export async function getScheduleStatus() {
};
// Fetch active apps once for per-app override aggregation
- const activeApps = await getActiveApps().catch(() => []);
+ const activeApps = await getActiveApps();
const totalAppCount = activeApps.length;
for (const [taskType, interval] of Object.entries(schedule.tasks)) {
diff --git a/server/services/taskSchedule.test.js b/server/services/taskSchedule.test.js
index bea12fc71d..933e439d52 100644
--- a/server/services/taskSchedule.test.js
+++ b/server/services/taskSchedule.test.js
@@ -2847,6 +2847,33 @@ describe('taskSchedule', () => {
})
describe('getScheduleStatus — appSchedules', () => {
+ it('rejects an unavailable registry and recovers with a valid empty registry', async () => {
+ mockSchedule({ tasks: { 'do-release': { type: 'on-demand', enabled: true, runAfter: [] } } })
+ getActiveApps.mockRejectedValueOnce(new Error('app registry unavailable'))
+
+ await expect(getScheduleStatus()).rejects.toThrow('app registry unavailable')
+
+ getActiveApps.mockResolvedValue([])
+ const task = (await getScheduleStatus()).tasks['do-release']
+ expect(task).toMatchObject({ totalAppCount: 0, enabledAppCount: 0, appOverrides: {}, appSchedules: [] })
+ expect(task.status).toMatchObject({ shouldRun: false, reason: 'on-demand-only' })
+ })
+
+ it('rejects unavailable app cadence instead of reporting a not-due row, then recovers', async () => {
+ await withRealCron()
+ getActiveApps.mockResolvedValue([{ id: 'app-1', name: 'Example App' }])
+ getAppTaskTypeOverrides.mockResolvedValue({ 'do-release': { enabled: true, interval: '15 9 * * *' } })
+ getAppTaskTypeInterval.mockRejectedValueOnce(new Error('app cadence unavailable'))
+ mockSchedule({ tasks: { 'do-release': { type: 'on-demand', enabled: true, runAfter: [] } } })
+
+ await expect(getScheduleStatus()).rejects.toThrow('app cadence unavailable')
+
+ getAppTaskTypeInterval.mockResolvedValue('15 9 * * *')
+ expect((await getScheduleStatus()).tasks['do-release'].appSchedules).toEqual([
+ expect.objectContaining({ appId: 'app-1', nextRunAt: '2026-01-01T17:15:00.000Z', reason: 'cron-cooldown' })
+ ])
+ })
+
// vi.clearAllMocks() keeps a mockResolvedValue, so these cases restore the
// apps.js factory defaults rather than leaking an app roster into the
// suites that follow.