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: hide live frames during video renders
Adam Eivy43f8deef8d49
diff --git a/client/src/components/videoGen/LiveVideoStage.jsx b/client/src/components/videoGen/LiveVideoStage.jsxindex bd83a74c6e..5231cb8b51 100644--- a/client/src/components/videoGen/LiveVideoStage.jsx+++ b/client/src/components/videoGen/LiveVideoStage.jsx@@ -5,9 +5,10 @@* to the Generate button; the clip appeared in the gallery minutes later. The* stage shows, at the render's RESOLVED geometry (so a portrait render is a* portrait box, not a letterboxed 16:9 one), whatever best represents the- * in-flight render: a live runner frame if one exists, otherwise the clip an- * extend is continuing (animated, muted, looping) or the still it is growing- * out of, and the finished clip once it lands.+ * in-flight render: the clip an extend is continuing (animated, muted, looping)+ * or the still it is growing out of, and the finished clip once it lands.+ * Transient runner frames stay off this surface because a single decoded frame+ * does not usefully represent the motion or quality of the finished video.** Hold and return. The stage never yanks a clip out from under the user: while* `held` is set by the page (the lightbox is open) or while the user is playingdiff --git a/client/src/components/videoGen/LiveVideoStage.test.jsx b/client/src/components/videoGen/LiveVideoStage.test.jsxindex 75469c5196..ff5e43b5f8 100644--- a/client/src/components/videoGen/LiveVideoStage.test.jsx+++ b/client/src/components/videoGen/LiveVideoStage.test.jsx@@ -6,14 +6,18 @@ import { resolveVideoStagePreview, VIDEO_STAGE_KIND } from '../../lib/videoStageconst stageFrame = () => screen.getByTestId('video-stage-frame');describe('LiveVideoStage', () => {- it('renders a live runner frame as an image at the render aspect ratio', () => {+ it('keeps conditioning media on stage instead of showing a live runner frame', () => {const descriptor = resolveVideoStagePreview({- generating: true, currentImage: 'iVBORw0KG', width: 480, height: 832,+ generating: true,+ currentImage: 'iVBORw0KG',+ sourceImageFile: 'start.png',+ width: 480,+ height: 832,});render(<LiveVideoStage descriptor={descriptor} generating progressPct={40} statusMsg="Rendering step 4/10" />);- const img = screen.getByAltText('Live frame');- expect(img.getAttribute('src')).toBe('data:image/png;base64,iVBORw0KG');+ expect(screen.queryByAltText('Live frame')).not.toBeInTheDocument();+ expect(screen.getByAltText('Start frame').getAttribute('src')).toBe('/data/images/start.png');// Portrait geometry: an inline style, never a computed Tailwind class// (a `aspect-[480/832]` class name would not survive the JIT build).// (CSS normalizes a bare number to `<n> / 1`, hence the split.)@@ -31,7 +35,7 @@ describe('LiveVideoStage', () => {});it('leaves the aspect ratio unset when the render geometry is unknown', () => {- const descriptor = resolveVideoStagePreview({ generating: true, currentImage: 'AAA' });+ const descriptor = resolveVideoStagePreview({ generating: true });render(<LiveVideoStage descriptor={descriptor} generating />);expect(stageFrame().style.aspectRatio).toBe('');});@@ -104,9 +108,9 @@ describe('LiveVideoStage', () => {const { rerender } = render(<LiveVideoStage descriptor={loop} generating />);fireEvent.play(screen.getByLabelText('Continuing from this clip'));- const live = resolveVideoStagePreview({ generating: true, currentImage: 'AAA' });- rerender(<LiveVideoStage descriptor={live} generating />);- expect(stageFrame().dataset.stageKind).toBe(VIDEO_STAGE_KIND.LIVE);+ const still = resolveVideoStagePreview({ generating: true, sourceImageFile: 'start.png' });+ rerender(<LiveVideoStage descriptor={still} generating />);+ expect(stageFrame().dataset.stageKind).toBe(VIDEO_STAGE_KIND.STILL);});it('surfaces a render failure over the stage', () => {diff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex e25b6831d0..aba3eda74d 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -82,7 +82,7 @@ grep -i "what you want to do" client/src/lib/README.md| `videoGenResolutions.js` | Shared resolution presets/default for video generation, model-specific preset/default resolvers (for native canvases such as MiniMax H3), and `snapAspectToImage()` to pick the closest-aspect preset for an I2V source. || `videoGenSubmission.js` | Builds the local, Grok, and federated video-generation request bodies from validated form state, including prompt envelopes and empty-value wire sentinels. || `videoReferenceModes.js` | Mirror of `server/lib/videoReferenceModes.js` (parity enforced by `server/lib/videoReferenceModes.mirror.test.js`) — the i2v reference-mode contract: `I2V_REFERENCE_MODES`, `I2V_REFERENCE_MODE_OPTIONS` (label + the promise sentence `AdvancedParamsPanel` and the source-frame note print), `runtimeSupportsI2vReferenceMode` (gates which options the picker offers), `resolveI2vReferenceStrength` (the effective strength the panel displays), and `i2vReferenceModeViolation` for pre-submit feedback. |-| `videoStagePreview.js` | VideoGen main-stage preview resolver (#4588). `resolveVideoStagePreview({ generating, currentImage, width, height, result, extendSource, sourceImageFile/Url, lastImageFile/Url, keyframes })` → `{ kind: 'live'|'loop'|'still'|'result'|'empty', src, poster, label, aspectRatio }` — what the stage should show at each moment of a render, with mid-render vs idle precedence. Plus `videoStageAspectRatio()` (a NUMBER for an inline `aspect-ratio` style — a computed Tailwind `aspect-[w/h]` class never reaches the JIT build; `null` means unknown geometry, not 16:9), `videoPreviewFrameSrc()` (the runners' `currentImage` is polymorphic — raw base64 from imageGen, a served URL from loraTraining — so classify before prefixing), and `videoStageSignature()` for the hold/return guard in `components/videoGen/LiveVideoStage.jsx`. |+| `videoStagePreview.js` | VideoGen main-stage preview resolver (#4588). `resolveVideoStagePreview({ generating, width, height, result, extendSource, sourceImageFile/Url, lastImageFile/Url, keyframes })` → `{ kind: 'loop'|'still'|'result'|'empty', src, poster, label, aspectRatio }` — conditioning media while a render runs and the finished clip once it lands; transient runner frames are intentionally excluded. Plus `videoStageAspectRatio()` (a NUMBER for an inline `aspect-ratio` style — a computed Tailwind `aspect-[w/h]` class never reaches the JIT build; `null` means unknown geometry, not 16:9) and `videoStageSignature()` for the hold/return guard in `components/videoGen/LiveVideoStage.jsx`. || `videoTilingOptions.js` | `VIDEO_TILING_OPTIONS` (the `<select>` rows) + `VIDEO_TILING_ENUM_SET` (the value-only Set). Single source consumed by `VideoGen.jsx` and the Remix URL builder in `useMediaPreviewActions`. Mirrors the server's `z.enum` in `server/routes/videoGen.js`. |## Graph & simdiff --git a/client/src/lib/videoStagePreview.js b/client/src/lib/videoStagePreview.jsindex f9556f6765..9383cfe3a6 100644--- a/client/src/lib/videoStagePreview.js+++ b/client/src/lib/videoStagePreview.js@@ -3,10 +3,10 @@** VideoGen used to show nothing but a percentage next to the Generate button* until the MP4 landed. This picks what the page's main stage should display at- * any moment of a render — a live runner frame when one exists, otherwise the- * conditioning the render is forming FROM (the clip an extend continues, the- * start/keyframe/end still an i2v or FFLF render is growing out of), and the- * finished clip once it arrives.+ * any moment of a render — the conditioning the render is forming FROM (the+ * clip an extend continues, the start/keyframe/end still an i2v or FFLF render+ * is growing out of), and the finished clip once it arrives. Transient runner+ * frames are deliberately omitted because they are not useful video previews.** Pure: every input is already in the page's hands, nothing fetches. The* component owns the hold/return behaviour; this module owns "what would be@@ -14,7 +14,6 @@*/export const VIDEO_STAGE_KIND = Object.freeze({- LIVE: 'live', // a decoded frame from the in-flight renderLOOP: 'loop', // an animated clip (the source an extend continues)STILL: 'still', // a conditioning image (start frame / keyframe / end frame)RESULT: 'result', // a finished render@@ -40,21 +39,6 @@ export function videoStageAspectRatio(width, height) {return isPositive(w) && isPositive(h) ? w / h : null;}-/**- * Build an <img> src from a runner's `currentImage` frame.- *- * That key is polymorphic across runners: imageGen/local.js emits a raw base64- * PNG body, loraTraining emits an already-served URL. Both ride the same field,- * so classify before prefixing — assuming base64 would corrupt the URL form.- * Returns `null` for absent/empty, which callers must treat as "no live frame"- * rather than as an empty image.- */-export function videoPreviewFrameSrc(currentImage) {- const raw = nonEmpty(currentImage);- if (!raw) return null;- return /^(data:|https?:|\/)/.test(raw) ? raw : `data:image/png;base64,${raw}`;-}-const videoSrc = (filename) => {const name = nonEmpty(filename);return name ? `/data/videos/${name}` : null;@@ -66,11 +50,6 @@ const thumbnailSrc = (thumbnail) => {const imageSrc = (uploadUrl, galleryFile) =>nonEmpty(uploadUrl) || (nonEmpty(galleryFile) ? `/data/images/${galleryFile}` : null);-const liveCandidate = (currentImage) => {- const src = videoPreviewFrameSrc(currentImage);- return src ? { kind: VIDEO_STAGE_KIND.LIVE, src, poster: null, label: 'Live frame' } : null;-};-const resultCandidate = (result) => {// `path` is what the completion payload carries; `filename` is the shape the// history records use. Accept either so the stage works whether the page@@ -109,14 +88,12 @@ const stillCandidate = ({ sourceImageFile, sourceUploadUrl, lastImageFile, lastU/*** Resolve the stage descriptor: `{ kind, src, poster, label, aspectRatio }`.*- * Precedence differs by phase on purpose. Mid-render the forming clip is the- * subject, so a live frame wins and the finished clip from the PREVIOUS render- * is only a last resort; idle, the finished clip is the subject and the- * conditioning stills are the fallback.+ * Precedence differs by phase on purpose. Mid-render the conditioning is the+ * subject and the finished clip from the PREVIOUS render is only a last resort;+ * idle, the finished clip is the subject and the conditioning is the fallback.*/export function resolveVideoStagePreview({generating = false,- currentImage = null,width = null,height = null,result = null,@@ -128,11 +105,10 @@ export function resolveVideoStagePreview({keyframes = null,} = {}) {const aspectRatio = videoStageAspectRatio(width, height);- const live = liveCandidate(currentImage);const finished = resultCandidate(result);const loop = loopCandidate(extendSource);const still = stillCandidate({ sourceImageFile, sourceUploadUrl, lastImageFile, lastUploadUrl, keyframes });- const ordered = generating ? [live, loop, still, finished] : [live, finished, loop, still];+ const ordered = generating ? [loop, still, finished] : [finished, loop, still];const picked = ordered.find(Boolean)|| { kind: VIDEO_STAGE_KIND.EMPTY, src: null, poster: null, label: 'Your render will appear here' };return { ...picked, aspectRatio };diff --git a/client/src/lib/videoStagePreview.test.js b/client/src/lib/videoStagePreview.test.jsindex 4a7b6c5129..a3fa8b02e3 100644--- a/client/src/lib/videoStagePreview.test.js+++ b/client/src/lib/videoStagePreview.test.js@@ -2,7 +2,6 @@ import { describe, it, expect } from 'vitest';import {VIDEO_STAGE_KIND,resolveVideoStagePreview,- videoPreviewFrameSrc,videoStageAspectRatio,videoStageSignature,} from './videoStagePreview';@@ -22,26 +21,6 @@ describe('videoStageAspectRatio', () => {});});-describe('videoPreviewFrameSrc', () => {- it('prefixes a raw base64 body', () => {- expect(videoPreviewFrameSrc('iVBORw0KG')).toBe('data:image/png;base64,iVBORw0KG');- });-- it('passes an already-usable src through unchanged', () => {- expect(videoPreviewFrameSrc('data:image/png;base64,AAA')).toBe('data:image/png;base64,AAA');- expect(videoPreviewFrameSrc('/api/lora-training/runs/r1/samples/step_4.png'))- .toBe('/api/lora-training/runs/r1/samples/step_4.png');- expect(videoPreviewFrameSrc('https://example.com/frame.png')).toBe('https://example.com/frame.png');- });-- it('treats absent and empty alike as "no frame" rather than an empty image', () => {- expect(videoPreviewFrameSrc(null)).toBeNull();- expect(videoPreviewFrameSrc(undefined)).toBeNull();- expect(videoPreviewFrameSrc('')).toBeNull();- expect(videoPreviewFrameSrc(42)).toBeNull();- });-});-describe('resolveVideoStagePreview', () => {const extendSource = { filename: 'clip-a.mp4', thumbnail: 'clip-a.jpg' };@@ -58,18 +37,6 @@ describe('resolveVideoStagePreview', () => {expect(stage.aspectRatio).toBeLessThan(1);});- it('prefers a live runner frame over every fallback while rendering', () => {- const stage = resolveVideoStagePreview({- generating: true,- currentImage: 'iVBORw0KG',- extendSource,- sourceImageFile: 'start.png',- result: { filename: 'done.mp4' },- });- expect(stage.kind).toBe(VIDEO_STAGE_KIND.LIVE);- expect(stage.src).toBe('data:image/png;base64,iVBORw0KG');- });-it('falls back to the animated source clip an extend is continuing', () => {const stage = resolveVideoStagePreview({ generating: true, extendSource, sourceImageFile: 'start.png' });expect(stage.kind).toBe(VIDEO_STAGE_KIND.LOOP);diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 8cba840995..13c55bd56e 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -386,14 +386,12 @@ export default function VideoGen() {const [progress, setProgress] = useState(null);const [statusMsg, setStatusMsg] = useState('');const [error, setError] = useState(null);- // Main-stage preview state (#4588). `currentImage` is the runner's latest- // decoded frame (absent for every runner that doesn't publish one yet, which- // is why the stage falls back to the render's conditioning). `renderGeometry`- // is the server's RESOLVED width/height — the form's values are what we- // asked for, and videoGen snaps both edges down to the model's grid.+ // Main-stage preview state (#4588). `renderGeometry` is the server's+ // RESOLVED width/height — the form's values are what we asked for, and+ // videoGen snaps both edges down to the model's grid. Transient runner frames+ // are intentionally ignored: they are not useful for judging a video render.// `lastRender` is this session's finished clip, so the stage hands off to it// instead of going blank when the render lands.- const [currentImage, setCurrentImage] = useState(null);const [renderGeometry, setRenderGeometry] = useState(null);const [lastRender, setLastRender] = useState(null);const { attach, eventSourceRef } = useMediaJobSse('video');@@ -433,15 +431,9 @@ export default function VideoGen() {onQueued: (msg) => setStatusMsg(typeof msg.position === 'number' ? `Queued (position ${msg.position})` : 'Queued'),onStarted: () => setStatusMsg('Starting render…'),onRenderMeta: (msg) => setRenderGeometry({ width: msg.width, height: msg.height }),- // Preview-only frame: a runner frame with no progress value. It must not- // disturb the progress bar, hence its own frame type on the wire.- onPreview: (msg) => { if (msg.currentImage) setCurrentImage(msg.currentImage); },onStatus: (msg) => setStatusMsg(msg.message),onProgress: (msg) => {setProgress({ progress: msg.progress });- // Runners throttle frames, so an absent key must leave the last frame- // on the stage rather than blanking it.- if (msg.currentImage) setCurrentImage(msg.currentImage);// A bare tqdm percentage shouldn't blank the STATUS line that just// preceded it; only overwrite when the progress event carries text.if (msg.message) setStatusMsg(msg.message);@@ -450,8 +442,7 @@ export default function VideoGen() {setGenerating(false);setProgress({ progress: 1 });setStatusMsg('Complete');- // Hand the stage off from the forming preview to the finished clip.- setCurrentImage(null);+ // Hand the stage off from the conditioning media to the finished clip.if (msg.result) setLastRender(msg.result);if (withToast) toast.success('Video generated');refreshHistory();@@ -672,7 +663,6 @@ export default function VideoGen() {);const stage = useMemo(() => resolveVideoStagePreview({generating,- currentImage,width: renderGeometry?.width ?? width,height: renderGeometry?.height ?? height,result: lastRender,@@ -681,7 +671,7 @@ export default function VideoGen() {lastImageFile, lastUploadUrl,keyframes: keyframesActive ? keyframes : null,}), [- generating, currentImage, renderGeometry, width, height, lastRender, extendSource,+ generating, renderGeometry, width, height, lastRender, extendSource,sourceImageFile, sourceUploadUrl, lastImageFile, lastUploadUrl, keyframesActive, keyframes,]);const showStage = generating || stage.kind !== VIDEO_STAGE_KIND.EMPTY;@@ -705,11 +695,9 @@ export default function VideoGen() {setProgress({ progress: 0 });setStatusMsg('Starting...');setError(null);- // Stale-job isolation: the previous run's frame and geometry must not be- // shown as if they belonged to this one. `lastRender` deliberately- // survives so the stage keeps the finished clip until this run produces- // something of its own.- setCurrentImage(null);+ // Stale-job isolation: the previous run's geometry must not be shown as if+ // it belonged to this one. `lastRender` deliberately survives so the stage+ // keeps the finished clip until this run produces something of its own.setRenderGeometry(null);const myToken = ++runTokenRef.current;