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: preview saved Production authoring settings (#9387)

[._.]/ Adam Eivya4fb6db00ad4
diff --git a/client/src/components/codeAnimation/ProductionPreflight.jsx b/client/src/components/codeAnimation/ProductionPreflight.jsx
new file mode 100644
index 0000000000..03f0c9a637
--- /dev/null
+++ b/client/src/components/codeAnimation/ProductionPreflight.jsx
@@ -0,0 +1,21 @@
+import { useState } from 'react';
+import { useAsyncAction } from '../../hooks/useAsyncAction';
+import { preflightCodeAnimationProject } from '../../services/apiCodeAnimation';
+
+export default function ProductionPreflight({ project, disabled }) {
+ const [result, setResult] = useState(null);
+ const [check, checking] = useAsyncAction(async () => {
+ setResult(null);
+ setResult(await preflightCodeAnimationProject(project.id, { silent: true }));
+ });
+ return <div className="space-y-2">
+ <button type="button" disabled={disabled || checking} onClick={check} className="rounded border border-port-border px-3 py-2 text-sm disabled:opacity-50">{checking ? 'Checking settings…' : 'Check saved authoring settings'}</button>
+ {!disabled && result && <div role="status" className="space-y-2 text-sm">
+ <p>{result.problems.length ? 'Settings need attention' : 'Settings are compatible with the configured route'}</p>
+ {result.resolved && <p className="break-words text-gray-400">{result.resolved.harness} · {result.resolved.mode} · {result.resolved.model || 'Unknown model'} · Effort: {result.resolved.effort || 'Unspecified'}</p>}
+ {result.problems.map(problem => <p key={problem} className="text-port-warning">{problem}</p>)}
+ {result.notes.map(note => <p key={note} className="text-gray-400">{note}</p>)}
+ <p className="text-gray-400">No provider was called. Actual execution settings remain unverified.</p>
+ </div>}
+ </div>;
+}
diff --git a/client/src/components/codeAnimation/ProductionProjectForm.jsx b/client/src/components/codeAnimation/ProductionProjectForm.jsx
index a60c0544d6..b821d7a009 100644
--- a/client/src/components/codeAnimation/ProductionProjectForm.jsx
+++ b/client/src/components/codeAnimation/ProductionProjectForm.jsx
@@ -1,4 +1,6 @@
import { useEffect, useState } from 'react';
+import useProviderModels from '../../hooks/useProviderModels';
+import ProviderModelSelector from '../ProviderModelSelector';
const inputClass = 'w-full rounded border border-port-border bg-port-bg px-3 py-2 text-sm';
const budgets = { iterations: 8, timeSeconds: 900, tokens: 128000, renderSeconds: 300, diskBytes: 512 * 1024 * 1024 };
@@ -13,8 +15,10 @@ const emptyManifest = {
export default function ProductionProjectForm({ project, onSave, busy, onDirtyChange }) {
const [manifest, setManifest] = useState(() => project?.manifest || emptyManifest);
const [limits, setLimits] = useState(() => project?.budgets || budgets);
- const [baseline, setBaseline] = useState(() => JSON.stringify({ manifest: project?.manifest || emptyManifest, budgets: project?.budgets || budgets }));
- const dirty = JSON.stringify({ manifest, budgets: limits }) !== baseline;
+ const { providers } = useProviderModels({ allowDefault: true, withEffort: true });
+ const [localSettings, setLocalSettings] = useState(() => project?.localSettings || {});
+ const [baseline, setBaseline] = useState(() => JSON.stringify({ manifest: project?.manifest || emptyManifest, budgets: project?.budgets || budgets, localSettings: project?.localSettings || {} }));
+ const dirty = JSON.stringify({ manifest, budgets: limits, localSettings }) !== baseline;
useEffect(() => { onDirtyChange?.(dirty); }, [dirty, onDirtyChange]);
const field = (name, label, value, change, type = 'text', props = {}) => (
<div key={name} className="min-w-0">
@@ -24,11 +28,12 @@ export default function ProductionProjectForm({ project, onSave, busy, onDirtyCh
);
return <form className="space-y-3" onSubmit={event => {
event.preventDefault();
- onSave({ manifest, budgets: limits }).then(saved => {
+ onSave({ manifest, budgets: limits, localSettings }).then(saved => {
if (saved) {
setManifest(saved.manifest);
setLimits(saved.budgets);
- setBaseline(JSON.stringify({ manifest: saved.manifest, budgets: saved.budgets }));
+ setLocalSettings(saved.localSettings || {});
+ setBaseline(JSON.stringify({ manifest: saved.manifest, budgets: saved.budgets, localSettings: saved.localSettings || {} }));
}
});
}}>
@@ -64,6 +69,14 @@ export default function ProductionProjectForm({ project, onSave, busy, onDirtyCh
</select>
</div>
</div>
+ <h3 className="text-sm font-medium">Authoring agent</h3>
+ <ProviderModelSelector providers={providers} selectedProviderId={localSettings.providerId || ''}
+ selectedModel={localSettings.model || ''} effort={localSettings.effort || ''}
+ emptyProviderOption="Select an authoring provider" emptyModelOption="Select a model"
+ onProviderChange={providerId => setLocalSettings({ providerId: providerId || null, model: null, effort: null, mode: null, connectionId: null })}
+ onModelChange={model => setLocalSettings(previous => ({ ...previous, model: model || null }))}
+ onEffortChange={effort => setLocalSettings(previous => ({ ...previous, effort: effort || null }))} />
+ <p className="text-xs text-gray-400">Saved on this machine. Renderer selection does not change the authoring agent. Reasoning effort is independent of the budgets below.</p>
<h3 className="text-sm font-medium">Independent budgets</h3>
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
{Object.entries({ iterations: 'Iterations', timeSeconds: 'Elapsed time (seconds)', tokens: 'Tokens', renderSeconds: 'Render time (seconds)', diskBytes: 'Retained source disk (bytes)' }).map(([name, label]) =>
diff --git a/client/src/components/codeAnimation/ProductionProjects.jsx b/client/src/components/codeAnimation/ProductionProjects.jsx
index 6dda79d20a..fd8e675a9f 100644
--- a/client/src/components/codeAnimation/ProductionProjects.jsx
+++ b/client/src/components/codeAnimation/ProductionProjects.jsx
@@ -14,6 +14,7 @@ import { downloadBlob } from '../../lib/downloadBlob';
import { formatCount, formatBytes, timeAgo } from '../../utils/formatters';
import InfiniteScrollFooter from '../ui/InfiniteScrollFooter';
import ProductionProjectForm from './ProductionProjectForm';
+import ProductionPreflight from './ProductionPreflight';
const EVENTS = ['code-animation:changed'];
const buttonClass = 'rounded border border-port-border px-3 py-2 text-sm hover:border-port-accent disabled:opacity-50';
@@ -106,6 +107,7 @@ export default function ProductionProjects() {
</section>
{project && <section className="min-w-0 space-y-4 rounded-xl border border-port-border bg-port-card p-4">
<h2 className="text-base font-semibold">Source and history</h2>
+ <ProductionPreflight key={JSON.stringify([project.id, project.localSettings, dirty])} project={project} disabled={busy || dirty} />
<div className="flex flex-wrap gap-2">
<button className={buttonClass} disabled={busy || dirty} onClick={() => download()}>Export brief</button>
{project.acceptedRevisionId && <button className={buttonClass} disabled={busy} onClick={() => download(project.acceptedRevisionId)}>Export accepted package</button>}
diff --git a/client/src/components/codeAnimation/ProductionProjects.test.jsx b/client/src/components/codeAnimation/ProductionProjects.test.jsx
index 6608a02e82..cc8e9c6e58 100644
--- a/client/src/components/codeAnimation/ProductionProjects.test.jsx
+++ b/client/src/components/codeAnimation/ProductionProjects.test.jsx
@@ -3,8 +3,10 @@ import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MemoryRouter, Route, Routes } from 'react-router';
+vi.mock('../../hooks/useProviderModels', () => ({ default: () => ({ providers: [{ id: 'example-provider', name: 'Example agent', type: 'cli', command: 'claude', models: ['example-model'] }] }) }));
vi.mock('../../services/socket', () => ({ default: { on: vi.fn(), off: vi.fn(), emit: vi.fn() } }));
vi.mock('../../services/apiCodeAnimation', () => ({
+ preflightCodeAnimationProject: vi.fn(),
listCodeAnimationProjects: vi.fn(), createCodeAnimationProject: vi.fn(), getCodeAnimationProject: vi.fn(),
updateCodeAnimationProject: vi.fn(), importCodeAnimationPackage: vi.fn(), acceptCodeAnimationSource: vi.fn(),
getCodeAnimationProjectBrief: vi.fn(), getCodeAnimationRevisionPackage: vi.fn(), listCodeAnimationProjectHistory: vi.fn(),
@@ -22,7 +24,7 @@ const project = {
execution: { requested: null, effective: null }, assets: [], events: [], shots: [],
},
budgets: { iterations: 3, timeSeconds: 123, tokens: 4321, renderSeconds: 45, diskBytes: 123456 },
- localSettings: { model: 'example-model', mode: 'cli' },
+ localSettings: { providerId: 'example-provider', model: 'example-model', mode: 'cli', effort: 'high' },
acceptedRevisionId: null, candidateRevisionId: '00000000-0000-4000-8000-000000000002',
};
const page = (items = []) => ({ items, nextCursor: null });
@@ -76,6 +78,24 @@ describe('Production project rendered interactions', () => {
expect(api.importCodeAnimationPackage).toHaveBeenCalledWith(project.id, source, { silent: true });
});
+ it('preserves the authoring pin across renderer edits and checks only saved settings', async () => {
+ const user = userEvent.setup();
+ renderPage();
+ await screen.findByLabelText('Renderer');
+ await user.selectOptions(screen.getByLabelText('Renderer'), 'blender');
+ expect(screen.getByRole('button', { name: 'Check saved authoring settings' })).toBeDisabled();
+ api.updateCodeAnimationProject.mockImplementation(async (_id, input) => ({ ...project, ...input }));
+ await user.click(screen.getByRole('button', { name: 'Save project settings' }));
+ await waitFor(() => expect(screen.getByRole('button', { name: 'Check saved authoring settings' })).toBeEnabled());
+ expect(api.updateCodeAnimationProject).toHaveBeenCalledWith(project.id, expect.objectContaining({ localSettings: project.localSettings, manifest: expect.objectContaining({ renderer: expect.objectContaining({ kind: 'blender' }) }) }), { silent: true });
+ api.preflightCodeAnimationProject.mockResolvedValue({ problems: ['Example unsupported effort'], resolved: null, notes: ['Settings preview only.'] });
+ await user.click(screen.getByRole('button', { name: 'Check saved authoring settings' }));
+ expect(await screen.findByText('Example unsupported effort')).toBeInTheDocument();
+ expect(screen.getByText(/Actual execution settings remain unverified/)).toBeInTheDocument();
+ await user.selectOptions(screen.getByLabelText('Renderer'), 'browser');
+ expect(screen.queryByText('Example unsupported effort')).not.toBeInTheDocument();
+ });
+
it('creates an opt-in project and navigates to its durable detail URL', async () => {
const user = userEvent.setup();
api.createCodeAnimationProject.mockResolvedValue(project);
diff --git a/client/src/services/apiCodeAnimation.js b/client/src/services/apiCodeAnimation.js
index 57b7d67a2d..537b2c5908 100644
--- a/client/src/services/apiCodeAnimation.js
+++ b/client/src/services/apiCodeAnimation.js
@@ -60,3 +60,5 @@ export const cancelCodeAnimationExport = (exportJobId, options) => request(`/htm
method: 'POST',
...options,
});
+
+export const preflightCodeAnimationProject = (id, options) => request(`/code-animation/projects/${encodeURIComponent(id)}/preflight`, options);
diff --git a/docs/CODE_ANIMATION_PACKAGES.md b/docs/CODE_ANIMATION_PACKAGES.md
index f49ac983b7..9f1bc6e4f3 100644
--- a/docs/CODE_ANIMATION_PACKAGES.md
+++ b/docs/CODE_ANIMATION_PACKAGES.md
@@ -76,3 +76,19 @@ settings changes the revision hash. The leaf contract in
`server/lib/codeAnimationPackage.js` provides the shared schema and builder.
No package is persisted by these endpoints, so this slice needs no new store,
seed, migration, or federation channel.
+
+## Saved authoring settings
+
+Production projects use the existing scoped provider/model/effort picker. These
+settings remain machine-local and independent of the renderer and production
+budgets. Save edits before using **Check saved authoring settings**.
+
+`GET /api/code-animation/projects/:id/preflight` reads the saved selection and
+reports missing/disabled routes, model pins, unsupported effort, and stale
+connection/mode constraints. `resolved` is a configuration preview; `effective`
+is null and `executed` is false. It neither contacts a model nor probes or grants
+tools. Catalog compatibility does not verify runtime installation, credentials,
+model access at the vendor, or render readiness. Production authoring dispatch,
+render/inspection/research adapters, fallback decisions and actual-run provenance
+remain pending under #9387 and the execution slices of #9383. Package export and
+import remain available for external authoring.
diff --git a/server/routes/codeAnimation.js b/server/routes/codeAnimation.js
index 3b293f847c..f169fe468c 100644
--- a/server/routes/codeAnimation.js
+++ b/server/routes/codeAnimation.js
@@ -14,6 +14,7 @@
*/
import { Router } from 'express';
+import { preflightProductionProject } from '../services/codeAnimation/preflight.js';
import { z } from 'zod';
import { asyncHandler, ServerError } from '../lib/errorHandler.js';
import { validateRequest } from '../lib/validation.js';
@@ -192,6 +193,10 @@ router.patch('/projects/:id', asyncHandler(async (req, res) => {
const { id } = validateRequest(exportParamsSchema, req.params);
res.json(await patchProductionProject(id, validateRequest(codeAnimationProjectPatchSchema, req.body)));
}));
+router.get('/projects/:id/preflight', asyncHandler(async (req, res) => {
+ const { id } = validateRequest(exportParamsSchema, req.params);
+ res.json(await preflightProductionProject(id));
+}));
router.get('/projects/:id/history', asyncHandler(async (req, res) => {
const { id } = validateRequest(exportParamsSchema, req.params);
res.json(await getProductionHistory(id, projectPage(req.query)));
diff --git a/server/services/codeAnimation/preflight.js b/server/services/codeAnimation/preflight.js
new file mode 100644
index 0000000000..f5985e265c
--- /dev/null
+++ b/server/services/codeAnimation/preflight.js
@@ -0,0 +1,51 @@
+/** Data-only preview. No provider invocation, tool probe, or execution grant. */
+import { getProductionProject } from './projects.js';
+import { getProviderById, getSelectableProviders } from '../providers.js';
+import { applyModelAccess } from '../../lib/aiToolkit/internal/modelAccess.js';
+import { harnessForProvider, providerRouteMode } from '../../lib/providerHarnesses.js';
+import { effortLevelsForProvider, hasEffortFlag, isConfiguredDefaultModel, antigravityBaseModels } from '../../lib/providerModels.js';
+import { isCompositeProviderId } from '../../lib/providerRef.js';
+
+export async function preflightProductionProject(id) {
+ const project = await getProductionProject(id);
+ const requested = project.localSettings;
+ const problems = [];
+ const result = { requested, resolved: null, effective: null, executed: false, problems,
+ capabilities: { packageImportExport: true, authoringDispatch: false, renderTools: false, imageInspection: false, research: false },
+ notes: ['Settings preview only. Authoring, rendering, visual inspection and research adapters are not connected; use package export/import.'],
+ };
+ if (!requested.providerId) {
+ problems.push('Select an authoring provider explicitly.');
+ return result;
+ }
+ const { providers } = await getSelectableProviders();
+ const provider = providers.find(item => item.id === requested.providerId)
+ || (isCompositeProviderId(requested.providerId) ? applyModelAccess(await getProviderById(requested.providerId)) : null);
+ if (!provider || provider.enabled === false) {
+ problems.push('The selected provider is missing or disabled.');
+ return result;
+ }
+ // Use the runner's own model resolution, including saved argv pins. Loading
+ // this helper does not create a run or call a provider.
+ const { resolveEffectiveModel } = await import('../promptRunner.js');
+ const model = resolveEffectiveModel(provider, requested.model);
+ const harness = harnessForProvider(provider)?.id ?? null;
+ const mode = providerRouteMode(provider);
+ const connectionId = provider.serviceId ?? null;
+ const effortLevels = mode === 'api' ? [] : effortLevelsForProvider(provider, model) || [];
+ const effort = requested.effort || provider.effort || null;
+ result.resolved = { providerId: provider.id, harness, connectionId, mode, model, effort: null };
+ if (!mode || !harness) problems.push('The selected route has no recognized authoring harness or mode.');
+ if (requested.mode && requested.mode !== mode) problems.push('The saved execution mode no longer matches the selected route.');
+ if (requested.connectionId && requested.connectionId !== connectionId) problems.push('The saved connection no longer matches the selected route.');
+ const catalog = (provider.models || []).map(item => typeof item === 'string' ? item : item.id);
+ const selectable = harness === 'antigravity' ? antigravityBaseModels(catalog) : catalog;
+ if (!model || isConfiguredDefaultModel(model)) problems.push('Select a concrete model; the harness default cannot establish model provenance.');
+ else if (!selectable.includes(model)) problems.push('The resolved model is not in this route’s selectable catalog.');
+ if (requested.model && requested.model !== model) problems.push('The selected model would be replaced by the provider configuration.');
+ if (mode !== 'api' && hasEffortFlag(provider.args || [])) problems.push('Saved provider arguments pin reasoning effort; remove that pin before comparing explicit settings.');
+ else if (effort && !effortLevels.includes(effort)) problems.push('The requested or configured reasoning effort is unsupported by this route and model.');
+ else result.resolved.effort = effort;
+ result.effortLevels = effortLevels;
+ return result;
+}
diff --git a/server/services/codeAnimation/preflight.test.js b/server/services/codeAnimation/preflight.test.js
new file mode 100644
index 0000000000..4ea2e8fd0d
--- /dev/null
+++ b/server/services/codeAnimation/preflight.test.js
@@ -0,0 +1,77 @@
+import express from 'express';
+import { request } from '../../lib/testHelper.js';
+import { errorMiddleware } from '../../lib/errorHandler.js';
+import router from '../../routes/codeAnimation.js';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+vi.mock('./projectStore.js', () => ({ getProjectRecord: vi.fn() }));
+vi.mock('../providers.js', () => ({ getProviderById: vi.fn(), getSelectableProviders: vi.fn() }));
+vi.mock('../socket.js', () => ({ emitCodeAnimationChanged: vi.fn() }));
+// Keep the real runner resolver, but trip if a data-only preview dispatches.
+vi.mock('../promptRunner.js', async importOriginal => ({ ...await importOriginal(), runPromptThroughProvider: vi.fn(() => { throw new Error('Unexpected provider call'); }) }));
+import { getProjectRecord } from './projectStore.js';
+import { getProviderById, getSelectableProviders } from '../providers.js';
+import { runPromptThroughProvider } from '../promptRunner.js';
+import { preflightProductionProject } from './preflight.js';
+
+const app = express();
+app.use('/api/code-animation', router);
+app.use(errorMiddleware);
+const projectId = '00000000-0000-4000-8000-000000000001';
+
+const provider = { id: 'example', type: 'cli', command: 'claude', enabled: true, models: ['example-model'], defaultModel: 'example-model', args: [] };
+const requested = { providerId: 'example', model: 'example-model', effort: 'high', mode: null, connectionId: null };
+beforeEach(() => {
+ vi.clearAllMocks();
+ getProjectRecord.mockResolvedValue({ id: 'project', localSettings: requested });
+ getSelectableProviders.mockResolvedValue({ providers: [provider] });
+});
+describe('saved production authoring preflight', () => {
+ it('resolves saved settings without dispatching or claiming execution or inspection', async () => {
+ const response = await request(app).get(`/api/code-animation/projects/${projectId}/preflight`);
+ expect(response.status).toBe(200);
+ const result = response.body;
+ expect(getProjectRecord).toHaveBeenCalledWith(projectId);
+ expect(result).toMatchObject({ requested, resolved: { harness: 'claude', mode: 'cli', model: 'example-model', effort: 'high' }, effective: null, executed: false, problems: [], capabilities: { authoringDispatch: false, imageInspection: false } });
+ expect(runPromptThroughProvider).not.toHaveBeenCalled();
+ });
+ it('rejects invalid and missing projects before accessing provider configuration', async () => {
+ expect((await request(app).get('/api/code-animation/projects/invalid/preflight')).status).toBe(400);
+ getProjectRecord.mockResolvedValue(null);
+ expect((await request(app).get(`/api/code-animation/projects/${projectId}/preflight`)).status).toBe(404);
+ expect(getSelectableProviders).not.toHaveBeenCalled();
+ });
+ it('reports a baked model override, effort pin and stale connection instead of accepting substitutions', async () => {
+ getSelectableProviders.mockResolvedValue({ providers: [{ ...provider, args: ['--model', 'different-model', '--effort', 'low'] }] });
+ getProjectRecord.mockResolvedValue({ localSettings: { ...requested, connectionId: 'old-connection', mode: 'api' } });
+ const { problems, resolved } = await preflightProductionProject('project');
+ expect(resolved).toMatchObject({ model: 'different-model', effort: null });
+ expect(problems.join(' ')).toMatch(/model would be replaced/);
+ expect(problems.join(' ')).toMatch(/pin reasoning effort/);
+ expect(problems.join(' ')).toMatch(/connection no longer matches/);
+ expect(problems.join(' ')).toMatch(/mode no longer matches/);
+ expect(runPromptThroughProvider).not.toHaveBeenCalled();
+ });
+ it('refuses to imply API effort support or widen the selectable catalog', async () => {
+ getSelectableProviders.mockResolvedValue({ providers: [{ ...provider, type: 'api', models: ['allowed-model'] }] });
+ const result = await preflightProductionProject('project');
+ expect(result.problems.join(' ')).toMatch(/not in this route’s selectable catalog/);
+ expect(result.problems.join(' ')).toMatch(/effort is unsupported/);
+ expect(result.resolved.effort).toBeNull();
+ });
+ it('resolves a custom route without returning credentials or execution configuration', async () => {
+ getProjectRecord.mockResolvedValue({ localSettings: { ...requested, providerId: 'claude.cli@example' } });
+ getProviderById.mockResolvedValue({ ...provider, id: 'claude.cli@example', serviceId: 'example', apiKey: 'example-secret', env: { PRIVATE: 'example-secret' } });
+ const result = await preflightProductionProject('project');
+ expect(getProviderById).toHaveBeenCalledWith('claude.cli@example');
+ expect(result.resolved.connectionId).toBe('example');
+ expect(JSON.stringify(result)).not.toContain('example-secret');
+ });
+ it('keeps unavailable provider selections visible without falling back', async () => {
+ getSelectableProviders.mockResolvedValue({ providers: [] });
+ const result = await preflightProductionProject('project');
+ expect(result.requested).toEqual(requested);
+ expect(result.resolved).toBeNull();
+ expect(result.problems).toEqual(['The selected provider is missing or disabled.']);
+ expect(getProviderById).not.toHaveBeenCalled();
+ });
+});