Integrate backend APIs and move review to center editor tab

This commit is contained in:
2026-02-24 14:22:39 +03:00
parent fe67753f74
commit 91a0a50b04
13 changed files with 1010 additions and 152 deletions
+46
View File
@@ -0,0 +1,46 @@
import { ApiHttpClient } from "./ApiHttpClient.js";
export class IndexingClientApi {
constructor(http = new ApiHttpClient(), pollMs = 700, timeoutMs = 120000) {
this.http = http;
this.pollMs = pollMs;
this.timeoutMs = timeoutMs;
}
async submitSnapshot(projectId, files) {
const queued = await this.http.request("/api/rag/sessions", {
method: "POST",
body: JSON.stringify({ project_id: projectId, files })
});
const status = await this.#pollRagJob(queued.rag_session_id, queued.index_job_id);
return { ...status, rag_session_id: queued.rag_session_id };
}
async submitChanges(ragSessionId, changedFiles) {
const queued = await this.http.request(`/api/rag/sessions/${encodeURIComponent(ragSessionId)}/changes`, {
method: "POST",
body: JSON.stringify({ changed_files: changedFiles })
});
const status = await this.#pollRagJob(ragSessionId, queued.index_job_id);
return { ...status, rag_session_id: ragSessionId };
}
async #pollRagJob(ragSessionId, jobId) {
const started = Date.now();
while (Date.now() - started < this.timeoutMs) {
const status = await this.http.request(
`/api/rag/sessions/${encodeURIComponent(ragSessionId)}/jobs/${encodeURIComponent(jobId)}`
);
if (status.status === "done") return status;
if (status.status === "error") {
throw new Error(status.error?.desc || "Indexing failed");
}
await this.#sleep(this.pollMs);
}
throw new Error("Index polling timeout");
}
#sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
}