fix: decouple AI completion from history save failures and improve history API errors

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-16 21:31:20 +08:00
parent 123a5cce6d
commit 187b08c3e1
8 changed files with 145 additions and 53 deletions
+16
View File
@@ -34,6 +34,22 @@ export async function saveHistoryEntry(
return data.entry;
}
export async function saveHistoryEntrySafe(
entry: CalcHistoryCreate,
): Promise<
{ ok: true; entry: CalcHistoryEntry } | { ok: false; error: string }
> {
try {
const saved = await saveHistoryEntry(entry);
return { ok: true, entry: saved };
} catch (err) {
return {
ok: false,
error: err instanceof Error ? err.message : String(err),
};
}
}
export async function deleteHistoryEntry(id: string): Promise<void> {
const res = await fetch(`/api/history/${encodeURIComponent(id)}`, {
method: "DELETE",