Skip to content

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

fix: use native video canvas while source images load (#8867)

[._.]/ Adam Eivy95b864cd102c
diff --git a/client/src/hooks/useVideoGenForm.js b/client/src/hooks/useVideoGenForm.js
index 7a27650aaf..18c72cb5fb 100644
--- a/client/src/hooks/useVideoGenForm.js
+++ b/client/src/hooks/useVideoGenForm.js
@@ -485,14 +485,15 @@ export function useVideoGenForm({
// Until the user deliberately chooses a size, model changes carry their own
// native default canvas. This is material for H3: the shared 768x512 default
// is an off-distribution wiring-test size, while its trained 16:9 canvas is
- // 1344x768. A source image still wins through the aspect-snap effect above,
- // and Remix/Continue/user edits set sizeManuallySetRef so they are preserved.
+ // 1344x768. Apply it even while a source image is loading (or fails to load),
+ // then let its onload callback choose the closest native aspect preset.
+ // Remix/Continue/user edits set sizeManuallySetRef so they are preserved.
useEffect(() => {
- if (!currentModel || sizeManuallySetRef.current || sourceImageFile || sourceUploadUrl) return;
+ if (!currentModel || sizeManuallySetRef.current) return;
const next = defaultResolutionForModel(currentModel);
setWidth(next.w);
setHeight(next.h);
- }, [currentModel, sourceImageFile, sourceUploadUrl]);
+ }, [currentModel]);
// Remix/deep-link/resume paths set model + sampler fields independently.
// Reconcile them once the model is known so a legacy LTX 8n+1 frame count
diff --git a/client/src/hooks/useVideoGenForm.test.jsx b/client/src/hooks/useVideoGenForm.test.jsx
index 6f4ae7b66f..6c88bb60e7 100644
--- a/client/src/hooks/useVideoGenForm.test.jsx
+++ b/client/src/hooks/useVideoGenForm.test.jsx
@@ -500,6 +500,46 @@ describe('useVideoGenForm', () => {
expect(result.current.modelId).toBe(H3.id);
});
+ it('uses the new model native canvas before an image loads, then snaps its aspect without overriding custom sizes', async () => {
+ const pendingImages = [];
+ vi.stubGlobal('Image', class {
+ naturalWidth = 576;
+ naturalHeight = 1024;
+ constructor() { pendingImages.push(this); }
+ });
+ try {
+ const { result } = render({
+ models: [MLX, H3],
+ url: '/media/video?sourceImageFile=example-source.png',
+ });
+ await waitFor(() => expect(result.current.modelId).toBe(MLX.id));
+ const previousModelImage = pendingImages.at(-1);
+ act(() => result.current.handleModelChange(H3.id));
+ await waitFor(() => expect(result.current.buildGeneratePayload()).toMatchObject({
+ mode: 'image', width: 1344, height: 768,
+ }));
+
+ // A superseded source callback cannot restore the prior model canvas.
+ act(() => previousModelImage.onload());
+ expect(result.current.buildGeneratePayload()).toMatchObject({ width: 1344, height: 768 });
+ act(() => pendingImages.at(-1).onload());
+ expect(result.current.buildGeneratePayload()).toMatchObject({ width: 768, height: 1344 });
+
+ // Explicit size choice survives both a model switch and its late image load.
+ act(() => {
+ result.current.handleResolutionChange(576, 1024);
+ result.current.handleModelChange(MLX.id);
+ });
+ await waitFor(() => expect(result.current.modelId).toBe(MLX.id));
+ act(() => result.current.handleModelChange(H3.id));
+ await waitFor(() => expect(result.current.modelId).toBe(H3.id));
+ act(() => pendingImages.at(-1).onload());
+ expect(result.current.buildGeneratePayload()).toMatchObject({ width: 576, height: 1024 });
+ } finally {
+ vi.unstubAllGlobals();
+ }
+ });
+
it('keeps the advisory last-frame note on a single-frame mlx_video runtime', async () => {
const { result } = render({ models: [MLX, H3] });
await waitFor(() => expect(result.current.modelId).toBe(MLX.id));