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: harden managed job override parity (#5037)

[._.]/ Adam Eivy336ff4755600
diff --git a/client/src/components/apps/tabs/CustomTasksSection.jsx b/client/src/components/apps/tabs/CustomTasksSection.jsx
index 92fafaeae2..f6ecbdc59d 100644
--- a/client/src/components/apps/tabs/CustomTasksSection.jsx
+++ b/client/src/components/apps/tabs/CustomTasksSection.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useCallback } from 'react';
+import { useState, useEffect, useCallback, useMemo } from 'react';
import { Plus, Play, Trash2, Edit3, Save, X, Clock } from 'lucide-react';
import toast from '../../ui/Toast';
import ToggleSwitch from '../../ToggleSwitch';
@@ -11,7 +11,8 @@ import { timeAgo } from '../../../utils/formatters';
import { DEFAULT_CRON, describeCron, describeRecurrence, parseCronToRecurrence, buildCronFromRecurrence } from '../../../utils/cronHelpers';
import CronSchedulePicker from '../../CronSchedulePicker';
import { AGENT_OPTIONS, agentOptionButtonClass } from '../../cos/constants';
-import AgentJobProviderFields, { activeProviderIdFromResponse, filterRunnableProviders } from '../../cos/AgentJobProviderFields';
+import AgentJobProviderFields from '../../cos/AgentJobProviderFields';
+import { filterRunnableProviders } from '../../../utils/providers';
const INTERVAL_OPTIONS = [
{ value: 'hourly', label: 'Every Hour' },
@@ -276,25 +277,32 @@ export default function CustomTasksSection({ appId, appName }) {
const [createForm, setCreateForm] = useState(emptyForm);
const [editingId, setEditingId] = useState(null);
const [editForm, setEditForm] = useState(emptyForm);
- const [providers, setProviders] = useState([]);
+ const [rawProviders, setRawProviders] = useState([]);
const [activeProviderId, setActiveProviderId] = useState('');
const [triggering, setTriggering] = useState(null);
const { isConfirming, requestDelete, cancelDelete, confirmDelete } = useConfirmDelete();
+ const providers = useMemo(
+ () => filterRunnableProviders(rawProviders, tasks.map(job => job.providerId)),
+ [rawProviders, tasks]
+ );
+
const fetchTasks = useCallback(async () => {
- const [data, providerData] = await Promise.all([
- api.getCosJobs().catch(() => null),
- api.getProviders({ silent: true }).catch(() => ({ providers: [] }))
- ]);
+ const data = await api.getCosJobs({ silent: true }).catch(() => null);
const appTasks = (data?.jobs || []).filter(j => j.appId === appId);
setTasks(appTasks);
- setProviders(filterRunnableProviders(providerData?.providers, appTasks.map(job => job.providerId)));
- setActiveProviderId(activeProviderIdFromResponse(providerData?.activeProvider));
setLoading(false);
}, [appId]);
useEffect(() => { fetchTasks(); }, [fetchTasks]);
+ useEffect(() => {
+ api.getProviders({ silent: true }).then(data => {
+ setRawProviders(data?.providers || []);
+ setActiveProviderId(data?.activeProvider || '');
+ }).catch(() => {});
+ }, []);
+
const validate = (form) => {
if (!form.name.trim()) { toast.error('Name is required'); return false; }
if (!form.promptTemplate.trim()) { toast.error('Prompt is required'); return false; }
diff --git a/client/src/components/cos/AgentJobProviderFields.jsx b/client/src/components/cos/AgentJobProviderFields.jsx
index 98367b161c..bf9c54a4dc 100644
--- a/client/src/components/cos/AgentJobProviderFields.jsx
+++ b/client/src/components/cos/AgentJobProviderFields.jsx
@@ -1,32 +1,6 @@
-import { effortAwareModelOptions, PROVIDER_TYPES } from '../../utils/providers.js';
+import { effortAwareModelOptions, filterRunnableProviders, resolveEffectiveProvider } from '../../utils/providers.js';
import ProviderModelSelector from '../ProviderModelSelector.jsx';
-export const RUNNABLE_PROVIDER_TYPES = Object.freeze([
- PROVIDER_TYPES.CLI,
- PROVIDER_TYPES.TUI
-]);
-
-/**
- * Keep the provider source shared by every agent-job form. ProviderModelSelector
- * applies the enabled/hardware visibility rules while retaining a saved disabled
- * provider long enough for the user to clear or replace it.
- */
-export const filterRunnableProviders = (providers, selectedProviderIds = []) => {
- const preservedIds = new Set(
- (Array.isArray(selectedProviderIds) ? selectedProviderIds : [selectedProviderIds]).filter(Boolean)
- );
- return (Array.isArray(providers) ? providers : []).filter(provider =>
- RUNNABLE_PROVIDER_TYPES.includes(provider?.type) || preservedIds.has(provider?.id)
- );
-};
-
-/**
- * The providers endpoint has historically returned either an id or a provider
- * object in `activeProvider`; normalize both wire shapes for job forms.
- */
-export const activeProviderIdFromResponse = (activeProvider) =>
- typeof activeProvider === 'string' ? activeProvider : (activeProvider?.id || '');
-
/**
* Shared provider/model/effort controls for persisted CoS agent jobs.
*
@@ -44,15 +18,14 @@ export default function AgentJobProviderFields({
}) {
if (!providers?.length) return null;
- const selectedProvider = providers.find(provider => provider.id === data.providerId)
- || providers.find(provider => provider.id === activeProviderId);
- const selectableProviders = providers.filter(provider =>
- RUNNABLE_PROVIDER_TYPES.includes(provider?.type) || provider?.id === data.providerId
+ const selectableProviders = filterRunnableProviders(providers, data.providerId);
+ const { provider: selectedProvider, usingActive } = resolveEffectiveProvider(
+ selectableProviders,
+ data.providerId,
+ activeProviderId
);
const availableModels = effortAwareModelOptions(selectedProvider, data.model);
- const effectiveProviderId = data.providerId
- ? undefined
- : (RUNNABLE_PROVIDER_TYPES.includes(selectedProvider?.type) ? (activeProviderId || undefined) : undefined);
+ const effectiveProviderId = usingActive ? (activeProviderId || undefined) : undefined;
return (
<div>
diff --git a/client/src/components/cos/AgentJobProviderFields.test.jsx b/client/src/components/cos/AgentJobProviderFields.test.jsx
index cabe7057ac..33750a02e2 100644
--- a/client/src/components/cos/AgentJobProviderFields.test.jsx
+++ b/client/src/components/cos/AgentJobProviderFields.test.jsx
@@ -1,6 +1,7 @@
import { describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen } from '@testing-library/react';
-import AgentJobProviderFields, { filterRunnableProviders } from './AgentJobProviderFields';
+import AgentJobProviderFields from './AgentJobProviderFields';
+import { filterRunnableProviders } from '../../utils/providers.js';
const PROVIDERS = [
{
@@ -90,4 +91,18 @@ describe('AgentJobProviderFields', () => {
expect(screen.getByRole('option', { name: 'Ollama API' })).toBeInTheDocument();
expect(screen.getByRole('option', { name: 'Claude' })).toBeInTheDocument();
});
+
+ it('does not borrow active-provider models for an unresolvable saved pin', async () => {
+ render(
+ <AgentJobProviderFields
+ data={{ providerId: 'deleted-provider', model: 'deleted-model', effort: '' }}
+ providers={PROVIDERS}
+ activeProviderId="claude-code"
+ onChange={vi.fn()}
+ />
+ );
+ await act(async () => {});
+
+ expect(screen.queryByRole('option', { name: 'claude-sonnet' })).not.toBeInTheDocument();
+ });
});
diff --git a/client/src/components/cos/tabs/JobsTab.jsx b/client/src/components/cos/tabs/JobsTab.jsx
index f3e1288340..6f5e14621a 100644
--- a/client/src/components/cos/tabs/JobsTab.jsx
+++ b/client/src/components/cos/tabs/JobsTab.jsx
@@ -5,7 +5,8 @@ import * as api from '../../../services/api';
import { timeAgo, timeUntil, formatDateTime, formatDateNumeric } from '../../../utils/formatters';
import { DEFAULT_CRON, describeCron, describeRecurrence, parseCronToRecurrence, buildCronFromRecurrence, JOB_INTERVAL_OPTIONS as INTERVAL_OPTIONS } from '../../../utils/cronHelpers';
import CronSchedulePicker from '../../CronSchedulePicker';
-import AgentJobProviderFields, { activeProviderIdFromResponse, filterRunnableProviders } from '../AgentJobProviderFields';
+import AgentJobProviderFields from '../AgentJobProviderFields';
+import { filterRunnableProviders } from '../../../utils/providers';
import InlineConfirmRow from '../../ui/InlineConfirmRow';
import FormField from '../../ui/FormField';
import { useConfirmDelete } from '../../../hooks/useConfirmDelete';
@@ -621,7 +622,7 @@ export default function JobsTab() {
useEffect(() => {
api.getProviders({ silent: true }).then(data => {
setRawProviders(data?.providers || []);
- setActiveProviderId(activeProviderIdFromResponse(data?.activeProvider));
+ setActiveProviderId(data?.activeProvider || '');
}).catch(() => {});
}, []);
diff --git a/client/src/utils/README.md b/client/src/utils/README.md
index 0fcaf916df..fcb941e154 100644
--- a/client/src/utils/README.md
+++ b/client/src/utils/README.md
@@ -42,6 +42,7 @@ grep -i "what you want to do" client/src/utils/README.md
| `platform` | `isMac` detection and `modKey` (⌘/Ctrl) for keyboard-shortcut display. |
| `navWorkingSet` | Recent/pinned nav persistence (`recordVisit`, `togglePin`, `isPinned`) plus `resolveRecentNavEntries` for mapping stored deep links back to their longest matching nav-manifest entry. Also `migrateLegacyNavPath(path, commands)` — maps a stored path onto the CURRENT path of the page that used to answer to it, driven by each command's own `previousPaths` (declared in `server/lib/navManifest.js` beside the page that moved, shipped whole in the palette manifest). A pin is a stored route path, so without it a moved page's pin stops matching the manifest and the sidebar row silently vanishes on update. |
| `providers` | AI-provider type predicates and helpers (`isCliProvider`, `isApiProvider`, `isCodexProvider`, `isAntigravityProvider`, `isLaunchableTuiProvider` — a TUI provider carrying the server-resolved `tuiCommandLine`, i.e. one a human can start at a shell prompt; shared by the Providers card's "Launch in Shell" button and the Shell page's launch menu so the two can't disagree — `PROVIDER_GATEWAYS` / `gatewayForProvider` / `isGatewayBackedProvider` (an OpenCode wrapper front-ending a hosted OpenAI-compatible gateway — `orcarouter`, `openrouter` — which inherits its API key at spawn time from the sibling API provider whose id equals the gateway id; reads the generic `gatewayBacked` marker and, forever, the legacy per-gateway boolean. MIRROR of `server/lib/providerGateways.js`, which the browser cannot import; keep the three copies in lockstep), `filterSelectableModels`, `resolveCliEffort` (mirror — what a stored effort actually runs as, so the picker can name a clamped level), `configuredDefaultIn` — the sentinel a provider's catalog carries, so a picker can render an option matching a sentinel-valued tier instead of a blank select — `getProviderTimeout`, `resolveEffectiveProvider` — the provider a record actually runs on (its pin, else the active provider) plus whether it fell back, so a "Default" option can name what it resolves to — `resolveSeriesRunLlm` (mirror of server `seriesLlmOverride.js`: which provider/model a Pipeline **series** run resolves to — per-run override → `series.llm` → active provider) and `providerModelLabel` (the one "Provider / model" phrasing), configured-default sentinels, and the claude/codex/agy thinking-effort levels — `effortLevelsForProvider`, mirror of server `providerModels.js`). Also `isRunnerAllowedCommand(command, allowedCommands)` — would the CoS Agent Runner (`/spawn`, `/spawn-tui`) accept this command? Mirrors only the *normalization* in `server/cos-runner/allowedCommands.js` (the list itself arrives as `runnerAllowedCommands` on `GET /api/providers`, because the allowlist is an exec boundary and stays hand-curated server-side); returns `null` for "list not fetched / field blank" so a failed fetch never renders a warning. Pinned by `server/cos-runner/allowedCommands.parity.test.js`. `isPrivateNetworkEndpoint(endpoint)` — loopback, RFC1918/tailnet address, or a `.local`/`.ts.net`/single-label host, i.e. somewhere an unauthenticated OpenAI-compatible server is a normal setup rather than a missing API key. `isLocalInstanceProvider(provider)` — the narrower question, mirroring server `localProviderRuntime.js#isLocalInstanceEndpoint`: does this provider talk to a daemon on THIS machine (loopback, or no endpoint at all)? Gate anything that explains a provider by inspecting the host PortOS runs on — install state, "start it from Settings → Local LLM" — since `localBackendForProvider` matches by NAME and would otherwise claim a peer's LM Studio. And `credentialSource(provider)` plus `providerCardState(provider, { runtime, status, keySetFor, envVarSet })` + `PROVIDER_CARD_STATE` — is a provider ready to run, benched, blocked on a missing prerequisite (CLI not installed / API key absent / empty credential environment variable), or simply switched off? Reads the SERVER's `missingPrerequisites` (published per provider on `GET /api/providers` from `server/lib/providerPrerequisites.js`, and the same computation `getFallbackProvider` routes on) and adds the local-app runtime shape plus tri-state checks for stored, inherited, and process environment credentials. Unknown lookup values mean "not probed", never "missing". Drives the AI Providers page card colors and grouping — distinct from `ProviderReadiness`/`GET /api/providers/readiness`, which probes the local daemon behind a provider. `resolvesOutsidePortosPath(provider)` — does this provider resolve its binary somewhere the runtime probe never looked (an explicit path in `command`, or its own `PATH` in `envVars`)? Mirror of the same two guards in the server's `providerRuntimeKey`, and what keeps the card's badge from accusing a working provider the router happily routes. And `providerRuntimeKey(provider)` — the key a provider's runtime is published under by `GET /api/providers/runtimes`, so a card can show its CLI install status (bare binary name for a cli/tui provider, provider id for an API provider fronted by a local app); the runtime table itself stays server-side. |
+| `providers` (agent jobs) | `RUNNABLE_PROVIDER_TYPES` and `filterRunnableProviders` keep the shared CoS agent-job pickers aligned with the server's CLI/TUI file-writing harness boundary while retaining saved pins long enough to clear them. |
| `systemCapabilities` | Server-annotated hardware compatibility helpers: preserve model/provider choices when compatibility is unknown, and hide only entries whose `hardwareCompatibility.state` is definitively `unavailable`. |
| `layeredIntelligenceReasons` | Canonical gloss for the Layered Intelligence loop's run-outcome reason tokens, shared by the on-demand toast and the durable "Last run" line (`formatLiReason`, `liReasonTone`, `LI_NEUTRAL_REASONS`). |
diff --git a/client/src/utils/providers.js b/client/src/utils/providers.js
index 98670239a6..95795c4882 100644
--- a/client/src/utils/providers.js
+++ b/client/src/utils/providers.js
@@ -175,6 +175,26 @@ export const PROVIDER_TYPES = Object.freeze({
API: 'api'
});
+// Agent jobs need the CLI/TUI file-writing harnesses. Keep this allowlist in
+// lockstep with isAgentHarness in server/services/agentProviderResolution.js.
+export const RUNNABLE_PROVIDER_TYPES = Object.freeze([
+ PROVIDER_TYPES.CLI,
+ PROVIDER_TYPES.TUI
+]);
+
+/**
+ * Retain an existing non-runnable pin so a saved job can still be edited and
+ * cleared, while limiting new agent-job selections to runnable providers.
+ */
+export const filterRunnableProviders = (providers, selectedProviderIds = []) => {
+ const preservedIds = new Set(
+ (Array.isArray(selectedProviderIds) ? selectedProviderIds : [selectedProviderIds]).filter(Boolean)
+ );
+ return (Array.isArray(providers) ? providers : []).filter(provider =>
+ RUNNABLE_PROVIDER_TYPES.includes(provider?.type) || preservedIds.has(provider?.id)
+ );
+};
+
/**
* Returns the provider's model list with internal sentinel values removed.
* Use this anywhere a list of user-selectable models is needed.
diff --git a/server/routes/cosJobRoutes.js b/server/routes/cosJobRoutes.js
index 52b2dc5be0..fd7f1d8092 100644
--- a/server/routes/cosJobRoutes.js
+++ b/server/routes/cosJobRoutes.js
@@ -205,7 +205,11 @@ router.post('/jobs/:id/trigger', asyncHandler(async (req, res) => {
// so a manual run cannot silently lose its saved reasoning override.
provider: task.metadata?.provider,
model: task.metadata?.model,
- effort: task.metadata?.effort
+ effort: task.metadata?.effort,
+ // Preserve the markers consumed by the job:spawned listener so Run now
+ // records the execution and re-registers the saved schedule.
+ autonomousJob: task.metadata?.autonomousJob,
+ jobId: task.metadata?.jobId
}, 'internal');
if (!taskResult?.id) {
diff --git a/server/routes/cosJobRoutes.test.js b/server/routes/cosJobRoutes.test.js
index e774dd2c8b..aca289995c 100644
--- a/server/routes/cosJobRoutes.test.js
+++ b/server/routes/cosJobRoutes.test.js
@@ -468,6 +468,8 @@ describe('CoS Job Routes', () => {
description: 'Review',
priority: 'MEDIUM',
metadata: {
+ autonomousJob: true,
+ jobId: 'j1',
app: 'app-xyz',
useWorktree: true,
openPR: true,
@@ -490,7 +492,9 @@ describe('CoS Job Routes', () => {
simplify: false,
provider: 'anthropic',
model: 'claude-opus-4-8',
- effort: 'high'
+ effort: 'high',
+ autonomousJob: true,
+ jobId: 'j1'
}),
'internal'
);
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index 503f80e894..287a8a26a4 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -336,6 +336,8 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
if (taskData.temperature !== undefined) metadata.temperature = taskData.temperature;
if (taskData.thinking !== undefined) metadata.thinking = taskData.thinking;
if (taskData.app) metadata.app = taskData.app;
+ if (taskData.autonomousJob === true) metadata.autonomousJob = true;
+ if (typeof taskData.jobId === 'string' && taskData.jobId) metadata.jobId = taskData.jobId;
// Pin this task to ONE federated instance (#4520): only that instance's CoS
// evaluator claims and runs it, every other peer passes over it. Absent —
// the default — leaves the opportunistic first-claim-wins behavior intact.
diff --git a/server/services/cosTaskStore.test.js b/server/services/cosTaskStore.test.js
index 67fb10cf56..0a6bb029ea 100644
--- a/server/services/cosTaskStore.test.js
+++ b/server/services/cosTaskStore.test.js
@@ -366,6 +366,20 @@ describe('cosTaskStore.addTask', () => {
expect(created.metadata.prompt).toBeUndefined();
});
+ it('preserves autonomous-job markers for manual triggers', async () => {
+ const created = await addTask({
+ description: 'manual scheduled job',
+ id: 'task-manual-job',
+ autonomousJob: true,
+ jobId: 'job-example'
+ }, 'internal');
+
+ expect(created.metadata).toMatchObject({ autonomousJob: true, jobId: 'job-example' });
+ const reloaded = await getTaskById('task-manual-job');
+ expect(reloaded.metadata.autonomousJob === true || reloaded.metadata.autonomousJob === 'true').toBe(true);
+ expect(reloaded.metadata.jobId).toBe('job-example');
+ });
+
it('round-trips OpenCode Ollama generation controls, including thinking off', async () => {
const created = await addTask({
description: 'local task', id: 'task-opencode', effort: 'high', temperature: 0.25, thinking: false,