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

feat: media lightbox full-screen mode with swipe nav + copyable seed

Adam Eivy93c9e98366da
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 11dceb8655..f89f1cd254 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -4,6 +4,7 @@
- Codex image gen: hi-res resolution presets (1024×1536, 1536×1024, 1536×1536) — gpt-image-1's native hi-res tier. Picking any ≥1536 size automatically appends a `(high quality)` hint to the codex prompt so the model renders at full fidelity instead of its 1024 default.
- Image Gen batch mode: a `× N` count input next to the Generate button (async modes only — local + codex) queues N renders of the same prompt+resolution in a single submit. The first job streams its progress live; the remaining N-1 land in the server queue and surface as `+N queued`. Each job gets a fresh random seed by default so the batch produces variations, not duplicates.
+- Media Lightbox full-screen mode (`F` key or top-right toggle): drops the modal's rounding and padding and lets the image fill the viewport. Swipe left/right (or arrow keys) navigates between gallery items; tap reveals the settings as a slide-in drawer. Layered Escape closes drawer → exits full-screen → closes the lightbox. The Seed row in the settings pane is now copyable for easy reuse in a remix.
## Changed
diff --git a/PLAN.md b/PLAN.md
index 7ec31a7b0d..fd29df4f38 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -41,6 +41,8 @@ The dgrauet/ltx-2-mlx runtime ships with FFLF (true keyframe interpolation), aud
- [ ] **Multi-reference image editing for FLUX.2** — UI on the Image Gen page that accepts 2+ reference images plus an edit prompt (e.g. "put the subject from image A into the scene from image B"). When this lands, swap the model registry's 9B entry to [`black-forest-labs/FLUX.2-klein-9B-kv`](https://huggingface.co/black-forest-labs/FLUX.2-klein-9B-kv) — KV-cache optimization gives up to 2.5× speedup on multi-reference workflows. Work involves: schema for multi-image payload (`referenceImages: [...]`), client multi-uploader, server FormData parsing, and adapting `flux2_macos.py` to call the multi-reference pipeline API. Separately-gated repo on HF — user must request access.
- [ ] **World Builder Phase 2 — external SD-API + per-bucket model overrides.** The shipped batch render only supports local mflux + Codex. Wire the existing external SD-API providers (Together, Replicate, Fal) into the world-builder batch path so high-end renders are practical, and let each bucket pick its own model (e.g. characters → SDXL portrait LoRA, environments → Flux-pro). Single touchpoint: `server/services/worldBuilder.js#compileBatchPrompts` + `worldBuilderCollectionHook.js`. (Surfaced from PR #211 follow-ups.)
- [ ] **Unify VideoGen.jsx RESOLUTIONS with the shared image-gen list** — `client/src/pages/VideoGen.jsx:54` defines its own private `RESOLUTIONS` array + finds-by-w/h block, duplicating the pattern in `client/src/lib/imageGenResolutions.js`. Move VideoGen's presets into a shared `client/src/lib/videoGenResolutions.js` (or extend `imageGenResolutions.js` with a `media: 'image' | 'video'` field) so the dropdown + custom-fallback logic only lives in one place. Surfaced during the codex hi-res / per-backend filter work — `filterResolutions(mode, runner)` is exactly the helper VideoGen will want once mlx-video models gain runner-specific size constraints.
+- [ ] **Extract `useSwipeNav` hook + `lib/clipboard.js`** — `MediaLightbox.jsx` hand-rolls touch-swipe nav (SWIPE_MIN_PX / TAP_MAX_PX / horizontal-dominant guard) and `navigator.clipboard.writeText` is inlined across 8+ call sites (`ExportTab`, `EditAppModal`, `NextActionBanner`, `JiraReports`, `RapidReader`, `Shell`, `RunsHistoryPage`, `MediaLightbox`). Extract once a second swipe consumer appears; clipboard can move now (`copy(text, label)` with the existing "insecure context" toast). Surfaced from the lightbox full-screen pass.
+- [ ] **Route `MediaLightbox` settings drawer through `components/Drawer.jsx`** — In full-screen mode the lightbox renders a hand-rolled aside (`absolute top-0 right-0 bottom-0 w-full sm:w-96 z-20`) that is exactly the project's existing `Drawer` component. Skipped during the simplify pass because `Drawer`'s flat Esc handler conflicts with the lightbox's layered Escape cascade (drawer → fullscreen → close); reconcile by either lifting the cascade above `Drawer` or letting `Drawer` accept a no-op-Esc prop.
### Civitai LoRA / Z-Image-Turbo follow-ups (from /simplify pass)
diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsx
index 93d824140a..7aa4f8701e 100644
--- a/client/src/components/media/MediaLightbox.jsx
+++ b/client/src/components/media/MediaLightbox.jsx
@@ -1,7 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import {
X, Copy, Sparkles, Film, Image as ImageIcon, Download, Eraser,
- ChevronLeft, ChevronRight,
+ ChevronLeft, ChevronRight, Maximize2, Minimize2,
} from 'lucide-react';
import toast from '../ui/Toast';
@@ -9,6 +9,11 @@ import toast from '../ui/Toast';
// new level, drop a label here and the pill renders automatically.
const CLEAN_LEVEL_LABELS = { light: 'Light', aggressive: 'Aggressive' };
+// Touch swipe thresholds. The horizontal-dominant guard (dx > dy×1.5) keeps a
+// diagonal scroll on the iOS gallery from being read as a nav swipe.
+const SWIPE_MIN_PX = 60;
+const TAP_MAX_PX = 10;
+
// onClean(item, level) — optional. Returning a rejected promise keeps the
// lightbox open (e.g. on error) so the user can retry.
export default function MediaLightbox({
@@ -24,6 +29,9 @@ export default function MediaLightbox({
hasNext = false,
}) {
const [cleaning, setCleaning] = useState(null);
+ const [fullScreen, setFullScreen] = useState(false);
+ const [drawerOpen, setDrawerOpen] = useState(false);
+ const touchStart = useRef({ x: null, y: null });
// Read callbacks from refs so the keydown listener doesn't re-subscribe on
// every parent render (callers pass inline arrows; the lightbox parent re-
// renders constantly while media-gen events stream in).
@@ -34,9 +42,15 @@ export default function MediaLightbox({
const onKey = (e) => {
const cb = callbacksRef.current;
if (e.key === 'Escape') {
+ if (fullScreen && drawerOpen) { setDrawerOpen(false); return; }
+ if (fullScreen) { setFullScreen(false); return; }
cb.onClose();
return;
}
+ if (e.key === 'f' || e.key === 'F') {
+ setFullScreen((v) => !v);
+ return;
+ }
if (e.key === 'ArrowLeft' && hasPrevious && cb.onPrevious) {
e.preventDefault();
cb.onPrevious();
@@ -50,7 +64,11 @@ export default function MediaLightbox({
const prev = document.body.style.overflow;
document.body.style.overflow = 'hidden';
return () => { window.removeEventListener('keydown', onKey); document.body.style.overflow = prev; };
- }, [item, hasPrevious, hasNext]);
+ }, [item, hasPrevious, hasNext, fullScreen, drawerOpen]);
+
+ // Reset drawer when item changes (swipe forwards w/ settings open shouldn't
+ // carry the open state to the next image — feels jumpy).
+ useEffect(() => { setDrawerOpen(false); }, [item?.key]);
if (!item) return null;
const isVideo = item.kind === 'video';
@@ -77,10 +95,37 @@ export default function MediaLightbox({
['Created', item.createdAt && new Date(item.createdAt).toLocaleString()],
].filter(([, v]) => v != null && v !== '');
+ const onTouchStart = (e) => {
+ const t = e.touches[0];
+ touchStart.current = { x: t.clientX, y: t.clientY };
+ };
+ const onTouchEnd = (e) => {
+ const start = touchStart.current;
+ if (start.x == null) return;
+ const end = e.changedTouches[0];
+ const dx = end.clientX - start.x;
+ const dy = end.clientY - start.y;
+ touchStart.current = { x: null, y: null };
+ if (Math.abs(dx) >= SWIPE_MIN_PX && Math.abs(dx) > Math.abs(dy) * 1.5) {
+ if (dx > 0 && hasPrevious) onPrevious?.();
+ else if (dx < 0 && hasNext) onNext?.();
+ return;
+ }
+ if (fullScreen && Math.abs(dx) < TAP_MAX_PX && Math.abs(dy) < TAP_MAX_PX) {
+ setDrawerOpen((o) => !o);
+ }
+ };
+
+ const cardClasses = fullScreen
+ ? 'relative w-full h-full bg-black flex'
+ : 'relative bg-port-card border border-port-border rounded-xl overflow-hidden max-w-6xl w-full max-h-[92vh] flex flex-col md:flex-row';
+ const overlayPad = fullScreen ? 'p-0' : 'p-4';
+ const imgMax = fullScreen ? 'max-w-[100vw] max-h-[100vh]' : 'max-w-full max-h-[92vh]';
+
return (
<div
role="presentation"
- className="fixed inset-0 z-50 bg-black/90 flex items-center justify-center p-4"
+ className={`fixed inset-0 z-50 bg-black/90 flex items-center justify-center ${overlayPad}`}
onClick={onClose}
onKeyDown={(e) => e.key === 'Escape' && onClose()}
>
@@ -88,7 +133,7 @@ export default function MediaLightbox({
<button
type="button"
onClick={(e) => { e.stopPropagation(); onPrevious?.(); }}
- className="absolute left-3 md:left-5 top-1/2 -translate-y-1/2 z-10 p-2.5 rounded-full bg-black/55 text-white border border-white/15 hover:bg-black/75 focus:outline-none focus:ring-2 focus:ring-port-accent"
+ className="absolute left-3 md:left-5 top-1/2 -translate-y-1/2 z-10 p-2.5 text-white/40 hover:text-white focus:outline-none focus:ring-2 focus:ring-port-accent rounded-full"
aria-label="Previous media"
title="Previous"
>
@@ -99,7 +144,7 @@ export default function MediaLightbox({
<button
type="button"
onClick={(e) => { e.stopPropagation(); onNext?.(); }}
- className="absolute right-3 md:right-5 top-1/2 -translate-y-1/2 z-10 p-2.5 rounded-full bg-black/55 text-white border border-white/15 hover:bg-black/75 focus:outline-none focus:ring-2 focus:ring-port-accent"
+ className="absolute right-3 md:right-5 top-1/2 -translate-y-1/2 z-10 p-2.5 text-white/40 hover:text-white focus:outline-none focus:ring-2 focus:ring-port-accent rounded-full"
aria-label="Next media"
title="Next"
>
@@ -107,7 +152,7 @@ export default function MediaLightbox({
</button>
)}
<div
- className="relative bg-port-card border border-port-border rounded-xl overflow-hidden max-w-6xl w-full max-h-[92vh] flex flex-col md:flex-row"
+ className={cardClasses}
onClick={(e) => e.stopPropagation()}
role="presentation"
// Pin card/border alpha to 1 inside this focused modal so glass-style themes
@@ -115,147 +160,209 @@ export default function MediaLightbox({
// bg-black/90 overlay — the translucent default makes button text illegible.
style={{ '--port-card-alpha': 1, '--port-border-alpha': 1 }}
>
- <div className="flex-1 bg-black flex items-center justify-center min-h-0">
+ <div
+ className="flex-1 bg-black flex items-center justify-center min-h-0 relative"
+ onTouchStart={onTouchStart}
+ onTouchEnd={onTouchEnd}
+ >
{isVideo ? (
- <video src={item.downloadUrl} controls autoPlay loop className="max-w-full max-h-[92vh]" />
+ <video src={item.downloadUrl} controls autoPlay loop className={imgMax} />
) : (
- <img src={item.previewUrl} alt={item.prompt} className="max-w-full max-h-[92vh] object-contain" />
+ <img src={item.previewUrl} alt={item.prompt} className={`${imgMax} object-contain`} />
+ )}
+ {/* z-30 so this stays clickable when the settings drawer (z-20)
+ slides in over the image area. Solid white pill keeps it
+ readable against black letterbox bars. */}
+ <button
+ type="button"
+ onClick={(e) => { e.stopPropagation(); setFullScreen((v) => !v); }}
+ className="absolute top-2 right-2 z-30 p-2 rounded-full bg-white text-black hover:bg-white/85 shadow-lg"
+ aria-label={fullScreen ? 'Exit full screen' : 'Full screen'}
+ title={fullScreen ? 'Exit full screen (Esc, F)' : 'Full screen (F)'}
+ >
+ {fullScreen ? <Minimize2 className="w-4 h-4" /> : <Maximize2 className="w-4 h-4" />}
+ </button>
+ {fullScreen && !drawerOpen && (
+ <div className="absolute bottom-2 left-1/2 -translate-x-1/2 text-[10px] uppercase tracking-wide text-white/40 select-none pointer-events-none">
+ tap for settings
+ </div>
)}
</div>
- <aside className="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]">
- <header className="flex items-center justify-between p-3 border-b border-port-border">
- <span className="text-xs uppercase tracking-wide text-gray-400">{isVideo ? 'Video' : 'Image'} settings</span>
- <button
- type="button"
- onClick={onClose}
- className="p-1.5 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
- aria-label="Close"
- >
- <X className="w-4 h-4" />
- </button>
- </header>
-
- <div className="flex-1 overflow-y-auto p-3 space-y-3 text-xs">
- {item.prompt && (
- <div>
- <div className="flex items-center justify-between mb-1">
- <span className="text-gray-500 uppercase tracking-wide">Prompt</span>
- <button
- type="button"
- onClick={() => copy(item.prompt, 'Prompt')}
- className="p-1 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
- title="Copy prompt"
- >
- <Copy className="w-3 h-3" />
- </button>
- </div>
- <p className="text-gray-200 whitespace-pre-wrap">{item.prompt}</p>
- </div>
- )}
-
- {item.negativePrompt && (
- <div>
- <div className="flex items-center justify-between mb-1">
- <span className="text-gray-500 uppercase tracking-wide">Negative</span>
- <button
- type="button"
- onClick={() => copy(item.negativePrompt, 'Negative prompt')}
- className="p-1 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
- title="Copy negative prompt"
- >
- <Copy className="w-3 h-3" />
- </button>
- </div>
- <p className="text-gray-300 whitespace-pre-wrap">{item.negativePrompt}</p>
- </div>
- )}
+ {(!fullScreen || drawerOpen) && (
+ <SettingsPane
+ item={item}
+ meta={meta}
+ isVideo={isVideo}
+ fullScreen={fullScreen}
+ onClose={fullScreen ? () => setDrawerOpen(false) : onClose}
+ onPrimaryClose={onClose}
+ onRemix={onRemix}
+ onSendToVideo={onSendToVideo}
+ onContinue={onContinue}
+ onClean={onClean}
+ cleaning={cleaning}
+ setCleaning={setCleaning}
+ copy={copy}
+ />
+ )}
+ </div>
+ </div>
+ );
+}
- {meta.length > 0 && (
- <dl className="grid grid-cols-[auto,1fr] gap-x-3 gap-y-1">
- {meta.map(([k, v]) => (
- <div key={k} className="contents">
- <dt className="text-gray-500">{k}</dt>
- <dd className="text-gray-200 break-all">{String(v)}</dd>
- </div>
- ))}
- </dl>
- )}
- </div>
+function SettingsPane({
+ item, meta, isVideo, fullScreen,
+ onClose, onPrimaryClose, onRemix, onSendToVideo, onContinue, onClean,
+ cleaning, setCleaning, copy,
+}) {
+ const asideClasses = fullScreen
+ ? 'absolute top-0 right-0 bottom-0 w-full sm:w-96 z-20 bg-port-card border-l border-port-border flex flex-col shadow-2xl'
+ : '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]';
+ return (
+ <aside className={asideClasses} onClick={(e) => e.stopPropagation()}>
+ <header className="flex items-center justify-between p-3 border-b border-port-border">
+ <span className="text-xs uppercase tracking-wide text-gray-400">{isVideo ? 'Video' : 'Image'} settings</span>
+ <button
+ type="button"
+ onClick={onClose}
+ className="p-1.5 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
+ aria-label={fullScreen ? 'Hide settings' : 'Close'}
+ >
+ <X className="w-4 h-4" />
+ </button>
+ </header>
- <footer className="flex flex-wrap gap-1.5 p-3 border-t border-port-border">
- {!isVideo && onRemix && (
+ <div className="flex-1 overflow-y-auto p-3 space-y-3 text-xs">
+ {item.prompt && (
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <span className="text-gray-500 uppercase tracking-wide">Prompt</span>
<button
type="button"
- onClick={() => { onRemix(item); onClose(); }}
- 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"
+ onClick={() => copy(item.prompt, 'Prompt')}
+ className="p-1 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
+ title="Copy prompt"
>
- <Sparkles className="w-3.5 h-3.5" /> Remix
+ <Copy className="w-3 h-3" />
</button>
- )}
- {!isVideo && onSendToVideo && (
+ </div>
+ <p className="text-gray-200 whitespace-pre-wrap">{item.prompt}</p>
+ </div>
+ )}
+
+ {item.negativePrompt && (
+ <div>
+ <div className="flex items-center justify-between mb-1">
+ <span className="text-gray-500 uppercase tracking-wide">Negative</span>
<button
type="button"
- onClick={() => { onSendToVideo(item); onClose(); }}
- 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"
+ onClick={() => copy(item.negativePrompt, 'Negative prompt')}
+ className="p-1 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
+ title="Copy negative prompt"
>
- <Film className="w-3.5 h-3.5" /> Send to Video
+ <Copy className="w-3 h-3" />
</button>
- )}
- {!isVideo && onClean && (
- <div
- className="flex items-stretch rounded overflow-hidden border border-port-border"
- role="group"
- aria-label="Clean image"
- >
- <span className="flex items-center gap-1 px-2 py-1.5 text-xs bg-port-border/40 text-gray-300">
- <Eraser className="w-3.5 h-3.5" /> Clean
- </span>
- {Object.entries(CLEAN_LEVEL_LABELS).map(([level, label]) => (
- <button
- key={level}
- type="button"
- disabled={cleaning != null}
- onClick={async () => {
- if (cleaning) return;
- setCleaning(level);
- let ok = false;
- try {
- await onClean(item, level);
- ok = true;
- } catch {
- // Caller toasts its own error; stay open so the user can retry.
- } finally {
- setCleaning(null);
- }
- if (ok) onClose();
- }}
- className={`px-2 py-1.5 text-xs border-l border-port-border text-white hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed ${level === 'aggressive' ? 'bg-port-warning/80' : 'bg-port-border/70'}`}
- >
- {cleaning === level ? '…' : label}
- </button>
- ))}
+ </div>
+ <p className="text-gray-300 whitespace-pre-wrap">{item.negativePrompt}</p>
+ </div>
+ )}
+
+ {meta.length > 0 && (
+ <dl className="grid grid-cols-[auto,1fr] gap-x-3 gap-y-1">
+ {meta.map(([k, v]) => (
+ <div key={k} className="contents">
+ <dt className="text-gray-500">{k}</dt>
+ <dd className="text-gray-200 break-all flex items-center gap-1.5">
+ <span>{String(v)}</span>
+ {k === 'Seed' && (
+ <button
+ type="button"
+ onClick={() => copy(String(v), 'Seed')}
+ className="p-0.5 rounded text-gray-400 hover:text-white hover:bg-port-border/50"
+ title="Copy seed"
+ >
+ <Copy className="w-3 h-3" />
+ </button>
+ )}
+ </dd>
</div>
- )}
- {isVideo && onContinue && (
+ ))}
+ </dl>
+ )}
+ </div>
+
+ <footer className="flex flex-wrap gap-1.5 p-3 border-t border-port-border">
+ {!isVideo && onRemix && (
+ <button
+ type="button"
+ onClick={() => { onRemix(item); onPrimaryClose(); }}
+ 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
+ </button>
+ )}
+ {!isVideo && onSendToVideo && (
+ <button
+ type="button"
+ onClick={() => { onSendToVideo(item); onPrimaryClose(); }}
+ 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
+ </button>
+ )}
+ {!isVideo && onClean && (
+ <div
+ className="flex items-stretch rounded overflow-hidden border border-port-border"
+ role="group"
+ aria-label="Clean image"
+ >
+ <span className="flex items-center gap-1 px-2 py-1.5 text-xs bg-port-border/40 text-gray-300">
+ <Eraser className="w-3.5 h-3.5" /> Clean
+ </span>
+ {Object.entries(CLEAN_LEVEL_LABELS).map(([level, label]) => (
<button
+ key={level}
type="button"
- onClick={() => { onContinue(item); onClose(); }}
- 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"
+ disabled={cleaning != null}
+ onClick={async () => {
+ if (cleaning) return;
+ setCleaning(level);
+ let ok = false;
+ try {
+ await onClean(item, level);
+ ok = true;
+ } catch {
+ // Caller toasts its own error; stay open so the user can retry.
+ } finally {
+ setCleaning(null);
+ }
+ if (ok) onPrimaryClose();
+ }}
+ className={`px-2 py-1.5 text-xs border-l border-port-border text-white hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed ${level === 'aggressive' ? 'bg-port-warning/80' : 'bg-port-border/70'}`}
>
- <ImageIcon className="w-3.5 h-3.5" /> Continue
+ {cleaning === level ? '…' : label}
</button>
- )}
- <a
- href={item.downloadUrl}
- download
- className="flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-port-border hover:bg-port-border/70 text-white rounded"
- >
- <Download className="w-3.5 h-3.5" />
- </a>
- </footer>
- </aside>
- </div>
- </div>
+ ))}
+ </div>
+ )}
+ {isVideo && onContinue && (
+ <button
+ type="button"
+ onClick={() => { onContinue(item); onPrimaryClose(); }}
+ 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
+ </button>
+ )}
+ <a
+ href={item.downloadUrl}
+ download
+ className="flex items-center justify-center gap-1.5 px-2 py-1.5 text-xs bg-port-border hover:bg-port-border/70 text-white rounded"
+ >
+ <Download className="w-3.5 h-3.5" />
+ </a>
+ </footer>
+ </aside>
);
}