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
feat: collapse-captions toggle, click-to-preview lightbox, full-height thumbs in LoRA dataset grid
[._.]/ Adam Eivy2aafb4e7dca5
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex f9f5695052..98240999b9 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,8 @@## Added+- **LoRA dataset grid: collapse captions, click-to-preview, and full-height thumbnails** — The dataset workbench image grid (`/media/training/:id`) gets three usability fixes. A **Hide captions / Show captions** toggle collapses every card's caption editor and action row at once, so you can scan the whole dataset as a clean thumbnail wall. Clicking any thumbnail now opens a **full-size preview lightbox** (← / → to step through the ready images, Esc to close) — the same affordance the media galleries already have. And thumbnails render at their **natural aspect ratio** (fixed column width, full relative height) instead of a fixed square crop, so portrait and landscape training images are no longer sliced off at the top and bottom. (`client/src/components/loraTraining/DatasetImageGrid.jsx`)+- **Describe a canon character / place / object from reference image(s)** — Each canon card in the Universe editor (Cast, Places, Objects) gains a **Describe from image(s)** button (the scan-text icon next to Render). Upload one reference image to turn it into an image-gen-ready prose description, or several images of the *same* subject (a character from multiple angles, a location across lighting conditions) and a vision model returns the description **common to all of them** — ignoring incidental differences like pose, background, and framing. You pick the **provider + model on demand** in the modal (only API/vision-capable providers are offered), edit the generated prose before applying, and it writes straight into the entry's descriptor field (`physicalDescription` for characters, `description` for places/objects) — the same field the render prompt reads. Vision runs through the existing API runner's `image_url` content-block path; the new `runPromptThroughProvider({ screenshots })` arg threads images through the shared runner, and the stateless `POST /api/universe-builder/describe-from-images` endpoint resolves an API provider (clear `NO_API_PROVIDER` error if none is configured) and builds the per-kind vision prompt. (`server/services/universeVisionDescribe.js`, `server/routes/universeBuilder.js`, `server/lib/promptRunner.js`, `client/src/components/universe/VisionDescribeModal.jsx`, `client/src/components/pipeline/CanonCard.jsx`, `client/src/components/universe/UniverseCanonSection.jsx`)- **Live LoRA training progress — watch the adapter learn, sample by sample** — A running training job used to show only a progress bar, a status line, and a single 32×32 thumbnail of the most recent preview. The active-run panel (`/media/training`) now renders a **live sample gallery**: a large current preview with its step label, a scrollable step-keyed thumbnail strip to scrub back through every earlier sample (so you can spot the moment a run starts to diverge), a **loss sparkline** that builds up over the session, and step / elapsed / **ETA** metrics. Samples merge two sources so a mid-run browser reload still shows the full timeline — a one-shot seed from a new `GET /api/lora-training/runs/:id/samples` endpoint (every preview persisted so far) plus the live SSE frames since re-subscribe. To drive the curve and key the thumbnails without re-parsing display strings, the trainer's STEP/SAMPLE line protocol now carries structured `loss` and `step` fields through the media-job SSE wire (additive — image/video gen frames are unaffected). (`server/services/loraTraining/progress.js`, `server/services/loraTraining/checkpoints.js`, `server/services/loraTraining/index.js`, `server/services/mediaJobQueue/index.js`, `server/routes/loraTraining.js`, `client/src/components/loraTraining/LiveSampleGallery.jsx`, `client/src/components/loraTraining/TrainingPanel.jsx`)diff --git a/client/src/components/loraTraining/DatasetImageGrid.jsx b/client/src/components/loraTraining/DatasetImageGrid.jsxindex 7740818305..53bbcd6cca 100644--- a/client/src/components/loraTraining/DatasetImageGrid.jsx+++ b/client/src/components/loraTraining/DatasetImageGrid.jsx@@ -3,9 +3,12 @@* Captions blur-save; local state updates reactively (no list refetch).*/-import { useState } from 'react';-import { Loader2, RefreshCw, AlertTriangle } from 'lucide-react';+import { useState, useEffect, useCallback } from 'react';+import {+ Loader2, RefreshCw, AlertTriangle, ChevronLeft, ChevronRight, X, Eye, EyeOff,+} from 'lucide-react';import toast from '../ui/Toast';+import Modal from '../ui/Modal';import ConfirmButtonPair from '../ui/ConfirmButtonPair';import AutoSizeTextarea from '../ui/AutoSizeTextarea';import {@@ -14,6 +17,70 @@ import {startLoraCaptionRun,} from '../../services/api';+// Lightweight full-size preview for a dataset image. Kept page-local (the+// rich MediaLightbox is bound to the media-gen `item` shape — prompts, clean/+// regen actions, annotations — none of which a raw training image carries).+// Navigates the ready-image subset with ← / → and Esc-closes via <Modal>.+function DatasetImageLightbox({ datasetId, images, index, onIndexChange, onClose }) {+ const img = images[index];+ const hasPrev = index > 0;+ const hasNext = index < images.length - 1;+ useEffect(() => {+ const onKey = (e) => {+ if (e.key === 'ArrowLeft' && hasPrev) { e.preventDefault(); onIndexChange(index - 1); }+ if (e.key === 'ArrowRight' && hasNext) { e.preventDefault(); onIndexChange(index + 1); }+ };+ window.addEventListener('keydown', onKey);+ return () => window.removeEventListener('keydown', onKey);+ }, [index, hasPrev, hasNext, onIndexChange]);+ if (!img) return null;+ return (+ <Modal open onClose={onClose} size="none" backdropClassName="bg-black/90" ariaLabel="Training image preview">+ <div className="relative flex flex-col items-center gap-3">+ <button+ type="button"+ onClick={onClose}+ className="absolute -top-1 right-0 z-10 p-2 rounded-full bg-white text-black hover:bg-white/85 shadow-lg focus:outline-none focus:ring-2 focus:ring-port-accent"+ aria-label="Close (Esc)"+ title="Close (Esc)"+ >+ <X className="w-4 h-4" />+ </button>+ <img+ src={`/data/lora-datasets/${datasetId}/images/${img.file}`}+ alt={img.caption || 'dataset image'}+ className="max-w-[92vw] max-h-[80vh] object-contain rounded-lg bg-black"+ />+ {img.caption && (+ <p className="max-w-[92vw] text-center text-sm text-gray-200 whitespace-pre-wrap">{img.caption}</p>+ )}+ {hasPrev && (+ <button+ type="button"+ onClick={() => onIndexChange(index - 1)}+ className="absolute left-2 md:-left-14 top-1/2 -translate-y-1/2 p-2.5 text-white/80 hover:text-white bg-black/50 hover:bg-black/70 backdrop-blur-sm rounded-full focus:outline-none focus:ring-2 focus:ring-port-accent"+ aria-label="Previous image"+ title="Previous (←)"+ >+ <ChevronLeft className="w-6 h-6" />+ </button>+ )}+ {hasNext && (+ <button+ type="button"+ onClick={() => onIndexChange(index + 1)}+ className="absolute right-2 md:-right-14 top-1/2 -translate-y-1/2 p-2.5 text-white/80 hover:text-white bg-black/50 hover:bg-black/70 backdrop-blur-sm rounded-full focus:outline-none focus:ring-2 focus:ring-port-accent"+ aria-label="Next image"+ title="Next (→)"+ >+ <ChevronRight className="w-6 h-6" />+ </button>+ )}+ </div>+ </Modal>+ );+}+const SOURCE_BADGE = {generated: { label: 'generated', cls: 'bg-port-accent/20 text-port-accent' },upload: { label: 'upload', cls: 'bg-emerald-600/20 text-emerald-300' },@@ -27,6 +94,16 @@ export default function DatasetImageGrid({ dataset, onImagesChange, onCaptionRunconst [confirmingId, setConfirmingId] = useState(null);const [deletingId, setDeletingId] = useState(null);const [recaptioningId, setRecaptioningId] = useState(null);+ const [showCaptions, setShowCaptions] = useState(true);+ // Index into the ready-image subset that the lightbox is previewing (null = closed).+ const [previewIndex, setPreviewIndex] = useState(null);++ // Only ready images are previewable — rendering/failed cells have no file.+ const readyImages = dataset.images.filter((i) => i.status === 'ready');+ const openPreview = useCallback((img) => {+ const idx = readyImages.findIndex((i) => i.id === img.id);+ if (idx >= 0) setPreviewIndex(idx);+ }, [readyImages]);const saveCaption = async (img) => {const draft = drafts[img.id];@@ -77,84 +154,118 @@ export default function DatasetImageGrid({ dataset, onImagesChange, onCaptionRun}return (- <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">- {dataset.images.map((img) => {- const badge = SOURCE_BADGE[img.source] || SOURCE_BADGE.upload;- return (- <div key={img.id} className="bg-port-card border border-port-border rounded-lg overflow-hidden flex flex-col">- <div className="relative aspect-square bg-port-bg">- {img.status === 'rendering' ? (- <div className="absolute inset-0 flex flex-col items-center justify-center text-gray-400 gap-2">- <Loader2 className="w-6 h-6 animate-spin" />- <span className="text-xs">rendering…</span>- </div>- ) : img.status === 'failed' ? (- <div className="absolute inset-0 flex flex-col items-center justify-center text-port-error gap-2">- <AlertTriangle className="w-6 h-6" />- <span className="text-xs">render failed</span>- </div>- ) : (- <img- src={`/data/lora-datasets/${dataset.id}/images/${img.file}`}- alt={img.caption || 'dataset image'}- className="absolute inset-0 w-full h-full object-cover"- loading="lazy"- />- )}- <span className={`absolute top-2 left-2 text-[10px] px-1.5 py-0.5 rounded ${badge.cls}`}>{badge.label}</span>- {img.variation?.view && (- <span className="absolute top-2 right-2 text-[10px] px-1.5 py-0.5 rounded bg-black/60 text-gray-300">- {img.variation.view}- </span>- )}- </div>- <div className="p-2 flex flex-col gap-2 flex-1">- <AutoSizeTextarea- value={drafts[img.id] ?? img.caption}- onChange={(e) => setDrafts((prev) => ({ ...prev, [img.id]: e.target.value }))}- onBlur={() => saveCaption(img)}- placeholder={img.status === 'ready' ? 'Caption (must include the trigger word)…' : ''}- disabled={img.status !== 'ready'}- // Per-grid-cell field — a visible label would be noise, so the- // accessible name comes from aria-label (the source + view give- // a screen-reader user enough to tell cells apart).- aria-label={`Caption for ${img.source}${img.variation?.view ? ` ${img.variation.view}` : ''} image`}- className="w-full min-h-[4.5rem] bg-port-bg border border-port-border rounded p-2 text-xs text-gray-200 disabled:opacity-50"- />- <div className="flex items-center justify-between text-xs">- <button- type="button"- onClick={() => recaption(img)}- disabled={img.status !== 'ready' || recaptioningId === img.id}- className="text-gray-400 hover:text-white flex items-center gap-1 disabled:opacity-50"- title="Re-caption with the vision model"- >- {recaptioningId === img.id || savingId === img.id- ? <Loader2 className="w-3.5 h-3.5 animate-spin" />- : <RefreshCw className="w-3.5 h-3.5" />}- Re-caption- </button>- {confirmingId === img.id ? (- <ConfirmButtonPair- prompt="Delete?"- busy={deletingId === img.id}- onConfirm={() => removeImage(img)}- onCancel={() => setConfirmingId(null)}- />+ <div className="space-y-3">+ <div className="flex justify-end">+ <button+ type="button"+ onClick={() => setShowCaptions((v) => !v)}+ className="text-xs text-gray-400 hover:text-white flex items-center gap-1.5"+ title={showCaptions ? 'Hide captions — show only thumbnails' : 'Show caption editors'}+ aria-pressed={!showCaptions}+ >+ {showCaptions ? <EyeOff className="w-3.5 h-3.5" /> : <Eye className="w-3.5 h-3.5" />}+ {showCaptions ? 'Hide captions' : 'Show captions'}+ </button>+ </div>+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 items-start">+ {dataset.images.map((img) => {+ const badge = SOURCE_BADGE[img.source] || SOURCE_BADGE.upload;+ return (+ <div key={img.id} className="bg-port-card border border-port-border rounded-lg overflow-hidden flex flex-col">+ <div className="relative bg-port-bg">+ {img.status === 'rendering' ? (+ <div className="aspect-square flex flex-col items-center justify-center text-gray-400 gap-2">+ <Loader2 className="w-6 h-6 animate-spin" />+ <span className="text-xs">rendering…</span>+ </div>+ ) : img.status === 'failed' ? (+ <div className="aspect-square flex flex-col items-center justify-center text-port-error gap-2">+ <AlertTriangle className="w-6 h-6" />+ <span className="text-xs">render failed</span>+ </div>) : (+ // Natural-height thumbnail: fixed column width, full relative+ // height so portrait/landscape crops aren't sliced by object-cover.<buttontype="button"- onClick={() => setConfirmingId(img.id)}- className="text-gray-500 hover:text-port-error"+ onClick={() => openPreview(img)}+ className="block w-full cursor-zoom-in focus:outline-none focus:ring-2 focus:ring-port-accent"+ title="Click to preview full size">- Delete+ <img+ src={`/data/lora-datasets/${dataset.id}/images/${img.file}`}+ alt={img.caption || 'dataset image'}+ className="block w-full h-auto"+ loading="lazy"+ /></button>)}+ <span className={`absolute top-2 left-2 text-[10px] px-1.5 py-0.5 rounded ${badge.cls}`}>{badge.label}</span>+ {img.variation?.view && (+ <span className="absolute top-2 right-2 text-[10px] px-1.5 py-0.5 rounded bg-black/60 text-gray-300">+ {img.variation.view}+ </span>+ )}</div>+ {showCaptions && (+ <div className="p-2 flex flex-col gap-2 flex-1">+ <AutoSizeTextarea+ value={drafts[img.id] ?? img.caption}+ onChange={(e) => setDrafts((prev) => ({ ...prev, [img.id]: e.target.value }))}+ onBlur={() => saveCaption(img)}+ placeholder={img.status === 'ready' ? 'Caption (must include the trigger word)…' : ''}+ disabled={img.status !== 'ready'}+ // Per-grid-cell field — a visible label would be noise, so the+ // accessible name comes from aria-label (the source + view give+ // a screen-reader user enough to tell cells apart).+ aria-label={`Caption for ${img.source}${img.variation?.view ? ` ${img.variation.view}` : ''} image`}+ className="w-full min-h-[4.5rem] bg-port-bg border border-port-border rounded p-2 text-xs text-gray-200 disabled:opacity-50"+ />+ <div className="flex items-center justify-between text-xs">+ <button+ type="button"+ onClick={() => recaption(img)}+ disabled={img.status !== 'ready' || recaptioningId === img.id}+ className="text-gray-400 hover:text-white flex items-center gap-1 disabled:opacity-50"+ title="Re-caption with the vision model"+ >+ {recaptioningId === img.id || savingId === img.id+ ? <Loader2 className="w-3.5 h-3.5 animate-spin" />+ : <RefreshCw className="w-3.5 h-3.5" />}+ Re-caption+ </button>+ {confirmingId === img.id ? (+ <ConfirmButtonPair+ prompt="Delete?"+ busy={deletingId === img.id}+ onConfirm={() => removeImage(img)}+ onCancel={() => setConfirmingId(null)}+ />+ ) : (+ <button+ type="button"+ onClick={() => setConfirmingId(img.id)}+ className="text-gray-500 hover:text-port-error"+ >+ Delete+ </button>+ )}+ </div>+ </div>+ )}</div>- </div>- );- })}+ );+ })}+ </div>+ {previewIndex !== null && readyImages[previewIndex] && (+ <DatasetImageLightbox+ datasetId={dataset.id}+ images={readyImages}+ index={previewIndex}+ onIndexChange={setPreviewIndex}+ onClose={() => setPreviewIndex(null)}+ />+ )}</div>);}