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: search on Media History + extracted-frame sidecars carry source video prompt

Adam Eivy2a0fba09f2df
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 5d45e67fa9..bb09c8b093 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -2,6 +2,9 @@
## Added
+- **Search box on Media History.** `/media/history` gains a search input (top-left of the toolbar) that filters the merged image+video timeline as you type. Whitespace tokens are AND-combined (e.g. `sunset flux2 1024` matches items whose searchable haystack contains all three substrings, in any order), and the haystack covers prompt, negative prompt, model id, filename, kind, seed, dimensions, LoRA names, plus virtual tokens for `extracted frame` / `stitched` / `upscaled 2x` so the existing corner badges are reachable through the search bar. Item counts in the Images / Videos / All filter chips update against the search-scoped totals, and the empty state offers a one-click "Clear search" when nothing matches. Haystacks are precomputed once per items list (memo keyed on `items`) so each keystroke only re-runs `String.includes()`, not array-build + join + lowercase per item — keeps the UI responsive on 500+ item galleries.
+- **Extracted video frames carry their video's prompt.** When you click "Continue" on a video card, PortOS extracts the last frame as a PNG into the gallery — that PNG now also gets a sidecar metadata.json copying the source video's `prompt`, `negativePrompt`, `modelId`, `width`/`height`, and `seed`, plus provenance fields (`extractedFromVideoId`, `extractedFromVideoFilename`, `kind: 'extracted-frame'`). The Media History card surfaces a yellow `frame` corner badge so extracted frames are visually distinct from raw renders, and the new fields flow through the search haystack so a query like `extracted frame` (or any prompt term from the parent video) filters the gallery to those frames. Sidecar write uses `writeFile({ flag: 'wx' })` so cache-hit re-clicks are race-free and cheap; pre-existing extracted frames get backfilled on the next continue-click without re-running ffmpeg.
+
- **ERNIE-Image runner.** Adds `runner: 'ernie'` so PortOS can drive Baidu's ERNIE-Image (8B DiT, Apache 2.0, no HF login) — both the SFT model (`baidu/ERNIE-Image`, 50 steps, guidance 4.0) and the Turbo distilled variant (`baidu/ERNIE-Image-Turbo`, 8 steps, CFG-disabled). Reuses the FLUX.2 venv (same diffusers + torch stack, no extra setup step). The runner script gains a generic `--pipeline-class` arg (used here for `ErnieImagePipeline` since it isn't yet in `AutoPipelineForText2Image`'s registry) and a `--use-pe` flag for ERNIE's built-in Prompt Enhancer module — both passed only when the loaded pipe accepts them, so existing Z-Image renders are unaffected. LoRA picker, suggestion search, and Civitai's `baseModel` mapping all gain the `'ernie'` family.
- **Multi-version curated cards** — a curated suggestion (e.g. `hyperdetailed-colored-pencil`) typically has separate Civitai versions per base model (Flux.1, Flux 2 Klein 4B, Klein 9B, Z-Image-Turbo, ERNIE…). The card now renders one **Install for X** button per available family, each installing the family-specific version via that family's `?modelVersionId=...`. Buttons flip to ✓ Installed independently, so you can install the Flux 2 version today and the Z-Image one later. Server-side `buildCuratedCard()` walks every `modelVersions[]` entry and builds an `installs: { mflux, flux2, 'z-image', ernie }` map (first match per family wins; versions without a `.safetensors` file are skipped).
- **One-click LoRA trigger-word insertion.** Each selected LoRA in the Image Gen picker now exposes a small `+ trigger` button next to its scale input — click it to append the LoRA's trigger words to the prompt, comma-separated, deduped (case-insensitive substring match against the existing prompt so re-clicking is a no-op). The "Test" deep-link from the LoRAs manager page (`/media/image?lora=<filename>`) also auto-inserts the trigger words on preselect — when a user clicks "Test this LoRA," they want to actually see the LoRA fire, which most LoRAs only do once the trigger is in the prompt. Helper `appendTriggerWords()` lives in `ImageGen.jsx` for now; would extract to `genUtils.js` if reused elsewhere.
diff --git a/client/src/components/media/MediaCard.jsx b/client/src/components/media/MediaCard.jsx
index e8d51e548b..9b76dbe7f4 100644
--- a/client/src/components/media/MediaCard.jsx
+++ b/client/src/components/media/MediaCard.jsx
@@ -50,12 +50,13 @@ export default function MediaCard({
{selectionLabel}
</div>
)}
- {item.stitchedFrom && (
- <span className="absolute top-1.5 right-1.5 text-[9px] px-1 py-0.5 bg-port-success/80 text-white rounded">stitched</span>
- )}
- {item.upscaledFrom && (
- <span className="absolute top-1.5 right-1.5 text-[9px] px-1 py-0.5 bg-port-accent/80 text-white rounded">2×</span>
- )}
+ {[
+ item.stitchedFrom && { label: 'stitched', cls: 'bg-port-success/80 text-white' },
+ item.upscaledFrom && { label: '2×', cls: 'bg-port-accent/80 text-white' },
+ item.extractedFromVideoId && { label: 'frame', cls: 'bg-port-warning/80 text-black', title: 'Extracted from video' },
+ ].filter(Boolean).map((b) => (
+ <span key={b.label} title={b.title} className={`absolute top-1.5 right-1.5 text-[9px] px-1 py-0.5 rounded ${b.cls}`}>{b.label}</span>
+ ))}
</button>
<div className="p-2 space-y-1.5">
<p className="text-[11px] text-gray-300 line-clamp-2" title={prompt}>{prompt}</p>
diff --git a/client/src/components/media/normalize.js b/client/src/components/media/normalize.js
index 4dc8359813..f50ce169de 100644
--- a/client/src/components/media/normalize.js
+++ b/client/src/components/media/normalize.js
@@ -48,6 +48,8 @@ export function normalizeImage(i) {
loraNames,
createdAt: i.createdAt,
hidden: !!i.hidden,
+ extractedFromVideoId: i.extractedFromVideoId || null,
+ extractedFromVideoFilename: i.extractedFromVideoFilename || null,
raw: i,
};
}
diff --git a/client/src/pages/MediaHistory.jsx b/client/src/pages/MediaHistory.jsx
index 32935d9764..93c4ca735a 100644
--- a/client/src/pages/MediaHistory.jsx
+++ b/client/src/pages/MediaHistory.jsx
@@ -6,7 +6,7 @@
import { useState, useEffect, useCallback, useMemo } from 'react';
import { Link, useNavigate } from 'react-router-dom';
-import { Combine, Image as ImageIcon, Film } from 'lucide-react';
+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';
@@ -28,6 +28,7 @@ export default function MediaHistory() {
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(true);
const [filter, setFilter] = useState('all');
+ const [query, setQuery] = useState('');
const [stitchMode, setStitchMode] = useState(false);
const [selected, setSelected] = useState([]); // video ids
const [stitching, setStitching] = useState(false);
@@ -49,15 +50,47 @@ export default function MediaHistory() {
useEffect(() => { refresh(); }, [refresh]);
+ // Precompute the searchable haystack per item once per items list — keystrokes
+ // then only re-run token .includes() against a cached string instead of
+ // rebuilding the array + join + lowercase per item per keystroke.
+ const haystacks = useMemo(() => items.map((item) => [
+ item.prompt,
+ item.negativePrompt,
+ item.modelId,
+ item.filename,
+ item.kind,
+ item.seed != null ? `seed ${item.seed}` : '',
+ item.width && item.height ? `${item.width}x${item.height}` : '',
+ ...(Array.isArray(item.loraNames) ? item.loraNames : []),
+ item.extractedFromVideoId ? 'extracted frame' : '',
+ item.stitchedFrom ? 'stitched' : '',
+ item.upscaledFrom ? 'upscaled 2x' : '',
+ ].filter(Boolean).join(' ').toLowerCase()), [items]);
+
+ // AND semantics across whitespace tokens — "sunset flux2 1024" matches items
+ // whose haystack contains all three substrings, in any order.
+ const tokens = useMemo(
+ () => query.trim().toLowerCase().split(/\s+/).filter(Boolean),
+ [query]
+ );
+
+ const searched = useMemo(
+ () => tokens.length === 0 ? items : items.filter((_, idx) => tokens.every((t) => haystacks[idx].includes(t))),
+ [items, haystacks, tokens]
+ );
const filtered = useMemo(
- () => filter === 'all' ? items : items.filter(i => i.kind === filter),
- [items, filter]
+ () => filter === 'all' ? searched : searched.filter(i => i.kind === filter),
+ [searched, filter]
);
- const counts = useMemo(() => ({
- all: items.length,
- image: items.filter(i => i.kind === 'image').length,
- video: items.filter(i => i.kind === 'video').length,
- }), [items]);
+ const counts = useMemo(() => {
+ const c = { all: 0, image: 0, video: 0 };
+ for (const i of searched) {
+ c.all++;
+ if (i.kind === 'image') c.image++;
+ else if (i.kind === 'video') c.video++;
+ }
+ return c;
+ }, [searched]);
const toggleSelect = (videoId) => {
setSelected((s) => s.includes(videoId) ? s.filter((x) => x !== videoId) : [...s, videoId]);
@@ -143,6 +176,28 @@ export default function MediaHistory() {
return (
<div className="space-y-4">
<div className="flex items-center justify-between gap-2 flex-wrap">
+ <div className="flex items-center gap-2 flex-1 min-w-[200px]">
+ <div className="relative flex-1 max-w-md">
+ <Search className="absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-500 pointer-events-none" />
+ <input
+ type="text"
+ value={query}
+ onChange={(e) => setQuery(e.target.value)}
+ placeholder="Search prompt, model, seed, lora…"
+ className="w-full pl-7 pr-7 py-1 bg-port-bg border border-port-border rounded text-xs text-white placeholder-gray-500 focus:outline-none focus:border-port-accent"
+ />
+ {query && (
+ <button
+ type="button"
+ onClick={() => setQuery('')}
+ className="absolute right-1 top-1/2 -translate-y-1/2 p-0.5 text-gray-500 hover:text-white"
+ title="Clear search"
+ >
+ <X className="w-3.5 h-3.5" />
+ </button>
+ )}
+ </div>
+ </div>
<div className="flex items-center gap-1 text-xs">
{FILTERS.map((f) => (
<button
@@ -194,11 +249,13 @@ export default function MediaHistory() {
<div className="text-gray-500 text-sm">Loading…</div>
) : filtered.length === 0 ? (
<div className="bg-port-card border border-port-border rounded-xl p-8 text-center text-gray-500 text-sm">
- {filter === 'video'
- ? <>No videos yet. <Link to="/media/video" className="text-port-accent hover:underline">Generate one →</Link></>
- : filter === 'image'
- ? <>No images yet. <Link to="/media/image" className="text-port-accent hover:underline">Generate one →</Link></>
- : <>Nothing here yet. Try <Link to="/media/image" className="text-port-accent hover:underline">Image</Link> or <Link to="/media/video" className="text-port-accent hover:underline">Video</Link>.</>}
+ {query.trim()
+ ? <>No matches for <span className="text-gray-300">"{query}"</span>. <button type="button" onClick={() => setQuery('')} className="text-port-accent hover:underline">Clear search</button></>
+ : filter === 'video'
+ ? <>No videos yet. <Link to="/media/video" className="text-port-accent hover:underline">Generate one →</Link></>
+ : filter === 'image'
+ ? <>No images yet. <Link to="/media/image" className="text-port-accent hover:underline">Generate one →</Link></>
+ : <>Nothing here yet. Try <Link to="/media/image" className="text-port-accent hover:underline">Image</Link> or <Link to="/media/video" className="text-port-accent hover:underline">Video</Link>.</>}
</div>
) : (
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3">
diff --git a/server/services/videoGen/local.js b/server/services/videoGen/local.js
index bba8795acc..4160802a3b 100644
--- a/server/services/videoGen/local.js
+++ b/server/services/videoGen/local.js
@@ -901,8 +901,32 @@ export async function extractLastFrame(historyId) {
return null;
}
};
+ // Sidecar carries the source video's prompt + provenance so the extracted
+ // frame surfaces in the gallery with searchable metadata. Cache-hit path
+ // calls this too so frames extracted before this change get backfilled.
+ // `wx` flag makes the create-if-missing race-free — EEXIST is the no-op.
+ const sidecarPath = join(PATHS.images, frameFilename.replace('.png', '.metadata.json'));
+ const writeSidecar = async () => {
+ const meta = {
+ filename: frameFilename,
+ prompt: item.prompt,
+ negativePrompt: item.negativePrompt,
+ modelId: item.modelId,
+ width: item.width,
+ height: item.height,
+ seed: item.seed,
+ extractedFromVideoId: item.id,
+ extractedFromVideoFilename: item.filename,
+ extractedAt: 'last-frame',
+ kind: 'extracted-frame',
+ createdAt: new Date().toISOString(),
+ };
+ await writeFile(sidecarPath, JSON.stringify(meta, null, 2), { flag: 'wx' }).catch(() => {});
+ };
+
const cachedSize = safeStatSize(framePath);
if (cachedSize != null && cachedSize > 0) {
+ await writeSidecar();
return { filename: frameFilename, path: `/data/images/${frameFilename}` };
}
if (cachedSize === 0) await unlink(framePath).catch(() => {});
@@ -927,6 +951,7 @@ export async function extractLastFrame(historyId) {
if (writtenSize === 0) await unlink(framePath).catch(() => {});
return reject(new ServerError('Failed to extract last frame', { status: 500, code: 'FFMPEG_FAILED' }));
}
+ await writeSidecar();
console.log(`🎞️ Extracted last frame: ${frameFilename}`);
resolve({ filename: frameFilename, path: `/data/images/${frameFilename}` });
});