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
feat: Creative Director auto-compose treatment from auto-cast (#1817)
[._.]/ Adam Eivy52f3c557548e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 46ba96b782..e4b25c24e7 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,5 +1,6 @@## Added+- **Creative Director auto-compose** — the Overview tab's Auto-cast control now has a `+ treatment` toggle (shown only before a treatment exists): with it on, once the director seeds the cast from the catalog it autonomously writes a first-pass treatment + scene plan grounded in that cast, instead of stopping at cast seeding. Director-first — the autonomous treatment is a starting point you keep editing on the same board, and it never clobbers an existing treatment. (#1817)- Shell page now has a **Fullscreen** button that promotes the terminal to a full-viewport overlay (above the sidebar), hiding the stacked header/tabs/quick-commands toolbars so the TUI gets the whole screen — a major mobile usability win where those toolbars previously ate most of the display. Fullscreen keeps a compact, horizontally-scrollable control bar (Exit, Ctrl+C, Paste, arrow/Enter keys) so you can still drive a TUI by thumb, and the Ctrl+C/Paste labels now collapse on small screens to save width.- OpenCode Ollama **TUI** provider for CoS tasks. The TUI completion workflow is now provider-aware: a slashdo-free TUI (OpenCode, which doesn't load Claude Code `/do:*` slash commands) gets a plain `git` + forge-CLI commit → push → open-PR-for-review → `.agent-done` sentinel handoff instead of `/do:pr` / `/do:push`, so an OpenCode TUI agent can actually complete an automated task. The manual path opens the PR/MR (GitHub `gh` or GitLab `glab`) for review without auto-merging. Ships `opencode-ollama-tui` to existing installs via migration 152. (#1814)diff --git a/client/src/components/creative-director/OverviewTab.jsx b/client/src/components/creative-director/OverviewTab.jsxindex 9c52b49815..4eb4e0822d 100644--- a/client/src/components/creative-director/OverviewTab.jsx+++ b/client/src/components/creative-director/OverviewTab.jsx@@ -8,6 +8,10 @@ export default function OverviewTab({ project, onProjectUpdate }) {const [disableAudio, setDisableAudio] = useState(project.disableAudio === true);const [saving, setSaving] = useState(false);const [autoCasting, setAutoCasting] = useState(false);+ // Auto-compose (#1817): when checked, auto-cast also hands the seeded cast to+ // the treatment agent so the director writes a first-pass treatment + scene+ // plan. Director-first — off by default so the user opts into the autonomy.+ const [composeAfter, setComposeAfter] = useState(false);// Track the project id this tab is currently mounted for. If the user// toggles audio and navigates to a different CD project before the PATCH// resolves, the late `.then()` would otherwise call onProjectUpdate on@@ -30,6 +34,8 @@ export default function OverviewTab({ project, onProjectUpdate }) {// id matching, so without this a same-instance project swap could strand the// flag (defensive; the parent currently remounts on id change).setAutoCasting(false);+ // The compose toggle is a per-project intent — don't carry it across a switch.+ setComposeAfter(false);}, [project.id]);useEffect(() => {if (!savingRef.current) {@@ -68,13 +74,22 @@ export default function OverviewTab({ project, onProjectUpdate }) {const handleAutoCast = () => {setAutoCasting(true);const requestProjectId = project.id;- applyCreativeDirectorAutoCast(requestProjectId, {}, { silent: true })+ // Only ask the server to compose when there's no treatment yet — the server+ // guards this too, but gating here keeps the toast honest. Omit the flag+ // entirely in the default case so the request body stays minimal.+ const wantCompose = composeAfter && !project.treatment;+ applyCreativeDirectorAutoCast(requestProjectId, wantCompose ? { compose: true } : {}, { silent: true }).then((result) => {if (projectIdRef.current !== requestProjectId) return;const added = result?.added?.length || 0;onProjectUpdate?.({ cast: result?.project?.cast || [] });- if (added > 0) toast.success(`Auto-cast added ${added} ingredient${added === 1 ? '' : 's'}`);- else toast.info('Auto-cast found no new catalog matches for this brief');+ if (result?.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'}`);+ } else {+ toast.info('Auto-cast found no new catalog matches for this brief');+ }}).catch((err) => toast.error(err.message || 'Auto-cast failed')).finally(() => {@@ -141,21 +156,42 @@ export default function OverviewTab({ project, onProjectUpdate }) {Cast ({Array.isArray(project.cast) ? project.cast.length : 0})</h2>{/* Autonomous auto-cast (#1810): seed the cast from the catalog without- hand-picking. Disabled with no brief to search on. */}- <button- type="button"- onClick={handleAutoCast}- disabled={autoCasting || !hasSearchableBrief(project)}- title={hasSearchableBrief(project)- ? 'Let the director pick catalog ingredients from this project’s brief'- : 'Add a style spec or story first — auto-cast searches the catalog from the project brief'}- className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-port-border text-port-text hover:border-port-accent disabled:opacity-50 disabled:cursor-not-allowed"- >- {autoCasting- ? <Loader2 size={12} className="animate-spin" aria-hidden="true" />- : <Sparkles size={12} aria-hidden="true" />}- {autoCasting ? 'Auto-casting…' : 'Auto-cast'}- </button>+ hand-picking. Disabled with no brief to search on. The compose+ toggle (#1817) chains the treatment agent after seeding — only+ offered while there's no treatment yet (it can't clobber one). */}+ <div className="flex items-center gap-2">+ {!project.treatment && (+ <label+ htmlFor="cd-compose-after"+ className="flex items-center gap-1 text-xs text-port-text-muted cursor-pointer"+ title="After seeding the cast, let the director write a first-pass treatment + scene plan grounded in it"+ >+ <input+ id="cd-compose-after"+ type="checkbox"+ checked={composeAfter}+ onChange={(e) => setComposeAfter(e.target.checked)}+ disabled={autoCasting}+ className="accent-port-accent"+ />+ <span>+ treatment</span>+ </label>+ )}+ <button+ type="button"+ onClick={handleAutoCast}+ disabled={autoCasting || !hasSearchableBrief(project)}+ title={hasSearchableBrief(project)+ ? 'Let the director pick catalog ingredients from this project’s brief'+ : 'Add a style spec or story first — auto-cast searches the catalog from the project brief'}+ className="inline-flex items-center gap-1 text-xs px-2 py-1 rounded border border-port-border text-port-text hover:border-port-accent disabled:opacity-50 disabled:cursor-not-allowed"+ >+ {autoCasting+ ? <Loader2 size={12} className="animate-spin" aria-hidden="true" />+ : <Sparkles size={12} aria-hidden="true" />}+ {autoCasting ? 'Auto-casting…' : 'Auto-cast'}+ </button>+ </div></div><p className="text-xs text-port-text-muted mb-2">Catalog ingredients remixed into this project — the director grounds the treatment and per-scene casting on them. Auto-cast appends new matches; you can always edit the result.diff --git a/client/src/components/creative-director/OverviewTab.test.jsx b/client/src/components/creative-director/OverviewTab.test.jsxindex e929265564..c38836d853 100644--- a/client/src/components/creative-director/OverviewTab.test.jsx+++ b/client/src/components/creative-director/OverviewTab.test.jsx@@ -84,3 +84,41 @@ describe('OverviewTab auto-cast (#1810)', () => {await waitFor(() => expect(screen.getByRole('button', { name: /^Auto-cast$/i })).toHaveProperty('disabled', false));});});++describe('OverviewTab auto-compose (#1817)', () => {+ it('offers the +treatment toggle only when the project has no treatment yet', () => {+ const { unmount } = renderTab(baseProject);+ expect(screen.getByLabelText(/\+ treatment/i)).toBeTruthy();+ unmount();+ renderTab({ ...baseProject, treatment: { scenes: [] } });+ expect(screen.queryByLabelText(/\+ treatment/i)).toBeNull();+ });++ it('passes compose:true when the toggle is checked', async () => {+ applyCreativeDirectorAutoCast.mockResolvedValue({ project: { id: 'cd-1', cast: [] }, added: [], suggestions: [] });+ renderTab(baseProject);+ fireEvent.click(screen.getByLabelText(/\+ treatment/i));+ fireEvent.click(screen.getByRole('button', { name: /^Auto-cast$/i }));+ await waitFor(() => expect(applyCreativeDirectorAutoCast).toHaveBeenCalledWith('cd-1', { compose: true }, { silent: true }));+ });++ it('toasts a composing message when the server kicks off the treatment', async () => {+ applyCreativeDirectorAutoCast.mockResolvedValue({+ project: { id: 'cd-1', cast: [{ ingredientId: 'p1', name: 'The Spire' }] },+ added: [{ ingredientId: 'p1', name: 'The Spire' }],+ suggestions: [],+ composing: true,+ });+ renderTab(baseProject);+ 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)));+ });++ it('omits the compose flag when the toggle is left unchecked', async () => {+ applyCreativeDirectorAutoCast.mockResolvedValue({ project: { id: 'cd-1', cast: [] }, added: [], suggestions: [] });+ renderTab(baseProject);+ fireEvent.click(screen.getByRole('button', { name: /^Auto-cast$/i }));+ await waitFor(() => expect(applyCreativeDirectorAutoCast).toHaveBeenCalledWith('cd-1', {}, { silent: true }));+ });+});diff --git a/client/src/services/apiCreativeDirector.js b/client/src/services/apiCreativeDirector.jsindex 730d57984b..906abbf511 100644--- a/client/src/services/apiCreativeDirector.js+++ b/client/src/services/apiCreativeDirector.js@@ -42,13 +42,17 @@ export const suggestCreativeDirectorAutoCast = (brief, { types, limit } = {}, opbody: JSON.stringify({ brief, ...(types ? { types } : {}), ...(limit ? { limit } : {}) }),...options,});-export const applyCreativeDirectorAutoCast = (id, { brief, types, limit } = {}, options = {}) =>+// `compose: true` (#1817) tells the director to autonomously write a treatment ++// scene plan grounded in the freshly-seeded cast — the response carries+// `composing: true` when the server actually kicked the agent off.+export const applyCreativeDirectorAutoCast = (id, { brief, types, limit, compose } = {}, options = {}) =>request(`/creative-director/${encodeURIComponent(id)}/auto-cast`, {method: 'POST',body: JSON.stringify({...(brief ? { brief } : {}),...(types ? { types } : {}),...(limit ? { limit } : {}),+ ...(compose ? { compose: true } : {}),}),...options,});diff --git a/server/lib/creativeDirectorValidation.js b/server/lib/creativeDirectorValidation.jsindex 52396d2e03..8edc8e3c66 100644--- a/server/lib/creativeDirectorValidation.js+++ b/server/lib/creativeDirectorValidation.js@@ -96,6 +96,11 @@ export const creativeDirectorAutoCastApplySchema = z.object({brief: z.string().max(10000).optional(),types: autoCastTypes,limit: autoCastLimit,+ // Auto-compose (#1817): when true, kick off the treatment agent after the cast+ // is seeded so the director autonomously writes a treatment + scene plan+ // grounded in the auto-cast cast. The route only honors it when the project has+ // a non-empty cast and no treatment yet (never clobbers an existing one).+ compose: z.boolean().optional(),});// Update is restricted to a few editable fields. modelId / aspectRatio /diff --git a/server/routes/creativeDirector.js b/server/routes/creativeDirector.jsindex e3171a9f6c..c2e8108e77 100644--- a/server/routes/creativeDirector.js+++ b/server/routes/creativeDirector.js@@ -97,10 +97,23 @@ router.delete('/:id', asyncHandler(async (req, res) => {// project (or accept an explicit one), search the catalog, APPEND the fresh// candidates to the project cast, and link them as creative-director refs.// Returns the updated project plus what was added/considered.+//+// Auto-compose (#1817): with `compose: true`, once the cast is seeded the+// director autonomously writes a treatment + scene plan grounded in that cast.+// We only kick off when the project ends up with a non-empty cast and has no+// treatment yet — never clobber an existing treatment or trip the render/stitch+// path. Fire-and-forget like /start; the UI's polling reflects the agent run ++// treatment as they land. The response carries `composing` so the UI can tell+// the user the director took over.router.post('/:id/auto-cast', asyncHandler(async (req, res) => {- const { brief, types, limit } = validateRequest(creativeDirectorAutoCastApplySchema, req.body);+ const { brief, types, limit, compose } = validateRequest(creativeDirectorAutoCastApplySchema, req.body);const result = await applyAutoCastToProject(req.params.id, { brief, types, limit });- res.json(result);+ const cast = result.project?.cast;+ const composing = Boolean(compose) && Array.isArray(cast) && cast.length > 0 && !result.project?.treatment;+ if (composing) {+ startCreativeDirectorProject(req.params.id).catch((e) => console.log(`⚠️ CD auto-compose failed: ${e.message}`));+ }+ res.json({ ...result, composing });}));// Agent-callable: write the treatment doc.diff --git a/server/routes/creativeDirector.test.js b/server/routes/creativeDirector.test.jsindex 8ff15b519c..ed32378146 100644--- a/server/routes/creativeDirector.test.js+++ b/server/routes/creativeDirector.test.js@@ -293,4 +293,51 @@ describe('creativeDirector routes', () => {expect(autoCast.applyAutoCastToProject).not.toHaveBeenCalled();});});++ describe('POST /:id/auto-cast — auto-compose (#1817)', () => {+ it('kicks off the treatment agent and reports composing when compose:true and the cast is seeded', async () => {+ autoCast.applyAutoCastToProject.mockResolvedValue({+ project: { id: 'cd-1', cast: [{ ingredientId: 'p1' }] }, added: [{ ingredientId: 'p1' }], 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(true);+ expect(hook.startCreativeDirectorProject).toHaveBeenCalledWith('cd-1');+ });++ it('does not compose when compose is omitted', async () => {+ autoCast.applyAutoCastToProject.mockResolvedValue({+ project: { id: 'cd-1', cast: [{ ingredientId: 'p1' }] }, added: [{ ingredientId: 'p1' }], suggestions: [],+ });+ const r = await request(app).post('/api/creative-director/cd-1/auto-cast').send({});+ expect(r.status).toBe(200);+ expect(r.body.composing).toBe(false);+ expect(hook.startCreativeDirectorProject).not.toHaveBeenCalled();+ });++ it('does not compose when the project ends up with an empty cast', async () => {+ autoCast.applyAutoCastToProject.mockResolvedValue({ project: { id: 'cd-1', cast: [] }, 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();+ });++ it('never clobbers an existing treatment even with compose:true', async () => {+ autoCast.applyAutoCastToProject.mockResolvedValue({+ project: { id: 'cd-1', cast: [{ ingredientId: 'p1' }], treatment: { scenes: [{ sceneId: 's1' }] } },+ 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();+ });++ it('400s on a non-boolean compose', async () => {+ const r = await request(app).post('/api/creative-director/cd-1/auto-cast').send({ compose: 'yes' });+ expect(r.status).toBe(400);+ expect(autoCast.applyAutoCastToProject).not.toHaveBeenCalled();+ });+ });});