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

fix: probe video covers by real filename; leave non-.png covers untouched (#13179)

Adam Eivyd46d0ca925bf
diff --git a/server/services/mediaAssetIndex/gallery.js b/server/services/mediaAssetIndex/gallery.js
index 696b5bce83..ec87b0811c 100644
--- a/server/services/mediaAssetIndex/gallery.js
+++ b/server/services/mediaAssetIndex/gallery.js
@@ -121,7 +121,7 @@ export async function listGalleryFacets(diskReader) {
categories: [...categories], kinds: [...kinds], collections: populated.filter(Boolean) };
}
-const FLAT_PNG_COVER = /^\/data\/images\/([A-Za-z0-9][A-Za-z0-9._-]*)\.png$/i;
+const FLAT_PNG_COVER = /^\/data\/images\/([A-Za-z0-9][A-Za-z0-9._-]*)\.png$/;
const VIDEO_THUMB_COVER = /^\/data\/video-thumbnails\/([A-Za-z0-9][A-Za-z0-9._-]*)\.[A-Za-z0-9]+$/;
/**
@@ -130,13 +130,17 @@ const VIDEO_THUMB_COVER = /^\/data\/video-thumbnails\/([A-Za-z0-9][A-Za-z0-9._-]
* asset is neither local nor peer-hosted becomes null so the card never issues
* a request that is certain to fail. Other shapes pass through unchanged.
*/
-async function projectCovers(summaries) {
+async function projectCovers(summaries, videoSnapshot) {
+ // A thumbnail's stem is not always the video id (posters, stitched renders),
+ // so probe by the real video filename recorded beside the thumbnail.
+ const videoByThumb = new Map(videoSnapshot.filter(v => v.thumbnail && v.filename).map(v => [v.thumbnail, v.filename]));
const { resolveMediaLocations } = await import('../peerHostedMedia.js');
const probes = summaries.map(({ cover }) => {
const png = FLAT_PNG_COVER.exec(cover || '');
if (png) return { kind: 'image', ref: `${png[1]}.png`, url: `/data/image-thumbnails/${png[1]}.webp` };
const thumb = VIDEO_THUMB_COVER.exec(cover || '');
- if (thumb) return { kind: 'video', ref: thumb[1], url: cover };
+ const videoFilename = thumb && videoByThumb.get(cover.slice('/data/video-thumbnails/'.length));
+ if (videoFilename) return { kind: 'video', ref: videoFilename, url: cover };
return null;
});
const located = await resolveMediaLocations(probes.filter(Boolean));
@@ -150,12 +154,12 @@ async function projectCovers(summaries) {
/** Collection grid covers and counts, without downloading all image sidecars. */
export async function listGalleryCollectionSummaries(diskReader) {
- return projectCovers(await collectionSummaryRows(diskReader));
+ const videoSnapshot = await (await import('../videoGen/history.js')).loadCompactHistory();
+ return projectCovers(await collectionSummaryRows(diskReader, videoSnapshot), videoSnapshot);
}
-async function collectionSummaryRows(diskReader) {
+async function collectionSummaryRows(diskReader, videoSnapshot) {
const collections = await (await import('../mediaCollections.js')).listCollections();
- const videoSnapshot = await (await import('../videoGen/history.js')).loadCompactHistory();
if (!escapeHatch()) {
const rows = await collectionCovers(collections.map(collection => ({
id: collection.id, coverKey: collection.coverKey,
diff --git a/server/services/mediaAssetIndex/gallery.test.js b/server/services/mediaAssetIndex/gallery.test.js
index 9f85db26f6..ca83664921 100644
--- a/server/services/mediaAssetIndex/gallery.test.js
+++ b/server/services/mediaAssetIndex/gallery.test.js
@@ -183,6 +183,27 @@ describe('collection cover projection', () => {
});
});
+describe('collection cover probes', () => {
+ it('probes a poster-style video thumbnail by its real filename and leaves uppercase PNG covers unprobed', async () => {
+ vi.stubEnv('MEMORY_BACKEND', 'file');
+ const video = { id: 'vid', filename: 'vid.mp4', thumbnail: 'vid-poster-1234.jpg', createdAt: '2026-01-02' };
+ loadHistory.mockResolvedValue([video]);
+ const collections = [
+ { id: 'poster', items: [{ kind: 'video', ref: 'vid', addedAt: '2026-01-01' }] },
+ { id: 'upper', items: [{ kind: 'image', ref: 'NAME.PNG', addedAt: '2026-01-01' }] },
+ ];
+ listCollections.mockResolvedValue(collections);
+ getCollection.mockImplementation(async id => collections.find(c => c.id === id));
+ resolveMediaLocations.mockImplementation(async items => items.map(() => ({ location: 'local' })));
+ const byId = Object.fromEntries((await listGalleryCollectionSummaries(async () => [{ filename: 'NAME.PNG', createdAt: '2026-01-01' }])).map(s => [s.id, s.cover]));
+ expect(byId.poster).toBe('/data/video-thumbnails/vid-poster-1234.jpg');
+ expect(byId.upper).toBe('/data/images/NAME.PNG');
+ const probed = resolveMediaLocations.mock.calls.flatMap(([items]) => items);
+ expect(probed).toContainEqual(expect.objectContaining({ kind: 'video', ref: 'vid.mp4' }));
+ expect(probed.some(p => /NAME/i.test(p.ref))).toBe(false);
+ });
+});
+
// The route test (routes/imageGen.clean.test.js) owns the both-directions
// contract end to end against a real clean. What only lives here: the SQL the
// indexed path emits, and the disk path the route test cannot reach because