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: keep music-video search results for structured concepts (#10955)

Adam Eivyb001e36ae14b
diff --git a/server/services/search.js b/server/services/search.js
index c470a59c32..f7069d04fe 100644
--- a/server/services/search.js
+++ b/server/services/search.js
@@ -287,6 +287,15 @@ function searchHealth(query) {
return { id: 'health', label: 'Health', icon: 'HeartPulse', results };
}
+// A music-video concept is a structured object (prompt/style/...) or a legacy string.
+// Pick a plain string for the snippet; never pass the object to extractSnippet.
+function musicVideoSnippetText(p) {
+ const concept = p.concept;
+ if (typeof concept === 'string' && concept.trim()) return concept;
+ const candidates = [concept?.prompt, concept?.style, p.description, p.name];
+ return candidates.find(v => typeof v === 'string' && v.trim()) ?? '';
+}
+
async function searchMusicVideo(query) {
const q = query.toLowerCase();
const projects = await listMusicVideoProjects({ includeDeleted: false }).catch(() => []);
@@ -295,7 +304,7 @@ async function searchMusicVideo(query) {
.map(p => ({
id: p.id,
title: p.name,
- snippet: extractSnippet(p.concept || p.description || p.name, query),
+ snippet: extractSnippet(musicVideoSnippetText(p), query),
url: `/music-video/${p.id}`,
type: 'music-video'
}))
diff --git a/server/services/search.test.js b/server/services/search.test.js
index 8c370e6518..0b28ab6fcd 100644
--- a/server/services/search.test.js
+++ b/server/services/search.test.js
@@ -338,5 +338,39 @@ describe('search service', () => {
expect(mvSource.results[0].url).toBe('/music-video/mv-1')
expect(mvSource.results[0].type).toBe('music-video')
})
+
+ it('should keep music-video matches when a concept is a structured object', async () => {
+ listMusicVideoProjects.mockResolvedValue([
+ { id: 'mv-1', name: 'Example project', concept: { prompt: 'Synthetic concept', style: 'Synthetic style' } },
+ { id: 'mv-2', name: 'Example legacy', concept: 'Legacy concept text' },
+ { id: 'mv-3', name: 'Example empty', concept: {} },
+ { id: 'mv-4', name: 'Example null', concept: null, description: 'Fallback description' }
+ ])
+
+ const results = await fanOutSearch('example')
+ const mvSource = results.find(s => s.id === 'musicVideo')
+ expect(mvSource).toBeDefined()
+ expect(mvSource.results).toHaveLength(4)
+ const snippets = Object.fromEntries(mvSource.results.map(r => [r.id, r.snippet]))
+ expect(snippets['mv-1']).toBe('Synthetic concept')
+ expect(snippets['mv-2']).toBe('Legacy concept text')
+ expect(snippets['mv-3']).toBe('Example empty')
+ expect(snippets['mv-4']).toBe('Fallback description')
+ })
+
+ it('should cap music-video results at five when concepts are structured', async () => {
+ listMusicVideoProjects.mockResolvedValue(
+ Array.from({ length: 7 }, (_, i) => ({
+ id: `mv-${i}`,
+ name: `Example ${i}`,
+ concept: { prompt: `Concept ${i}`, style: 'Style' }
+ }))
+ )
+
+ const results = await fanOutSearch('example')
+ const mvSource = results.find(s => s.id === 'musicVideo')
+ expect(mvSource.results).toHaveLength(5)
+ expect(mvSource.results.every(r => typeof r.snippet === 'string')).toBe(true)
+ })
})
})