feat: establish unified administration and model context baseline
This commit is contained in:
@@ -232,11 +232,16 @@ test("getMe fetches the typed authenticated principal", async () => {
|
||||
});
|
||||
|
||||
test("resumeSession returns the typed runtime disposition", async () => {
|
||||
server.use(http.post("/api/sessions/s1/resume", () =>
|
||||
HttpResponse.json({ id: "s1", alreadyActive: false })));
|
||||
workspacePreferences.save({ workspaceId: "different-workspace", provider: "local", model: "qwen", thinking: "medium" });
|
||||
let body: unknown;
|
||||
server.use(http.post("/api/sessions/s1/resume", async ({ request }) => {
|
||||
body = await request.json();
|
||||
return HttpResponse.json({ id: "s1", alreadyActive: false });
|
||||
}));
|
||||
|
||||
const result: { id: string; alreadyActive: boolean } = await resumeSession("s1");
|
||||
expect(result).toEqual({ id: "s1", alreadyActive: false });
|
||||
expect(body).toEqual({ provider: "local", model: "qwen" });
|
||||
});
|
||||
|
||||
test("renameSession POSTs {name}", async () => {
|
||||
|
||||
@@ -26,11 +26,12 @@ async function selectedPreferences(precondition?: AuthOperationPrecondition): Pr
|
||||
// application memory from the installation defaults once, then keep choices ephemeral.
|
||||
const legacy = await getSettings();
|
||||
requireAuthOperationPrecondition(precondition);
|
||||
const latest = workspacePreferences.load();
|
||||
return workspacePreferences.save({
|
||||
workspaceId: saved.workspaceId ?? legacy.workspace,
|
||||
provider: saved.provider ?? legacy.provider,
|
||||
model: saved.model ?? legacy.model,
|
||||
thinking: saved.thinking ?? legacy.thinking,
|
||||
workspaceId: latest.workspaceId ?? legacy.workspace,
|
||||
provider: latest.provider ?? legacy.provider,
|
||||
model: latest.model ?? legacy.model,
|
||||
thinking: latest.thinking ?? legacy.thinking,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,8 +140,20 @@ export const postSteer = (id: string, text: string) =>
|
||||
export const closeSession = (id: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/close`, { method: "POST" });
|
||||
|
||||
export const resumeSession = (id: string) =>
|
||||
apiFetch<ResumeSessionResult>(`/sessions/${id}/resume`, { method: "POST" });
|
||||
export async function resumeSession(id: string) {
|
||||
const operation = captureAuthOperation();
|
||||
const precondition = operation ? {
|
||||
operation,
|
||||
isCurrent: () => isAuthOperationCurrent(operation, { sessionId: null, disposalEpoch: operation.disposalEpoch }),
|
||||
} : undefined;
|
||||
const selected = await selectedPreferences(precondition);
|
||||
requireAuthOperationPrecondition(precondition);
|
||||
return apiFetch<ResumeSessionResult>(`/sessions/${id}/resume`, {
|
||||
method: "POST",
|
||||
// The workspace is owned by the persisted session, never by this request.
|
||||
body: JSON.stringify({ provider: selected.provider, model: selected.model }),
|
||||
});
|
||||
}
|
||||
|
||||
export const renameSession = (id: string, name: string) =>
|
||||
apiFetch<void>(`/sessions/${id}/rename`, { method: "POST", body: JSON.stringify({ name }) });
|
||||
|
||||
@@ -160,6 +160,8 @@ export interface Principal {
|
||||
export interface ResumeSessionResult {
|
||||
id: string;
|
||||
alreadyActive: boolean;
|
||||
/** The session's pinned workspace; never supplied by the client. */
|
||||
workspaceId?: string;
|
||||
}
|
||||
|
||||
export interface SessionDocument {
|
||||
|
||||
Reference in New Issue
Block a user