feat(TRUEREF-0023): add sqlite-vec search pipeline

This commit is contained in:
Giancarmine Salucci
2026-04-01 14:09:19 +02:00
parent 0752636847
commit 9525c58e9a
45 changed files with 4009 additions and 614 deletions

View File

@@ -7,39 +7,33 @@
$effect(() => {
job = null;
let stopped = false;
let completeFired = false;
const es = new EventSource(`/api/v1/jobs/${jobId}/stream`);
async function poll() {
if (stopped) return;
try {
const res = await fetch(`/api/v1/jobs/${jobId}`);
if (res.ok) {
const data = await res.json();
job = data.job;
if (!completeFired && (job?.status === 'done' || job?.status === 'failed')) {
completeFired = true;
oncomplete?.();
}
}
} catch {
// ignore transient errors
}
}
es.addEventListener('job-progress', (event) => {
const data = JSON.parse(event.data);
job = { ...job, ...data } as IndexingJob;
});
void poll();
const interval = setInterval(() => {
if (job?.status === 'done' || job?.status === 'failed') {
clearInterval(interval);
return;
}
void poll();
}, 2000);
es.addEventListener('job-done', () => {
void fetch(`/api/v1/jobs/${jobId}`)
.then(r => r.json())
.then(d => { job = d.job; oncomplete?.(); });
es.close();
});
return () => {
stopped = true;
clearInterval(interval);
es.addEventListener('job-failed', (event) => {
const data = JSON.parse(event.data);
if (job) job = { ...job, status: 'failed', error: data.error ?? 'Unknown error' } as IndexingJob;
oncomplete?.();
es.close();
});
es.onerror = () => {
es.close();
void fetch(`/api/v1/jobs/${jobId}`).then(r => r.json()).then(d => { job = d.job; });
};
return () => es.close();
});
const progress = $derived(job?.progress ?? 0);