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: load deferred music-video previews when the viewport reaches desktop

[._.]/ Adam Eivy7d9d9a27e036
diff --git a/client/src/components/musicVideo/CompositionPreviewPlayer.jsx b/client/src/components/musicVideo/CompositionPreviewPlayer.jsx
index aa49e168a2..e8cac4f00d 100644
--- a/client/src/components/musicVideo/CompositionPreviewPlayer.jsx
+++ b/client/src/components/musicVideo/CompositionPreviewPlayer.jsx
@@ -13,7 +13,8 @@ const lyricAt = (cues, t) => {
// A phone's collapsed mini-player has no picture to show, so it must not pull
// every scene take into memory up front — iOS Safari kills the tab and offers
// only "A problem repeatedly occurred". Without matchMedia, load eagerly.
-const startsDeferred = (collapsed) => collapsed && window.matchMedia?.('(min-width: 1024px)').matches === false;
+const DESKTOP_QUERY = '(min-width: 1024px)';
+const startsDeferred = (collapsed) => collapsed && window.matchMedia?.(DESKTOP_QUERY).matches === false;
/**
* Live preview of the project's composition document: the sandboxed iframe,
@@ -35,7 +36,16 @@ export default function CompositionPreviewPlayer({ project, audioUrl, seekReques
const [previewError, setPreviewError] = useState('');
const [status, setStatus] = useState('');
const [wanted, setWanted] = useState(() => !startsDeferred(collapsed));
- useEffect(() => { if (!collapsed) setWanted(true); }, [collapsed]);
+ useEffect(() => {
+ if (!collapsed) { setWanted(true); return undefined; }
+ const desktop = window.matchMedia?.(DESKTOP_QUERY);
+ // The desktop dock is always visible and has no expand button. A preview
+ // deferred on a phone must therefore load when its viewport becomes wide.
+ const reveal = () => { if (!desktop || desktop.matches) setWanted(true); };
+ reveal();
+ desktop?.addEventListener?.('change', reveal);
+ return () => desktop?.removeEventListener?.('change', reveal);
+ }, [collapsed]);
const [t, setT] = useState(0);
const [playing, setPlaying] = useState(false);
const iframeRef = useRef(null);
diff --git a/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx b/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx
index 9f23c227f6..a261899501 100644
--- a/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx
+++ b/client/src/components/musicVideo/CompositionPreviewPlayer.test.jsx
@@ -63,6 +63,32 @@ describe('CompositionPreviewPlayer', () => {
}
});
+ it('loads a deferred preview when resizing to desktop without expanding the mobile dock', async () => {
+ const original = window.matchMedia;
+ const desktop = Object.assign(new EventTarget(), { matches: false });
+ window.matchMedia = vi.fn(() => desktop);
+ try {
+ render(<CompositionPreviewPlayer project={project} audioUrl="/data/music/song.mp3" collapsed />);
+ await act(async () => {});
+ expect(api.getMusicVideoCompositionPreview).not.toHaveBeenCalled();
+ await act(async () => {
+ desktop.matches = true;
+ desktop.dispatchEvent(new Event('change'));
+ });
+ await screen.findByTitle('Composition document preview');
+ expect(screen.getByRole('button', { name: 'Play' })).toBeEnabled();
+ expect(api.getMusicVideoCompositionPreview).toHaveBeenCalledTimes(1);
+ await act(async () => {
+ desktop.matches = false;
+ desktop.dispatchEvent(new Event('change'));
+ });
+ expect(screen.getByTitle('Composition document preview')).toBeInTheDocument();
+ expect(api.getMusicVideoCompositionPreview).toHaveBeenCalledTimes(1);
+ } finally {
+ window.matchMedia = original;
+ }
+ });
+
it('runs the document in an opaque-origin sandbox and renders nothing without one', async () => {
const { container, rerender } = render(<CompositionPreviewPlayer project={{ ...project, composition: { mode: 'document' } }} audioUrl={null} />);
expect(container).toBeEmptyDOMElement();