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([issue-1970]): group pipeline image-gen drawers into labeled sections
[._.]/ Adam Eivya6e89be963e1
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex eb7bdfb1bc..21bdb334cd 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -28,6 +28,10 @@- **[issue-1946] Download full videos from a YouTube or x.com URL.** A new **Dev Tools → Video Downloader** page lets you paste a YouTube (video/shorts/youtu.be) or x.com/Twitter status URL and download the *full video* (not just the audio, which is #1945's job) via `yt-dlp` — the same host dependency the music-video track import already uses. The clip lands in your video storage as a distinguishable `downloaded-<id>.mp4`, gets an auto-generated thumbnail, and — because it's written as a `source: 'download'` entry into the shared video-history store — also shows up in your media gallery alongside AI-generated renders (no new "library" concept; the existing media asset index picks it up through the same completed-video path it already uses, and prunes it on delete). Download progress streams live (download % → merging → finalizing) with a Cancel button, and the page lists everything you've downloaded (thumbnail, title, source link, age) with delete. x.com/Twitter pulls are best-effort — login-walled or rate-limited posts surface a clear error rather than a generic failure. Long/huge downloads are bounded (≤1h, ≤2GB) so a livestream or archive URL can't eat disk unbounded. `POST /api/devtools/video-download` (`server/services/videoDownload.js`, `server/routes/videoDownload.js`) mirrors #1945's async-job/SSE pattern. (Closes #1946)+## Pipeline++- **[issue-1970] Pipeline image-gen drawers now group their settings into labeled sections.** The "Reference image gen" (NounsStage) and "Comic page image gen" (ComicScriptStage) config drawers previously rendered the shared `ImageGenSettingsForm` as one flat scroll; they now show three organized sections — **Backend**, **Model & LoRA**, and **Prompts & Style** — so the backend picker, per-model controls grid, and prompt/style textareas are visually separated instead of running together. Both drawers open at the `md` size so the per-model controls grid isn't cramped. The organization is opt-in via a new `grouped` prop on `ImageGenSettingsForm`, so the form's in-page host (UniverseBuilder's Batch-render card) keeps its existing flat layout unchanged. All controls and save/apply behavior are preserved — this is layout-only. The Backend section is dropped (leaving just the "no backend configured" warning) when no backend is available, and the Prompts & Style section is dropped when both style fields and the preset picker are hidden, so no empty section card ever shows. (`client/src/components/imageGen/ImageGenSettingsForm.jsx`, `client/src/components/pipeline/stages/NounsStage.jsx`, `client/src/components/pipeline/stages/ComicScriptStage.jsx`) (Closes #1970)+## Architecture- **[issue-1878] CoS runner now wires the process-level `unhandledRejection`/`uncaughtException` net (defense-in-depth).** The main server (`server/index.js`) already registered a process-level net via the shared `setupProcessErrorHandlers()` helper (`server/lib/errorHandler.js`) — but the standalone CoS runner (`server/cos-runner/index.js`), a separate long-lived PM2 process that spawns and supervises child agents, had none, so a stray async handler that rejected/threw outside the request lifecycle would crash it with Node's default unhandled output. The runner now calls the same shared helper, giving it the identical, already-tested convention: log via the emoji-prefixed `console.error` style, log-and-stay-alive on an unhandled rejection, and log-then-exit-cleanly on an uncaught exception (after flushing, so PM2 restarts a process that would otherwise be left in an undefined state and reaps any orphaned agents on boot). Reusing the shared helper (rather than rolling inline handlers) keeps the two long-lived processes consistent and routes arbitrary non-Error throw values through `normalizeError`, so the net can't itself throw on a `reason` with no `.stack`. This is the backstop for the per-handler try/catch wrapping done in #1825 — not a replacement for it. While wiring this up, hardened the shared helper's `uncaughtException` branch, which dereferenced `error.stack` on the raw thrown value — a non-Error throw (`throw null`) made the net itself throw, masking the original exception and skipping the clean exit/flush; it now guards `error instanceof Error` (mirroring the existing `unhandledRejection` branch). A regression test (`server/process-safety-net.test.js`) asserts the shared helper registers both handlers, that both entry processes wire it up, and that the `uncaughtException` listener tolerates a non-Error throw value. (Closes #1878)diff --git a/client/src/components/imageGen/ImageGenSettingsForm.jsx b/client/src/components/imageGen/ImageGenSettingsForm.jsxindex c3d05be67d..d85929f5d5 100644--- a/client/src/components/imageGen/ImageGenSettingsForm.jsx+++ b/client/src/components/imageGen/ImageGenSettingsForm.jsx@@ -7,6 +7,12 @@// Caller owns the `value` shape — typically a flat object like// { mode, modelId, width, height, steps, guidance, negativePrompt, extraStyle }// — and a single `onChange(next)` callback receives the merged object.+//+// `grouped` opts into organized, labeled sections (Backend / Model & LoRA /+// Prompts & Style) instead of one flat scroll — the lightweight alternative to+// full drawer tabs for the medium-sized pipeline image-gen drawers (NounsStage,+// ComicScriptStage). Left off (default) the form stays a flat `space-y-4` column+// so in-page hosts (UniverseBuilder's Batch-render card) keep their existing look.import BackendChipStrip from '../media/BackendChipStrip';import ImageGenControls from './ImageGenControls';@@ -14,6 +20,18 @@ import LoraPicker from './LoraPicker';import StylePresetPicker from '../media/StylePresetPicker';import { IMAGE_GEN_MODE } from '../../lib/imageGenBackends';+// Labeled card wrapper used only in `grouped` mode. Header is a plain heading+// (not interactive) so every control stays visible above the fold — organization+// without hiding anything behind a collapse.+function Section({ title, children }) {+ return (+ <section className="rounded-lg border border-port-border bg-port-bg/30 p-3">+ <h3 className="text-[11px] font-semibold uppercase tracking-wider text-gray-500 mb-2">{title}</h3>+ {children}+ </section>+ );+}+export default function ImageGenSettingsForm({value,onChange,@@ -31,6 +49,8 @@ export default function ImageGenSettingsForm({// holds the full preset object (not just the id) so consumers can compose// styled prompts without a second lookup.showStylePreset = false,+ // Render as labeled sections (see module header) instead of a flat column.+ grouped = false,disabled = false,}) {const cfg = value || {};@@ -40,102 +60,137 @@ export default function ImageGenSettingsForm({const labelCls = 'block text-xs font-medium text-gray-400 mb-1';const textareaCls = 'w-full bg-port-bg border border-port-border rounded-lg px-2 py-2 text-sm text-white focus:outline-none focus:border-port-accent disabled:opacity-50 resize-y';- return (- <div className="space-y-4">- {availableBackends.length === 0 ? (- <div className="text-[11px] text-port-warning bg-port-warning/10 border border-port-warning/40 rounded px-2 py-1.5">- No image gen backend configured. Open Settings → Image Gen to enable Local mflux or Codex <code className="text-gray-400">$imagegen</code>.- </div>- ) : null}-- {availableBackends.length > 0 ? (- <div>- <span className={labelCls}>Backend</span>- <BackendChipStrip- availableBackends={availableBackends}- value={cfg.mode}- onChange={(id) => merge({ mode: id })}- size="md"- ariaLabel="Image gen backend"- titlePrefix="Render via"- disabled={disabled}- />- {isCodex ? (- <p className="text-[10px] text-gray-500 mt-1">- Codex's <code className="text-gray-400">$imagegen</code> picks model, steps, and seed internally. Only resolution + style fields apply.- </p>- ) : null}- </div>- ) : null}+ const noBackend = availableBackends.length === 0 ? (+ <div className="text-[11px] text-port-warning bg-port-warning/10 border border-port-warning/40 rounded px-2 py-1.5">+ No image gen backend configured. Open Settings → Image Gen to enable Local mflux or Codex <code className="text-gray-400">$imagegen</code>.+ </div>+ ) : null;- <ImageGenControls- mode={cfg.mode}- models={models}- modelId={cfg.modelId}- onModelChange={(modelId) => merge({ modelId, steps: '', guidance: '' })}- width={cfg.width}- height={cfg.height}- onResolutionChange={(width, height) => merge({ width, height })}- steps={cfg.steps}- onStepsChange={(steps) => merge({ steps })}- guidance={cfg.guidance}- onGuidanceChange={(guidance) => merge({ guidance })}- cfgScale={cfg.cfgScale}- onCfgScaleChange={(cfgScale) => merge({ cfgScale })}- quantize={cfg.quantize}- onQuantizeChange={(quantize) => merge({ quantize })}- seed={cfg.seed}- onSeedChange={(seed) => merge({ seed })}- showSeed+ const backendPicker = availableBackends.length > 0 ? (+ <div>+ <span className={labelCls}>Backend</span>+ <BackendChipStrip+ availableBackends={availableBackends}+ value={cfg.mode}+ onChange={(id) => merge({ mode: id })}+ size="md"+ ariaLabel="Image gen backend"+ titlePrefix="Render via"disabled={disabled}/>+ {isCodex ? (+ <p className="text-[10px] text-gray-500 mt-1">+ Codex's <code className="text-gray-400">$imagegen</code> picks model, steps, and seed internally. Only resolution + style fields apply.+ </p>+ ) : null}+ </div>+ ) : null;- {showLoras && isLocal ? (- <LoraPicker- availableLoras={availableLoras}- selected={Array.isArray(cfg.loras) ? cfg.loras : []}- onChange={(loras) => merge({ loras })}- currentRunnerFamily={currentRunnerFamily}- currentCompatKey={currentCompatKey}- onAppendTrigger={onAppendTrigger}+ const controls = (+ <ImageGenControls+ mode={cfg.mode}+ models={models}+ modelId={cfg.modelId}+ onModelChange={(modelId) => merge({ modelId, steps: '', guidance: '' })}+ width={cfg.width}+ height={cfg.height}+ onResolutionChange={(width, height) => merge({ width, height })}+ steps={cfg.steps}+ onStepsChange={(steps) => merge({ steps })}+ guidance={cfg.guidance}+ onGuidanceChange={(guidance) => merge({ guidance })}+ cfgScale={cfg.cfgScale}+ onCfgScaleChange={(cfgScale) => merge({ cfgScale })}+ quantize={cfg.quantize}+ onQuantizeChange={(quantize) => merge({ quantize })}+ seed={cfg.seed}+ onSeedChange={(seed) => merge({ seed })}+ showSeed+ disabled={disabled}+ />+ );++ const loraPicker = showLoras && isLocal ? (+ <LoraPicker+ availableLoras={availableLoras}+ selected={Array.isArray(cfg.loras) ? cfg.loras : []}+ onChange={(loras) => merge({ loras })}+ currentRunnerFamily={currentRunnerFamily}+ currentCompatKey={currentCompatKey}+ onAppendTrigger={onAppendTrigger}+ disabled={disabled}+ />+ ) : null;++ const stylePreset = showStylePreset ? (+ <StylePresetPicker+ value={cfg.stylePreset?.id || ''}+ onChange={(preset) => merge({ stylePreset: preset })}+ disabled={disabled}+ />+ ) : null;++ const styleFields = showStyleFields ? (+ <div className="space-y-3">+ <label className="block">+ <span className={labelCls}>Extra style (optional)</span>+ <textarea+ rows={2}+ value={cfg.extraStyle || ''}+ onChange={(e) => merge({ extraStyle: e.target.value })}+ placeholder="cinematic ink, bold panel borders…"+ className={textareaCls}disabled={disabled}/>- ) : null}-- {showStylePreset ? (- <StylePresetPicker- value={cfg.stylePreset?.id || ''}- onChange={(preset) => merge({ stylePreset: preset })}+ </label>+ <label className="block">+ <span className={labelCls}>Negative prompt (optional)</span>+ <textarea+ rows={2}+ value={cfg.negativePrompt || ''}+ onChange={(e) => merge({ negativePrompt: e.target.value })}+ placeholder="blurry, low quality, watermark…"+ className={textareaCls}disabled={disabled}/>- ) : null}+ </label>+ </div>+ ) : null;- {showStyleFields ? (- <div className="space-y-3">- <label className="block">- <span className={labelCls}>Extra style (optional)</span>- <textarea- rows={2}- value={cfg.extraStyle || ''}- onChange={(e) => merge({ extraStyle: e.target.value })}- placeholder="cinematic ink, bold panel borders…"- className={textareaCls}- disabled={disabled}- />- </label>- <label className="block">- <span className={labelCls}>Negative prompt (optional)</span>- <textarea- rows={2}- value={cfg.negativePrompt || ''}- onChange={(e) => merge({ negativePrompt: e.target.value })}- placeholder="blurry, low quality, watermark…"- className={textareaCls}- disabled={disabled}- />- </label>- </div>- ) : null}+ // Grouped: organized cards. Skip the Prompts & Style section entirely when it+ // has no content so an empty card never shows with both pickers disabled.+ if (grouped) {+ const hasPrompts = !!(stylePreset || styleFields);+ return (+ <div className="space-y-4">+ {noBackend}+ {backendPicker ? <Section title="Backend">{backendPicker}</Section> : null}+ <Section title="Model & LoRA">+ <div className="space-y-4">+ {controls}+ {loraPicker}+ </div>+ </Section>+ {hasPrompts ? (+ <Section title="Prompts & Style">+ <div className="space-y-3">+ {stylePreset}+ {styleFields}+ </div>+ </Section>+ ) : null}+ </div>+ );+ }++ return (+ <div className="space-y-4">+ {noBackend}+ {backendPicker}+ {controls}+ {loraPicker}+ {stylePreset}+ {styleFields}</div>);}diff --git a/client/src/components/imageGen/ImageGenSettingsForm.test.jsx b/client/src/components/imageGen/ImageGenSettingsForm.test.jsxnew file mode 100644index 0000000000..fcc4231b97--- /dev/null+++ b/client/src/components/imageGen/ImageGenSettingsForm.test.jsx@@ -0,0 +1,62 @@+import { describe, it, expect, vi } from 'vitest';+import { render, screen } from '@testing-library/react';+import ImageGenSettingsForm from './ImageGenSettingsForm';++// Stub the heavy child pickers so the test pins ONLY this form's own+// responsibility: preserving every control + arranging them flat vs. grouped.+vi.mock('../media/BackendChipStrip', () => ({+ default: () => <div data-testid="backend-chip-strip" />,+}));+vi.mock('./ImageGenControls', () => ({+ default: () => <div data-testid="image-gen-controls" />,+}));+vi.mock('./LoraPicker', () => ({+ default: () => <div data-testid="lora-picker" />,+}));+vi.mock('../media/StylePresetPicker', () => ({+ default: () => <div data-testid="style-preset-picker" />,+}));++const BACKENDS = [{ id: 'local', label: 'Local' }];+const SECTION_TITLES = ['Backend', 'Model & LoRA', 'Prompts & Style'];++const renderForm = (props) =>+ render(<ImageGenSettingsForm value={{ mode: 'local' }} onChange={vi.fn()} {...props} />);++describe('ImageGenSettingsForm layout', () => {+ it('flat mode (default) renders no section headings but keeps all controls', () => {+ renderForm({ availableBackends: BACKENDS });+ SECTION_TITLES.forEach((title) => expect(screen.queryByRole('heading', { name: title })).toBeNull());+ expect(screen.getByTestId('backend-chip-strip')).toBeTruthy();+ expect(screen.getByTestId('image-gen-controls')).toBeTruthy();+ expect(screen.getByLabelText('Extra style (optional)')).toBeTruthy();+ expect(screen.getByLabelText('Negative prompt (optional)')).toBeTruthy();+ });++ it('grouped mode renders the three organized sections', () => {+ renderForm({ availableBackends: BACKENDS, grouped: true });+ SECTION_TITLES.forEach((title) =>+ expect(screen.getByRole('heading', { name: title })).toBeTruthy());+ // Every control from the flat layout is still present.+ expect(screen.getByTestId('backend-chip-strip')).toBeTruthy();+ expect(screen.getByTestId('image-gen-controls')).toBeTruthy();+ expect(screen.getByLabelText('Extra style (optional)')).toBeTruthy();+ expect(screen.getByLabelText('Negative prompt (optional)')).toBeTruthy();+ });++ it('grouped mode drops the Backend section (but not the warning) when no backend is configured', () => {+ renderForm({ availableBackends: [], grouped: true });+ expect(screen.queryByRole('heading', { name: 'Backend' })).toBeNull();+ expect(screen.getByText(/No image gen backend configured/)).toBeTruthy();+ // Model + Prompts sections still render.+ expect(screen.getByRole('heading', { name: 'Model & LoRA' })).toBeTruthy();+ expect(screen.getByRole('heading', { name: 'Prompts & Style' })).toBeTruthy();+ });++ it('grouped mode drops the Prompts & Style section when both style fields and preset are hidden', () => {+ renderForm({ availableBackends: BACKENDS, grouped: true, showStyleFields: false, showStylePreset: false });+ expect(screen.getByRole('heading', { name: 'Model & LoRA' })).toBeTruthy();+ expect(screen.queryByRole('heading', { name: 'Prompts & Style' })).toBeNull();+ expect(screen.queryByLabelText('Extra style (optional)')).toBeNull();+ });+});diff --git a/client/src/components/pipeline/stages/ComicScriptStage.jsx b/client/src/components/pipeline/stages/ComicScriptStage.jsxindex a9faf035b5..933fe2f5ff 100644--- a/client/src/components/pipeline/stages/ComicScriptStage.jsx+++ b/client/src/components/pipeline/stages/ComicScriptStage.jsx@@ -751,12 +751,13 @@ export default function ComicScriptStage({ issue, series, onStageUpdate, actions</details>) : null}- <Drawer open={settingsOpen} onClose={closeImageSettings} title="Comic page image gen">+ <Drawer open={settingsOpen} onClose={closeImageSettings} title="Comic page image gen" size="md"><ImageGenSettingsFormvalue={imageCfg}onChange={persistImageCfg}models={imageModels}availableBackends={availableBackends}+ grouped/></Drawer></div>diff --git a/client/src/components/pipeline/stages/NounsStage.jsx b/client/src/components/pipeline/stages/NounsStage.jsxindex b7d1f8d9c2..749072eb21 100644--- a/client/src/components/pipeline/stages/NounsStage.jsx+++ b/client/src/components/pipeline/stages/NounsStage.jsx@@ -595,12 +595,13 @@ export default function NounsStage({ issue, series, onStageUpdate }) {/>))}- <Drawer open={settingsOpen} onClose={closeSettings} title="Reference image gen">+ <Drawer open={settingsOpen} onClose={closeSettings} title="Reference image gen" size="md"><ImageGenSettingsFormvalue={imageCfg}onChange={persistImageCfg}models={imageModels}availableBackends={availableBackends}+ grouped/></Drawer>