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 lightbox send-to-video navigation

[._.]/ Adam Eivy4be076909030
diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsx
index f027d9c7b3..af63702a58 100644
--- a/client/src/components/media/MediaLightbox.jsx
+++ b/client/src/components/media/MediaLightbox.jsx
@@ -362,6 +362,10 @@ function SettingsPane({
const asideClasses = 'md:w-80 lg:w-96 shrink-0 flex flex-col border-t md:border-t-0 md:border-l border-port-border max-h-[40vh] md:max-h-[92vh]';
const [cleaning, setCleaning] = useState(false);
const starred = !!annotation?.starred;
+ const closeThenRun = (handler) => {
+ onClose?.();
+ handler?.(item);
+ };
// Local draft state debounces saves so each keystroke doesn't PATCH.
// onSaveRef keeps the debounce effect off the parent's render churn —
// page components pass inline-arrow onAnnotationChange callbacks, which
@@ -563,7 +567,7 @@ function SettingsPane({
{onRemix && (
<button
type="button"
- onClick={() => { onRemix(item); onClose(); }}
+ onClick={() => closeThenRun(onRemix)}
className="flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-port-accent text-white hover:opacity-90 rounded"
>
<Sparkles className="w-3.5 h-3.5" /> Remix
@@ -572,7 +576,7 @@ function SettingsPane({
{!isVideo && onSendToVideo && (
<button
type="button"
- onClick={() => { onSendToVideo(item); onClose(); }}
+ onClick={() => closeThenRun(onSendToVideo)}
className="flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-port-success text-white hover:opacity-90 rounded"
>
<Film className="w-3.5 h-3.5" /> Send to Video
@@ -606,7 +610,7 @@ function SettingsPane({
{isVideo && onContinue && (
<button
type="button"
- onClick={() => { onContinue(item); onClose(); }}
+ onClick={() => closeThenRun(onContinue)}
className="flex-1 flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-port-accent text-white hover:opacity-90 rounded"
>
<ImageIcon className="w-3.5 h-3.5" /> Continue
diff --git a/client/src/components/media/MediaLightbox.test.jsx b/client/src/components/media/MediaLightbox.test.jsx
index 2d62603259..864ff76070 100644
--- a/client/src/components/media/MediaLightbox.test.jsx
+++ b/client/src/components/media/MediaLightbox.test.jsx
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
-import { render, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import MediaLightbox from './MediaLightbox';
// The footer's AddToCollectionMenu and the (closed) PromptRefineModal pull the
@@ -20,6 +20,16 @@ const videoItem = {
createdAt: Date.now(),
};
+const imageItem = {
+ kind: 'image',
+ key: 'image:frame.png',
+ filename: 'frame.png',
+ previewUrl: '/data/images/frame.png',
+ downloadUrl: '/data/images/frame.png',
+ prompt: 'a cat portrait',
+ createdAt: Date.now(),
+};
+
describe('MediaLightbox video element (mobile playback)', () => {
// jsdom doesn't implement HTMLMediaElement.play; stub it per-test so we can
// drive the unmute-on-open effect down both the granted and blocked paths.
@@ -76,3 +86,25 @@ describe('MediaLightbox video element (mobile playback)', () => {
expect(video.hasAttribute('poster')).toBe(false);
});
});
+
+describe('MediaLightbox route-changing actions', () => {
+ it('closes the preview before Send to Video runs so query cleanup cannot override navigation', () => {
+ const calls = [];
+ const onClose = vi.fn(() => calls.push('close'));
+ const onSendToVideo = vi.fn(() => calls.push('send'));
+
+ render(
+ <MediaLightbox
+ item={imageItem}
+ onClose={onClose}
+ onSendToVideo={onSendToVideo}
+ />
+ );
+
+ fireEvent.click(screen.getByRole('button', { name: /send to video/i }));
+
+ expect(onClose).toHaveBeenCalledTimes(1);
+ expect(onSendToVideo).toHaveBeenCalledWith(imageItem);
+ expect(calls).toEqual(['close', 'send']);
+ });
+});