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

set a CoS task's provider/model/effort inline on its schedule card

[._.]/ Adam Eivyedc62bd1af57
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 22605af2f7..d72dd26ec5 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -6,6 +6,8 @@
- **Quota burn's dispatch cap is now opt-in — `-1` (unlimited) is the default, so a plan stops when the *quota* says so rather than when a tally runs out.** `maxDispatchesPerWindow` counted how many burns one target window could spend, and at its old default of 5 it was routinely the first gate to close: a weekly window with days left and headroom above the reserve would sit idle at "dispatch cap reached (5/5)" — the exact "allowance expires unused" outcome the feature exists to prevent. It read as a safety property, but the gates that actually bound spend all measure live numbers: the reset horizon (`resetWithinHours`), the reserve (`reservePercent`, checked against the *tightest* window on the card), and the provider's own refusal, which blocks the family outright when the short window empties underneath a weekly plan. A count stacked on top of those adds no protection they don't already give. A hard ceiling is still available — set 1–50 on the family card — and the window is charged either way, so the card still shows how many burns it has spent (with no denominator when uncapped). `0` is deliberately not accepted: "never burn" is what switching the family off means, and the client's number field collapses anything below 1 to the sentinel so stepping the spinner down can't 400. Migration 226 lifts an existing plan that still carries the old default of 5 — a changed default reaches nobody otherwise, since the normalizer has written that 5 into every install's `quota-burn.json` — while any other stored value is a number the user chose and is left alone.
+- **Retargeting a scheduled task at a different model no longer costs a trip through the config drawer.** Each card on CoS → Schedule now carries the provider, model and effort pins inline, right above its Run button — so the common loop of "point this task at a stronger model and run it on one app" is three clicks on the card instead of opening the drawer, scrolling to the provider block, changing it, and closing again. The pins write immediately, exactly as they do in the drawer (picking a provider clears the model and effort with it, since a model from the previous provider wouldn't resolve), and a failed write rolls the select back to what is actually stored rather than leaving the card claiming a setting the server never took. Run stays disabled while a pin is still being saved: the run reads the server-side config, not the inputs on screen, so triggering mid-write would quietly run the *previous* model — the failure this repo's "in-flight saves must gate dependent actions" rule exists to prevent, and one a tooltip would not have stopped. Leaving the provider on Default no longer means the model and effort selects have nothing to offer: Default now names the provider it currently resolves to and lists that provider's catalog, so "same provider, higher effort" doesn't require pinning the provider first — the same fallback the pipeline's LLM pickers already use. Effort only appears for providers that actually have a ladder, and it is narrowed by the picked model, so an Antigravity model with no tiers doesn't offer one. A pipeline task, whose provider and model are resolved per stage, gets a link to the stage config instead of a card-level pin that its runs would ignore. Card and drawer now share one implementation of the select/write/rollback trio (`useTaskModelPins`), so the two surfaces can't drift.
+
- **The `cosAgents.js` barrel is gone, so an agent function no longer arrives from a specifier that says nothing about which layer it lives in.** The #2530 decomposition split a ~1090-line module into four focused siblings — `cosAgentIndex.js` (date-bucket index + on-disk archive layout), `cosAgentLifecycle.js` (register / update / complete / output / terminate), `cosAgentFeedback.js` (capture + classifier), `cosAgentArchive.js` (state-eviction sweeps) — then put an `export *` wall back in front of all four so no import path had to change. Three years of imports later, `updateAgent` and `getAgentsByDate` came from the same specifier despite sitting in different layers, and the wall is what made `cos.js` a *two*-hop forwarder of a lifecycle transition, which is the shape #3450's guard exists to delete. All ~20 production importers and ~14 `vi.mock` targets now name the module that declares what they asked for — several of which turn out to want only the index (`cosReports.js`, the peer cos-history merge) or only the lifecycle layer (the runner sync, the TUI output spooler, the completion cleanup), so the graph gets narrower as well as flatter. The four leaf modules are unchanged; the two test files that only ever exercised one of them are renamed to sit beside it (`cosAgentLifecycle.test.js`, `cosAgentIndex.merge.test.js`). The forwarder guard in `agentImportCycles.test.js` — which walks re-export edges rather than naming barrels, so a new one is covered the day it is written — now asserts `cos.js` is the *only* module forwarding a transition, and was bypass-probed both ways: planting a fresh `export *` barrel turns it red, and so does routing a production import of `completeAgent` back through `cos.js`. Its two module-loading assertions also take an explicit timeout: they transform `cos.js`'s whole service graph, which lands at 5–10s and straddles Vitest's 10s default, so the guard was one busy machine away from failing for a reason that had nothing to do with the invariant (#3450).
- **The agent lifecycle has a named entry point instead of seven mutually-recursive modules.** The `cos.js → cosAgents.js → cosAgentLifecycle.js → agentManagement.js → agents.js → subAgentSpawner.js → agentLifecycle.js` cluster has no owner, so reasoning about one transition — pause, kill, complete, spawn — means holding all seven files in mind, and several of the back-edges are `await import(...)` calls that exist only to dodge a load-time cycle. `server/services/agentOrchestrator.js` is the facade above that cluster: it imports the transition owners one-directionally, carries the transition-vs-leaf classification in its header so later passes start from it, and renames apart the two different functions both called `terminateAgent` — `requestAgentTermination` only emits the event and returns, while `terminateAgent` keeps the name for the real SIGTERM/SIGKILL sequence. The four agent routes (terminate, pause, kill, stats) now go through it, one hop instead of three. `agentImportCycles.test.js` gains a guard that fails if anything reachable from the facade imports it back, statically *or* via `import(...)` — the dynamic form matters because reaching across a blocked layer that way is exactly this cluster's habit, and the forbidden set is derived from the graph rather than listed so it can't fall behind. Widening that suite's graph builder to walk subdirectories closed a hole in the pre-existing cycle guard too: it read only top-level `server/services/*.js`, so a cycle routed through one subdirectory hop (`agentTuiSpawning/outputSpooler.js` already imports back up to `../cosAgents.js`) was invisible to it. The remaining call sites and the dynamic-import workarounds follow in later PRs (#3450).
diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsx
index 54689cfcad..45d9cd7cfb 100644
--- a/client/src/components/cos/tabs/ScheduleTab.jsx
+++ b/client/src/components/cos/tabs/ScheduleTab.jsx
@@ -15,7 +15,7 @@ import { TASK_FILTERS, DEFAULT_FILTER_ID } from './schedule/scheduleConstants';
// passed down — same convention as TasksTab/AgentsTab — so this tab's provider/
// model pickers stay live without standing up a second independent poll of the
// same data.
-export default function ScheduleTab({ apps, providers }) {
+export default function ScheduleTab({ apps, providers, activeProviderId }) {
const [searchParams, setSearchParams] = useSearchParams();
const [schedule, setSchedule] = useState(null);
const [loading, setLoading] = useState(true);
@@ -48,15 +48,20 @@ export default function ScheduleTab({ apps, providers }) {
fetchSchedule();
}, [fetchSchedule]);
+ // Resolves a boolean so optimistic callers (the card's quick model pins) can
+ // roll their local selection back — this handler owns the error toast, so it
+ // never rejects.
const handleUpdateTask = async (taskType, settings) => {
const result = await api.updateCosTaskInterval(taskType, settings, { silent: true }).catch(err => {
toast.error(err.message);
return null;
});
- if (result?.success) {
- toast.success(`Updated ${taskType} interval`);
- fetchSchedule();
- }
+ if (!result?.success) return false;
+ // Not "interval" — this handler carries every task setting (provider, model,
+ // effort, prompt, dependencies), and the card's pins now use it too.
+ toast.success(`Updated ${taskType}`);
+ fetchSchedule();
+ return true;
};
const handleTriggerTask = async (taskType, appId = null) => {
@@ -151,7 +156,10 @@ export default function ScheduleTab({ apps, providers }) {
<AppTaskTypeSection
tasks={tasks}
apps={apps}
+ providers={providers}
+ activeProviderId={activeProviderId}
onTrigger={handleTriggerAppImprovement}
+ onUpdate={handleUpdateTask}
onSelectTask={setSelectedTask}
improvementDisabled={improvementDisabled}
filter={filter}
@@ -173,6 +181,7 @@ export default function ScheduleTab({ apps, providers }) {
onTrigger={handleTriggerAppImprovement}
onReset={handleResetTask}
providers={providers}
+ activeProviderId={activeProviderId}
apps={apps}
onUpdateOverride={handleUpdateOverride}
onBulkToggleOverride={handleBulkToggleOverride}
diff --git a/client/src/components/cos/tabs/schedule/AppTaskCard.jsx b/client/src/components/cos/tabs/schedule/AppTaskCard.jsx
index 8c757c4804..6fc5529379 100644
--- a/client/src/components/cos/tabs/schedule/AppTaskCard.jsx
+++ b/client/src/components/cos/tabs/schedule/AppTaskCard.jsx
@@ -1,18 +1,27 @@
-import { Clock, AlertTriangle, SlidersHorizontal } from 'lucide-react';
+import { useState } from 'react';
+import { Clock, AlertTriangle, SlidersHorizontal, GitMerge } from 'lucide-react';
import { timeAgo } from '../../../../utils/formatters';
import { describeNextRun, coverageTone } from './scheduleConstants';
import TaskHeader from './TaskHeader';
import RunTaskButton from './RunTaskButton';
+import TaskModelQuickControls from './TaskModelQuickControls';
-// One scheduled task rendered as a status-rich card. Browsing happens here;
-// detailed configuration lives in the slide-over drawer (opened via Configure).
-export default function AppTaskCard({ taskType, config, apps, onTrigger, onConfigure, improvementDisabled }) {
+// One scheduled task rendered as a status-rich card. Browsing plus the common
+// "retarget the model and run it" loop happen here; the rest of the
+// configuration lives in the slide-over drawer (opened via Configure).
+export default function AppTaskCard({ taskType, config, apps, onTrigger, onConfigure, onUpdate, providers, activeProviderId, improvementDisabled }) {
+ // A pin write is async; Run reads the server-side config, so it must stay
+ // disabled until the write lands (see TaskModelQuickControls).
+ const [savingPins, setSavingPins] = useState(false);
const enabledCount = config.enabledAppCount ?? 0;
const totalCount = config.totalAppCount ?? 0;
const hasApps = totalCount > 0;
const coverage = coverageTone(enabledCount, totalCount);
const coveragePct = hasApps ? Math.round((enabledCount / totalCount) * 100) : 0;
const nextRun = describeNextRun(config);
+ // A pipeline task resolves provider/model per stage — a single card-level pin
+ // would be ignored, so point at the drawer instead of offering one.
+ const pipelineStages = config.taskMetadata?.pipeline?.stages?.length || 0;
return (
<div className="flex flex-col border border-port-border rounded-lg bg-port-card hover:border-port-border/60 transition-colors">
@@ -58,6 +67,27 @@ export default function AppTaskCard({ taskType, config, apps, onTrigger, onConfi
</div>
</button>
+ {/* Quick model pins — the drawer's Global defaults, inline */}
+ {onUpdate && (pipelineStages > 0 ? (
+ <button
+ type="button"
+ onClick={() => onConfigure(taskType)}
+ className="flex items-center gap-1.5 px-4 py-2.5 text-xs text-left text-gray-500 border-t border-port-border hover:text-gray-300 transition-colors"
+ >
+ <GitMerge size={12} className="shrink-0" />
+ Provider/model is set per stage ({pipelineStages}) — configure
+ </button>
+ ) : (
+ <TaskModelQuickControls
+ taskType={taskType}
+ config={config}
+ providers={providers}
+ activeProviderId={activeProviderId}
+ onUpdate={onUpdate}
+ onSavingChange={setSavingPins}
+ />
+ ))}
+
{/* Footer actions */}
<div className="flex items-center gap-2 px-4 py-2.5 border-t border-port-border">
<RunTaskButton
@@ -65,6 +95,7 @@ export default function AppTaskCard({ taskType, config, apps, onTrigger, onConfi
apps={apps}
onTrigger={onTrigger}
improvementDisabled={improvementDisabled}
+ saving={savingPins}
/>
<button
type="button"
diff --git a/client/src/components/cos/tabs/schedule/AppTaskCard.test.jsx b/client/src/components/cos/tabs/schedule/AppTaskCard.test.jsx
index d6e851e4e6..21341fe415 100644
--- a/client/src/components/cos/tabs/schedule/AppTaskCard.test.jsx
+++ b/client/src/components/cos/tabs/schedule/AppTaskCard.test.jsx
@@ -1,7 +1,13 @@
import { describe, it, expect, vi } from 'vitest';
-import { render, screen, fireEvent } from '@testing-library/react';
+import { render, screen, fireEvent, waitFor, within } from '@testing-library/react';
import AppTaskCard from './AppTaskCard';
+// `claude-code-*` ids carry the claude effort ladder (see effortLevelsForProvider).
+const providers = [
+ { id: 'claude-code', name: 'Claude Code', models: ['opus', 'sonnet'] },
+ { id: 'gemini', name: 'Gemini', models: ['gemini-3-pro'] },
+];
+
const baseConfig = {
enabled: true,
type: 'daily',
@@ -27,6 +33,12 @@ function renderCard(overrides = {}, props = {}) {
return { onTrigger, onConfigure };
}
+// Card with the inline provider/model/effort pins wired up.
+function renderCardWithPins(overrides = {}, props = {}) {
+ const onUpdate = props.onUpdate || vi.fn().mockResolvedValue(true);
+ return { onUpdate, ...renderCard(overrides, { providers, ...props, onUpdate }) };
+}
+
describe('AppTaskCard', () => {
it('shows app coverage prominently', () => {
renderCard();
@@ -97,4 +109,96 @@ describe('AppTaskCard', () => {
renderCard({});
expect(screen.queryByText(/^×\d/)).toBeNull();
});
+
+ it('omits the quick model pins when no onUpdate handler is supplied', () => {
+ renderCard({}, { providers });
+ expect(screen.queryByLabelText('Provider')).toBeNull();
+ });
+
+ describe('quick model pins', () => {
+ it('persists a provider pick and clears the model + effort pins with it', async () => {
+ const { onUpdate } = renderCardWithPins({ providerId: 'gemini', model: 'gemini-3-pro' });
+ fireEvent.change(screen.getByLabelText('Provider'), { target: { value: 'claude-code' } });
+ await waitFor(() => expect(onUpdate).toHaveBeenCalledWith('code-review', {
+ providerId: 'claude-code', model: null, effort: null,
+ }));
+ // Model options follow the newly picked provider.
+ expect(screen.getByRole('option', { name: 'opus' })).toBeTruthy();
+ });
+
+ it('persists a model pick on its own', async () => {
+ const { onUpdate } = renderCardWithPins({ providerId: 'claude-code' });
+ fireEvent.change(screen.getByLabelText('Model'), { target: { value: 'sonnet' } });
+ await waitFor(() => expect(onUpdate).toHaveBeenCalledWith('code-review', { model: 'sonnet' }));
+ });
+
+ it('clears a pin back to the provider default', async () => {
+ const { onUpdate } = renderCardWithPins({ providerId: 'claude-code', model: 'opus' });
+ fireEvent.change(screen.getByLabelText('Model'), { target: { value: '' } });
+ await waitFor(() => expect(onUpdate).toHaveBeenCalledWith('code-review', { model: null }));
+ });
+
+ it('offers effort only for effort-capable providers', () => {
+ renderCardWithPins({ providerId: 'claude-code' });
+ expect(screen.getByLabelText('Effort')).toBeTruthy();
+ expect(screen.getByRole('option', { name: 'xhigh' })).toBeTruthy();
+ });
+
+ it('hides effort for a provider with no ladder', () => {
+ renderCardWithPins({ providerId: 'gemini' });
+ expect(screen.queryByLabelText('Effort')).toBeNull();
+ });
+
+ it('resolves model + effort options against the active provider when nothing is pinned', () => {
+ renderCardWithPins({}, { activeProviderId: 'claude-code' });
+ // Naming what "Default" resolves to is what makes the options below it readable.
+ expect(screen.getByRole('option', { name: 'Active: Claude Code' })).toBeTruthy();
+ expect(screen.getByRole('option', { name: 'sonnet' })).toBeTruthy();
+ expect(screen.getByLabelText('Effort')).toBeTruthy();
+ });
+
+ it('falls back to a bare Default when the active provider is unknown', () => {
+ renderCardWithPins();
+ expect(within(screen.getByLabelText('Provider')).getByRole('option', { name: 'Default' })).toBeTruthy();
+ expect(screen.queryByLabelText('Effort')).toBeNull();
+ });
+
+ it('keeps a pinned model the provider no longer lists selectable', () => {
+ renderCardWithPins({ providerId: 'claude-code', model: 'retired-model' });
+ expect(screen.getByLabelText('Model').value).toBe('retired-model');
+ });
+
+ it('blocks Run while a pin write is still in flight, then re-enables it', async () => {
+ let resolveUpdate;
+ const onUpdate = vi.fn(() => new Promise(resolve => { resolveUpdate = resolve; }));
+ const { onTrigger } = renderCardWithPins({ providerId: 'claude-code' }, { onUpdate });
+
+ fireEvent.change(screen.getByLabelText('Model'), { target: { value: 'sonnet' } });
+ const run = screen.getByRole('button', { name: /Run Now/i });
+ await waitFor(() => expect(run.disabled).toBe(true));
+ fireEvent.click(run);
+ expect(onTrigger).not.toHaveBeenCalled();
+
+ resolveUpdate(true);
+ await waitFor(() => expect(run.disabled).toBe(false));
+ fireEvent.click(run);
+ expect(onTrigger).toHaveBeenCalledWith('code-review');
+ });
+
+ it('rolls the selection back when the write fails', async () => {
+ const onUpdate = vi.fn().mockResolvedValue(false);
+ renderCardWithPins({ providerId: 'claude-code', model: 'opus' }, { onUpdate });
+ fireEvent.change(screen.getByLabelText('Model'), { target: { value: 'sonnet' } });
+ await waitFor(() => expect(screen.getByLabelText('Model').value).toBe('opus'));
+ });
+
+ it('points pipeline tasks at the drawer instead of a card-level pin', () => {
+ const { onConfigure } = renderCardWithPins({
+ taskMetadata: { pipeline: { stages: [{ name: 'plan' }, { name: 'build' }] } },
+ });
+ expect(screen.queryByLabelText('Provider')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: /set per stage \(2\)/ }));
+ expect(onConfigure).toHaveBeenCalledWith('code-review');
+ });
+ });
});
diff --git a/client/src/components/cos/tabs/schedule/AppTaskTypeSection.jsx b/client/src/components/cos/tabs/schedule/AppTaskTypeSection.jsx
index 6da2306e6b..b0fc9e16ec 100644
--- a/client/src/components/cos/tabs/schedule/AppTaskTypeSection.jsx
+++ b/client/src/components/cos/tabs/schedule/AppTaskTypeSection.jsx
@@ -3,7 +3,7 @@ import { Search, X } from 'lucide-react';
import AppTaskCard from './AppTaskCard';
import { TASK_FILTERS, DEFAULT_FILTER_ID, taskSortKey } from './scheduleConstants';
-export default function AppTaskTypeSection({ tasks, apps, onTrigger, onSelectTask, improvementDisabled, filter, onFilterChange }) {
+export default function AppTaskTypeSection({ tasks, apps, providers, activeProviderId, onTrigger, onUpdate, onSelectTask, improvementDisabled, filter, onFilterChange }) {
const [search, setSearch] = useState('');
const taskEntries = Object.entries(tasks || {});
@@ -89,7 +89,10 @@ export default function AppTaskTypeSection({ tasks, apps, onTrigger, onSelectTas
taskType={taskType}
config={config}
apps={apps}
+ providers={providers}
+ activeProviderId={activeProviderId}
onTrigger={onTrigger}
+ onUpdate={onUpdate}
onConfigure={onSelectTask}
improvementDisabled={improvementDisabled}
/>
diff --git a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
index 69a57240d3..f8900b8add 100644
--- a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
+++ b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
@@ -11,7 +11,7 @@ import { useCodeReviewDefaults } from '../../../../hooks/useCodeReviewDefaults';
import useReviewerModelOptions from '../../../../hooks/useReviewerModelOptions';
import { reviewerModelsFromDefaults } from '../../../../lib/reviewerModels';
import ToggleSwitch from '../../../ToggleSwitch';
-import { filterSelectableModels } from '../../../../utils/providers';
+import useTaskModelPins from '../../../../hooks/useTaskModelPins';
import EffortSelect from '../../EffortSelect';
import PromptEditor from './PromptEditor';
import RunTaskButton from './RunTaskButton';
@@ -22,27 +22,34 @@ import { INTERVAL_DESCRIPTIONS, toggleMetadataField } from './scheduleConstants'
// runs (no app) land on the server-side fallback.
const PR_COMPLETION_INHERIT_HINT = `Uses the target app's "After opening PR" default (Apps → Edit App), or "${prCompletionOption(IMPLICIT_PR_COMPLETION)?.label}" when it has none.`;
-export default function GlobalConfigControls({ taskType, config, onUpdate, onTrigger, onReset, category: _category, providers, apps, updating, setUpdating, allTaskTypes, improvementDisabled }) {
+export default function GlobalConfigControls({ taskType, config, onUpdate, onTrigger, onReset, category: _category, providers, activeProviderId, apps, updating, setUpdating, allTaskTypes, improvementDisabled }) {
const reviewDefaults = useCodeReviewDefaults();
// Resolved model lists for the reviewer table's Model column (the picker itself
// never fetches — see its `modelOptions` prop).
const reviewerModelOptions = useReviewerModelOptions();
const [selectedType, setSelectedType] = useState(config.type);
- const [selectedProviderId, setSelectedProviderId] = useState(config.providerId || '');
- const [selectedModel, setSelectedModel] = useState(config.model || '');
- const [selectedEffort, setSelectedEffort] = useState(config.effort || '');
const [editingPrompt, setEditingPrompt] = useState(false);
const [promptValue, setPromptValue] = useState(config.prompt || '');
+ // Provider/model/effort pins are shared with the schedule card's quick
+ // controls — same optimistic write + rollback, one implementation.
+ const {
+ providerId: selectedProviderId,
+ model: selectedModel,
+ effort: selectedEffort,
+ provider: selectedProvider,
+ usingActiveProvider,
+ availableModels,
+ changeProvider: handleProviderChange,
+ changeModel: handleModelChange,
+ changeEffort: handleEffortChange,
+ } = useTaskModelPins({ taskType, config, providers, activeProviderId, onUpdate, onBusyChange: setUpdating });
useEffect(() => {
setSelectedType(config.type);
- setSelectedProviderId(config.providerId || '');
- setSelectedModel(config.model || '');
- setSelectedEffort(config.effort || '');
if (!editingPrompt) {
setPromptValue(config.prompt || '');
}
- }, [config.type, config.providerId, config.model, config.effort, config.prompt, editingPrompt]);
+ }, [config.type, config.prompt, editingPrompt]);
const activeApps = apps?.filter(app => !app.archived) || [];
@@ -103,34 +110,6 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
setUpdating(false);
};
- const handleProviderChange = async (newProviderId) => {
- setUpdating(true);
- setSelectedProviderId(newProviderId);
- setSelectedModel('');
- setSelectedEffort('');
- const providerId = newProviderId === '' ? null : newProviderId;
- await onUpdate(taskType, { providerId, model: null, effort: null }).catch(() => {
- setSelectedProviderId(config.providerId || '');
- setSelectedModel(config.model || '');
- setSelectedEffort(config.effort || '');
- });
- setUpdating(false);
- };
-
- // Optimistic single-field update: set locally, PUT ('' → null clears the
- // pin), roll back to the persisted value on failure. Shared by the model and
- // effort selects (provider has its own handler — it also resets these two).
- const makeScalarFieldHandler = (field, setter) => async (newValue) => {
- setUpdating(true);
- setter(newValue);
- await onUpdate(taskType, { [field]: newValue === '' ? null : newValue }).catch(() => {
- setter(config[field] || '');
- });
- setUpdating(false);
- };
- const handleModelChange = makeScalarFieldHandler('model', setSelectedModel);
- const handleEffortChange = makeScalarFieldHandler('effort', setSelectedEffort);
-
const handlePrAuthorFilterChange = async (value) => {
setUpdating(true);
// Send the full merged taskMetadata — updateTaskInterval replaces the
@@ -191,8 +170,8 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
? prCompletion === '' || prCompletion === 'review-then-merge'
: !!config.taskMetadata?.reviewLoop;
- const selectedProvider = providers?.find(p => p.id === (selectedProviderId || ''));
- const availableModels = filterSelectableModels(selectedProvider?.models);
+ // `selectedProvider` / `availableModels` come from useTaskModelPins above —
+ // it resolves the pin against the active provider and keeps a stale pin listed.
const status = config.status || {};
return (
@@ -311,7 +290,9 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
disabled={updating}
className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm"
>
- <option value="">Default (active provider)</option>
+ <option value="">
+ {usingActiveProvider ? `Default (active: ${selectedProvider.name})` : 'Default (active provider)'}
+ </option>
{providers?.map(provider => (
<option key={provider.id} value={provider.id}>{provider.name}</option>
))}
@@ -339,6 +320,7 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
<EffortSelect
provider={selectedProvider}
+ model={selectedModel}
value={selectedEffort}
onChange={handleEffortChange}
disabled={updating}
diff --git a/client/src/components/cos/tabs/schedule/RunTaskButton.jsx b/client/src/components/cos/tabs/schedule/RunTaskButton.jsx
index 5b7063e128..a6aa661de0 100644
--- a/client/src/components/cos/tabs/schedule/RunTaskButton.jsx
+++ b/client/src/components/cos/tabs/schedule/RunTaskButton.jsx
@@ -1,14 +1,20 @@
import { useState, useRef, useEffect } from 'react';
import { Play, ChevronDown, Package } from 'lucide-react';
-import { triggerButtonClass, IMPROVEMENT_DISABLED_TITLE } from './scheduleConstants';
+import { triggerButtonClass, IMPROVEMENT_DISABLED_TITLE, SAVING_TITLE } from './scheduleConstants';
// Trigger an on-demand run. When the task targets managed apps, opens a picker
// so the run carries app context; otherwise fires a plain global run. Shared by
// the schedule card and the drawer's global-config controls so both stay in sync.
-export default function RunTaskButton({ taskType, apps, onTrigger, improvementDisabled }) {
+//
+// `saving` means a provider/model/effort pin is still being persisted. The run
+// reads the server-side config, so triggering mid-write would run the previous
+// settings — hence a hard disable rather than a tooltip.
+export default function RunTaskButton({ taskType, apps, onTrigger, improvementDisabled, saving = false }) {
const [open, setOpen] = useState(false);
const ref = useRef(null);
const activeApps = apps?.filter(app => !app.archived) || [];
+ const disabled = improvementDisabled || saving;
+ const disabledTitle = improvementDisabled ? IMPROVEMENT_DISABLED_TITLE : SAVING_TITLE;
useEffect(() => {
if (!open) return;
@@ -19,18 +25,18 @@ export default function RunTaskButton({ taskType, apps, onTrigger, improvementDi
// Without this, an open dropdown survives a flip to disabled and pops back open when re-enabled.
useEffect(() => {
- if (improvementDisabled) setOpen(false);
- }, [improvementDisabled]);
+ if (disabled) setOpen(false);
+ }, [disabled]);
if (activeApps.length === 0) {
return (
- <span title={improvementDisabled ? IMPROVEMENT_DISABLED_TITLE : 'Run this task immediately (bypasses schedule)'} className="inline-block">
+ <span title={disabled ? disabledTitle : 'Run this task immediately (bypasses schedule)'} className="inline-block">
<button
type="button"
- onClick={() => !improvementDisabled && onTrigger(taskType)}
- disabled={improvementDisabled}
- aria-disabled={improvementDisabled || undefined}
- className={triggerButtonClass(improvementDisabled)}
+ onClick={() => !disabled && onTrigger(taskType)}
+ disabled={disabled}
+ aria-disabled={disabled || undefined}
+ className={triggerButtonClass(disabled)}
>
<Play size={14} />
Run Now
@@ -42,21 +48,21 @@ export default function RunTaskButton({ taskType, apps, onTrigger, improvementDi
return (
<div className="relative" ref={ref}>
{/* Tooltip on the wrapper, not the button: most browsers skip hover events on disabled controls. */}
- <span title={improvementDisabled ? IMPROVEMENT_DISABLED_TITLE : 'Run this task on a specific app'} className="inline-block">
+ <span title={disabled ? disabledTitle : 'Run this task on a specific app'} className="inline-block">
<button
type="button"
- onClick={() => !improvementDisabled && setOpen(o => !o)}
- disabled={improvementDisabled}
- aria-disabled={improvementDisabled || undefined}
+ onClick={() => !disabled && setOpen(o => !o)}
+ disabled={disabled}
+ aria-disabled={disabled || undefined}
aria-expanded={open}
- className={triggerButtonClass(improvementDisabled)}
+ className={triggerButtonClass(disabled)}
>
<Play size={14} />
Run on App
<ChevronDown size={12} className={`transition-transform ${open ? 'rotate-180' : ''}`} />
</button>
</span>
- {open && !improvementDisabled && (
+ {open && !disabled && (
<div className="port-menu-surface absolute bottom-full left-0 mb-1 z-50 w-64 max-w-[calc(100vw-2rem)] max-h-64 overflow-y-auto border border-port-border rounded-lg shadow-lg">
<div className="p-2 border-b border-port-border">
<span className="text-xs text-gray-400">Select an app to run {taskType} on:</span>
diff --git a/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx b/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx
index 720e3d4b4a..0010c40c54 100644
--- a/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx
+++ b/client/src/components/cos/tabs/schedule/TaskConfigDrawer.jsx
@@ -28,6 +28,7 @@ export default function TaskConfigDrawer({
onTrigger,
onReset,
providers,
+ activeProviderId,
apps,
onUpdateOverride,
onBulkToggleOverride,
@@ -88,6 +89,7 @@ export default function TaskConfigDrawer({
onReset={onReset}
category="appImprovement"
providers={providers}
+ activeProviderId={activeProviderId}
apps={apps}
updating={updating}
setUpdating={setUpdating}
diff --git a/client/src/components/cos/tabs/schedule/TaskModelQuickControls.jsx b/client/src/components/cos/tabs/schedule/TaskModelQuickControls.jsx
new file mode 100644
index 0000000000..a60b23a7d8
--- /dev/null
+++ b/client/src/components/cos/tabs/schedule/TaskModelQuickControls.jsx
@@ -0,0 +1,73 @@
+import { FormField } from '../../../ui/FormField';
+import EffortSelect from '../../EffortSelect';
+import useTaskModelPins from '../../../../hooks/useTaskModelPins';
+
+const LABEL_CLASS = 'block text-[10px] uppercase tracking-wide text-gray-500 mb-0.5';
+const SELECT_CLASS = 'w-full bg-port-card border border-port-border rounded px-1.5 py-1 text-xs text-white disabled:opacity-60';
+
+// Compact provider/model/effort pins rendered directly on a schedule card, so
+// the common "point this task at a different model and run it" loop doesn't
+// require opening the config drawer. Writes go through the same task-update
+// path as the drawer's Global defaults tab (useTaskModelPins).
+//
+// `onSavingChange` lifts the in-flight flag to the card, which disables Run
+// while a pin is still being persisted — the run reads the server-side config,
+// not these inputs.
+export default function TaskModelQuickControls({ taskType, config, providers, activeProviderId, onUpdate, disabled = false, onSavingChange }) {
+ const { providerId, model, effort, provider, usingActiveProvider, availableModels, saving, changeProvider, changeModel, changeEffort } =
+ useTaskModelPins({ taskType, config, providers, activeProviderId, onUpdate, onBusyChange: onSavingChange });
+
+ const locked = disabled || saving;
+ // Name what "Default" resolves to right now, so the model/effort options
+ // below it aren't from a provider the user has to guess at.
+ const defaultLabel = usingActiveProvider ? `Active: ${provider.name}` : 'Default';
+
+ return (
+ <div className="flex flex-wrap items-end gap-2 px-4 py-2.5 border-t border-port-border">
+ <FormField label="Provider" className="min-w-[7rem] flex-1" labelClassName={LABEL_CLASS}>
+ <select
+ value={providerId}
+ onChange={(e) => changeProvider(e.target.value)}
+ disabled={locked}
+ className={SELECT_CLASS}
+ title="Provider for this task's runs — Default follows the active provider"
+ >
+ <option value="">{defaultLabel}</option>
+ {providers?.map(p => (
+ <option key={p.id} value={p.id}>{p.name}</option>
+ ))}
+ </select>
+ </FormField>
+
+ <FormField label="Model" className="min-w-[7rem] flex-1" labelClassName={LABEL_CLASS}>
+ <select
+ value={model}
+ onChange={(e) => changeModel(e.target.value)}
+ disabled={locked}
+ className={SELECT_CLASS}
+ title="Model override — Default uses the provider's default model"
+ >
+ <option value="">Default</option>
+ {/* A pin the current provider no longer lists still renders, or the
+ select would show blank and read as "Default". */}
+ {model && !availableModels.includes(model) && <option value={model}>{model}</option>}
+ {availableModels.map(m => (
+ <option key={m} value={m}>{m}</option>
+ ))}
+ </select>
+ </FormField>
+
+ <EffortSelect
+ provider={provider}
+ model={model}
+ value={effort}
+ onChange={changeEffort}
+ disabled={locked}
+ label="Effort"
+ fieldClassName="min-w-[7rem] flex-1"
+ labelClassName={LABEL_CLASS}
+ className={SELECT_CLASS}
+ />
+ </div>
+ );
+}
diff --git a/client/src/components/cos/tabs/schedule/scheduleConstants.js b/client/src/components/cos/tabs/schedule/scheduleConstants.js
index b14d92bd1c..888661d008 100644
--- a/client/src/components/cos/tabs/schedule/scheduleConstants.js
+++ b/client/src/components/cos/tabs/schedule/scheduleConstants.js
@@ -43,6 +43,8 @@ export const badge = (variant) => `text-xs font-medium px-2.5 py-1 rounded-full
export const IMPROVEMENT_DISABLED_TITLE = 'Improvement is disabled — enable it in CoS → Config';
+export const SAVING_TITLE = 'Saving provider/model settings — the run will use them once saved';
+
export const triggerButtonClass = (disabled) =>
`flex items-center gap-1 px-3 py-1.5 text-sm rounded transition-colors ${disabled ? 'bg-port-border/30 text-gray-500 cursor-not-allowed' : 'bg-port-accent/20 hover:bg-port-accent/30 text-port-accent'}`;
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 4240d5f2ba..db2001c5f8 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -143,6 +143,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `useAppDeploy` | Stream `deploy.sh` output via Socket.IO. | App deployment surfaces only. |
| `useAppOperation` | Socket-based app ops (update, standardize) with step tracking. | App operations UI. |
| `useAppOverrideActions` | Per-app scheduled-task override mutations (`{ handleUpdateOverride, handleBulkToggleOverride }`) with shared toast copy + silent flag; pass the tab's `refetch`. | Any surface hosting `PerAppOverrideList` (Schedule tab, Timeline tab) — don't re-copy the write-plus-toast-plus-refetch handlers. |
+| `useTaskModelPins` | Provider/model/effort pins for one CoS scheduled task: optimistic write per change (`'' → null` clears; picking a provider clears model+effort), rollback when `onUpdate` resolves `false`, plus a `saving` flag to gate "Run Now". | Any surface that retargets a scheduled task's model (schedule card quick controls, config drawer Global defaults) — don't re-roll the select/PUT/rollback trio. |
| `useCanonPatch` | Optimistic canon-entry patch: rebuild the kind list with one entry mutated, apply locally, PATCH the universe, re-apply the server copy. Targets + staleness-guards on the loaded record's `universe.id` so a mid-flight universe swap can't cross-PATCH or resurrect stale state. `apply` is `setUniverse` or `onUniverseChange`. | Inline canon-field edits on a universe (UniverseCanonSection, NounsStage). Don't re-roll the optimistic-then-confirm dance. |
| `useCityAudio` | CyberCity ambient audio. | CyberCity only. |
| `useCityData` | CyberCity environment data + physics. | CyberCity only. |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index 9e23b8aa52..786cbdf4cb 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -164,6 +164,7 @@ export * from './useSidebarUniverses.js';
export * from './useAppDeploy.js';
export * from './useAppOperation.js';
export * from './useAppOverrideActions.js';
+export * from './useTaskModelPins.js';
export * from './useCanonPatch.js';
export * from './useCityData.js';
export * from './useCityPlayback.js';
diff --git a/client/src/hooks/useTaskModelPins.js b/client/src/hooks/useTaskModelPins.js
new file mode 100644
index 0000000000..d5219d0fdf
--- /dev/null
+++ b/client/src/hooks/useTaskModelPins.js
@@ -0,0 +1,104 @@
+import { useState, useEffect, useCallback } from 'react';
+import { filterSelectableModels } from '../utils/providers';
+
+/**
+ * Provider / model / effort pins for one CoS scheduled task, shared by the
+ * schedule card's quick controls and the config drawer's global controls so a
+ * change made in either place goes through the same optimistic-write path.
+ *
+ * Each change is written immediately (`'' → null` clears the pin) and rolled
+ * back to the persisted value when the write fails. Picking a provider also
+ * clears model + effort in the same PUT — a model from the previous provider
+ * would not resolve.
+ *
+ * `saving` is the in-flight flag callers must use to gate any action that reads
+ * these pins server-side (the "Run Now" button), per the repo's
+ * "in-flight saves must gate dependent actions" convention — otherwise the user
+ * picks a model and triggers a run before the server has it.
+ *
+ * @param {object} params
+ * @param {string} params.taskType - Task id (e.g. `code-review`).
+ * @param {object} params.config - The live task config from the schedule payload.
+ * @param {object[]} [params.providers] - Provider records, for resolving the model list.
+ * @param {string} [params.activeProviderId] - The install's active provider. With
+ * no provider pinned the task runs on it, so the model list and effort ladder
+ * resolve against it — otherwise "no provider pinned" would mean "no way to
+ * pin a model or effort either" (same fallback as the pipeline's LLM pickers).
+ * @param {function} params.onUpdate - `(taskType, settings) => Promise<boolean|void>`;
+ * resolving `false` (or rejecting) rolls the local selection back.
+ * @param {function} [params.onBusyChange] - Mirrors `saving` into a caller-owned
+ * updating flag (the drawer disables its whole form off one).
+ * @returns {{providerId: string, model: string, effort: string, provider: object|undefined,
+ * usingActiveProvider: boolean, availableModels: string[], saving: boolean,
+ * changeProvider: function, changeModel: function, changeEffort: function}}
+ */
+export function useTaskModelPins({ taskType, config, providers, activeProviderId, onUpdate, onBusyChange }) {
+ const [providerId, setProviderId] = useState(config?.providerId || '');
+ const [model, setModel] = useState(config?.model || '');
+ const [effort, setEffort] = useState(config?.effort || '');
+ const [saving, setSaving] = useState(false);
+
+ // Re-sync from the refetched config (and when the hosting surface switches task).
+ useEffect(() => {
+ setProviderId(config?.providerId || '');
+ setModel(config?.model || '');
+ setEffort(config?.effort || '');
+ }, [taskType, config?.providerId, config?.model, config?.effort]);
+
+ const setBusy = useCallback((busy) => {
+ setSaving(busy);
+ onBusyChange?.(busy);
+ }, [onBusyChange]);
+
+ const commit = useCallback(async (patch, rollback) => {
+ setBusy(true);
+ // Callers that own their own error toast resolve `false` on failure; the
+ // ones that resolve nothing (older call sites, tests) count as success.
+ const ok = await onUpdate(taskType, patch).catch(() => false);
+ if (ok === false) rollback();
+ setBusy(false);
+ }, [onUpdate, taskType, setBusy]);
+
+ const restore = useCallback(() => {
+ setProviderId(config?.providerId || '');
+ setModel(config?.model || '');
+ setEffort(config?.effort || '');
+ }, [config?.providerId, config?.model, config?.effort]);
+
+ const changeProvider = useCallback((next) => {
+ setProviderId(next);
+ setModel('');
+ setEffort('');
+ return commit({ providerId: next === '' ? null : next, model: null, effort: null }, restore);
+ }, [commit, restore]);
+
+ const changeModel = useCallback((next) => {
+ setModel(next);
+ return commit({ model: next === '' ? null : next }, restore);
+ }, [commit, restore]);
+
+ const changeEffort = useCallback((next) => {
+ setEffort(next);
+ return commit({ effort: next === '' ? null : next }, restore);
+ }, [commit, restore]);
+
+ // With nothing pinned the run resolves to the active provider, so that's whose
+ // catalog the model/effort pickers must offer.
+ const resolvedProviderId = providerId || activeProviderId || '';
+ const provider = providers?.find(p => p.id === resolvedProviderId);
+
+ return {
+ providerId,
+ model,
+ effort,
+ provider,
+ usingActiveProvider: !providerId && !!provider,
+ availableModels: filterSelectableModels(provider?.models),
+ saving,
+ changeProvider,
+ changeModel,
+ changeEffort,
+ };
+}
+
+export default useTaskModelPins;
diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsx
index 762779b0f1..a645fc2340 100644
--- a/client/src/pages/ChiefOfStaff.jsx
+++ b/client/src/pages/ChiefOfStaff.jsx
@@ -70,6 +70,9 @@ export default function ChiefOfStaff() {
const [agents, setAgents] = useState([]);
const [health, setHealth] = useState(null);
const [providers, setProviders] = useState([]);
+ // Which provider an unpinned task actually runs on — the Schedule tab names it
+ // on the "Default" option and resolves model/effort choices against it.
+ const [activeProviderId, setActiveProviderId] = useState(null);
const [apps, setApps] = useState([]);
const [loading, setLoading] = useState(true);
const [agentState, setAgentState] = useState('sleeping');
@@ -160,6 +163,7 @@ export default function ChiefOfStaff() {
return healthData;
});
setProviders(providersData.providers || []);
+ setActiveProviderId(providersData.activeProvider || null);
// Filter out PortOS Autofixer (it's part of PortOS project)
setApps(appsData.filter(a => a.id !== 'portos-autofixer'));
setLearningSummary(learningSummaryData);
@@ -927,7 +931,7 @@ export default function ChiefOfStaff() {
)}
{activeTab === 'schedule' && (
<div role="tabpanel" id="tabpanel-schedule" aria-labelledby="tab-schedule">
- <ScheduleTab apps={apps} providers={providers} />
+ <ScheduleTab apps={apps} providers={providers} activeProviderId={activeProviderId} />
</div>
)}
{activeTab === 'workflow' && (