fix: harden resume and SSE replay
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { server } from "../test/msw";
|
||||
import { createSession, listSessions, prewarmRuntime } from "./sessions";
|
||||
import { createSession, listSessions, prewarmRuntime, resumeSession } from "./sessions";
|
||||
import {
|
||||
renameSession, setSessionGroup, archiveSession, unarchiveSession,
|
||||
deleteSession, getSessionDocuments,
|
||||
@@ -36,6 +36,14 @@ test("listSessions GETs the array", async () => {
|
||||
expect(rows[0].id).toBe("s1");
|
||||
});
|
||||
|
||||
test("resumeSession returns the typed runtime disposition", async () => {
|
||||
server.use(http.post("http://localhost:8787/sessions/s1/resume", () =>
|
||||
HttpResponse.json({ id: "s1", alreadyActive: false })));
|
||||
|
||||
const result: { id: string; alreadyActive: boolean } = await resumeSession("s1");
|
||||
expect(result).toEqual({ id: "s1", alreadyActive: false });
|
||||
});
|
||||
|
||||
test("renameSession POSTs {name}", async () => {
|
||||
let body: unknown = null;
|
||||
server.use(http.post("http://localhost:8787/sessions/s1/rename", async ({ request }) => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { apiFetch } from "./client";
|
||||
import type { SessionSummary, SessionDocument, UiResponse } from "./types";
|
||||
import type { ResumeSessionResult, SessionSummary, SessionDocument, UiResponse } from "./types";
|
||||
|
||||
export const createSession = (i: { question: string; name?: string }) =>
|
||||
apiFetch<{ id: string }>("/sessions", { method: "POST", body: JSON.stringify(i) });
|
||||
@@ -29,7 +29,7 @@ export const closeSession = (id: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/close`, { method: "POST" });
|
||||
|
||||
export const resumeSession = (id: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/resume`, { method: "POST" });
|
||||
apiFetch<ResumeSessionResult>(`/sessions/${id}/resume`, { method: "POST" });
|
||||
|
||||
export const renameSession = (id: string, name: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/rename`, { method: "POST", body: JSON.stringify({ name }) });
|
||||
|
||||
@@ -89,7 +89,7 @@ export type StreamEvent =
|
||||
};
|
||||
}
|
||||
| { type: "info"; level?: "info" | "warning" | "error"; text: string }
|
||||
| { type: "system_event"; event: string; [k: string]: unknown };
|
||||
| { type: "system_event"; event: string };
|
||||
|
||||
export interface SessionSummary {
|
||||
id: string;
|
||||
@@ -104,6 +104,11 @@ export interface SessionSummary {
|
||||
archived: boolean;
|
||||
}
|
||||
|
||||
export interface ResumeSessionResult {
|
||||
id: string;
|
||||
alreadyActive: boolean;
|
||||
}
|
||||
|
||||
export interface SessionDocument {
|
||||
phase: string;
|
||||
key: string;
|
||||
|
||||
Reference in New Issue
Block a user