fix: trace debug — show Stranger_NNN for unnamed traces instead of unknown
This commit is contained in:
@@ -245,37 +245,44 @@ async function tauriInvoke<T>(command: string, args?: Record<string, unknown>):
|
||||
|
||||
// ── Unified API functions ───────────────────────────────────────────────
|
||||
|
||||
export async function searchVideos(query: string, limit = 10, mode = 'vector'): Promise<SearchResult> {
|
||||
export async function searchVideos(query: string, limit = 10, mode = 'vector', fileUuid?: string): Promise<SearchResult> {
|
||||
if (isTauri()) {
|
||||
return tauriInvoke<SearchResult>('search_videos', { query, limit, mode })
|
||||
return tauriInvoke<SearchResult>('search_videos', { query, limit, mode, uuid: fileUuid })
|
||||
}
|
||||
|
||||
const config = getConfig()
|
||||
const url = `${config.api_base_url}/api/v1/search/universal`
|
||||
|
||||
const body: any = { query, limit, mode }
|
||||
if (fileUuid) body.uuid = fileUuid
|
||||
|
||||
const response: any = await httpFetch<any>(url, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ query, limit }),
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
|
||||
return {
|
||||
query: response.query || query,
|
||||
count: response.results?.length || 0,
|
||||
hits: (response.results || []).map((r: any) => ({
|
||||
id: r.chunk_id || r.id,
|
||||
vid: r.uuid || r.vid || r.file_uuid || '',
|
||||
start_frame: Math.floor((r.start_time || 0) * (r.fps || 30)),
|
||||
end_frame: Math.floor((r.end_time || 0) * (r.fps || 30)),
|
||||
fps: r.fps || 30,
|
||||
start: r.start_time || r.start || 0,
|
||||
end: r.end_time || r.end || 0,
|
||||
text: r.text || r.text_content || '',
|
||||
score: r.score || 0,
|
||||
title: r.title || r.file_name || '',
|
||||
file_path: r.file_path,
|
||||
has_visual_stats: !!r.visual_stats,
|
||||
parent_id: r.parent_chunk_id,
|
||||
})),
|
||||
hits: (response.results || []).map((r: any) => {
|
||||
const chunkId = r.chunk_id || r.id || ''
|
||||
const fileUuid = r.uuid || r.vid || r.file_uuid || chunkId.split('_').slice(0, -1).join('_') || ''
|
||||
return {
|
||||
id: chunkId,
|
||||
vid: fileUuid,
|
||||
start_frame: r.start_frame || Math.floor((r.start_time || 0) * (r.fps || 30)),
|
||||
end_frame: r.end_frame || Math.floor((r.end_time || 0) * (r.fps || 30)),
|
||||
fps: r.fps || 30,
|
||||
start: r.start_time || r.start || 0,
|
||||
end: r.end_time || r.end || 0,
|
||||
text: r.text || r.text_content || '',
|
||||
score: r.score || 0,
|
||||
title: r.title || r.file_name || '',
|
||||
file_path: r.file_path,
|
||||
has_visual_stats: !!r.visual_stats,
|
||||
parent_id: r.parent_chunk_id,
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user