feat(frontend): contract types + REST client (MSW-tested)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 12:13:50 +02:00
co-authored by Claude Sonnet 4.6
parent 7e42ac11ef
commit 913ac30137
10 changed files with 147 additions and 1 deletions
+34
View File
@@ -0,0 +1,34 @@
import { apiFetch } from "./client";
import type { SessionSummary, UiResponse } from "./types";
export const createSession = (i: {
workspace: string;
question: string;
provider?: string;
model?: string;
thinking?: string;
name?: string;
}) => apiFetch<{ id: string }>("/sessions", { method: "POST", body: JSON.stringify(i) });
export const listSessions = () => apiFetch<SessionSummary[]>("/sessions");
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getSession = (id: string) => apiFetch<any>(`/sessions/${id}`);
export const postResponse = (id: string, uiResponse: UiResponse) =>
apiFetch<void>(`/sessions/${id}/response`, {
method: "POST",
body: JSON.stringify({ ui_response: uiResponse }),
});
export const postSteer = (id: string, text: string) =>
apiFetch<void>(`/sessions/${id}/steer`, {
method: "POST",
body: JSON.stringify({ text }),
});
export const closeSession = (id: string) =>
apiFetch<void>(`/sessions/${id}/close`, { method: "POST" });
export const resumeSession = (id: string) =>
apiFetch<void>(`/sessions/${id}/resume`, { method: "POST" });