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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix(media): mobile lightbox UX + DRY lightbox wiring across 4 pages
Adam Eivyc182390b4d2c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 69f42e959d..9753916017 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -61,6 +61,10 @@## Fixed+- **Mobile MediaLightbox UX overhaul.** On a phone the lightbox was effectively unnavigable: prev/next chevrons rendered as faint `text-white/40` glyphs that disappeared on bright images, the swipe threshold was too strict for thumb arcs (`dx > dy×1.5`, 60 px), tapping in fullscreen opened a settings drawer that took the whole screen with no obvious dismiss, the chevrons sat at viewport `top-1/2` directly over landscape image content, and tapping the maximize/minimize button bubbled to the image div's tap handler — collapsing fullscreen AND toggling the drawer in the same gesture, leaving a `drawerOpen=true` state stranded under `fullScreen=false` that flashed the SettingsPane through the bottom-sheet layout on exit. Now: chevrons get a `bg-black/40 backdrop-blur` pill (visible on any image) and re-anchor to `bottom-4` in fullscreen so they sit in the letterbox bar for landscape renders; the fullscreen settings drawer is a bottom sheet (`max-h-[55vh]`) on mobile so the image + chevrons stay reachable above it (desktop keeps the side drawer); the swipe guard loosens to `dx > dy×1.2`, `SWIPE_MIN_PX=50`; touch handlers on the image area ignore events that originate inside a `<button>` via `e.target.closest('button')` so the max/min toggle no longer leaks into the tap-toggle; and a new `useEffect` clears `drawerOpen` whenever `fullScreen` falls back to false so the stale-state flash can't recur. The bottom-of-card hint also extends to `"tap for settings · swipe to navigate"` when prev/next exist.++- **Unified MediaLightbox wiring across all four gallery pages.** Image Gen, Media History, Media Collection Detail, and Video Gen each rolled their own `<MediaLightbox>` props block — same boilerplate (`item={preview}`, `onClose={() => setPreview(null)}`, the annotation lookup/patch dance) but with small drift: Media Collection Detail was missing `previewNavProps` entirely, so collections had no prev/next arrows or swipe nav at all, and it pre-filtered handlers by `preview.kind` despite `MediaLightbox` already gating the action buttons internally. The four call sites now share one wrapper, `client/src/components/media/MediaPreview.jsx`, that owns the close handler, the memoized `getMediaNavProps()` call, and the annotation wiring; nav props are spread after caller handlers so a stray `onPrevious`/`onNext` can't shadow the wrapper's contract. Collection view picks up prev/next nav as a side effect. Net diff: ~50 lines removed across the four pages.+- **DRY pointer cursor on interactive elements.** Tailwind v4 dropped the default `cursor: pointer` on `<button>`, which meant every clickable in PortOS had to spell out `className="cursor-pointer"` — and most didn't, so buttons hover-rendered with the text I-beam. A single global rule in `client/src/index.css` now restores pointer for `button`, `a[href]`, `summary`, `select`, clickable input types (checkbox/radio/submit/button/reset/file/range/color), `<label>` wrapping a checkbox/radio, and ARIA roles (`button`, `link`, `tab`, `menuitem`, `option`, `checkbox`, `radio`, `switch`). Placed before the existing `[disabled] { cursor: not-allowed }` block so disabled elements still get the correct override. Existing `cursor-pointer` utility classes are now redundant but harmless.- Pipeline issues no longer get stuck in `status: 'running'` after a server restart mid auto-run. Boot now walks every issue and demotes any `running` to `needs-review` (the same terminal state a normal completion lands on) — the UI shows the issue as needing attention instead of spinning forever waiting for SSE that will never arrive.- Pipeline EpisodeVideoStage final-video render no longer breaks when the underlying mp4 is missing — both surfaces (Creative Director SegmentsTab + Pipeline EpisodeVideoStage) now route through a shared `ScenePreview` component with the onError-missing-media fallback + Retry + cache-bust pattern.diff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsxindex cb06a3e0ed..c1bef9895d 100644--- a/client/src/components/media/MediaLightbox.jsx+++ b/client/src/components/media/MediaLightbox.jsx@@ -21,9 +21,9 @@ const NOTE_DEBOUNCE_MS = 500;// 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;+// Touch thresholds. dx > dy×1.2 keeps a diagonal scroll from being read as a+// nav swipe but stays forgiving for a real thumb swipe.+const SWIPE_MIN_PX = 50;const TAP_MAX_PX = 10;// onClean(item, level) — optional. Returning a rejected promise keeps the@@ -98,6 +98,9 @@ export default function MediaLightbox({// 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); setRefineOpen(false); }, [item?.key]);+ // The tap-toggle only fires in fullscreen, so drawerOpen under !fullScreen is+ // always stale — clear it so a re-enter into fullscreen starts clean.+ useEffect(() => { if (!fullScreen) setDrawerOpen(false); }, [fullScreen]);if (!item) return null;const isVideo = item.kind === 'video';@@ -129,18 +132,24 @@ export default function MediaLightbox({['Created', item.createdAt && new Date(item.createdAt).toLocaleString()],].filter(([, v]) => v != null && v !== '');+ // Ignore touches that originate on inline buttons (max/min toggle).+ // Without this, their tap bubbles to onTouchEnd here and is read as a+ // tap-on-image → drawer toggles alongside the button's own action.+ const isButtonTouch = (e) => !!e.target.closest('button');const onTouchStart = (e) => {+ if (isButtonTouch(e)) { touchStart.current = { x: null, y: null }; return; }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;+ if (isButtonTouch(e)) { touchStart.current = { x: null, y: 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 (Math.abs(dx) >= SWIPE_MIN_PX && Math.abs(dx) > Math.abs(dy) * 1.2) {if (dx > 0 && hasPrevious) onPrevious?.();else if (dx < 0 && hasNext) onNext?.();return;@@ -155,6 +164,17 @@ export default function MediaLightbox({: '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]';+ // Anchor low in fullscreen so the chevrons land in the letterbox bar of a+ // landscape image instead of covering it. Non-fullscreen keeps them centered+ // — bottom-anchoring would bury them in the SettingsPane underneath.+ let chevronPositionClass;+ if (fullScreen && drawerOpen) {+ chevronPositionClass = 'hidden sm:flex bottom-4';+ } else if (fullScreen) {+ chevronPositionClass = 'bottom-4';+ } else {+ chevronPositionClass = 'top-1/2 -translate-y-1/2';+ }return (<div@@ -167,7 +187,7 @@ export default function MediaLightbox({<buttontype="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 text-white/40 hover:text-white focus:outline-none focus:ring-2 focus:ring-port-accent rounded-full"+ className={`absolute left-3 md:left-5 ${chevronPositionClass} z-30 p-2.5 text-white/80 hover:text-white bg-black/40 hover:bg-black/60 backdrop-blur-sm focus:outline-none focus:ring-2 focus:ring-port-accent rounded-full`}aria-label="Previous media"title="Previous">@@ -178,7 +198,7 @@ export default function MediaLightbox({<buttontype="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 text-white/40 hover:text-white focus:outline-none focus:ring-2 focus:ring-port-accent rounded-full"+ className={`absolute right-3 md:right-5 ${chevronPositionClass} z-30 p-2.5 text-white/80 hover:text-white bg-black/40 hover:bg-black/60 backdrop-blur-sm focus:outline-none focus:ring-2 focus:ring-port-accent rounded-full`}aria-label="Next media"title="Next">@@ -217,8 +237,8 @@ export default function MediaLightbox({{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 className="absolute bottom-2 left-1/2 -translate-x-1/2 text-[10px] uppercase tracking-wide text-white/50 select-none pointer-events-none">+ tap for settings{(hasPrevious || hasNext) ? ' · swipe to navigate' : ''}</div>)}</div>@@ -255,8 +275,10 @@ function SettingsPane({cleaning, setCleaning, copy, onRefine,annotation, onAnnotationChange,}) {+ // Fullscreen: bottom sheet (max 55vh) on mobile so the image + chevrons+ // stay reachable above it; side drawer (w-96) on desktop.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'+ ? 'absolute left-0 right-0 bottom-0 max-h-[55vh] sm:left-auto sm:top-0 sm:bottom-0 sm:max-h-none sm:w-96 z-20 bg-port-card border-t sm:border-t-0 sm: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]';const starred = !!annotation?.starred;// Local draft state debounces saves so each keystroke doesn't PATCH.diff --git a/client/src/components/media/MediaPreview.jsx b/client/src/components/media/MediaPreview.jsxnew file mode 100644index 0000000000..2d6869a815--- /dev/null+++ b/client/src/components/media/MediaPreview.jsx@@ -0,0 +1,37 @@+import { useMemo } from 'react';+import MediaLightbox from './MediaLightbox';+import { getMediaNavProps } from '../../lib/mediaNavigation';++// Thin wrapper around MediaLightbox that owns the consistent wiring every+// page repeated by hand: open/close, prev/next nav, and the annotation+// lookup/patch dance. Page-specific handlers pass through as-is.+//+// MediaLightbox already gates Remix / SendToVideo / Clean on `isVideo` and+// Continue on `!isVideo`, so callers should pass handlers unconditionally+// rather than pre-filtering by `preview.kind`.+//+// Nav props win over handlers (spread order) so a stray `onPrevious`/`onNext`+// in a caller can't accidentally shadow the wrapper's navigation contract.+export default function MediaPreview({+ preview,+ setPreview,+ items,+ annotations,+ updateAnnotation,+ ...handlers+}) {+ const navProps = useMemo(+ () => getMediaNavProps(items, preview, setPreview),+ [items, preview, setPreview]+ );+ return (+ <MediaLightbox+ item={preview}+ onClose={() => setPreview(null)}+ annotation={annotations?.[preview?.key] ?? null}+ onAnnotationChange={preview && updateAnnotation ? (patch) => updateAnnotation(preview.key, patch) : undefined}+ {...handlers}+ {...navProps}+ />+ );+}diff --git a/client/src/pages/ImageGen.jsx b/client/src/pages/ImageGen.jsxindex c283abf749..16dde178ce 100644--- a/client/src/pages/ImageGen.jsx+++ b/client/src/pages/ImageGen.jsx@@ -13,7 +13,7 @@ import { useNavigate, useSearchParams, Link } from 'react-router-dom';import Drawer from '../components/Drawer';import { ImageGenTab } from '../components/settings/ImageGenTab';import MediaCard from '../components/media/MediaCard';-import MediaLightbox from '../components/media/MediaLightbox';+import MediaPreview from '../components/media/MediaPreview';import FavoritesFilterChip from '../components/media/FavoritesFilterChip';import StylePresetPicker from '../components/media/StylePresetPicker';import BackendChipStrip from '../components/media/BackendChipStrip';@@ -31,7 +31,6 @@ import {} from 'lucide-react';import { composeStyledPrompt } from '../lib/composeStyledPrompt';import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../lib/imageGenBackends';-import { getMediaNavProps } from '../lib/mediaNavigation';import toast from '../components/ui/Toast';import BrailleSpinner from '../components/BrailleSpinner';import { useImageGenProgress } from '../hooks/useImageGenProgress';@@ -467,7 +466,6 @@ export default function ImageGen() {...visibleGallery.map(normalizeImage),...(showHidden ? hiddenGallery.map(normalizeImage) : []),], [visibleGallery, hiddenGallery, showHidden]);- const previewNavProps = getMediaNavProps(previewItems, preview, setPreview);// Snapshots current form state into a server payload + POSTs it to the// mediaJobQueue. Returns the queue's response ({ jobId, position, ... }).@@ -1181,15 +1179,15 @@ export default function ImageGen() {</div>)}- <MediaLightbox- item={preview}- onClose={() => setPreview(null)}+ <MediaPreview+ preview={preview}+ setPreview={setPreview}+ items={previewItems}+ annotations={annotations}+ updateAnnotation={updateAnnotation}onRemix={(item) => item?.raw && handleRemix(item.raw)}onSendToVideo={(item) => item?.raw?.filename && sendToVideo(item.raw)}onClean={(item, level) => handleClean(item?.raw, level)}- annotation={preview ? annotations[preview.key] ?? null : null}- onAnnotationChange={preview ? (patch) => updateAnnotation(preview.key, patch) : undefined}- {...previewNavProps}/>diff --git a/client/src/pages/MediaCollectionDetail.jsx b/client/src/pages/MediaCollectionDetail.jsxindex ec565261ee..bbee51aca5 100644--- a/client/src/pages/MediaCollectionDetail.jsx+++ b/client/src/pages/MediaCollectionDetail.jsx@@ -3,7 +3,7 @@ import { useParams, Link, useNavigate } from 'react-router-dom';import { ArrowLeft, CheckSquare, Copy, FolderInput, Inbox, Pencil, Star, StarOff, Trash2, X } from 'lucide-react';import toast from '../components/ui/Toast';import MediaCard from '../components/media/MediaCard';-import MediaLightbox from '../components/media/MediaLightbox';+import MediaPreview from '../components/media/MediaPreview';import BulkTargetPicker from '../components/media/BulkTargetPicker';import { normalizeImage, normalizeVideo } from '../components/media/normalize';import { useMediaAnnotations } from '../hooks/useMediaAnnotations';@@ -484,18 +484,17 @@ export default function MediaCollectionDetail() {</div>)}- {preview && (- <MediaLightbox- item={preview}- onClose={() => setPreview(null)}- onRemix={preview.kind === 'image' ? (i) => handleRemix(i) : undefined}- onSendToVideo={preview.kind === 'image' ? (i) => handleSendToVideo(i) : undefined}- onContinue={preview.kind === 'video' ? (i) => handleContinue(i.raw || i) : undefined}- onClean={preview.kind === 'image' ? (i, level) => handleClean(i?.raw || i, level) : undefined}- annotation={annotations[preview.key] ?? null}- onAnnotationChange={(patch) => updateAnnotation(preview.key, patch)}- />- )}+ <MediaPreview+ preview={preview}+ setPreview={setPreview}+ items={items}+ annotations={annotations}+ updateAnnotation={updateAnnotation}+ onRemix={handleRemix}+ onSendToVideo={handleSendToVideo}+ onContinue={(i) => handleContinue(i.raw || i)}+ onClean={(i, level) => handleClean(i?.raw || i, level)}+ /></div>);}diff --git a/client/src/pages/MediaHistory.jsx b/client/src/pages/MediaHistory.jsxindex 41284cd09e..7e85545e66 100644--- a/client/src/pages/MediaHistory.jsx+++ b/client/src/pages/MediaHistory.jsx@@ -9,12 +9,11 @@ import { Link, useNavigate } from 'react-router-dom';import { Combine, Image as ImageIcon, Film, Search, X } from 'lucide-react';import toast from '../components/ui/Toast';import MediaCard from '../components/media/MediaCard';-import MediaLightbox from '../components/media/MediaLightbox';+import MediaPreview from '../components/media/MediaPreview';import FavoritesFilterChip from '../components/media/FavoritesFilterChip';import { normalizeImage, normalizeVideo } from '../components/media/normalize';import { useMediaCompletionRefresh } from '../hooks/useMediaCompletionRefresh';import { useMediaAnnotations } from '../hooks/useMediaAnnotations';-import { getMediaNavProps } from '../lib/mediaNavigation';import {listVideoHistory, deleteVideoHistoryItem, extractLastFrame, stitchVideos,upscaleVideo,@@ -96,7 +95,6 @@ export default function MediaHistory() {() => favoritesOnly ? kindFiltered.filter((i) => annotations[i.key]?.starred) : kindFiltered,[kindFiltered, favoritesOnly, annotations]);- const previewNavProps = getMediaNavProps(filtered, preview, setPreview);const counts = useMemo(() => {const c = { all: 0, image: 0, video: 0 };for (const i of searched) {@@ -313,16 +311,16 @@ export default function MediaHistory() {</div>)}- <MediaLightbox- item={preview}- onClose={() => setPreview(null)}+ <MediaPreview+ preview={preview}+ setPreview={setPreview}+ items={filtered}+ annotations={annotations}+ updateAnnotation={updateAnnotation}onRemix={handleRemix}onSendToVideo={handleSendToVideo}onContinue={handleContinue}onClean={(item, level) => handleClean(item?.raw, level)}- annotation={preview ? annotations[preview.key] ?? null : null}- onAnnotationChange={preview ? (patch) => updateAnnotation(preview.key, patch) : undefined}- {...previewNavProps}/></div>);diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 9bf5753589..cec3cb1f49 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -29,7 +29,7 @@ import { useSearchParams, useNavigate, Link } from 'react-router-dom';import Drawer from '../components/Drawer';import { ImageGenTab } from '../components/settings/ImageGenTab';import MediaCard from '../components/media/MediaCard';-import MediaLightbox from '../components/media/MediaLightbox';+import MediaPreview from '../components/media/MediaPreview';import StylePresetPicker from '../components/media/StylePresetPicker';import { normalizeVideo } from '../components/media/normalize';import { composeStyledPrompt } from '../lib/composeStyledPrompt';@@ -51,7 +51,6 @@ import {listImageGallery,} from '../services/api';import { randomSeed, safeParseJSON } from '../lib/genUtils';-import { getMediaNavProps } from '../lib/mediaNavigation';const RESOLUTIONS = [{ label: '512×320 (16:10)', w: 512, h: 320 },@@ -233,7 +232,6 @@ export default function VideoGen() {...galleryVisible.map(normalizeVideo),...(showHidden ? galleryHidden.map(normalizeVideo) : []),], [galleryVisible, galleryHidden, showHidden]);- const previewNavProps = getMediaNavProps(previewItems, preview, setPreview);const handleDeleteHistory = async (item) => {await deleteVideoHistoryItem(item.id).catch((err) => toast.error(err.message || 'Delete failed'));@@ -1374,13 +1372,13 @@ export default function VideoGen() {</div>)}- <MediaLightbox- item={preview}- onClose={() => setPreview(null)}+ <MediaPreview+ preview={preview}+ setPreview={setPreview}+ items={previewItems}+ annotations={annotations}+ updateAnnotation={updateAnnotation}onContinue={(item) => handleContinueHistory(item.raw)}- annotation={preview ? annotations[preview.key] ?? null : null}- onAnnotationChange={preview ? (patch) => updateAnnotation(preview.key, patch) : undefined}- {...previewNavProps}/><Drawer open={settingsOpen} onClose={closeSettings} title="Media Generation Settings">