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-1969]): group Media Generation Settings into pills sub-tabs
[._.]/ Adam Eivy3246676aa047
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex eb7bdfb1bc..3c0d98a358 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -8,6 +8,10 @@- **[issue-1835] Brain & CoS list endpoints now support opt-in `limit`/`offset` pagination** — `GET /api/brain/people|projects|ideas|admin|memories` and `GET /api/cos/tasks` previously returned their entire backing store with no bound, while sibling endpoints (`GET /api/brain/links`, `GET /api/memory`) already exposed pagination envelopes. Each of these endpoints now accepts `limit`/`offset` query params: when neither is present they return the exact same shape as before (raw array for the brain collections; the `{ user, cos }` grouped structure for tasks), so every existing client keeps working; when a pagination param is passed they return a bounded `{ <collection>, total, limit, offset }` envelope — and for `/api/cos/tasks` the paginated branch windows each source's `tasks` array, adds a `pagination` block, and drops the full-set derived collections (`grouped`, `autoApproved`, `awaitingApproval`) so the response is genuinely bounded rather than re-leaking the whole queue. `limit` defaults to 50 and is clamped to 500. Shared `isPaginationRequested` / `paginateArray` helpers were added to `server/lib/validation.js` alongside the existing `parsePagination`. (#1835)+## Media Generation++- **[issue-1969] Media Generation Settings is now grouped into tabs.** The image/video backend settings surface — one long flat scroll rendered by the Image Gen, Video Gen, and Storyboard settings drawers — now groups its fields into a pills sub-navigation (Backend / External / Local / Codex CLI / Tokens / Expose / Test) that collapses to a `<select>` on mobile, so no single section is page-length. The grouping is internal to `ImageGenTab` (built on the shared `TabPills`), so it renders identically in every host drawer with no tabs-within-tabs; the active sub-tab deep-links via a `?mediaTab=` search param (`useDrawerTab`) so an open section is shareable and reload-safe. The Save + Test Connection bar stays pinned below the tabs on every section. All existing controls, save/test behavior, and label wiring are unchanged. (`client/src/components/settings/ImageGenTab.jsx`, Closes #1969)+## Music Video- **Deep-link straight to a project's scene board.** The Music Video page's selected project now lives in the URL (`/media/music-video/:projectId`) instead of local component state, so a project's edit/scene-selection board is directly shareable, bookmarkable, and reachable from ⌘K, voice nav, and the media job-completion hooks — clicking a project navigates to its id'd route, deleting the open project returns to the index, and a stale/deleted id renders a "project not found → back to projects" fallback rather than a blank selection. Establishes the project-wide convention (now documented in `CLAUDE.md`) that every selectable UI element encodes its selection in the URL by id. (`client/src/pages/MusicVideo.jsx`, `client/src/App.jsx`)diff --git a/client/src/components/settings/ImageGenTab.jsx b/client/src/components/settings/ImageGenTab.jsxindex 48b35cb1b5..7bddb7e377 100644--- a/client/src/components/settings/ImageGenTab.jsx+++ b/client/src/components/settings/ImageGenTab.jsx@@ -12,8 +12,10 @@ import {Sparkles, Terminal, Key, Check, Trash2} from 'lucide-react';import toast from '../ui/Toast';+import TabPills from '../ui/TabPills';import BrailleSpinner from '../BrailleSpinner';import LocalSetupPanel from './LocalSetupPanel';+import useDrawerTab from '../../hooks/useDrawerTab';import { isLoopbackHost } from '../../lib/loopbackHost.js';import {getSettings, updateSettings, getImageGenStatus, generateImage,@@ -36,10 +38,31 @@ const PARALLEL_FALLBACK = { min: 1, max: 10, default: 1 };const clampParallel = (n, bounds = PARALLEL_FALLBACK) =>Math.max(bounds.min, Math.min(bounds.max, Math.floor(Number(n) || bounds.default)));+// Sub-navigation for this settings surface. Rendered as internal TabPills+// (pills variant + mobile <select>) rather than a tabbed <Drawer>, so the same+// grouping works whether ImageGenTab is hosted in a plain Drawer (ImageGen /+// VideoGen / StoryboardPanel) or elsewhere — no tabs-within-tabs. The active+// tab deep-links via the `mediaTab` search param (useDrawerTab).+const MEDIA_TABS = [+ { id: 'backend', label: 'Backend', icon: ImageIcon },+ { id: 'external', label: 'External', icon: Cloud },+ { id: 'local', label: 'Local', icon: Cpu },+ { id: 'codex', label: 'Codex CLI', icon: Terminal },+ { id: 'tokens', label: 'Tokens', icon: Key },+ { id: 'expose', label: 'Expose', icon: Globe },+ { id: 'test', label: 'Test', icon: Sparkles },+];+const MEDIA_TAB_IDS = MEDIA_TABS.map((t) => t.id);+export function ImageGenTab() {const [loading, setLoading] = useState(true);const [saving, setSaving] = useState(false);+ // Deep-linkable active sub-tab, backed by the `mediaTab` search param so the+ // open section survives reload/share and is reachable from a bookmark. A+ // stale/hand-edited value degrades to 'backend'.+ const [mediaTab, setMediaTab] = useDrawerTab('mediaTab', 'backend', MEDIA_TAB_IDS);+// Mode + per-mode configconst [mode, setMode] = useState(IMAGE_GEN_MODE.EXTERNAL);const [sdapiUrl, setSdapiUrl] = useState('');@@ -363,8 +386,29 @@ export function ImageGenTab() {})();return (- <div className="space-y-5">- {/* Mode picker */}+ <div className="space-y-4">+ {/* Sub-navigation — groups this long settings surface into tabs so no+ single scroll is page-length. Internal to the component so it renders+ identically inside a plain Drawer or the Settings page. */}+ <TabPills+ tabs={MEDIA_TABS}+ activeTab={mediaTab}+ onChange={setMediaTab}+ variant="pills"+ mobileDropdown+ mobileSelectId="media-settings-tab-select"+ ariaLabel="Media generation settings sections"+ controlsIdPrefix="media-settings-tabpanel"+ />++ <div+ id={`media-settings-tabpanel-${mediaTab}`}+ role="tabpanel"+ aria-labelledby={`tab-${mediaTab}`}+ className="space-y-5"+ >+ {mediaTab === 'backend' && (+ /* Mode picker */<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><div className="flex items-center gap-2 text-white"><ImageIcon size={18} />@@ -413,9 +457,9 @@ export function ImageGenTab() {)}</div></div>+ )}- {/* External-mode config */}- {mode === IMAGE_GEN_MODE.EXTERNAL && (+ {mediaTab === 'external' && (<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><h3 className="text-sm font-medium text-gray-300">External AUTOMATIC1111 / Forge URL</h3><input@@ -435,8 +479,7 @@ export function ImageGenTab() {</div>)}- {/* Local-mode config */}- {mode === IMAGE_GEN_MODE.LOCAL && (+ {mediaTab === 'local' && (<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><h3 className="text-sm font-medium text-gray-300">Local Python (mflux + mlx_video)</h3><p className="text-xs text-gray-500">@@ -454,9 +497,9 @@ export function ImageGenTab() {</div>)}- {/* Codex CLI config — always visible (the toggle that enables the- option lives here). Codex appears as a backend tile only after- the user flips this on. */}+ {mediaTab === 'codex' && (+ /* Codex CLI config — the toggle that enables the option lives here.+ Codex appears as a backend tile only after the user flips this on. */<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><div className="flex items-center gap-2 text-white"><Terminal size={18} />@@ -554,10 +597,12 @@ export function ImageGenTab() {</div>)}</div>+ )}- {/* HuggingFace token — used by local Flux models (FLUX.1-dev, FLUX.2-klein).- Independent of the mode picker because the token persists in settings- and applies whenever local image gen runs. */}+ {mediaTab === 'tokens' && (+ /* HuggingFace token — used by local Flux models (FLUX.1-dev, FLUX.2-klein).+ Independent of the mode picker because the token persists in settings+ and applies whenever local image gen runs. */<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><div className="flex items-center gap-2 text-white"><Key size={18} />@@ -632,38 +677,9 @@ export function ImageGenTab() {</button>)}</div>+ )}- {/* Save + status */}- <div className="flex items-center gap-3">- <button- type="button"- onClick={handleSave}- disabled={saving || !isDirty}- className="flex items-center gap-2 px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white text-sm rounded-lg transition-colors disabled:opacity-50 min-h-[40px]"- >- {saving ? <BrailleSpinner /> : <Save size={14} />}- Save- </button>- <button- type="button"- onClick={checkStatus}- disabled={checking || isDirty}- className="flex items-center gap-2 px-4 py-2 bg-port-border hover:bg-port-border/70 text-white text-sm rounded-lg transition-colors disabled:opacity-50 min-h-[40px]"- title={isDirty ? 'Save settings first to test' : 'Probe the active backend'}- >- {checking ? <BrailleSpinner /> : <Zap size={14} />}- Test Connection- </button>- {status && (- <span className={`text-sm ${status.connected ? 'text-port-success' : 'text-port-error'}`}>- {status.connected- ? `${status.mode} — ${status.model || status.pythonPath}`- : status.reason || 'Not connected'}- </span>- )}- </div>-- {/* Tailnet expose */}+ {mediaTab === 'expose' && (<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><div className="flex items-center gap-2 text-white"><Globe size={18} />@@ -697,8 +713,9 @@ export function ImageGenTab() {</div>)}</div>+ )}- {/* Test render */}+ {mediaTab === 'test' && (<div className="bg-port-card border border-port-border rounded-xl p-6 space-y-4"><div className="flex items-center gap-2 text-white"><Sparkles size={18} />@@ -740,6 +757,41 @@ export function ImageGenTab() {</div>)}</div>+ )}+ </div>++ {/* Persistent global save + status bar — applies across every tab since+ Save persists the whole imageGen config and Test Connection probes the+ active backend. Kept outside the tab panel so it's reachable no matter+ which section is open. */}+ <div className="flex items-center gap-3 pt-3 border-t border-port-border">+ <button+ type="button"+ onClick={handleSave}+ disabled={saving || !isDirty}+ className="flex items-center gap-2 px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white text-sm rounded-lg transition-colors disabled:opacity-50 min-h-[40px]"+ >+ {saving ? <BrailleSpinner /> : <Save size={14} />}+ Save+ </button>+ <button+ type="button"+ onClick={checkStatus}+ disabled={checking || isDirty}+ className="flex items-center gap-2 px-4 py-2 bg-port-border hover:bg-port-border/70 text-white text-sm rounded-lg transition-colors disabled:opacity-50 min-h-[40px]"+ title={isDirty ? 'Save settings first to test' : 'Probe the active backend'}+ >+ {checking ? <BrailleSpinner /> : <Zap size={14} />}+ Test Connection+ </button>+ {status && (+ <span className={`text-sm ${status.connected ? 'text-port-success' : 'text-port-error'}`}>+ {status.connected+ ? `${status.mode} — ${status.model || status.pythonPath}`+ : status.reason || 'Not connected'}+ </span>+ )}+ </div>{/* CoS integration footer */}<div className="text-xs text-gray-500 px-1 flex items-center gap-2">diff --git a/client/src/components/settings/ImageGenTab.test.jsx b/client/src/components/settings/ImageGenTab.test.jsxnew file mode 100644index 0000000000..0e805de979--- /dev/null+++ b/client/src/components/settings/ImageGenTab.test.jsx@@ -0,0 +1,128 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, fireEvent, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';++vi.mock('../../services/api', () => ({+ getSettings: vi.fn(),+ updateSettings: vi.fn(),+ getImageGenStatus: vi.fn(),+ generateImage: vi.fn(),+ registerTool: vi.fn(),+ updateTool: vi.fn(),+ getToolsList: vi.fn(),+ getHfTokenStatus: vi.fn(),+ saveHfToken: vi.fn(),+ clearHfToken: vi.fn(),+}));+vi.mock('../ui/Toast', () => ({+ default: Object.assign(vi.fn(), {+ success: vi.fn(), error: vi.fn(), warning: vi.fn(), info: vi.fn(),+ }),+}));+// LocalSetupPanel has its own SSE/install-stream deps — stub it out; this suite+// only cares that the Local tab hosts a python-path panel.+vi.mock('./LocalSetupPanel', () => ({+ default: ({ pythonPath }) => <div data-testid="local-setup-panel">{pythonPath}</div>,+}));+vi.mock('../../hooks/useMediaJobSse', () => ({+ useMediaJobSse: () => ({ attach: vi.fn(), close: vi.fn() }),+}));++import {+ getSettings, getToolsList, getHfTokenStatus, updateSettings,+} from '../../services/api';+import { ImageGenTab } from './ImageGenTab';++const renderTab = async (initialEntries = ['/media/image']) => {+ render(+ <MemoryRouter initialEntries={initialEntries}>+ <ImageGenTab />+ </MemoryRouter>,+ );+ // Cards render only after the settings fetch resolves.+ await waitFor(() => expect(screen.getByRole('tablist')).toBeTruthy());+};++beforeEach(() => {+ vi.clearAllMocks();+ getSettings.mockResolvedValue({+ imageGen: {+ mode: 'external',+ external: { sdapiUrl: 'http://localhost:7860' },+ local: { pythonPath: '/usr/bin/python3' },+ codex: { enabled: false },+ expose: { a1111: false },+ },+ });+ getToolsList.mockResolvedValue([]);+ getHfTokenStatus.mockResolvedValue({ hfTokenPresent: false, source: 'none' });+ updateSettings.mockResolvedValue({});+});++describe('ImageGenTab grouped tabs', () => {+ it('renders a pills sub-nav with all seven media-settings groups', async () => {+ await renderTab();+ const tabs = screen.getAllByRole('tab').map((t) => t.textContent);+ for (const label of ['Backend', 'External', 'Local', 'Codex CLI', 'Tokens', 'Expose', 'Test']) {+ expect(tabs.some((t) => t.includes(label))).toBe(true);+ }+ });++ it('defaults to the Backend tab and shows the mode cards', async () => {+ await renderTab();+ expect(screen.getByRole('heading', { name: 'Backend' })).toBeTruthy();+ expect(screen.getByText('External SD API')).toBeTruthy();+ expect(screen.getByText('Local (mflux)')).toBeTruthy();+ // Sections from other tabs are not mounted in the default view.+ expect(screen.queryByText('HuggingFace Token')).toBeNull();+ expect(screen.queryByText('Test Render')).toBeNull();+ });++ it('switches to the External tab and shows only that group', async () => {+ await renderTab();+ fireEvent.click(screen.getByRole('tab', { name: /External/i }));+ expect(screen.getByText('External AUTOMATIC1111 / Forge URL')).toBeTruthy();+ // Backend mode cards are no longer mounted.+ expect(screen.queryByText('External SD API')).toBeNull();+ });++ it('hosts the python-path panel on the Local tab regardless of active mode', async () => {+ await renderTab();+ fireEvent.click(screen.getByRole('tab', { name: /^Local/i }));+ expect(screen.getByTestId('local-setup-panel')).toBeTruthy();+ });++ it('deep-links the active sub-tab from the mediaTab search param', async () => {+ await renderTab(['/media/image?mediaTab=tokens']);+ // The Tokens group renders immediately without a click.+ expect(screen.getByRole('heading', { name: 'HuggingFace Token' })).toBeTruthy();+ const tokensTab = screen.getByRole('tab', { name: /Tokens/i });+ expect(tokensTab.getAttribute('aria-selected')).toBe('true');+ });++ it('keeps the global Save + Test Connection bar visible on every tab', async () => {+ await renderTab();+ expect(screen.getByRole('button', { name: /^Save$/ })).toBeTruthy();+ expect(screen.getByRole('button', { name: /Test Connection/i })).toBeTruthy();+ // Still present after switching to a non-backend tab.+ fireEvent.click(screen.getByRole('tab', { name: /Expose/i }));+ expect(screen.getByText('Expose as A1111 API on the Tailnet')).toBeTruthy();+ expect(screen.getByRole('button', { name: /^Save$/ })).toBeTruthy();+ });++ it('preserves the save behavior — dirtying a field enables Save and PUTs the full imageGen patch', async () => {+ await renderTab();+ fireEvent.click(screen.getByRole('tab', { name: /External/i }));+ const urlInput = screen.getByPlaceholderText('http://localhost:7860');+ fireEvent.change(urlInput, { target: { value: 'http://localhost:9999' } });+ const saveBtn = screen.getByRole('button', { name: /^Save$/ });+ expect(saveBtn.disabled).toBe(false);+ fireEvent.click(saveBtn);+ await waitFor(() => expect(updateSettings).toHaveBeenCalled());+ const patch = updateSettings.mock.calls[0][0];+ expect(patch.imageGen.external.sdapiUrl).toBe('http://localhost:9999');+ expect(patch.imageGen.mode).toBe('external');+ expect(patch.imageGen).toHaveProperty('codex');+ expect(patch.imageGen).toHaveProperty('expose');+ });+});