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

address review (codex): advance the baseline per saved stage; hold the vision picker while scanning

Adam Eivy894b78e9cbef
diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx
index 1e125be14c..92e4c58572 100644
--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx
+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.jsx
@@ -130,7 +130,12 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o
const saveGlobal = async () => {
// Only PUT stages that actually changed — each call re-derives the whole
- // assignments payload server-side.
+ // assignments payload server-side. There is no multi-stage transaction, so
+ // each stage's baseline is advanced the moment ITS PUT lands: if a later
+ // stage then fails we bail with the earlier one already recorded as
+ // persisted. Otherwise the user could revert that control to its original
+ // displayed value, the retry would see it as clean and skip it, and the
+ // server would keep the value they just backed out of.
let latest = null;
for (const { key, label } of STAGES) {
const d = drafts[key];
@@ -144,6 +149,7 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o
return null;
});
if (!next) return null;
+ setBaseline((prev) => ({ ...prev, [key]: d }));
latest = next;
}
return latest;
@@ -228,6 +234,12 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o
// scan has settled — until then `modelOptions` is regex-only, which
// is exactly the stale answer that hid the user's VLMs.
const visionPending = visionLocal && !visionLoaded;
+ // Picking a provider seeds its default model, and for a vision stage
+ // that seed is only correct once we know what's installed — pick
+ // during the scan and the stage is left on a blank pin, which the
+ // evaluator resolves to the provider's own (possibly text-only)
+ // default. Hold the control rather than seeding from a stale answer.
+ const visionUnknown = entry?.modelFilter === 'vision' && !visionLoaded;
// A local backend with nothing left to offer means no VLM is
// installed — say so instead of showing a bare text box that reads
// as a broken dropdown.
@@ -251,6 +263,7 @@ export default function CreativeDirectorModelsDrawer({ open, onClose, project, o
<select
value={draft.providerId}
aria-label={`${stage.label} provider`}
+ disabled={visionUnknown}
onChange={(e) => {
const providerId = e.target.value;
// Vision-filtered stages (scene evaluation) seed the first
diff --git a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx
index dced8d9d81..807d488239 100644
--- a/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx
+++ b/client/src/components/creative-director/CreativeDirectorModelsDrawer.test.jsx
@@ -160,6 +160,23 @@ describe('CreativeDirectorModelsDrawer', () => {
expect(screen.queryByText(/No vision-capable models found/i)).toBeNull();
});
+ // Picking a provider seeds its default model; during the capability scan that
+ // seed comes from the stale regex answer, so a vision stage would be left on a
+ // blank pin that the evaluator resolves to a possibly text-only default.
+ it('holds the vision provider control until the capability scan settles', async () => {
+ let resolveVision;
+ getVisionModels.mockReturnValue(new Promise((r) => { resolveVision = r; }));
+ renderDrawer({ id: 'cd-1', name: 'Demo', modelOverrides: {} });
+ await waitFor(() => expect(screen.getByLabelText('Scene evaluation provider')).toBeTruthy());
+
+ // Vision stage is held; the non-vision stages stay usable.
+ expect(screen.getByLabelText('Scene evaluation provider').disabled).toBe(true);
+ expect(screen.getByLabelText('Treatment provider').disabled).toBe(false);
+
+ resolveVision({ models: [{ providerId: 'ollama', backend: 'ollama', id: 'gemma4:26b', vision: true }] });
+ await waitFor(() => expect(screen.getByLabelText('Scene evaluation provider').disabled).toBe(false));
+ });
+
it('does not fetch vision models while closed', async () => {
// The drawer stays mounted on the page; the endpoint asks Ollama for every
// installed model's capabilities, so a closed drawer must not pay for it.
@@ -298,6 +315,34 @@ describe('CreativeDirectorModelsDrawer', () => {
expect(updateAiAssignment.mock.calls.map((c) => c[0])).not.toContain('settings.creativeDirector.plan');
});
+ // There is no multi-stage transaction: if stage 2's PUT fails after stage 1's
+ // landed, stage 1 must still be recorded as persisted. Otherwise the user can
+ // revert that control to its original value, the retry skips it as "clean",
+ // and the server silently keeps the value they backed out of.
+ it('keeps an already-persisted stage dirty-tracked when a later stage fails', async () => {
+ updateAiAssignment
+ .mockResolvedValueOnce(ASSIGNMENTS) // treatment: OK
+ .mockRejectedValueOnce(new Error('boom')); // plan: fails
+ renderGlobal();
+ await waitFor(() => expect(screen.getByLabelText('Treatment provider')).toBeTruthy());
+
+ fireEvent.change(screen.getByLabelText('Treatment provider'), { target: { value: 'agent-a' } });
+ fireEvent.change(screen.getByLabelText('Production plan provider'), { target: { value: 'agent-a' } });
+ fireEvent.click(screen.getByRole('button', { name: /Save/i }));
+
+ await waitFor(() => expect(updateAiAssignment).toHaveBeenCalledTimes(2));
+ // Treatment persisted, so reverting it is a REAL change again — the retry
+ // must re-PUT it rather than skipping it as unchanged.
+ fireEvent.change(screen.getByLabelText('Treatment provider'), { target: { value: '' } });
+ updateAiAssignment.mockReset();
+ updateAiAssignment.mockResolvedValue(ASSIGNMENTS);
+ fireEvent.click(screen.getByRole('button', { name: /Save/i }));
+
+ await waitFor(() => expect(updateAiAssignment).toHaveBeenCalled());
+ expect(updateAiAssignment.mock.calls.map((c) => c[0]))
+ .toContain('settings.creativeDirector.treatment');
+ });
+
it('does not write the project record', async () => {
updateAiAssignment.mockResolvedValue(ASSIGNMENTS);
renderGlobal();
diff --git a/client/src/components/settings/AiAssignmentsTab.jsx b/client/src/components/settings/AiAssignmentsTab.jsx
index a3f854ca4a..612417d323 100644
--- a/client/src/components/settings/AiAssignmentsTab.jsx
+++ b/client/src/components/settings/AiAssignmentsTab.jsx
@@ -50,7 +50,7 @@ export default function AiAssignmentsTab() {
// vision-filtered row (Scene evaluation) isn't reduced to an empty list by
// the client's id regex not knowing a newer VLM family. This table renders a
// <select> either way (no "none installed" claim), so it needs the map only.
- const { idsByProvider: visionIdsByProvider } = useVisionModelIds();
+ const { idsByProvider: visionIdsByProvider, loaded: visionLoaded } = useVisionModelIds();
const load = useCallback(async () => {
setLoading(true);
@@ -260,6 +260,11 @@ export default function AiAssignmentsTab() {
const providerOptions = assignmentProviderOptions(entry, data.providers);
const modelOptions = assignmentModelOptions(entry, data.providers, draft.providerId, visionIdsByProvider);
const dirty = !sameDraft(entry, draft);
+ // Choosing a provider seeds its default model; for a vision row
+ // that seed is only correct once the capability scan has settled.
+ // Picking during it leaves a blank model pin, which the evaluator
+ // resolves to the provider's own (possibly text-only) default.
+ const visionUnknown = entry.modelFilter === 'vision' && !visionLoaded;
return (
<tr key={entry.id} className="align-top">
<td className="px-3 py-3 text-sm text-gray-300 whitespace-nowrap">
@@ -284,7 +289,8 @@ export default function AiAssignmentsTab() {
setDraft(entry.id, { providerId: nextProviderId, model: entry.modelEditable === false ? draft.model : nextDefault });
}}
aria-label={`Provider for ${entry.label}`}
- className="w-full bg-port-card border border-port-border rounded px-2 py-2 text-sm text-white"
+ disabled={visionUnknown}
+ className="w-full bg-port-card border border-port-border rounded px-2 py-2 text-sm text-white disabled:opacity-50"
>
<option value="">Default / unset</option>
{providerOptions.map((p) => <option key={p.id} value={p.id}>{p.name}</option>)}