fix(api): retry transient session reads safely

This commit is contained in:
john
2026-07-27 08:45:46 +08:00
parent 0708d56d61
commit 32da0c0583
4 changed files with 168 additions and 17 deletions
+9 -3
View File
@@ -1443,7 +1443,9 @@ export async function listSessions(options?: {
if (options?.offset != null) params.set('offset', String(options.offset));
if (options?.query?.trim()) params.set('query', options.query.trim());
const qs = params.size ? `?${params.toString()}` : '';
const result = await apiFetch<SessionListResponse>(`/sessions${qs}`);
const result = await apiFetch<SessionListResponse>(`/sessions${qs}`, undefined, {
retryOnTransientFailure: true,
});
return { items: result.sessions ?? [], page: result.page ?? {} };
}
@@ -1452,7 +1454,9 @@ function sessionPath(sessionId: string, suffix = '') {
}
export async function getSession(sessionId: string): Promise<Session> {
return apiFetch<Session>(sessionPath(sessionId));
return apiFetch<Session>(sessionPath(sessionId), undefined, {
retryOnTransientFailure: true,
});
}
export async function deleteChatSession(sessionId: string): Promise<void> {
@@ -1474,7 +1478,9 @@ export async function loadSessionDetail(
if (history?.before != null) params.set('history_before', String(history.before));
if (history?.limit != null) params.set('history_limit', String(history.limit));
const qs = params.size ? `?${params.toString()}` : '';
const detail = await apiFetch<Session>(`${sessionPath(sessionId)}${qs}`);
const detail = await apiFetch<Session>(`${sessionPath(sessionId)}${qs}`, undefined, {
retryOnTransientFailure: true,
});
const messages = normalizeConversationMessages(
(detail.conversation ?? []).filter((m) => m.metadata?.userVisible),
);