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
surface curated video LoRA suggestions + Image/Video filter on LoRA Manager
[._.]/ Adam Eivy6e71b71615f9
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex e3ab535048..b5887a4f23 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -12,6 +12,8 @@- **Video LoRAs — install LTX-2 LoRAs from HuggingFace and fuse them into Video Gen renders** — LoRA support now extends past image models to the **dgrauet `ltx2` video runtime**. A new **"Install video LoRA from HuggingFace"** box on the LoRA Manager (`/media/loras`) takes any HF repo URL or `org/name` id (e.g. `fal/ltx2.3-audio-reactive-lora`), fetches the repo metadata, picks the `.safetensors`, auto-detects the video family from the repo id / tags / `base_model` (LTX-Video → `ltx-video`), and writes a sidecar — the HuggingFace analogue of the existing Civitai installer (gated repos use your HuggingFace token from Image Gen settings). Video Gen (`/media/video`) gains a **LoRA picker** that appears only on an LTX-2 (`ltx2`) model, filtered to the `ltx-video` family, with per-LoRA strength and a trigger-word append button — the same component the Image Gen page uses. Selected LoRAs fuse into the transformer via the pipeline's `_pending_loras` hook (the exact mechanism upstream's `ltx-2-mlx generate --lora` CLI uses), so they apply across **every** mode — text, image, FFLF, extend, and audio-to-video — including multi-chunk chains. Applied LoRAs are stamped into the video-history entry and round-trip through the resume/Remix flow. Only the `ltx2` runtime can fuse LoRAs today; the route and service reject LoRAs on the legacy `mlx_video` / `wan22` / `hunyuan` runtimes with a clear error. (`server/lib/huggingfaceLora.js`, `server/services/loras.js`, `server/routes/loras.js`, `server/services/videoGen/local.js`, `server/routes/videoGen.js`, `scripts/generate_ltx2.py`, `server/lib/runners.js`, `client/src/lib/runnerFamilies.js`, `client/src/pages/VideoGen.jsx`, `client/src/pages/Loras.jsx`)+- **Suggested video LoRAs + Image/Video filter on the LoRA Manager** — The LoRA Manager (`/media/loras`) only suggested image LoRAs (Civitai per-runner-family), so a video LoRA like `fal/ltx2.3-audio-reactive-lora` was reachable only by knowing its repo and pasting it into the install box. A new **Video LoRAs** section now surfaces a curated quick-install list of HuggingFace LTX-Video LoRAs alongside the Civitai suggestions — one click installs through the HF path with the right family pre-stamped. An **All / Image / Video** filter at the top of the page narrows *both* the suggestion panel and the installed list by media type, so a video-focused session isn't buried under image suggestions. Curated video cards mark themselves "Installed" by matching the installed sidecar's HF repo, and installed video LoRAs now link back out to HuggingFace from their card. The curated list enriches each card with HuggingFace metadata best-effort (description/preview) and degrades to the static card on a fetch failure, caching for an hour like the Civitai panel. (`server/services/videoLoraSuggestions.js`, `server/routes/loras.js`, `server/services/loras.js`, `server/lib/runners.js`, `client/src/lib/runnerFamilies.js`, `client/src/pages/Loras.jsx`)+## Changed- **LoRA dataset workbench now coaches toward a quality target, not just the 10-image floor** — The readiness summary only knew two states ("add more" / "ready to train"), so a barely-trainable 10-image dataset looked just as finished as a strong 25-image one. The workbench now tracks a recommended quality target (~20, sweet spot 20–30) alongside the hard `MIN_TRAINING_IMAGES` floor: the count badge turns amber while trainable-but-thin and green once it clears the target, the sub-label tells you exactly how many more captioned images are recommended, and the Train panel echoes the same nudge. A new collapsible **"Tips for a strong character dataset"** panel spells out the variety that actually matters — vary angle, framing (face close-ups + full-body), pose, expression, outfit, lighting, and background; keep it single-subject and on-model; drop blurry/near-duplicate frames. The **Generate** batch dialog now defaults to 20 images (was 12) and notes the sweet spot inline. Advisory only — the server still trains any dataset that clears the 10-image gate. (`server/lib/loraDataset.js`, `client/src/pages/LoraDatasetDetail.jsx`, `client/src/components/loraTraining/TrainingPanel.jsx`, `client/src/components/loraTraining/GenerateBatchDialog.jsx`)diff --git a/client/src/lib/runnerFamilies.js b/client/src/lib/runnerFamilies.jsindex e80e47b1cc..a7302457cc 100644--- a/client/src/lib/runnerFamilies.js+++ b/client/src/lib/runnerFamilies.js@@ -19,6 +19,13 @@ export const VIDEO_LORA_FAMILIES = Object.freeze({LTX_VIDEO: 'ltx-video',});+// Predicate: is this LoRA family a video family (vs. an image RUNNER_FAMILIES+// one)? Backs the Image/Video filter on /media/loras. Anything not in+// VIDEO_LORA_FAMILIES (including null/legacy) is treated as image. Mirror of+// server/lib/runners.js.+const VIDEO_LORA_FAMILY_SET = new Set(Object.values(VIDEO_LORA_FAMILIES));+export const isVideoLoraFamily = (family) => VIDEO_LORA_FAMILY_SET.has(family);+// Map a video model (carries `runtime`, not `runner`) to its LoRA family. Only// the dgrauet `ltx2` runtime fuses arbitrary user LoRAs today; everything else// returns null so the VideoGen picker hides itself. Mirror ofdiff --git a/client/src/pages/Loras.jsx b/client/src/pages/Loras.jsxindex ca080d5eee..92ed29aeb9 100644--- a/client/src/pages/Loras.jsx+++ b/client/src/pages/Loras.jsx@@ -14,7 +14,7 @@ import toast from '../components/ui/Toast';import Modal from '../components/ui/Modal';import Banner from '../components/ui/Banner';import { formatBytes } from '../utils/formatters';-import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES } from '../lib/runnerFamilies';+import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES, isVideoLoraFamily } from '../lib/runnerFamilies';import {listLorasFull,installLoraFromCivitai,@@ -34,6 +34,7 @@ const RUNNER_LABEL = {[RUNNER_FAMILIES.ERNIE]: 'ERNIE',[RUNNER_FAMILIES.HIDREAM]: 'HiDream',[RUNNER_FAMILIES.QWEN]: 'Qwen',+ [VIDEO_LORA_FAMILIES.LTX_VIDEO]: 'LTX-Video',};const RUNNER_BADGE_CLASS = {[RUNNER_FAMILIES.MFLUX]: 'bg-port-accent/20 text-port-accent border-port-accent/30',@@ -42,8 +43,17 @@ const RUNNER_BADGE_CLASS = {[RUNNER_FAMILIES.ERNIE]: 'bg-amber-600/20 text-amber-300 border-amber-500/30',[RUNNER_FAMILIES.HIDREAM]: 'bg-rose-600/20 text-rose-300 border-rose-500/30',[RUNNER_FAMILIES.QWEN]: 'bg-sky-600/20 text-sky-300 border-sky-500/30',+ [VIDEO_LORA_FAMILIES.LTX_VIDEO]: 'bg-fuchsia-600/20 text-fuchsia-300 border-fuchsia-500/30',};+// Image/Video filter applied to BOTH the suggestion panel and the installed+// list (see the user request: filter suggestions + installed by media type).+const MEDIA_FILTERS = [+ { id: 'all', label: 'All' },+ { id: 'image', label: 'Image' },+ { id: 'video', label: 'Video' },+];+// Stable identity for a suggestion's specific model+version — used for React// keys, install-in-flight tracking, and "Load more" dedup. Curated cards pass// a family-specific versionId that differs from the card's primary, so the key@@ -73,10 +83,15 @@ export default function Loras() {// so users don't have to remember what they were installing.const [auth, setAuth] = useState({ hasKey: false, source: 'none' });const [authPrompt, setAuthPrompt] = useState(null);- // suggestions: { runners: { mflux: [...], flux2: [...], 'z-image': [...] }, fetchedAt }+ // suggestions: { runners: { mflux: [...], flux2: [...], 'z-image': [...] }, video: [...], fetchedAt }const [suggestions, setSuggestions] = useState(null);const [loadingSuggestions, setLoadingSuggestions] = useState(true);const [installingSuggestion, setInstallingSuggestion] = useState(null);+ // Repo of the video suggestion currently installing (HF installs key off+ // repo, not modelId/versionId like the Civitai path).+ const [installingVideoRepo, setInstallingVideoRepo] = useState(null);+ // Image/Video media-type filter for both panels. 'all' | 'image' | 'video'.+ const [mediaFilter, setMediaFilter] = useState('all');const refresh = useCallback(() => {setError(null);@@ -168,6 +183,22 @@ export default function Loras() {return runHfInstall(hfUrl.trim(), undefined);}, [hfUrl, runHfInstall]);+ // Quick-install a curated video LoRA suggestion. Routes through the HF+ // installer (not the Civitai one) with the card's known family. Tracks the+ // in-flight repo in its own state because the Civitai `installingSuggestion`+ // key is modelId/versionId-based — video installs have neither.+ const installVideoSuggestion = useCallback(async (card) => {+ if (!card?.installUrl || installingVideoRepo) return;+ setInstallingVideoRepo(card.repo);+ await installLoraFromHuggingface({ url: card.installUrl, family: card.runnerFamily, silent: true })+ .then((sidecar) => {+ toast.success(`Installed ${sidecar.name}`);+ refresh();+ })+ .catch((err) => toast.error(err?.message || 'HuggingFace install failed'))+ .finally(() => setInstallingVideoRepo(null));+ }, [installingVideoRepo, refresh]);+const handleDelete = async (filename) => {setDeleting(filename);await deleteLoraFull(filename)@@ -179,6 +210,15 @@ export default function Loras() {.finally(() => setDeleting(null));};+ // Installed list narrowed to the active media filter. Video families+ // (ltx-video) are video; everything else (image families + legacy null) is+ // image.+ const visibleLoras = loras.filter((l) => {+ if (mediaFilter === 'image') return !isVideoLoraFamily(l.runnerFamily);+ if (mediaFilter === 'video') return isVideoLoraFamily(l.runnerFamily);+ return true;+ });+return (<div className="space-y-6"><div>@@ -300,12 +340,18 @@ export default function Loras() {/>)}+ <MediaFilter value={mediaFilter} onChange={setMediaFilter} />+<SuggestionsPanelsuggestions={suggestions}loading={loadingSuggestions}+ mediaFilter={mediaFilter}installedFilenames={new Set(loras.map((l) => l.filename))}+ installedHfRepos={new Set(loras.map((l) => l.huggingface?.repo).filter(Boolean))}installingSuggestionKey={installingSuggestion}+ installingVideoRepo={installingVideoRepo}onRefresh={() => refreshSuggestions({ force: true })}+ onInstallVideo={installVideoSuggestion}onInstall={async (card, url, versionId) => {// Curated cards pass a family-specific (url, versionId); non-curated// cards omit versionId and we fall back to the card's primary.@@ -323,14 +369,16 @@ export default function Loras() {{error && (<Banner tone="error" size="md" icon={AlertTriangle} align="center">{error}</Banner>)}- {!loading && !error && loras.length === 0 && (+ {!loading && !error && visibleLoras.length === 0 && (<div className="text-sm text-gray-500 italic">- No LoRAs installed yet — pick one from the suggestions above, or paste a Civitai URL.+ {loras.length === 0+ ? 'No LoRAs installed yet — pick one from the suggestions above, or paste a Civitai URL.'+ : `No ${mediaFilter} LoRAs installed.`}</div>)}- {loras.length > 0 && (+ {visibleLoras.length > 0 && (<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">- {loras.map((lora) => (+ {visibleLoras.map((lora) => (<LoraCard key={lora.filename} lora={lora} onDelete={() => handleDelete(lora.filename)} deleting={deleting === lora.filename} />))}</div>@@ -340,9 +388,40 @@ export default function Loras() {);}-function SuggestionsPanel({ suggestions, loading, installedFilenames, installingSuggestionKey, onRefresh, onInstall }) {+// Segmented All / Image / Video control. Pure presentational — the parent owns+// the `mediaFilter` state and applies it to both the suggestion panel and the+// installed list.+function MediaFilter({ value, onChange }) {+ return (+ <div className="flex items-center gap-2">+ <span className="text-xs text-gray-500">Show</span>+ <div className="inline-flex rounded-lg border border-port-border overflow-hidden">+ {MEDIA_FILTERS.map((f) => (+ <button+ key={f.id}+ type="button"+ onClick={() => onChange(f.id)}+ aria-pressed={value === f.id}+ className={`px-3 py-1 text-xs font-medium transition-colors ${+ value === f.id+ ? 'bg-port-accent text-white'+ : 'bg-port-card text-gray-400 hover:text-gray-200'+ }`}+ >+ {f.label}+ </button>+ ))}+ </div>+ </div>+ );+}++function SuggestionsPanel({ suggestions, loading, mediaFilter = 'all', installedFilenames, installedHfRepos, installingSuggestionKey, installingVideoRepo, onRefresh, onInstall, onInstallVideo }) {const curated = suggestions?.curated || [];const runners = suggestions?.runners || {};+ const video = suggestions?.video || [];+ const showImage = mediaFilter !== 'video';+ const showVideo = mediaFilter !== 'image';const sections = [{ key: 'curated', label: 'Curated picks', cards: curated, hint: 'Hand-picked LoRAs that work across multiple base models.' },// The runner-family sections always render, even when Civitai search@@ -378,7 +457,7 @@ function SuggestionsPanel({ suggestions, loading, installedFilenames, installing{loading && !suggestions && (<div className="text-sm text-gray-500">Loading suggestions…</div>)}- {sections.map((section) => (+ {showImage && sections.map((section) => (<SuggestionsSectionkey={section.key}label={section.label}@@ -394,6 +473,99 @@ function SuggestionsPanel({ suggestions, loading, installedFilenames, installingonInstall={onInstall}/>))}+ {showVideo && (+ <VideoSuggestionsSection+ cards={video}+ installedHfRepos={installedHfRepos}+ installingVideoRepo={installingVideoRepo}+ onInstall={onInstallVideo}+ />+ )}+ </div>+ );+}++// Curated HuggingFace video LoRAs (LTX-Video). No keyword search / pagination+// like the Civitai sections — it's a small hand-picked list installed via the+// HF path. Installed-state matches on the repo (HF installs carry no+// modelId/versionId).+function VideoSuggestionsSection({ cards, installedHfRepos, installingVideoRepo, onInstall }) {+ const list = cards || [];+ return (+ <div>+ <div className="flex items-baseline gap-3 mb-2">+ <h3 className="text-sm font-medium text-gray-300">Video LoRAs</h3>+ <span className="text-xs text-gray-600">{list.length}</span>+ </div>+ <p className="text-xs text-gray-500 mb-2">+ Curated LTX-Video LoRAs from HuggingFace — apply on an LTX-2 (ltx2) model in{' '}+ <Link to="/media/video" className="text-port-accent hover:underline">Video Gen</Link>.+ </p>+ {list.length === 0 ? (+ <p className="text-xs text-gray-600 italic">No video LoRA suggestions yet.</p>+ ) : (+ <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">+ {list.map((card) => (+ <VideoSuggestionCard+ key={card.repo}+ card={card}+ installed={installedHfRepos?.has(card.repo)}+ installing={installingVideoRepo === card.repo}+ onInstall={onInstall}+ />+ ))}+ </div>+ )}+ </div>+ );+}++function VideoSuggestionCard({ card, installed, installing, onInstall }) {+ return (+ <div className="bg-port-card border border-port-border rounded-lg overflow-hidden flex flex-col">+ {card.previewImageUrl ? (+ <img src={card.previewImageUrl} alt="" className="w-full h-64 object-cover bg-port-bg" loading="lazy" referrerPolicy="no-referrer" />+ ) : (+ <div className="w-full h-64 bg-port-bg flex items-center justify-center text-gray-700">+ <Sparkles size={32} />+ </div>+ )}+ <div className="p-3 flex-1 flex flex-col gap-2">+ <div className="flex items-start justify-between gap-2">+ <h4 className="font-semibold text-white text-sm flex-1 break-words">{card.name}</h4>+ <span className={`text-[10px] px-1.5 py-0.5 rounded border whitespace-nowrap ${RUNNER_BADGE_CLASS[card.runnerFamily] || 'bg-gray-600/20 text-gray-300 border-gray-500/30'}`}>+ {RUNNER_LABEL[card.runnerFamily] || 'Video'}+ </span>+ </div>+ {card.note && <p className="text-[11px] text-gray-400 italic break-words">{card.note}</p>}+ {card.description && (+ <details className="text-[11px] text-gray-500">+ <summary className="cursor-pointer hover:text-gray-300">Details</summary>+ <p className="mt-1 text-[10px] leading-snug bg-port-bg p-1.5 rounded border border-port-border line-clamp-4">{card.description}</p>+ </details>+ )}+ <div className="flex items-center gap-2 mt-auto">+ {installed ? (+ <button disabled className="flex-1 bg-port-success/20 text-port-success border border-port-success/30 px-3 py-1.5 rounded text-xs font-medium flex items-center justify-center gap-1">+ <Check size={12} /> Installed+ </button>+ ) : (+ <button+ type="button"+ onClick={() => onInstall(card)}+ disabled={installing}+ className="flex-1 bg-port-accent text-white px-3 py-1.5 rounded text-xs font-medium hover:bg-port-accent/90 disabled:opacity-50"+ >+ {installing ? 'Installing…' : 'Quick install'}+ </button>+ )}+ </div>+ {card.hfUrl && (+ <a href={card.hfUrl} target="_blank" rel="noopener noreferrer" className="text-[10px] text-gray-500 hover:text-gray-300 inline-flex items-center gap-1 self-start" title="Open on HuggingFace">+ <ExternalLink size={11} /> View on HuggingFace+ </a>+ )}+ </div></div>);}@@ -865,6 +1037,17 @@ function LoraCard({ lora, onDelete, deleting }) {<ExternalLink size={14} /></a>)}+ {lora.huggingface?.url && (+ <a+ href={lora.huggingface.url}+ target="_blank"+ rel="noopener noreferrer"+ className="text-gray-400 hover:text-gray-200 p-1.5 rounded hover:bg-port-bg"+ title="Open on HuggingFace"+ >+ <ExternalLink size={14} />+ </a>+ )}<buttononClick={onDelete}disabled={deleting}diff --git a/server/lib/huggingfaceLora.js b/server/lib/huggingfaceLora.jsindex 0e45347078..30cca299d4 100644--- a/server/lib/huggingfaceLora.js+++ b/server/lib/huggingfaceLora.js@@ -172,6 +172,15 @@ export const detectVideoLoraFamily = ({ repo, model } = {}) => {const DESCRIPTION_MAX_CHARS = 2000;+// Read the HF model-card description, clamped to `maxChars`. Shared by the+// sidecar builder (long, persisted) and the video-suggestion card builder+// (short, display-only) — both read the same `cardData.description` but clamp+// to different lengths, so the field-extraction lives in one place.+export const extractHfCardDescription = (model, maxChars) => {+ const raw = typeof model?.cardData?.description === 'string' ? model.cardData.description : '';+ return raw.length > maxChars ? raw.slice(0, maxChars) : raw;+};+// Build the canonical sidecar for an HF-installed video LoRA. Shape mirrors the// Civitai sidecar (services builds the same fields) but carries a `huggingface`// block instead of `civitai`, sets `source: 'huggingface'`, and stamps@@ -188,8 +197,7 @@ export const buildHfLoraSidecar = ({ repo, revision, file, model, family, filenaconst instancePrompt = typeof model?.cardData?.instance_prompt === 'string'? model.cardData.instance_prompt.trim(): '';- const rawDesc = typeof model?.cardData?.description === 'string' ? model.cardData.description : '';- const description = rawDesc.length > DESCRIPTION_MAX_CHARS ? rawDesc.slice(0, DESCRIPTION_MAX_CHARS) : rawDesc;+ const description = extractHfCardDescription(model, DESCRIPTION_MAX_CHARS);return {filename,name: repo.split('/')[1] || repo,diff --git a/server/lib/runners.js b/server/lib/runners.jsindex 1a3c1e328e..18ad554b7b 100644--- a/server/lib/runners.js+++ b/server/lib/runners.js@@ -38,6 +38,14 @@ export const VIDEO_LORA_FAMILIES = Object.freeze({LTX_VIDEO: 'ltx-video',});+// Predicate: is this LoRA family a video family (vs. an image RUNNER_FAMILIES+// one)? Backs the Image/Video filter on /media/loras — both the installed-list+// filter and the suggestion-panel section gating. Anything not in+// VIDEO_LORA_FAMILIES (including null/legacy) is treated as image. Mirror of+// client/src/lib/runnerFamilies.js.+const VIDEO_LORA_FAMILY_SET = new Set(Object.values(VIDEO_LORA_FAMILIES));+export const isVideoLoraFamily = (family) => VIDEO_LORA_FAMILY_SET.has(family);+// Map a video-model registry entry (which carries `runtime`, not `runner`) to// the LoRA family the picker filters on. Only dgrauet's `ltx2` runtime can// fuse arbitrary user LoRAs today — its `ltx_pipelines_mlx` pipelines honor adiff --git a/server/routes/loras.js b/server/routes/loras.jsindex 5c9a72f2b5..01d8d7009d 100644--- a/server/routes/loras.js+++ b/server/routes/loras.js@@ -21,6 +21,7 @@ import {patchLoraSidecar,} from '../services/loras.js';import { getSuggestions, searchLorasInFamily } from '../services/civitaiSuggestions.js';+import { getVideoSuggestions } from '../services/videoLoraSuggestions.js';import { findLorasByCharacter } from '../services/characterLoraResolver.js';import { getSettings, updateSettingsWith } from '../services/settings.js';import { RUNNER_FAMILIES, VIDEO_LORA_FAMILIES } from '../lib/runners.js';@@ -31,14 +32,19 @@ router.get('/', asyncHandler(async (_req, res) => {res.json(await listLoras());}));-// Civitai LoRA suggestions per runner family (mflux / flux2 / z-image / ernie).-// Cached server-side for 1h. `?force=1` busts the cache for a manual refresh.-// Default 4 cards per family — that's enough to show breadth without-// overwhelming the panel; users can paste a URL for anything specific.+// LoRA suggestions — Civitai image LoRAs per runner family (mflux / flux2 /+// z-image / ernie …) PLUS a curated list of HuggingFace video LoRAs. Cached+// server-side for 1h. `?force=1` busts both caches for a manual refresh.+// Default 4 cards per family — enough to show breadth without overwhelming the+// panel; users can paste a URL for anything specific.router.get('/suggestions', asyncHandler(async (req, res) => {const force = req.query.force === '1' || req.query.force === 'true';const limit = Math.max(1, Math.min(24, Number(req.query.limit) || 4));- res.json(await getSuggestions({ force, limit }));+ const [civitai, video] = await Promise.all([+ getSuggestions({ force, limit }),+ getVideoSuggestions({ force }),+ ]);+ res.json({ ...civitai, video });}));// Live keyword search + cursor pagination within one runner family. Backs thediff --git a/server/routes/loras.test.js b/server/routes/loras.test.jsindex 7ba3acf1e1..cf038aa218 100644--- a/server/routes/loras.test.js+++ b/server/routes/loras.test.js@@ -23,6 +23,11 @@ vi.mock('../services/civitaiSuggestions.js', () => ({_echo: { cursor, limit },})),}));+vi.mock('../services/videoLoraSuggestions.js', () => ({+ getVideoSuggestions: vi.fn(async () => ([+ { source: 'huggingface', repo: 'fal/ltx2.3-audio-reactive-lora', name: 'LTX', runnerFamily: 'ltx-video' },+ ])),+}));vi.mock('../services/settings.js', () => ({getSettings: vi.fn(async () => ({})),updateSettingsWith: vi.fn(async () => ({})),@@ -85,3 +90,17 @@ describe('GET /api/loras/search', () => {expect(res.status).toBe(400);});});++describe('GET /api/loras/suggestions', () => {+ it('merges the curated video LoRAs into the Civitai suggestion payload', async () => {+ const res = await request(makeApp()).get('/api/loras/suggestions');+ expect(res.status).toBe(200);+ // Civitai shape preserved …+ expect(res.body).toHaveProperty('curated');+ expect(res.body).toHaveProperty('runners');+ // … plus the merged video section.+ expect(Array.isArray(res.body.video)).toBe(true);+ expect(res.body.video[0].runnerFamily).toBe('ltx-video');+ expect(res.body.video[0].repo).toBe('fal/ltx2.3-audio-reactive-lora');+ });+});diff --git a/server/services/loras.js b/server/services/loras.jsindex bccecc96b9..d54d8f9ca1 100644--- a/server/services/loras.js+++ b/server/services/loras.js@@ -148,6 +148,10 @@ export const listLoras = async () => {installedAt: sidecar?.installedAt || s.birthtime?.toISOString?.() || null,// sidecar fields surfaced for the picker / manager UI:civitai: sidecar?.civitai || null,+ // HF-installed video LoRAs carry this instead of `civitai` — the+ // manager matches curated video suggestions to installs by repo and+ // links the card out to HuggingFace.+ huggingface: sidecar?.huggingface || null,runnerFamily,fluxVariant,loraCompatKey,diff --git a/server/services/videoLoraSuggestions.js b/server/services/videoLoraSuggestions.jsnew file mode 100644index 0000000000..31f5845ead--- /dev/null+++ b/server/services/videoLoraSuggestions.js@@ -0,0 +1,94 @@+/**+ * Video-LoRA suggestions — a hand-curated quick-install list of HuggingFace+ * video LoRAs (LTX-2 / LTX-Video) so /media/loras surfaces them next to the+ * Civitai image suggestions instead of forcing the user to know the repo id.+ *+ * Why this is separate from civitaiSuggestions.js: video LoRAs live on+ * HuggingFace, not Civitai (see services/loras.js#installFromHuggingface), and+ * the Civitai search iterates Object.values(RUNNER_FAMILIES) — a video family+ * has no Civitai baseModel mapping and would 400. So the two suggestion sources+ * stay decoupled and the route merges them (`video` alongside `curated`/`runners`).+ *+ * Cards are usable from the static curated entry alone; an HF metadata fetch+ * only ENRICHES them (description + preview) and is best-effort — a 404 / rate+ * limit degrades to the static card rather than dropping the suggestion. Cached+ * in-memory with the same 1-hour TTL as the Civitai panel.+ */++import { VIDEO_LORA_FAMILIES } from '../lib/runners.js';+import { extractHfCardDescription, fetchHuggingfaceModel } from '../lib/huggingfaceLora.js';+import { getHfToken } from '../lib/hfToken.js';++const TTL_MS = 60 * 60 * 1000; // 1 hour — matches the Civitai suggestion cache.+const DESCRIPTION_MAX_CHARS = 240;++// Hand-picked HuggingFace video LoRAs. `family` is stamped here (HF has no+// Civitai-style baseModel string for the installer to re-derive) so the+// quick-install routes through installFromHuggingface with an explicit family.+const CURATED_VIDEO_LORAS = [+ {+ repo: 'fal/ltx2.3-audio-reactive-lora',+ family: VIDEO_LORA_FAMILIES.LTX_VIDEO,+ name: 'LTX-2.3 Audio Reactive',+ note: 'Drives camera and scene energy from an audio track — built for LTX-2 (ltx2) video renders.',+ },+];++const now = () => Date.now();++// HF cards rarely carry a single canonical preview; try the few fields that+// sometimes hold one and fall back to null (the card shows a placeholder).+const pickHfPreview = (model) => {+ const card = model?.cardData;+ if (typeof card?.thumbnail === 'string' && card.thumbnail.trim()) return card.thumbnail.trim();+ return null;+};++// Build one suggestion card from a curated entry. `model` is the HF metadata+// (or null when the fetch failed) — the card is fully functional without it.+const buildCard = (entry, model) => {+ const description = extractHfCardDescription(model, DESCRIPTION_MAX_CHARS);+ return {+ source: 'huggingface',+ repo: entry.repo,+ name: entry.name || (entry.repo.split('/')[1] || entry.repo),+ note: entry.note || '',+ description,+ runnerFamily: entry.family,+ previewImageUrl: pickHfPreview(model),+ hfUrl: `https://huggingface.co/${entry.repo}`,+ // The same value /api/loras/install/huggingface accepts — the UI passes it+ // back without re-deriving, mirroring the Civitai card's installUrl.+ installUrl: `https://huggingface.co/${entry.repo}`,+ };+};++let cache = null; // { fetchedAt: number, items: card[] }++const fetchCards = async ({ fetchImpl }) => {+ const token = (await getHfToken().catch(() => null)) || '';+ return Promise.all(CURATED_VIDEO_LORAS.map(async (entry) => {+ const model = await fetchHuggingfaceModel(entry.repo, { token, fetchImpl })+ .catch((err) => {+ console.log(`⚠️ Video LoRA suggestion ${entry.repo} metadata fetch failed: ${err?.message || err}`);+ return null;+ });+ return buildCard(entry, model);+ }));+};++// Public API — returns the curated video-LoRA cards. Never throws on a partial+// HF failure; on a total failure it serves the previous (stale) cache or the+// static cards so the panel always has something to show.+export const getVideoSuggestions = async ({ fetchImpl, force = false } = {}) => {+ if (!force && cache && now() - cache.fetchedAt < TTL_MS) return cache.items;+ const items = await fetchCards({ fetchImpl }).catch((err) => {+ console.log(`⚠️ Video LoRA suggestions fetch failed: ${err?.message || err}`);+ return cache?.items || CURATED_VIDEO_LORAS.map((entry) => buildCard(entry, null));+ });+ cache = { fetchedAt: now(), items };+ return items;+};++// Test seam — clear the cache between tests.+export const _resetVideoSuggestionsCache = () => { cache = null; };diff --git a/server/services/videoLoraSuggestions.test.js b/server/services/videoLoraSuggestions.test.jsnew file mode 100644index 0000000000..e90ce514ad--- /dev/null+++ b/server/services/videoLoraSuggestions.test.js@@ -0,0 +1,59 @@+import { describe, it, expect, beforeEach, vi } from 'vitest';+import { mockJsonResponse } from '../lib/testHelper.js';++let svc;++beforeEach(async () => {+ vi.resetModules();+ // No HF token in tests — getHfToken reads settings/env, stub to null.+ vi.doMock('../lib/hfToken.js', () => ({ getHfToken: async () => null }));+ svc = await import('./videoLoraSuggestions.js');+ svc._resetVideoSuggestionsCache();+});++describe('getVideoSuggestions', () => {+ it('returns curated video cards enriched with HF metadata', async () => {+ const fetchImpl = async () => mockJsonResponse({+ cardData: { description: 'Audio-reactive LTX LoRA.', thumbnail: 'https://hf/preview.png' },+ });+ const cards = await svc.getVideoSuggestions({ fetchImpl });+ expect(cards.length).toBeGreaterThan(0);+ const card = cards[0];+ expect(card.source).toBe('huggingface');+ expect(card.runnerFamily).toBe('ltx-video');+ expect(card.repo).toBe('fal/ltx2.3-audio-reactive-lora');+ expect(card.description).toBe('Audio-reactive LTX LoRA.');+ expect(card.previewImageUrl).toBe('https://hf/preview.png');+ expect(card.installUrl).toBe('https://huggingface.co/fal/ltx2.3-audio-reactive-lora');+ });++ it('degrades to the static card when the HF metadata fetch fails', async () => {+ const fetchImpl = async () => ({ ok: false, status: 404 });+ const cards = await svc.getVideoSuggestions({ fetchImpl });+ expect(cards.length).toBeGreaterThan(0);+ expect(cards[0].repo).toBe('fal/ltx2.3-audio-reactive-lora');+ expect(cards[0].runnerFamily).toBe('ltx-video');+ // No metadata → no description / preview, but the card is still usable.+ expect(cards[0].description).toBe('');+ expect(cards[0].previewImageUrl).toBe(null);+ expect(cards[0].installUrl).toBe('https://huggingface.co/fal/ltx2.3-audio-reactive-lora');+ });++ it('caches across calls within the TTL (no re-fetch)', async () => {+ let calls = 0;+ const fetchImpl = async () => { calls += 1; return mockJsonResponse({ cardData: {} }); };+ await svc.getVideoSuggestions({ fetchImpl });+ const after = calls;+ await svc.getVideoSuggestions({ fetchImpl });+ expect(calls).toBe(after);+ });++ it('force=true busts the cache', async () => {+ let calls = 0;+ const fetchImpl = async () => { calls += 1; return mockJsonResponse({ cardData: {} }); };+ await svc.getVideoSuggestions({ fetchImpl });+ const after = calls;+ await svc.getVideoSuggestions({ fetchImpl, force: true });+ expect(calls).toBeGreaterThan(after);+ });+});