feat(frontend): settings api, typed PiModel, question-only createSession

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-28 16:19:51 +02:00
co-authored by Claude Opus 4.8
parent ec36ee421a
commit fa0f878c97
4 changed files with 34 additions and 12 deletions
+8 -1
View File
@@ -1,3 +1,10 @@
import { apiFetch } from "./client";
export const listModels = () => apiFetch<{ models: unknown[] }>("/models");
export interface PiModel {
provider: string;
id: string;
name: string;
reasoning: boolean;
}
export const listModels = () => apiFetch<{ models: PiModel[] }>("/models");
+11 -3
View File
@@ -2,10 +2,18 @@ import { http, HttpResponse } from "msw";
import { server } from "../test/msw";
import { createSession, listSessions } from "./sessions";
test("createSession POSTs and returns the id", async () => {
server.use(http.post("http://localhost:8787/sessions", () => HttpResponse.json({ id: "s1" })));
expect(await createSession({ workspace: "w", question: "q" })).toEqual({ id: "s1" });
test("createSession POSTs only {question} and returns the id", async () => {
let body: unknown = null;
server.use(
http.post("http://localhost:8787/sessions", async ({ request }) => {
body = await request.json();
return HttpResponse.json({ id: "s1" });
}),
);
expect(await createSession({ question: "q" })).toEqual({ id: "s1" });
expect(body).toEqual({ question: "q" });
});
test("listSessions GETs the array", async () => {
server.use(http.get("http://localhost:8787/sessions", () => HttpResponse.json([{ id: "s1", status: "open", question: "q", summary: null, created_at: "t", updated_at: null, author: null }])));
const rows = await listSessions();
+2 -8
View File
@@ -1,14 +1,8 @@
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 createSession = (i: { question: string; name?: string }) =>
apiFetch<{ id: string }>("/sessions", { method: "POST", body: JSON.stringify(i) });
export const listSessions = () => apiFetch<SessionSummary[]>("/sessions");
+13
View File
@@ -0,0 +1,13 @@
import { apiFetch } from "./client";
export interface Settings {
workspace?: string;
provider?: string;
model?: string;
thinking?: string;
}
export const getSettings = () => apiFetch<Settings>("/settings");
export const putSettings = (s: Settings) =>
apiFetch<Settings>("/settings", { method: "PUT", body: JSON.stringify(s) });