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
fix: give QuickImagePrompt a custom-size option via shared ResolutionField (#2437)
Adam Eivy64a1ff07976b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 1f1ae0da1e..9fd8713f56 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Changes+- **The dashboard's Quick Image widget now offers custom output dimensions and no longer shows a blank size dropdown for off-preset sizes (#2437).** The quick widget had its own inline resolution `<select>` over the universal presets and never gained the **Custom…** option added to the full Image Gen page, so its size picker was inconsistent — and a remix/off-preset size (any width/height not on the preset list) rendered a blank dropdown because no matching `<option>` existed. It now reuses the shared `ResolutionField` control, so selecting **Custom…** reveals Width/Height inputs (any edge 64–3840px, total ≤ 8,294,400px, matching the server's `imageEdgeSchema` + pixel cap), and an off-preset size auto-opens those inputs with the exact dimensions visible instead of collapsing to a blank select. No behavior change to the presets themselves.+- **Duplicated child-process stream/discovery helpers converged into shared lib modules (#2392).** Three hand-copied "split a stdout/stderr chunk stream into lines with a carry buffer" implementations (`ytdlpAudioImport.js`, `videoDownload.js`, `hfDownload.js`) had already drifted — only hfDownload's copy flushed the final unterminated line. They now share `server/lib/streamLines.js#createLineReader(onLine, {splitRe?, maxCarry?})`, which carries the partial trailing line across chunks, exposes a `flush()` for the last newline-less line (so the two yt-dlp paths stop dropping it — and skip the flush on cancel so a partial marker can't fire a stray progress frame), clamps the carry buffer against a newline-less runaway stream, and takes a `splitRe: /[\r\n]+/` option for bare-`\r` torch/tqdm progress redraws. The four bare-`\r` progress-splitter siblings (`midiRuntime.js`, `videoGen.js`, `music.js` install-log routes, and `pythonSetup.js#streamSpawn`) are converged onto the same reader with that option, so a progress line split across a chunk boundary is no longer torn. Separately, the inline `which`/`where` PATH probes in `ytdlp.js`, `ffmpeg.js` (×2), `pythonSetup.js`, and voice `bootstrap.js` are replaced by a single `whichFirst(name)` in `server/lib/processEnv.js` (Malloc-stripped env, 5s timeout, first-line result). The vendored `aiToolkit/providers.js` copy is intentionally left alone (self-contained by design). Behavior-preserving; both new helpers are unit-tested.- **Runtime/venv install SSE flows now log to the server console too, matching the HF model-download logging (#2432).** The image/video/MuScriptor runtime installers (spawning `setup-image-video.sh`), the FLUX.2 venv bootstrap, and the local image-gen pip installer streamed multi-GB pip/git progress only to the browser via SSE — a headless / PM2 log had no record the install ever ran (the same gap `startHfDownloadStream` had already closed for HF model downloads). A new shared `createInstallLogger` chokepoint (`server/lib/installLogger.js`) now emits a single-line START, throttled heartbeats + `stage` milestones, and the OUTCOME (success/fail/cancel) with installer name, target, and elapsed time — without echoing every raw pip/bash line. Wired into all five install spawn sites in `music.js`, `videoGen.js`, `imageGen.js` (FLUX.2 venv + local pip install), and `midiRuntime.js`.diff --git a/client/src/components/QuickImagePrompt.jsx b/client/src/components/QuickImagePrompt.jsxindex a05cc6fe7d..5e992819ee 100644--- a/client/src/components/QuickImagePrompt.jsx+++ b/client/src/components/QuickImagePrompt.jsx@@ -3,7 +3,8 @@ import { Link, useNavigate } from 'react-router-dom';import { Sparkles, Pencil, ChevronDown, ChevronRight } from 'lucide-react';import { generateImage } from '../services/api';import { DEFAULT_NEGATIVE_PROMPT } from '../lib/imageGenDefaults';-import { RESOLUTIONS, resolveResolutionLabel } from '../lib/imageGenResolutions';+import { RESOLUTIONS, MAX_IMAGE_EDGE, MAX_IMAGE_PIXELS } from '../lib/imageGenResolutions';+import ResolutionField from './media/ResolutionField';import MediaJobThumb from './pipeline/MediaJobThumb';import toast from './ui/Toast';@@ -28,11 +29,7 @@ export default function QuickImagePrompt() {const submittingRef = useRef(false);const navigate = useNavigate();- const { label: resolutionLabel } = resolveResolutionLabel(QUICK_RESOLUTIONS, width, height);- const handleResolution = (e) => {- const r = QUICK_RESOLUTIONS.find((opt) => opt.label === e.target.value);- if (r) { setWidth(r.w); setHeight(r.h); }- };+ const handleResolution = (w, h) => { setWidth(w); setHeight(h); };const handleGenerate = async (e) => {e?.preventDefault();@@ -114,17 +111,27 @@ export default function QuickImagePrompt() {className="flex-1 min-h-[60px] px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm resize-none"/>- <div className="shrink-0">- <label htmlFor="quick-image-resolution" className="block text-xs font-medium text-gray-400 mb-1">Resolution</label>- <select- id="quick-image-resolution"- value={resolutionLabel}+ {/* Shared preset dropdown + "Custom…" width/height inputs. Reuses the+ same control as the full Image Gen page so the quick widget offers+ custom sizes and (unlike the old inline <select>) never shows a+ blank dropdown for an off-preset/remix size — ResolutionField+ auto-opens the custom inputs and displays the W×H instead. The+ image route accepts any integer edge in [64, 3840] with total+ pixels ≤ 8.29M, so step=1 keeps hand-typed non-multiple-of-8 edges+ from tripping native form validation. */}+ <div className="shrink-0 flex flex-col gap-2">+ <ResolutionField+ presets={QUICK_RESOLUTIONS}+ width={width}+ height={height}onChange={handleResolution}+ min={64}+ max={MAX_IMAGE_EDGE}+ step={1}+ maxPixels={MAX_IMAGE_PIXELS}disabled={isSubmitting}- className={`${inputCls} disabled:opacity-50`}- >- {QUICK_RESOLUTIONS.map((r) => <option key={r.label} value={r.label}>{r.label}</option>)}- </select>+ inputClassName={`${inputCls} disabled:opacity-50`}+ /></div><div className="shrink-0">diff --git a/client/src/components/QuickImagePrompt.test.jsx b/client/src/components/QuickImagePrompt.test.jsxnew file mode 100644index 0000000000..4b822e878b--- /dev/null+++ b/client/src/components/QuickImagePrompt.test.jsx@@ -0,0 +1,64 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, fireEvent, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';+import QuickImagePrompt from './QuickImagePrompt';++// generateImage is the only network call; MediaJobThumb subscribes to sockets+// (irrelevant to this widget's resolution wiring) so stub it to a marker.+const generateImage = vi.fn();+vi.mock('../services/api', () => ({ generateImage: (...args) => generateImage(...args) }));+vi.mock('./pipeline/MediaJobThumb', () => ({ default: () => <div data-testid="job-thumb" /> }));+vi.mock('./ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));++const renderWidget = () =>+ render(+ <MemoryRouter>+ <QuickImagePrompt />+ </MemoryRouter>,+ );++describe('QuickImagePrompt — resolution control', () => {+ beforeEach(() => {+ generateImage.mockReset();+ generateImage.mockResolvedValue({ jobId: 'job-1', status: 'queued' });+ });++ it('offers a Custom… option alongside the universal presets', () => {+ renderWidget();+ expect(screen.getByRole('option', { name: 'Custom…' })).toBeTruthy();+ expect(screen.getByRole('option', { name: '1024×1024' })).toBeTruthy();+ });++ it('reveals width/height inputs when Custom… is selected and generates with the typed size', async () => {+ renderWidget();+ // Default 1024×1024 matches a preset → no custom inputs yet.+ expect(screen.queryByLabelText('Width')).toBeNull();++ fireEvent.change(screen.getByLabelText('Resolution'), { target: { value: '__custom__' } });+ const widthInput = screen.getByLabelText('Width');+ const heightInput = screen.getByLabelText('Height');+ expect(widthInput.value).toBe('1024');++ fireEvent.change(widthInput, { target: { value: '704' } });+ fireEvent.change(heightInput, { target: { value: '1280' } });++ fireEvent.change(screen.getByLabelText('Image prompt'), { target: { value: 'a neon alley' } });+ fireEvent.click(screen.getByTitle('Generate with these settings'));++ await waitFor(() => expect(generateImage).toHaveBeenCalled());+ expect(generateImage).toHaveBeenCalledWith(+ expect.objectContaining({ prompt: 'a neon alley', width: 704, height: 1280 }),+ );+ });++ it('keeps an off-preset size visible in the inputs rather than a blank select', () => {+ renderWidget();+ // Land on an off-preset size via the custom flow, then confirm it round-trips+ // to the visible inputs (the old inline <select> rendered a blank option).+ fireEvent.change(screen.getByLabelText('Resolution'), { target: { value: '__custom__' } });+ fireEvent.change(screen.getByLabelText('Width'), { target: { value: '900' } });+ expect(screen.getByLabelText('Width').value).toBe('900');+ // Select still reflects the custom sentinel, not an empty value.+ expect(screen.getByLabelText('Resolution').value).toBe('__custom__');+ });+});