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
skip Civitai video entries when picking a LoRA preview thumbnail
[._.]/ Adam Eivy9b94a9ccf61e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex bf948d1fe2..ed88b2f5f8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -40,6 +40,8 @@- **One over-long character-arc field no longer bricks every save on the Series settings page.** The arc editor's inputs — character name, want, need, start/end state, transition label, at-issue — carried no length caps, while the PATCH route enforces `CHARACTER_ARC_LIMITS` with Zod. Because `updateSeries` replaces `characterArcs` wholesale, Save re-sends the entire arc list every time, so a single field over its cap rejected the **whole** series PATCH — name, logline, premise, style guide and all — and kept rejecting it on every subsequent attempt, with only a raw validation path (`characterArcs.4.transitions.3.label`) to go on. (Seen repeating across hours of a live install's server log.) The inputs now cap at the server's limits, and a parity suite fails if the mirrored caps ever drift from `server/lib/seriesCharacterArc.js`.+- **LoRA cards no longer show a permanently broken thumbnail for video previews.** Civitai`s `images[]` is really a media list — entries carry `type: 'image'` or `type: 'video'` — but the preview picker only sorted by `nsfwLevel`, so a version whose least-explicit entry was a clip stored an `.mp4` URL that the card then rendered in an `<img>`. Videos are now skipped when picking a preview, and a version with no still image yields none at all so the card falls back to its placeholder. Applied on read as well as on install (mirroring the existing URL normalization), so already-installed LoRAs recover without a reinstall.+- **Brain Memory and Media History no longer paint every record at once.** A live install with ~1.5k imported ChatGPT memories was mounting full Markdown trees for every card (~180k DOM nodes / multi-MB of text), and Media History mounted ~1.8k gallery cards with images in one grid — both tabs froze on open. Memory now shows a plain teaser for imported transcripts (full thread still opens in the conversation viewer) and both lists use a progressive "Show more" window so search still covers the full set while only a page of cards mounts. CoS 3D avatars also probe WebGL before creating a canvas, so headless/no-GPU displays degrade to a hint instead of unhandled `WebGLRenderer` rejections.- **The pre-episode arc-spine check now resolves at the altitude it judged at.** That checkpoint deliberately verifies the arc spine with the episode lineup hidden — no episodes have been planned in earnest yet, so it only asks whether the premise, principals, engine, and volume allocation are safe to expand. The auto-resolver behind it, though, was still handed the full episode lineup and the general "correct an episode synopsis when the contradiction originates there" instruction, so it answered spine findings by rewriting episode synopses the gate had never read. Those edits could not close what was flagged, the arc and volume text stayed unfixed, and the next spine verification came back with twice the blockers — a round that got reverted wholesale and paused the run. (Observed on a run that went in with 3 blocking findings, spent its round editing 3 episode synopses, and came back with 6.) Spine rounds now render the resolver the same episode-empty plan the verifier saw, tell it to fix the arc and volumes only, and discard any episode edits it returns anyway, so a customized or stale installed prompt can't re-open the blast radius. Nothing changes for the full arc gate that runs after episodes exist: it still verifies and repairs episode synopses, which is the only place an episode-scoped contradiction can converge. Sparse finding-keyed patches and the blocker-count rollback are untouched.diff --git a/server/lib/civitai.js b/server/lib/civitai.jsindex 420f44e54e..b63bbd3fb3 100644--- a/server/lib/civitai.js+++ b/server/lib/civitai.js@@ -155,15 +155,40 @@ export const pickPrimaryFile = (version) => {return safetensors.find((f) => f.primary) || safetensors[0];};+// Civitai's `images[]` is really a MEDIA list — entries carry `type: 'image'`+// or `type: 'video'`, and video entries have `.mp4` / `.webm` URLs. The LoRA+// card renders the pick in an `<img>`, so a video URL is a permanently broken+// thumbnail. Older sidecars were written before `type` was recorded, so fall+// back to the extension rather than trusting the field alone.+const VIDEO_EXT_RE = /\.(mp4|webm|mov|m4v)(\?|#|$)/i;++const isVideoUrl = (url) => typeof url === 'string' && VIDEO_EXT_RE.test(url);++const isVideoMedia = (media) => media?.type === 'video' || isVideoUrl(media?.url);++/**+ * A stored preview URL, or null when it points at a video.+ *+ * Applied on READ as well as on install, so sidecars written before+ * `pickPreviewImage` learned to skip videos stop rendering a broken `<img>`+ * without needing a reinstall — same reasoning as normalizeCivitaiImageUrl's+ * read-side application in services/loras.js.+ */+export const stillPreviewUrl = (url) => (isVideoUrl(url) ? null : url);+// Pick a representative preview image URL for a version (for the LoRA card// thumbnail). Civitai returns nsfwLevel as a numeric flag — 1 is "None", 2// is "Soft", 4 is "Mature", 8 is "X". We prefer the lowest-rated image so// the manager UI thumbnail isn't unexpectedly explicit; users who want the// full preview can click through to civitai.com.+//+// Video entries are skipped entirely — a version whose only media are videos+// yields null, so the card shows its placeholder instead of a broken image.export const pickPreviewImage = (version) => {const images = Array.isArray(version?.images) ? version.images : [];- if (!images.length) return null;- const sorted = [...images].sort((a, b) => (a.nsfwLevel ?? 0) - (b.nsfwLevel ?? 0));+ const stills = images.filter((media) => !isVideoMedia(media));+ if (!stills.length) return null;+ const sorted = [...stills].sort((a, b) => (a.nsfwLevel ?? 0) - (b.nsfwLevel ?? 0));return sorted[0] || null;};diff --git a/server/lib/civitai.test.js b/server/lib/civitai.test.jsindex 8cc52f79ba..182eba6348 100644--- a/server/lib/civitai.test.js+++ b/server/lib/civitai.test.js@@ -15,6 +15,7 @@ import {pickVersion,searchCivitaiLoras,slugifyForFilename,+ stillPreviewUrl,} from './civitai.js';describe('parseCivitaiUrl', () => {@@ -168,6 +169,28 @@ describe('pickPreviewImage', () => {expect(pickPreviewImage({ images: [] })).toBe(null);expect(pickPreviewImage({})).toBe(null);});+ // Civitai's `images[]` is a media list — a video entry rendered in the card's+ // <img> is a permanently broken thumbnail, so it must never win the pick+ // even when it is the least explicit entry.+ it('skips video entries flagged by type, even at the lowest nsfwLevel', () => {+ const v = { images: [+ { url: 'clip.mp4', nsfwLevel: 1, type: 'video' },+ { url: 'still.jpg', nsfwLevel: 4, type: 'image' },+ ] };+ expect(pickPreviewImage(v).url).toBe('still.jpg');+ });+ it('skips video entries by extension when type is absent (legacy sidecars)', () => {+ const v = { images: [+ { url: 'https://image.civitai.com/h/u/original=true/1.mp4', nsfwLevel: 1 },+ { url: 'https://image.civitai.com/h/u/original=true/2.webm', nsfwLevel: 1 },+ { url: 'still.png', nsfwLevel: 8 },+ ] };+ expect(pickPreviewImage(v).url).toBe('still.png');+ });+ it('returns null when every entry is a video, so the card shows a placeholder', () => {+ const v = { images: [{ url: 'a.mp4', nsfwLevel: 1 }, { url: 'b.webm', nsfwLevel: 2 }] };+ expect(pickPreviewImage(v)).toBe(null);+ });});describe('buildAuthHeaders / applyDownloadToken', () => {@@ -230,6 +253,24 @@ describe('detectEarlyAccess', () => {});});+describe('stillPreviewUrl', () => {+ it('drops a video URL so the card falls back to its placeholder', () => {+ expect(stillPreviewUrl('https://image.civitai.com/h/u/original=true/1.mp4')).toBe(null);+ expect(stillPreviewUrl('https://image.civitai.com/h/u/original=true/1.webm?x=1')).toBe(null);+ expect(stillPreviewUrl('https://image.civitai.com/h/u/original=true/1.mp4#t=2')).toBe(null);+ });+ it('passes still images and empty values through unchanged', () => {+ const url = 'https://image.civitai.com/h/u/width=512/1.jpeg';+ expect(stillPreviewUrl(url)).toBe(url);+ expect(stillPreviewUrl(null)).toBe(null);+ expect(stillPreviewUrl(undefined)).toBe(undefined);+ });+ it('does not mistake an image whose name merely contains a video word', () => {+ const url = 'https://image.civitai.com/h/u/width=512/mp4-style-preview.jpeg';+ expect(stillPreviewUrl(url)).toBe(url);+ });+});+describe('normalizeCivitaiImageUrl', () => {it('rewrites the original=true transform to a width-bounded variant', () => {const original = 'https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1f686daa-ff68-4830-ae94-c318e8f9ee30/original=true/129269017.jpeg';diff --git a/server/services/loras.js b/server/services/loras.jsindex e869089cce..0103dbe8ec 100644--- a/server/services/loras.js+++ b/server/services/loras.js@@ -40,6 +40,7 @@ import {pickPrimaryFile,pickVersion,slugifyForFilename,+ stillPreviewUrl,} from '../lib/civitai.js';import {buildHfAuthHeaders,@@ -162,7 +163,9 @@ export const listLoras = async () => {recommendedScale: Number.isFinite(sidecar?.recommendedScale) ? sidecar.recommendedScale : 1.0,// Normalize on read so already-installed LoRAs (sidecars written// before the URL-normalize fix) also benefit without a reinstall.- previewImageUrl: normalizeCivitaiImageUrl(sidecar?.previewImageUrl) || null,+ // stillPreviewUrl drops a video URL for the same reason: Civitai's+ // media list mixes clips in, and the card renders this in an <img>.+ previewImageUrl: normalizeCivitaiImageUrl(stillPreviewUrl(sidecar?.previewImageUrl)) || null,description: sidecar?.description || '',// Trained-LoRA surfacing (sidecars written by services/loraTraining):// 'trained' source + the character identity block let the library UI