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

feat([issue-2326]): edit per-app provider/model + LI behavior from the app Automation page

[._.]/ Adam Eivy2254fcb2356d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 61e731ce81..fdcb48757b 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -4,6 +4,7 @@
- **[issue-2322] Layered Intelligence is now a per-app scheduled task, not a global sweep.** The self-improvement loop used to run as a single global "Layered Intelligence Loop" job that swept every enabled app on one daily fire, with a confusing split between a global on/off (CoS → System Tasks) and per-app config (Edit App → Intelligence) — a per-app card could read "Enabled · Due now" while nothing ran. It now runs like every other self-improvement automation: a per-app, deterministic, handler-backed task in CoS → Schedule with its own per-app enable, interval, provider/model, and "Run now". Enabling the `layered-intelligence` task in the Schedule (plus per app on the Intelligence tab) drives it; the reasoning model still only returns JSON and files one deduplicated tracker issue — no code, no agent. Per-app behavior (telemetry sources, allowed scopes, guidance rules, hand-off) still lives on the app's Intelligence tab. An install upgrade migrates each app's scheduling into its per-app task override and tombstones the old global job, preserving effective on/off state. Note: because it's now a self-improvement task, the loop runs only while CoS improvement is enabled.
- The standalone `/layered-intelligence` page has been removed — with the loop now a per-app scheduled task, its status is seen and managed in CoS → Schedule like every other task, and per-app behavior stays on Edit App → Intelligence. (The dedicated cross-app overview/proposals page and its endpoints are gone; nothing else surfaced there.)
+ - **[issue-2326] The app Automation page now edits per-task provider/model overrides inline.** Each task row on Edit App → Automation gained a "⚙ Configure" disclosure that expands a per-app provider + model override (with "Use default provider" to inherit the global/task default) — previously reachable only from CoS → Schedule → Configure. The `layered-intelligence` row additionally links straight to its behavior config (telemetry sources, allowed scopes, guidance rules) on the Edit App → Intelligence tab, so an app's full self-improvement setup is configurable without leaving the app.
## Fixed
diff --git a/client/src/components/apps/tabs/AutomationTab.jsx b/client/src/components/apps/tabs/AutomationTab.jsx
index 97720026ab..ebe6f2210b 100644
--- a/client/src/components/apps/tabs/AutomationTab.jsx
+++ b/client/src/components/apps/tabs/AutomationTab.jsx
@@ -1,14 +1,19 @@
import { useState, useEffect, useCallback } from 'react';
-import { RefreshCw, Play, PauseCircle } from 'lucide-react';
+import { useNavigate } from 'react-router-dom';
+import { RefreshCw, Play, PauseCircle, Settings, ChevronDown, ChevronRight, Sparkles } from 'lucide-react';
import toast from '../../ui/Toast';
import BrailleSpinner from '../../BrailleSpinner';
import CronInput from '../../CronInput';
import ToggleSwitch from '../../ToggleSwitch';
+import ProviderModelSelector from '../../ProviderModelSelector';
import * as api from '../../../services/api';
import { AGENT_OPTIONS, toggleAppMetadataOverride, agentOptionButtonClass } from '../../cos/constants';
import { isCronExpression, describeCron } from '../../../utils/cronHelpers';
+import { PROVIDER_TYPES, filterSelectableModels } from '../../../utils/providers';
import CustomTasksSection from './CustomTasksSection';
+const RUNNABLE_PROVIDER_TYPES = Object.values(PROVIDER_TYPES);
+
const INTERVAL_OPTIONS = [
{ value: null, label: 'Inherit Global' },
{ value: 'rotation', label: 'Rotation' },
@@ -20,23 +25,35 @@ const INTERVAL_OPTIONS = [
];
export default function AutomationTab({ appId, appName }) {
+ const navigate = useNavigate();
const [overrides, setOverrides] = useState({});
const [schedule, setSchedule] = useState(null);
+ const [providers, setProviders] = useState([]);
const [paused, setPaused] = useState(false);
const [resuming, setResuming] = useState(false);
const [loading, setLoading] = useState(true);
const [triggering, setTriggering] = useState(null);
const [cronEditing, setCronEditing] = useState({});
+ // Only one Configure panel open at a time — a per-task disclosure holding the
+ // per-app provider/model override (and, for layered-intelligence, a link to
+ // the behavior config on the Edit App → Intelligence tab).
+ const [expandedTaskType, setExpandedTaskType] = useState(null);
const fetchData = useCallback(async () => {
- const [taskTypesData, scheduleData, statusData] = await Promise.all([
+ const [taskTypesData, scheduleData, statusData, providersData] = await Promise.all([
api.getAppTaskTypes(appId).catch(() => ({ taskTypeOverrides: {} })),
api.getCosSchedule().catch(() => null),
- api.getCosStatus().catch(() => null)
+ api.getCosStatus().catch(() => null),
+ api.getProviders({ silent: true }).catch(() => ({ providers: [] }))
]);
setOverrides(taskTypesData.taskTypeOverrides || {});
setSchedule(scheduleData);
setPaused(statusData?.paused === true);
+ // Every ENABLED provider of a runnable type (cli/tui/api) — handler-backed
+ // tasks dispatch on provider.type, so any of them is a valid override.
+ setProviders((providersData?.providers || []).filter(
+ p => RUNNABLE_PROVIDER_TYPES.includes(p.type) && p.enabled !== false
+ ));
setLoading(false);
}, [appId]);
@@ -112,6 +129,32 @@ export default function AutomationTab({ appId, appName }) {
}));
};
+ const handleProviderChange = async (taskType, newProviderId) => {
+ // Picking a new provider clears any pinned model so a stale model from the
+ // previous provider can't leak through. Empty → inherit the default.
+ const providerId = newProviderId || null;
+ await api.updateAppTaskTypeOverride(appId, taskType, { providerId, model: '' }, { silent: true }).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setOverrides(prev => ({
+ ...prev,
+ [taskType]: { ...prev[taskType], providerId, model: '' }
+ }));
+ };
+
+ const handleModelChange = async (taskType, newModel) => {
+ const model = newModel || '';
+ await api.updateAppTaskTypeOverride(appId, taskType, { model }, { silent: true }).catch(err => {
+ toast.error(err.message);
+ return null;
+ });
+ setOverrides(prev => ({
+ ...prev,
+ [taskType]: { ...prev[taskType], model }
+ }));
+ };
+
const handleTrigger = async (taskType) => {
setTriggering(taskType);
const result = await api.triggerCosOnDemandTask(taskType, appId, { silent: true }).catch(err => {
@@ -199,16 +242,41 @@ export default function AutomationTab({ appId, appName }) {
? describeCron(overrideInterval) || 'cron'
: overrideInterval || (globalConfig.type || 'rotation');
const intervalSuffix = !overrideInterval && globalConfig.intervalMs ? ` (${Math.round(globalConfig.intervalMs / 3600000)}h)` : '';
+ const isExpanded = expandedTaskType === taskType;
+ const overrideProviderId = override.providerId || '';
+ const overrideModel = override.model || '';
+ const selectedProvider = providers.find(p => p.id === overrideProviderId);
+ const availableModels = filterSelectableModels(selectedProvider?.models);
+ // Keep a pinned model visible even when it's not in the provider's
+ // fetched list (avoids a blanked select on a stale/custom model).
+ const modelOptions = overrideModel && !availableModels.includes(overrideModel)
+ ? [overrideModel, ...availableModels]
+ : availableModels;
+ const effectiveProviderId = override.providerId || globalConfig.providerId || null;
+ const effectiveProviderName = effectiveProviderId
+ ? (providers.find(p => p.id === effectiveProviderId)?.name || effectiveProviderId)
+ : 'default (active provider)';
+ const isLayeredIntelligence = taskType === 'layered-intelligence';
return (
<div key={taskType} className="bg-port-card border border-port-border rounded-lg p-3 space-y-2">
- {/* Row 1: name + toggle + run now */}
+ {/* Row 1: name + toggle + configure + run now */}
<div className="flex items-center gap-3">
<ToggleSwitch enabled={isEnabled} onChange={() => handleToggle(taskType, isEnabled)} size="sm" activeColor="bg-port-success" />
<div className="flex-1 min-w-0">
<span className="text-white font-mono text-xs">{taskType}</span>
<div className="text-xs text-gray-500">{effectiveLabel}{intervalSuffix}</div>
</div>
+ <button
+ onClick={() => setExpandedTaskType(prev => prev === taskType ? null : taskType)}
+ aria-expanded={isExpanded}
+ aria-label={`${isExpanded ? 'Hide' : 'Show'} provider and model overrides for ${taskType}`}
+ className="px-2 py-1 bg-port-border/60 text-gray-300 hover:bg-port-border rounded text-xs inline-flex items-center gap-1 shrink-0"
+ >
+ {isExpanded ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
+ <Settings size={12} />
+ Configure
+ </button>
<button
onClick={() => handleTrigger(taskType)}
disabled={triggering === taskType || !isEnabled}
@@ -270,6 +338,42 @@ export default function AutomationTab({ appId, appName }) {
})}
</div>
</div>
+ {/* Expanded config: per-app provider/model override (+ LI behavior link) */}
+ {isExpanded && (
+ <div className="border-t border-port-border pt-3 space-y-3">
+ <ProviderModelSelector
+ providers={providers}
+ selectedProviderId={overrideProviderId}
+ selectedModel={overrideModel}
+ availableModels={modelOptions}
+ onProviderChange={id => handleProviderChange(taskType, id)}
+ onModelChange={model => handleModelChange(taskType, model)}
+ label="Provider override"
+ emptyProviderOption="Use default provider"
+ emptyModelOption="Default model"
+ alwaysShowModel
+ layout="stacked"
+ />
+ <p className="text-xs text-gray-500">
+ Effective provider: <span className="text-gray-300">{effectiveProviderName}</span>
+ {override.providerId ? ' (app override)' : globalConfig.providerId ? ' (task default)' : ''}
+ </p>
+ {isLayeredIntelligence && (
+ <div className="pt-1">
+ <button
+ onClick={() => navigate(`/apps/${appId}?edit=1&appTab=intelligence`)}
+ className="inline-flex items-center gap-1 text-xs text-port-accent hover:underline"
+ >
+ <Sparkles size={12} />
+ Configure behavior (sources, scopes, rules) →
+ </button>
+ <p className="text-xs text-gray-500 mt-1">
+ Telemetry sources, allowed scopes, and guidance rules live on the Edit App → Intelligence tab.
+ </p>
+ </div>
+ )}
+ </div>
+ )}
</div>
);
})}
diff --git a/client/src/components/apps/tabs/AutomationTab.test.jsx b/client/src/components/apps/tabs/AutomationTab.test.jsx
new file mode 100644
index 0000000000..e8fcedb6ce
--- /dev/null
+++ b/client/src/components/apps/tabs/AutomationTab.test.jsx
@@ -0,0 +1,141 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
+
+// ── Mock router — capture navigate calls, no real Router needed ────────────────
+const mockNavigate = vi.hoisted(() => vi.fn());
+vi.mock('react-router-dom', () => ({
+ useNavigate: () => mockNavigate,
+}));
+
+// ── Mock toast ────────────────────────────────────────────────────────────────
+const mockToast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), loading: vi.fn(), dismiss: vi.fn() }));
+vi.mock('../../ui/Toast', () => ({ default: mockToast }));
+
+// ── Mock API ──────────────────────────────────────────────────────────────────
+const api = vi.hoisted(() => ({
+ getAppTaskTypes: vi.fn(),
+ getCosSchedule: vi.fn(),
+ getCosStatus: vi.fn(),
+ getProviders: vi.fn(),
+ updateAppTaskTypeOverride: vi.fn(),
+ toggleAllAppTaskTypes: vi.fn(),
+ triggerCosOnDemandTask: vi.fn(),
+ resumeCos: vi.fn(),
+ // Consumed by the nested CustomTasksSection on mount.
+ getCosJobs: vi.fn(),
+ createCosJob: vi.fn(),
+ updateCosJob: vi.fn(),
+ toggleCosJob: vi.fn(),
+ triggerCosJob: vi.fn(),
+ deleteCosJob: vi.fn(),
+}));
+vi.mock('../../../services/api', () => api);
+
+const AutomationTab = (await import('./AutomationTab')).default;
+
+const SCHEDULE = {
+ tasks: {
+ 'layered-intelligence': { type: 'daily', taskMetadata: {}, providerId: 'global-claude' },
+ 'app-improvement': { type: 'rotation', taskMetadata: {} },
+ },
+};
+
+const PROVIDERS = {
+ providers: [
+ { id: 'claude-cli', name: 'Claude Code', type: 'cli', enabled: true, models: ['opus', 'sonnet'] },
+ { id: 'global-claude', name: 'Global Claude', type: 'api', enabled: true, models: ['gpt-5.5'] },
+ { id: 'disabled-one', name: 'Disabled', type: 'api', enabled: false, models: [] },
+ ],
+};
+
+const renderTab = async (overrides = {}) => {
+ api.getAppTaskTypes.mockResolvedValue({ taskTypeOverrides: overrides });
+ api.getCosSchedule.mockResolvedValue(SCHEDULE);
+ api.getCosStatus.mockResolvedValue({ paused: false });
+ api.getProviders.mockResolvedValue(PROVIDERS);
+ api.getCosJobs.mockResolvedValue({ jobs: [] });
+ api.updateAppTaskTypeOverride.mockResolvedValue({ success: true });
+ render(<AutomationTab appId="app-1" appName="MyApp" />);
+ await screen.findByText('layered-intelligence');
+};
+
+// Find the task-row card that contains the given task-type label.
+const rowFor = (taskType) => screen.getByText(taskType).closest('.bg-port-card');
+
+beforeEach(() => {
+ vi.clearAllMocks();
+});
+
+describe('AutomationTab per-app overrides', () => {
+ it('Configure toggle expands the provider override panel', async () => {
+ await renderTab();
+ const row = rowFor('layered-intelligence');
+ const configureBtn = within(row).getByRole('button', { name: /show provider and model overrides/i });
+ expect(configureBtn).toHaveAttribute('aria-expanded', 'false');
+ // Provider selector is not rendered until expanded.
+ expect(within(row).queryByLabelText('Provider override')).toBeNull();
+
+ fireEvent.click(configureBtn);
+
+ expect(configureBtn).toHaveAttribute('aria-expanded', 'true');
+ expect(within(row).getByLabelText('Provider override')).toBeInTheDocument();
+ });
+
+ it('changing the provider PATCHes updateAppTaskTypeOverride with providerId + cleared model', async () => {
+ await renderTab();
+ const row = rowFor('app-improvement');
+ fireEvent.click(within(row).getByRole('button', { name: /show provider and model overrides/i }));
+
+ const providerSelect = within(row).getByLabelText('Provider override');
+ fireEvent.change(providerSelect, { target: { value: 'claude-cli' } });
+
+ await waitFor(() => expect(api.updateAppTaskTypeOverride).toHaveBeenCalled());
+ expect(api.updateAppTaskTypeOverride).toHaveBeenCalledWith(
+ 'app-1',
+ 'app-improvement',
+ { providerId: 'claude-cli', model: '' },
+ { silent: true }
+ );
+ });
+
+ it('changing the model PATCHes updateAppTaskTypeOverride with the model', async () => {
+ await renderTab({ 'app-improvement': { providerId: 'claude-cli' } });
+ const row = rowFor('app-improvement');
+ fireEvent.click(within(row).getByRole('button', { name: /show provider and model overrides/i }));
+
+ fireEvent.change(within(row).getByLabelText('Model'), { target: { value: 'sonnet' } });
+
+ await waitFor(() => expect(api.updateAppTaskTypeOverride).toHaveBeenCalledWith(
+ 'app-1',
+ 'app-improvement',
+ { model: 'sonnet' },
+ { silent: true }
+ ));
+ });
+
+ it('excludes disabled providers from the picker', async () => {
+ await renderTab();
+ const row = rowFor('app-improvement');
+ fireEvent.click(within(row).getByRole('button', { name: /show provider and model overrides/i }));
+ const providerSelect = within(row).getByLabelText('Provider override');
+ expect(within(providerSelect).queryByText('Disabled')).toBeNull();
+ expect(within(providerSelect).getByText('Claude Code')).toBeInTheDocument();
+ });
+
+ it('layered-intelligence row shows a behavior link that deep-links to the Intelligence tab', async () => {
+ await renderTab();
+ const row = rowFor('layered-intelligence');
+ fireEvent.click(within(row).getByRole('button', { name: /show provider and model overrides/i }));
+
+ const link = within(row).getByRole('button', { name: /configure behavior/i });
+ fireEvent.click(link);
+ expect(mockNavigate).toHaveBeenCalledWith('/apps/app-1?edit=1&appTab=intelligence');
+ });
+
+ it('non-LI row does not show the behavior link', async () => {
+ await renderTab();
+ const row = rowFor('app-improvement');
+ fireEvent.click(within(row).getByRole('button', { name: /show provider and model overrides/i }));
+ expect(within(row).queryByRole('button', { name: /configure behavior/i })).toBeNull();
+ });
+});