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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat: remove recommended maintenance order card and runner from cos schedule tab
[._.]/ Adam Eivy8326c6543d17
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsxindex 3cc19c057f..cf5cf72c35 100644--- a/client/src/components/cos/tabs/ScheduleTab.jsx+++ b/client/src/components/cos/tabs/ScheduleTab.jsx@@ -9,7 +9,6 @@ import { CodeReviewDefaultsProvider } from '../../../hooks/useCodeReviewDefaultsimport { useAppOverrideActions } from '../../../hooks/useAppOverrideActions';import AppTaskTypeSection from './schedule/AppTaskTypeSection';import TaskConfigDrawer from './schedule/TaskConfigDrawer';-import MaintenanceRunForm from './schedule/MaintenanceRunForm';import { TASK_FILTERS, DEFAULT_FILTER_ID, TASK_SORTS, DEFAULT_SORT_ID, suggestedOrderSteps } from './schedule/scheduleConstants';export function mergeUpdatedTaskInterval(schedule, taskType, interval, status) {@@ -188,14 +187,6 @@ export default function ScheduleTab({ apps, providers, providersLoaded, activePr</button></div>- <Banner size="md" title="Recommended maintenance order">- <p className="text-xs">Choose how to handle findings, then review the steps before starting.</p>- <details className="mt-2">- <summary className="cursor-pointer text-sm font-medium">Run maintenance now</summary>- <MaintenanceRunForm schedule={{ ...schedule, tasks }} apps={apps} providers={providers} providersLoaded={providersLoaded} improvementDisabled={improvementDisabled} daemonRunning={daemonRunning} onRefresh={fetchSchedule} />- </details>- </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.jsxindex 21d2912f30..cf63d22b2b 100644--- a/client/src/components/cos/tabs/ScheduleTab.test.jsx+++ b/client/src/components/cos/tabs/ScheduleTab.test.jsx@@ -8,7 +8,6 @@ const toast = vi.hoisted(() => ({ success: vi.fn(), error: vi.fn() }));const api = vi.hoisted(() => ({getCodeReviewDefaults: vi.fn(),getCosSchedule: vi.fn(),- getMaintenanceRuns: vi.fn().mockResolvedValue({ runs: [] }),triggerCosOnDemandTask: vi.fn(),updateCosTaskInterval: vi.fn(),getLocalLlmStatus: vi.fn().mockResolvedValue(null),@@ -217,16 +216,18 @@ describe('Schedule labels', () => {});});-it('keeps maintenance selections and the last saved schedule after a refresh failure', async () => {+it('keeps the last saved schedule after a refresh failure', async () => {const user = userEvent.setup();api.getCodeReviewDefaults.mockResolvedValue({});- api.getCosSchedule.mockReset().mockResolvedValueOnce({ tasks: {} }).mockRejectedValueOnce(new Error('offline'));+ api.getCosSchedule.mockReset().mockResolvedValueOnce({+ tasks: {+ security: { type: 'on-demand', enabled: true, displayName: 'Security' },+ },+ }).mockRejectedValueOnce(new Error('offline'));render(<MemoryRouter><ScheduleTab apps={[{ id: 'example', name: 'Example App' }]} providers={[]} providersLoaded /></MemoryRouter>);- await user.click(await screen.findByText('Run maintenance now'));- await user.selectOptions(screen.getByLabelText('App'), 'example');+ expect(await screen.findByText('Security')).toBeVisible();await user.click(screen.getByRole('button', { name: 'Refresh' }));await waitFor(() => expect(api.getCosSchedule).toHaveBeenCalledTimes(2));- expect(screen.getByLabelText('App')).toHaveValue('example');- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();+ expect(screen.getByText('Security')).toBeVisible();expect(screen.queryByText('Failed to load task schedule')).not.toBeInTheDocument();});diff --git a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsx b/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsxdeleted file mode 100644index 05fa43b87b..0000000000--- a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.jsx+++ /dev/null@@ -1,252 +0,0 @@-import { useCallback, useEffect, useRef, useState } from 'react';-import { Link } from 'react-router';-import socket from '../../../../services/socket';-import MaintenanceStepSettings from './MaintenanceStepSettings';-import MaintenanceRunStatus from './MaintenanceRunStatus';-import MaintenanceStepChecklist from './MaintenanceStepChecklist';-import { buildMaintenanceSteps } from '../../../../../../server/lib/maintenanceSequence';-import ProviderModelSelector from '../../../ProviderModelSelector';-import * as api from '../../../../services/api';-import { useAutoRefetch } from '../../../../hooks/useAutoRefetch';-import { buildQuotaBurnTaskCatalog, maintenancePrerequisites, taskSourceHref } from '../../../../lib/quotaBurnTasks';-import { getAppName } from '../../../../utils/formatters';-import { effortAwareModelOptions, enabledProcessProviderFilter } from '../../../../utils/providers';--const RUNS_POLL_MS = 15_000;--export default function MaintenanceRunForm({ schedule, apps = [], providers = [], providersLoaded, improvementDisabled, daemonRunning, onRefresh }) {- const [appId, setAppId] = useState('');- const [providerId, setProviderId] = useState('');- const [model, setModel] = useState('');- const [effort, setEffort] = useState('');- const [claimHandler, setClaimHandler] = useState({ providerId: '', model: '', effort: '' });- const [mode, setMode] = useState('file-issues');- const [claimBetweenAudits, setClaimBetweenAudits] = useState(true);- const [consent, setConsent] = useState(false);- const [busy, setBusy] = useState(false);- const [preparing, setPreparing] = useState(false);- const [message, setMessage] = useState('');- // `null` = not read yet, `[]` = read and empty — the first read must happen- // even when there is nothing to show.- const [runs, setRuns] = useState(null);- const revision = useRef(0);- const availableProviders = providers.filter(enabledProcessProviderFilter);- const provider = availableProviders.find(entry => entry.id === providerId);- const groups = buildQuotaBurnTaskCatalog({ schedule, apps });- const prerequisites = maintenancePrerequisites(groups, appId, { mode, claimBetweenAudits });- const plannedSteps = buildMaintenanceSteps({ appId, idPrefix: 'preview', mode, claimBetweenAudits });- const hasClaims = plannedSteps.some(step => step.drain);- const claimProvider = availableProviders.find(entry => entry.id === claimHandler.providerId);- const claimReady = !hasClaims || !claimHandler.providerId || Boolean(claimProvider && claimHandler.model);- const ready = Boolean(appId) && prerequisites.length === 0;- const blocked = improvementDisabled || daemonRunning === false;-- const fetchRuns = useCallback(async () => {- const requestedRevision = revision.current;- const response = await api.getMaintenanceRuns({ silent: true }).catch(() => null);- // A failed read stays `null` so the poll keeps trying; only a real answer- // settles the list.- if (response && requestedRevision === revision.current) setRuns(response.runs || []);- }, []);- const anyRunning = (runs || []).some(run => run.status === 'running');- // One read on mount, then polling only while a run is in flight — an idle- // form costs nothing, and a start/resume already holds the fresh record.- const { refetch: refreshRuns } = useAutoRefetch(fetchRuns, RUNS_POLL_MS, { pollOnly: true, enabled: runs === null || anyRunning, immediate: runs === null });-- useEffect(() => {- const subscribe = () => { socket.emit('cos:subscribe'); fetchRuns(); };- const update = updated => {- revision.current += 1;- setRuns(current => {- const previous = (current || []).find(entry => entry.id === updated.id);- if (previous?.updatedAt > updated.updatedAt) return current;- return [updated, ...(current || []).filter(entry => entry.id !== updated.id)];- });- };- socket.on('cos:maintenance:updated', update);- socket.on('connect', subscribe);- socket.emit('cos:subscribe');- return () => {- socket.off('cos:maintenance:updated', update);- socket.off('connect', subscribe);- };- }, [fetchRuns]);-- const prepare = async () => {- if (busy || !onRefresh || !prerequisites.length || prerequisites.some(item => item.unavailable)) return;- setBusy(true);- setPreparing(true);- setMessage('Enabling required tasks…');- const save = async () => {- for (const { taskType, settings, enableApp } of prerequisites) {- if (Object.keys(settings).length) {- const result = await api.updateCosTaskInterval(taskType, settings, { silent: true });- if (!result?.success) throw new Error(`Could not update ${taskType}`);- }- if (enableApp) {- const result = await api.updateAppTaskTypeOverride(appId, taskType, { enabled: true }, { silent: true });- if (!result?.success) throw new Error(`Could not enable ${taskType} for this app`);- }- }- return true;- };- const saved = await save().catch(error => {- setMessage(`Setup incomplete: ${error.message}. Saved changes are kept; retry to finish.`);- return false;- });- // Refresh even after a partial save so retries use the persisted settings.- const refreshed = await onRefresh().catch(() => false);- if (!refreshed) setMessage(current => saved- ? 'Could not refresh task settings. Refresh the schedule before running maintenance.'- : `${current} Refreshing the schedule also failed.`);- else if (saved) setMessage('Required task settings saved.');- setPreparing(false);- setBusy(false);- };-- const describe = result => (result?.dispatched- ? `Maintenance started with ${result.taskType}. Later steps follow as each one finishes; progress is shown below and in Tasks.`- : `Maintenance run saved; holding: ${result?.reason || 'nothing dispatched'}. It retries on its own.`);-- const run = async () => {- if (busy || blocked || !ready || !claimReady || !provider || !model || !consent) return;- setBusy(true);- setMessage('Starting maintenance…');- const response = await api.startMaintenanceRun({ appId, providerId, model, effort: effort || null, mode, claimBetweenAudits, ...(hasClaims && claimHandler.providerId ? { claimHandler: { ...claimHandler, effort: claimHandler.effort || null } } : {}) }, { silent: true }).catch(error => {- setMessage(`Could not start maintenance: ${error.message}`);- return null;- });- if (response?.run) {- revision.current += 1;- setRuns(current => [response.run, ...(current || []).filter(entry => entry.id !== response.run.id)]);- setMessage(describe(response.result));- setConsent(false);- }- setBusy(false);- };-- const applyRun = updated => {- if (!updated) return;- revision.current += 1;- setRuns(current => (current || []).map(entry => (entry.id === updated.id && !(entry.updatedAt > updated.updatedAt) ? updated : entry)));- };- const stop = async id => {- const response = await api.stopMaintenanceRun(id, { silent: true }).catch(error => {- setMessage(`Could not stop the run: ${error.message}`);- return null;- });- applyRun(response?.run);- };- const visibleRuns = (runs || []).filter(entry => entry.status === 'running');-- return (- <div className="mt-3 space-y-3 text-sm">- <div className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,18rem),24rem))] gap-3">- <label htmlFor="maintenance-run-app" className="block min-w-0">- App- <select id="maintenance-run-app" value={appId} disabled={busy} onChange={event => setAppId(event.target.value)} className="mt-1 w-full bg-port-bg border border-port-border rounded p-2 text-white">- <option value="">Select an app</option>- {apps.filter(app => app.archived !== true).map(app => <option key={app.id} value={app.id}>{app.name}</option>)}- </select>- </label>- <label htmlFor="maintenance-run-mode" className="block min-w-0">- Audit mode- <select id="maintenance-run-mode" value={mode} disabled={busy} onChange={event => { setMode(event.target.value); setConsent(false); }} className="mt-1 w-full bg-port-bg border border-port-border rounded p-2 text-white">- <option value="file-issues">File issues</option>- <option value="fix">Audit and fix</option>- </select>- </label>- {mode === 'file-issues' && <label htmlFor="maintenance-run-claims" className="block min-w-0">- Issue handling- <select id="maintenance-run-claims" value={String(claimBetweenAudits)} disabled={busy} onChange={event => { setClaimBetweenAudits(event.target.value === 'true'); setConsent(false); }} className="mt-1 w-full bg-port-bg border border-port-border rounded p-2 text-white">- <option value="true">Resolve issues between audits</option>- <option value="false">Leave issues open for review</option>- </select>- </label>}- </div>- <p className="text-xs">{mode === 'fix'- ? 'Fix findings in each audit; finish with documentation and one final claim pass.'- : claimBetweenAudits ? 'Claim passes resolve the backlog before the next audit.' : 'File findings for review; run documentation last. No claim jobs.'}</p>- <div className="space-y-2">- <p className="font-medium">Planned steps · {plannedSteps.length}</p>- <MaintenanceStepChecklist steps={plannedSteps} label="Planned maintenance steps" />- </div>- <p className="font-medium">Audit and documentation handler</p>- <ProviderModelSelector- providers={availableProviders}- selectedProviderId={providerId}- selectedModel={model}- availableModels={provider ? effortAwareModelOptions(provider, model) : []}- onProviderChange={next => { setProviderId(next); setModel(''); setEffort(''); setConsent(false); }}- onModelChange={next => { setModel(next); setConsent(false); }}- effort={effort}- onEffortChange={next => { setEffort(next); setConsent(false); }}- emptyProviderOption="Select a subscription provider"- emptyModelOption="Select a model" includeDefaultModel- alwaysShowModel- loading={!providersLoaded}- disabled={busy}- />- {hasClaims && <fieldset className="space-y-2">- <legend className="font-medium">Claim-issue handler</legend>- <ProviderModelSelector- providers={availableProviders}- label="Claim provider"- selectedProviderId={claimHandler.providerId}- selectedModel={claimHandler.model}- availableModels={claimProvider ? effortAwareModelOptions(claimProvider, claimHandler.model) : []}- onProviderChange={next => { setClaimHandler({ providerId: next, model: '', effort: '' }); setConsent(false); }}- onModelChange={next => { setClaimHandler(current => ({ ...current, model: next })); setConsent(false); }}- effort={claimHandler.effort}- onEffortChange={next => { setClaimHandler(current => ({ ...current, effort: next })); setConsent(false); }}- emptyProviderOption="Same as audit handler"- emptyModelOption="Select a model" includeDefaultModel- alwaysShowModel={Boolean(claimHandler.providerId)}- loading={!providersLoaded}- disabled={busy}- />- </fieldset>}- {appId && !ready && <div className="space-y-2">- <p role="status">Run now needs these saved task settings:</p>- <ul className="list-disc pl-5 space-y-1">- {prerequisites.map(item => <li key={item.taskType}>- <Link className="underline" to={taskSourceHref(item)}>{item.taskType}</Link>: {item.reason}- </li>)}- </ul>- {onRefresh && !prerequisites.some(item => item.unavailable) && <>- <p className="text-xs">Enable the listed tasks globally and for this app. Claim jobs require perpetual mode. Existing schedules may also run.</p>- <button type="button" onClick={prepare} disabled={busy} className="px-3 py-1.5 bg-port-accent text-white rounded disabled:opacity-50">- {preparing ? 'Enabling…' : 'Enable required tasks'}- </button>- </>}- </div>}- {blocked && <p role="status">Enable Improvement and start the CoS daemon before running maintenance.</p>}- <p className="text-xs">Runs sequentially, without Quota Burn gates. Blank effort uses each task’s saved setting.</p>- <label className="flex items-start gap-2" htmlFor="maintenance-run-consent">- <input id="maintenance-run-consent" type="checkbox" checked={consent} disabled={busy} onChange={event => setConsent(event.target.checked)} />- <span>Run these steps now using the selected providers’ quota.</span>- </label>- <div className="flex items-center gap-3 flex-wrap">- <button type="button" onClick={run} disabled={busy || blocked || !ready || !claimReady || !provider || !model || !consent || !providersLoaded} className="px-3 py-1.5 bg-port-accent text-white rounded disabled:opacity-50">- {busy && !preparing ? 'Starting…' : 'Run now'}- </button>- <Link className="underline" to="/devtools/quota-burn">Schedule this sequence in Quota Burn instead</Link>- </div>- {message && <p role="status">{message}</p>}- {visibleRuns.length > 0 && <ul aria-label="Maintenance runs" className="space-y-2">- {visibleRuns.map(entry => {- return <li key={entry.id} className="border border-port-border rounded p-2 flex flex-wrap items-center gap-x-3 gap-y-1">- <span className="font-medium">{getAppName(entry.appId, apps, entry.appId)}</span>- <span className="text-xs">{entry.providerId}{entry.model ? ` · ${entry.model}` : ''}</span>- <MaintenanceRunStatus run={entry} showSteps renderStepSettings={step => (- <MaintenanceStepSettings key={`${step.id}:${JSON.stringify(step.overrides)}`} run={entry} step={step}- providers={availableProviders} loading={!providersLoaded} onSaved={applyRun} />- )} />- <button type="button" onClick={() => stop(entry.id)} className="px-2 py-1 text-xs bg-port-border rounded">Stop</button>- </li>;- })}- </ul>}- {visibleRuns.length > 0 && <button type="button" onClick={refreshRuns} className="text-xs underline">Refresh runs</button>}- </div>- );-}diff --git a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsx b/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsxdeleted file mode 100644index 4b36af17b2..0000000000--- a/client/src/components/cos/tabs/schedule/MaintenanceRunForm.test.jsx+++ /dev/null@@ -1,256 +0,0 @@-import { useState } from 'react';-import { beforeEach, describe, expect, it, vi } from 'vitest';-import { act, render, screen, waitFor, within } from '@testing-library/react';-import userEvent from '@testing-library/user-event';-import { MemoryRouter } from 'react-router';-import { MAINTENANCE_TASK_ORDER } from '../../../../lib/quotaBurnTasks';-import { MAINTENANCE_SEQUENCE_TYPES } from '../../../../../../server/lib/maintenanceSequence';-import MaintenanceRunForm from './MaintenanceRunForm';-import { findEnabledByRole } from '../../../../test/enabledBarrier.js';--const socket = vi.hoisted(() => ({ on: vi.fn(), off: vi.fn(), emit: vi.fn() }));-vi.mock('../../../../services/socket', () => ({ default: socket }));-const api = vi.hoisted(() => ({- getMaintenanceRuns: vi.fn(), startMaintenanceRun: vi.fn(), stopMaintenanceRun: vi.fn(),- updateCosTaskInterval: vi.fn(), updateAppTaskTypeOverride: vi.fn(),-}));-vi.mock('../../../../services/api', () => api);-const tasks = Object.fromEntries([...MAINTENANCE_TASK_ORDER, 'claim-issue'].map(taskType => [taskType, {- enabled: true, perpetual: taskType === 'claim-issue', appOverrides: { example: { enabled: true } },-}]));-const props = {- schedule: { tasks }, apps: [{ id: 'example', name: 'Example App' }],- providers: [{ id: 'claude', name: 'Claude', type: 'cli', command: 'claude', enabled: true, models: ['sonnet'] }],- providersLoaded: true, daemonRunning: true,-};-const steps = MAINTENANCE_SEQUENCE_TYPES.map((taskType, index) => ({ id: `maint-1-${index}`, taskRef: { taskType } }));-const runRecord = (overrides = {}) => ({- id: 'maint-1', appId: 'example', providerId: 'claude', model: 'sonnet', status: 'running', steps,- completed: { 'maint-1-0': 'done' }, active: { stepId: 'maint-1-1', taskType: 'claim-issue' }, reason: null, ...overrides,-});-const show = (overrides = {}) => render(<MemoryRouter><MaintenanceRunForm {...props} {...overrides} /></MemoryRouter>);-const select = async user => {- await user.selectOptions(screen.getByLabelText('App'), 'example');- await user.selectOptions(screen.getByRole('combobox', { name: 'Provider' }), 'claude');- await user.selectOptions(screen.getByRole('combobox', { name: 'Model' }), 'sonnet');- await user.selectOptions(screen.getByRole('combobox', { name: /effort/i }), 'high');- await user.click(screen.getByRole('checkbox'));-};-beforeEach(() => {- vi.clearAllMocks();- api.updateCosTaskInterval.mockResolvedValue({ success: true });- api.updateAppTaskTypeOverride.mockResolvedValue({ success: true });- api.getMaintenanceRuns.mockResolvedValue({ runs: [] });- api.startMaintenanceRun.mockResolvedValue({ run: runRecord({ completed: {}, active: { stepId: 'maint-1-0', taskType: 'better-structural-drift' } }), result: { dispatched: true, taskType: 'better-structural-drift' } });-});-describe('maintenance launch', () => {- it('starts a standalone run with the app and pins, and shows its progress', async () => {- const user = userEvent.setup();- let finishStart;- api.startMaintenanceRun.mockReturnValue(new Promise(resolve => { finishStart = resolve; }));- show();- await select(user);- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(screen.getByRole('button', { name: 'Starting…' })).toBeDisabled();- expect(api.startMaintenanceRun).toHaveBeenCalledWith({ appId: 'example', providerId: 'claude', model: 'sonnet', effort: 'high', mode: 'file-issues', claimBetweenAudits: true }, { silent: true });- finishStart({ run: runRecord(), result: { dispatched: true, taskType: 'better-structural-drift' } });- expect(await screen.findByText(/Maintenance started with better-structural-drift/)).toBeInTheDocument();- const row = screen.getByRole('list', { name: 'Maintenance runs' });- expect(row).toHaveTextContent('Example App');- expect(row).toHaveTextContent('running · 2/13 steps · claim-issue');- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(screen.getByRole('link', { name: /Quota Burn/ })).toHaveAttribute('href', '/devtools/quota-burn');- });- it('names the live 1-based step while a recommended-workflow audit is running', async () => {- const auditSteps = MAINTENANCE_TASK_ORDER.map((taskType, index) => ({ id: `maint-1-${index}`, taskRef: { taskType } }));- api.getMaintenanceRuns.mockResolvedValue({ runs: [runRecord({- steps: auditSteps,- completed: { 'maint-1-0': 'done', 'maint-1-1': 'done' },- active: { stepId: 'maint-1-2', taskType: 'module-hygiene' },- })] });- show();- const row = await screen.findByRole('list', { name: 'Maintenance runs' });- expect(row).toHaveTextContent('running · 3/7 steps · module-hygiene');- expect(screen.getByRole('progressbar')).toHaveAttribute('value', '2');- });- it('reports a saved-but-holding run and a failed start honestly', async () => {- const user = userEvent.setup();- api.startMaintenanceRun.mockResolvedValueOnce({ run: runRecord({ completed: {}, active: null, reason: 'provider unavailable' }), result: { dispatched: false, reason: 'provider unavailable' } });- show();- await select(user);- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(await screen.findByText(/holding: provider unavailable/)).toBeInTheDocument();- api.startMaintenanceRun.mockRejectedValueOnce(new Error('a maintenance run is already in progress'));- await user.click(screen.getByRole('checkbox'));- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(await screen.findByText(/Could not start maintenance: a maintenance run is already in progress/)).toBeInTheDocument();- });- it('shows only active runs and removes a run when stopped', async () => {- const user = userEvent.setup();- api.getMaintenanceRuns.mockResolvedValue({ runs: [- runRecord({ id: 'old-completed', status: 'completed', providerId: 'historical-completed' }),- runRecord(),- runRecord({ id: 'old-stopped', status: 'stopped', providerId: 'historical-stopped' }),- ] });- api.stopMaintenanceRun.mockResolvedValue({ run: runRecord({ status: 'stopped', reason: 'stopped by the user' }) });- show();- await screen.findByRole('button', { name: 'Stop' });- expect(screen.queryByText(/historical-/)).not.toBeInTheDocument();- expect(screen.queryByRole('button', { name: 'Resume' })).not.toBeInTheDocument();- await user.click(screen.getByRole('button', { name: 'Stop' }));- expect(api.stopMaintenanceRun).toHaveBeenCalledWith('maint-1', { silent: true });- expect(screen.queryByRole('list', { name: 'Maintenance runs' })).not.toBeInTheDocument();- expect(screen.queryByRole('button', { name: 'Refresh runs' })).not.toBeInTheDocument();- });- it('blocks missing task eligibility and a stopped daemon', async () => {- const user = userEvent.setup();- show({ schedule: { tasks: {} }, daemonRunning: false, onRefresh: vi.fn() });- await select(user);- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(screen.getByText(/Run now needs these saved task settings/)).toBeInTheDocument();- expect(screen.getByText(/start the CoS daemon/)).toBeInTheDocument();- expect(screen.queryByRole('button', { name: 'Enable required tasks' })).not.toBeInTheDocument();- expect(api.startMaintenanceRun).not.toHaveBeenCalled();- });-});--// Regression: a valid provider/model selection must have a path out of the-// disabled launch state, and only persisted prerequisites may unlock launch.-it('enables only missing prerequisites and waits for refreshed saved settings before launch', async () => {- const user = userEvent.setup();- const incomplete = { ...tasks,- simplify: { ...tasks.simplify, enabled: false, appOverrides: {} },- 'claim-issue': { ...tasks['claim-issue'], perpetual: false },- };- let finishRefresh;- const refreshed = new Promise(resolve => { finishRefresh = resolve; });- function Harness() {- const [schedule, setSchedule] = useState({ tasks: incomplete });- return <MaintenanceRunForm {...props} schedule={schedule} onRefresh={async () => {- await refreshed;- setSchedule({ tasks });- return { tasks };- }} />;- }- render(<MemoryRouter><Harness /></MemoryRouter>);- await select(user);- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(screen.getByRole('link', { name: 'simplify' })).toHaveAttribute('href', '/cos/schedule?task=simplify');- expect(screen.getByText(/disabled globally; disabled for this app/)).toBeInTheDocument();- await user.click(screen.getByRole('button', { name: 'Enable required tasks' }));- await waitFor(() => expect(api.updateCosTaskInterval).toHaveBeenCalledTimes(2));- expect(api.updateCosTaskInterval).toHaveBeenCalledWith('simplify', { enabled: true }, { silent: true });- expect(api.updateCosTaskInterval).toHaveBeenCalledWith('claim-issue', { perpetual: true }, { silent: true });- expect(api.updateAppTaskTypeOverride).toHaveBeenCalledExactlyOnceWith('example', 'simplify', { enabled: true }, { silent: true });- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(screen.getByRole('combobox', { name: 'App' })).toBeDisabled();- expect(api.startMaintenanceRun).not.toHaveBeenCalled();- finishRefresh();- await findEnabledByRole('button', { name: 'Run now' });- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(await screen.findByText(/Maintenance started/)).toBeInTheDocument();-});--it('refreshes partial setup after failure without starting work', async () => {- const user = userEvent.setup();- const onRefresh = vi.fn().mockRejectedValue(new Error('refresh unavailable'));- api.updateAppTaskTypeOverride.mockRejectedValueOnce(new Error('save unavailable'));- show({ schedule: { tasks: { ...tasks, simplify: { ...tasks.simplify, enabled: false, appOverrides: {} } } }, onRefresh });- await select(user);- await user.click(screen.getByRole('button', { name: 'Enable required tasks' }));- expect(await screen.findByText(/Setup incomplete: save unavailable/)).toBeInTheDocument();- expect(onRefresh).toHaveBeenCalledOnce();- expect(screen.getByText(/Refreshing the schedule also failed/)).toBeInTheDocument();- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(api.startMaintenanceRun).not.toHaveBeenCalled();-});--it('streams agent activity and completed steps, and removes listeners on unmount', async () => {- api.getMaintenanceRuns.mockResolvedValue({ runs: [runRecord({ completed: {} })] });- const view = show();- await screen.findByRole('list', { name: 'Maintenance runs' });- const update = socket.on.mock.calls.find(([name]) => name === 'cos:maintenance:updated')[1];- act(() => update(runRecord({ completed: {}, active: { taskType: 'better-structural-drift', status: 'running', agentId: 'agent-example' } })));- expect(screen.getByRole('link', { name: 'Open agent in new tab' })).toHaveAttribute('href', '/cos/agents/agent-example');- expect(screen.getByRole('link', { name: 'Open agent in new tab' })).toHaveAttribute('target', '_blank');- act(() => update(runRecord()));- expect(screen.getByRole('progressbar')).toHaveAttribute('value', '1');- act(() => update(runRecord({ status: 'completed', active: null })));- expect(screen.queryByRole('list', { name: 'Maintenance runs' })).not.toBeInTheDocument();- view.unmount();- expect(socket.off).toHaveBeenCalledWith('cos:maintenance:updated', update);-});--it('keeps a newer live update when an older initial fetch resolves late, and refreshes on reconnect', async () => {- let resolveRead;- api.getMaintenanceRuns.mockReturnValueOnce(new Promise(resolve => { resolveRead = resolve; }));- show();- const update = socket.on.mock.calls.find(([name]) => name === 'cos:maintenance:updated')[1];- act(() => update(runRecord()));- await act(async () => resolveRead({ runs: [runRecord({ completed: {} })] }));- expect(screen.getByRole('progressbar')).toHaveAttribute('value', '1');- api.getMaintenanceRuns.mockResolvedValue({ runs: [runRecord({ status: 'completed', active: null })] });- await act(async () => socket.on.mock.calls.find(([name]) => name === 'connect')[1]());- expect(screen.queryByRole('list', { name: 'Maintenance runs' })).not.toBeInTheDocument();-});--it('launches fix mode only after renewed consent', async () => {- const user = userEvent.setup();- show();- await select(user);- await user.selectOptions(screen.getByLabelText('Audit mode'), 'fix');- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(screen.getByText(/one final claim pass/)).toBeInTheDocument();- expect(screen.getByText('Planned steps · 8')).toBeInTheDocument();- expect(screen.queryByLabelText('Issue handling')).not.toBeInTheDocument();- await user.click(screen.getByRole('checkbox'));- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(api.startMaintenanceRun).toHaveBeenCalledWith(expect.objectContaining({ mode: 'fix' }), { silent: true });-});--it('previews and starts issue filing without requiring claim jobs', async () => {- const user = userEvent.setup();- show({ schedule: { tasks: { ...tasks, 'claim-issue': { enabled: false } } } });- await select(user);- await user.selectOptions(screen.getByLabelText('Issue handling'), 'false');- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- expect(screen.getByText('Planned steps · 7')).toBeInTheDocument();- expect(screen.getByRole('list', { name: 'Planned maintenance steps' })).not.toHaveTextContent('claim-issue');- expect(screen.queryByText(/Run now needs these saved task settings/)).not.toBeInTheDocument();- await user.click(screen.getByRole('checkbox'));- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(api.startMaintenanceRun).toHaveBeenCalledWith(expect.objectContaining({ mode: 'file-issues', claimBetweenAudits: false }), { silent: true });-});--it('selects an independent claim handler and omits it in file-only mode', async () => {- const user = userEvent.setup();- show();- await select(user);- const claim = within(screen.getByRole('group', { name: 'Claim-issue handler' }));- await user.selectOptions(claim.getByRole('combobox', { name: 'Claim provider' }), 'claude');- expect(screen.getByRole('button', { name: 'Run now' })).toBeDisabled();- await user.selectOptions(claim.getByRole('combobox', { name: 'Model' }), 'sonnet');- await user.selectOptions(claim.getByRole('combobox', { name: /effort/i }), 'low');- await user.click(screen.getByRole('checkbox'));- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(api.startMaintenanceRun).toHaveBeenLastCalledWith(expect.objectContaining({ effort: 'high', claimHandler: { providerId: 'claude', model: 'sonnet', effort: 'low' } }), { silent: true });- await user.selectOptions(screen.getByLabelText('Issue handling'), 'false');- expect(screen.queryByRole('group', { name: 'Claim-issue handler' })).not.toBeInTheDocument();- await user.click(screen.getByRole('checkbox'));- await user.click(screen.getByRole('button', { name: 'Run now' }));- expect(api.startMaintenanceRun.mock.calls.at(-1)[0]).not.toHaveProperty('claimHandler');- await user.selectOptions(screen.getByLabelText('Audit mode'), 'fix');- expect(screen.getByRole('group', { name: 'Claim-issue handler' })).toBeInTheDocument();-});--it('offers an enabled process provider with no subscription family, and hides a disabled one', async () => {- show({ providers: [- ...props.providers,- { id: 'opencode-tui', name: 'OpenCode TUI', type: 'tui', command: 'opencode', enabled: true, models: ['gpt-5'] },- { id: 'disabled-cli', name: 'Disabled CLI', type: 'cli', command: 'disabled', enabled: false, models: ['x'] },- ] });- await screen.findByRole('button', { name: 'Run now' });- const options = within(screen.getByRole('combobox', { name: 'Provider' })).getAllByRole('option').map(option => option.textContent);- expect(options).toContain('OpenCode TUI');- expect(options).not.toContain('Disabled CLI');-});diff --git a/client/src/components/cos/tabs/schedule/MaintenanceStepSettings.jsx b/client/src/components/cos/tabs/schedule/MaintenanceStepSettings.jsxdeleted file mode 100644index e3508e1431..0000000000--- a/client/src/components/cos/tabs/schedule/MaintenanceStepSettings.jsx+++ /dev/null@@ -1,39 +0,0 @@-import { useState } from 'react';-import ProviderModelSelector from '../../../ProviderModelSelector';-import { effortAwareModelOptions } from '../../../../utils/providers';-import { updateMaintenanceStep } from '../../../../services/apiAgents';--/** Drafts apply to this run only, and only before the runner dispatches the stage. */-export default function MaintenanceStepSettings({ run, step, providers, loading, onSaved }) {- const [draft, setDraft] = useState(() => ({ providerId: step.overrides?.providerId || '', model: step.overrides?.model || '', effort: step.overrides?.effort || '' }));- const [saving, setSaving] = useState(false);- const [error, setError] = useState('');- const editable = run.status === 'running' && !run.completed?.[step.id] && !step.startedAt && run.active?.stepId !== step.id;- const provider = providers.find(entry => entry.id === draft.providerId);- const dirty = ['providerId', 'model', 'effort'].some(key => draft[key] !== (step.overrides?.[key] || ''));- const save = async () => {- if (!editable || saving || !dirty || !provider || !draft.model) return;- setSaving(true);- setError('');- const response = await updateMaintenanceStep(run.id, step.id, { ...draft, effort: draft.effort || null }, { silent: true })- .catch(err => { setError(err.message); return null; });- if (response?.run) onSaved(response.run);- setSaving(false);- };- return <div className="w-full min-w-0">- {editable ? <fieldset disabled={saving} className="space-y-2">- <legend className="sr-only">Handler for {step.taskRef.taskType}</legend>- <ProviderModelSelector providers={providers} selectedProviderId={draft.providerId} selectedModel={draft.model}- availableModels={provider ? effortAwareModelOptions(provider, draft.model) : []}- onProviderChange={providerId => setDraft({ providerId, model: '', effort: '' })}- onModelChange={model => setDraft(current => ({ ...current, model }))}- effort={draft.effort} onEffortChange={effort => setDraft(current => ({ ...current, effort }))}- emptyProviderOption="Select a subscription provider" emptyModelOption="Select a model" includeDefaultModel- alwaysShowModel layout="stacked" loading={loading} disabled={saving} />- <p className="text-port-text-muted">Blank effort uses the task’s saved setting. Applies to this stage only.</p>- <button type="button" onClick={save} disabled={saving || loading || !dirty || !provider || !draft.model}- className="px-2 py-1 rounded bg-port-border disabled:opacity-50">{saving ? 'Saving…' : 'Save stage'}</button>- </fieldset> : <p className="text-port-text-muted break-words">{step.overrides?.providerId} · {step.overrides?.model}{step.overrides?.effort ? ` · ${step.overrides.effort}` : ''}</p>}- {error && <p role="alert">{error}</p>}- </div>;-}diff --git a/client/src/components/cos/tabs/schedule/MaintenanceStepSettings.test.jsx b/client/src/components/cos/tabs/schedule/MaintenanceStepSettings.test.jsxdeleted file mode 100644index b21f0b6a24..0000000000--- a/client/src/components/cos/tabs/schedule/MaintenanceStepSettings.test.jsx+++ /dev/null@@ -1,37 +0,0 @@-import { beforeEach, expect, it, vi } from 'vitest';-import { render, screen } from '@testing-library/react';-import userEvent from '@testing-library/user-event';-import MaintenanceStepSettings from './MaintenanceStepSettings';-import { updateMaintenanceStep } from '../../../../services/apiAgents';--vi.mock('../../../../services/apiAgents', () => ({ updateMaintenanceStep: vi.fn() }));-const providers = [{ id: 'codex', name: 'Codex', type: 'cli', command: 'codex', enabled: true, models: ['example-one', 'example-two'] }];-const step = { id: 'step-2', taskRef: { taskType: 'simplify' }, overrides: { providerId: 'codex', model: 'example-one', effort: 'high' } };-const run = { id: 'maint-1', status: 'running', completed: {}, active: { stepId: 'step-1' } };-beforeEach(() => vi.resetAllMocks());--it('saves pending stage settings and surfaces rejection without applying failed edits', async () => {- const user = userEvent.setup();- const onSaved = vi.fn();- render(<MaintenanceStepSettings run={run} step={step} providers={providers} onSaved={onSaved} />);- expect(screen.getByRole('button', { name: 'Save stage' })).toBeDisabled();- await user.selectOptions(screen.getByLabelText('Model'), 'example-two');- await user.selectOptions(screen.getByRole('combobox', { name: /effort/i }), 'low');- updateMaintenanceStep.mockRejectedValueOnce(new Error('Stage already started'));- await user.click(screen.getByRole('button', { name: 'Save stage' }));- expect(await screen.findByRole('alert')).toHaveTextContent('Stage already started');- expect(onSaved).not.toHaveBeenCalled();- updateMaintenanceStep.mockResolvedValueOnce({ run });- await user.click(screen.getByRole('button', { name: 'Save stage' }));- expect(updateMaintenanceStep).toHaveBeenLastCalledWith('maint-1', 'step-2', { providerId: 'codex', model: 'example-two', effort: 'low' }, { silent: true });- expect(onSaved).toHaveBeenCalledWith(run);-});--it('removes editing when a live update marks the stage dispatched', () => {- const { rerender } = render(<MaintenanceStepSettings run={run} step={step} providers={providers} />);- expect(screen.getByLabelText('Provider')).toBeInTheDocument();- rerender(<MaintenanceStepSettings run={{ ...run, active: { stepId: step.id } }} step={step} providers={providers} />);- expect(screen.queryByRole('combobox')).not.toBeInTheDocument();- rerender(<MaintenanceStepSettings run={run} step={{ ...step, startedAt: '2026-01-01' }} providers={providers} />);- expect(screen.queryByRole('combobox')).not.toBeInTheDocument();-});diff --git a/client/src/socketSubscriptionConventions.test.js b/client/src/socketSubscriptionConventions.test.jsindex 326c933a84..70dc8a6a5c 100644--- a/client/src/socketSubscriptionConventions.test.js+++ b/client/src/socketSubscriptionConventions.test.js@@ -65,7 +65,6 @@ const ALLOWED = {'src/hooks/useBeeperRealtime.js': 're-subscribes beeper:* on connect already','src/hooks/useMoltworldWs.js': 're-subscribes agents:* on connect already','src/hooks/useOnDemandTaskToast.js': 're-subscribes cos:* on connect already',- 'src/components/cos/tabs/schedule/MaintenanceRunForm.jsx': 're-subscribes cos:* on connect already','src/pages/ChiefOfStaff.jsx': 're-subscribes cos:* on connect already (two taskLists modes)',// Does not itself re-subscribe on connect, but rides on the shared cos:*// namespace that useCosTaskUpdates (always mounted from Layout) keeps alive