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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): gate auto-compose on composable status + flip UI to planning (#1817)
[._.]/ Adam Eivy6aefb74c9b50
diff --git a/client/src/components/creative-director/OverviewTab.jsx b/client/src/components/creative-director/OverviewTab.jsxindex 4eb4e0822d..04b03fd292 100644--- a/client/src/components/creative-director/OverviewTab.jsx+++ b/client/src/components/creative-director/OverviewTab.jsx@@ -82,8 +82,16 @@ export default function OverviewTab({ project, onProjectUpdate }) {.then((result) => {if (projectIdRef.current !== requestProjectId) return;const added = result?.added?.length || 0;- onProjectUpdate?.({ cast: result?.project?.cast || [] });- if (result?.composing) {+ const composing = Boolean(result?.composing);+ // When the director starts composing, optimistically flip the status to+ // 'planning' as well — the detail page disables polling for 'draft'+ // projects, so without this the treatment + runs the agent produces stay+ // invisible until a manual refresh. The 5s poll re-corrects if needed.+ onProjectUpdate?.({+ cast: result?.project?.cast || [],+ ...(composing ? { status: 'planning' } : {}),+ });+ if (composing) {toast.success(`Auto-cast added ${added} ingredient${added === 1 ? '' : 's'} — director is composing the treatment…`);} else if (added > 0) {toast.success(`Auto-cast added ${added} ingredient${added === 1 ? '' : 's'}`);diff --git a/client/src/components/creative-director/OverviewTab.test.jsx b/client/src/components/creative-director/OverviewTab.test.jsxindex c38836d853..a980fdfbe9 100644--- a/client/src/components/creative-director/OverviewTab.test.jsx+++ b/client/src/components/creative-director/OverviewTab.test.jsx@@ -102,17 +102,20 @@ describe('OverviewTab auto-compose (#1817)', () => {await waitFor(() => expect(applyCreativeDirectorAutoCast).toHaveBeenCalledWith('cd-1', { compose: true }, { silent: true }));});- it('toasts a composing message when the server kicks off the treatment', async () => {+ it('toasts a composing message and flips status to planning when the server kicks off the treatment', async () => {+ const onProjectUpdate = vi.fn();applyCreativeDirectorAutoCast.mockResolvedValue({project: { id: 'cd-1', cast: [{ ingredientId: 'p1', name: 'The Spire' }] },added: [{ ingredientId: 'p1', name: 'The Spire' }],suggestions: [],composing: true,});- renderTab(baseProject);+ renderTab(baseProject, onProjectUpdate);fireEvent.click(screen.getByLabelText(/\+ treatment/i));fireEvent.click(screen.getByRole('button', { name: /^Auto-cast$/i }));await waitFor(() => expect(toast.success).toHaveBeenCalledWith(expect.stringMatching(/composing the treatment/i)));+ // Optimistically enable polling — the detail page disables it for 'draft'.+ expect(onProjectUpdate).toHaveBeenCalledWith(expect.objectContaining({ status: 'planning' }));});it('omits the compose flag when the toggle is left unchecked', async () => {diff --git a/server/routes/creativeDirector.js b/server/routes/creativeDirector.jsindex c2e8108e77..b98be0c9fb 100644--- a/server/routes/creativeDirector.js+++ b/server/routes/creativeDirector.js@@ -108,8 +108,15 @@ router.delete('/:id', asyncHandler(async (req, res) => {router.post('/:id/auto-cast', asyncHandler(async (req, res) => {const { brief, types, limit, compose } = validateRequest(creativeDirectorAutoCastApplySchema, req.body);const result = await applyAutoCastToProject(req.params.id, { brief, types, limit });- const cast = result.project?.cast;- const composing = Boolean(compose) && Array.isArray(cast) && cast.length > 0 && !result.project?.treatment;+ const project = result.project;+ const cast = project?.cast;+ // `advanceAfterSceneSettled` (what startCreativeDirectorProject calls) bails+ // immediately for paused/failed projects, so kicking off there would no-op+ // while we falsely report `composing` to the UI. Auto-compose deliberately+ // does NOT do /start's failed-scene recovery — it's only the first-pass+ // treatment path — so we simply skip those statuses.+ const composable = project && project.status !== 'paused' && project.status !== 'failed';+ const composing = Boolean(compose) && composable && Array.isArray(cast) && cast.length > 0 && !project.treatment;if (composing) {startCreativeDirectorProject(req.params.id).catch((e) => console.log(`⚠️ CD auto-compose failed: ${e.message}`));}diff --git a/server/routes/creativeDirector.test.js b/server/routes/creativeDirector.test.jsindex ed32378146..25c2af136f 100644--- a/server/routes/creativeDirector.test.js+++ b/server/routes/creativeDirector.test.js@@ -339,5 +339,15 @@ describe('creativeDirector routes', () => {expect(r.status).toBe(400);expect(autoCast.applyAutoCastToProject).not.toHaveBeenCalled();});++ it.each(['paused', 'failed'])('does not compose a %s project (orchestrator would no-op)', async (status) => {+ autoCast.applyAutoCastToProject.mockResolvedValue({+ project: { id: 'cd-1', status, cast: [{ ingredientId: 'p1' }] }, added: [], suggestions: [],+ });+ const r = await request(app).post('/api/creative-director/cd-1/auto-cast').send({ compose: true });+ expect(r.status).toBe(200);+ expect(r.body.composing).toBe(false);+ expect(hook.startCreativeDirectorProject).not.toHaveBeenCalled();+ });});});