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: preserve portrait and square animation preview proportions

[._.]/ Adam Eivy84ab7b32d4c5
diff --git a/client/src/components/codeAnimation/CodeAnimationPreview.jsx b/client/src/components/codeAnimation/CodeAnimationPreview.jsx
index bdfcac73e2..8c0ffe27ee 100644
--- a/client/src/components/codeAnimation/CodeAnimationPreview.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationPreview.jsx
@@ -144,8 +144,11 @@ export default function CodeAnimationPreview({ html, audioUrl, messages, audioGl
if (jobId) body.jobId = jobId;
else body.html = html;
if (audioChoice === 'with-audio' && audioUrl) body.audioUrl = audioUrl;
- if (frame?.width) body.width = Math.min(1920, Math.round(frame.width));
- if (frame?.height) body.height = Math.min(1080, Math.round(frame.height));
+ // Fit the renderer's bounds with one scale so portrait and square canvases
+ // retain their composition instead of stretching each axis independently.
+ const scale = Math.min(1, 1920 / (frame?.width || 1920), 1080 / (frame?.height || 1080));
+ if (frame?.width) body.width = Math.round(frame.width * scale);
+ if (frame?.height) body.height = Math.round(frame.height * scale);
return body;
}, [html, audioChoice, audioGlobal, jobId, audioUrl, frame]);
const preview = useGeneratedPreview({ active: !!request, request });
diff --git a/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx b/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx
index 5e0d06303c..2f496e1275 100644
--- a/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx
+++ b/client/src/components/codeAnimation/CodeAnimationPreview.test.jsx
@@ -41,9 +41,9 @@ import { useSseProgress } from '../../hooks/useSseProgress';
const MESSAGES = { ready: 'ca:ready', record: 'ca:record', recorded: 'ca:recorded', progress: 'ca:progress', error: 'ca:error' };
const HTML = '<!DOCTYPE html><html><head><title>x</title></head><body><canvas></canvas></body></html>';
-const renderPreview = ({ audioUrl = null, jobId, html = HTML } = {}) => render(
+const renderPreview = ({ audioUrl = null, jobId, html = HTML, frame = { width: 1920, height: 1080, durationSeconds: 5 } } = {}) => render(
<MemoryRouter>
- <CodeAnimationPreview html={html} audioUrl={audioUrl} messages={MESSAGES} audioGlobal="ANIMATION_AUDIO_URL" frame={{ width: 1920, height: 1080, durationSeconds: 5 }} title="Lantern" jobId={jobId} />
+ <CodeAnimationPreview html={html} audioUrl={audioUrl} messages={MESSAGES} audioGlobal="ANIMATION_AUDIO_URL" frame={frame} title="Lantern" jobId={jobId} />
</MemoryRouter>,
);
@@ -83,6 +83,20 @@ describe('CodeAnimationPreview', () => {
afterEach(() => vi.unstubAllGlobals());
+ it.each([
+ ['portrait', 1080, 1920, 608, 1080],
+ ['oversized landscape', 3840, 2160, 1920, 1080],
+ ['square', 1440, 1440, 1080, 1080],
+ ['below-limit landscape', 1280, 720, 1280, 720],
+ ])('preserves the %s canvas aspect when opening the isolated preview', async (_label, width, height, previewWidth, previewHeight) => {
+ renderPreview({ frame: { width, height } });
+ await screen.findByTitle('Code animation preview');
+ expect(previewOpens().at(-1)[1]).toEqual(expect.objectContaining({
+ width: previewWidth,
+ height: previewHeight,
+ }));
+ });
+
it('downloads a standalone three film with the vendored modules inlined and does not execute it here (#10464)', async () => {
const user = userEvent.setup();
getCodeAnimationThreeVendor.mockResolvedValue({ files: [