Add mock AI provider and AI integration tests; fix sign-in transition and card flip
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
parent
74a98ac1f1
commit
75158c4449
8 changed files with 720 additions and 33 deletions
|
|
@ -545,9 +545,13 @@ export function startGeneration(app: AppContext, input: z.input<typeof generateR
|
|||
.catch((err) => {
|
||||
const message = err instanceof AIError ? err.message : err instanceof Error && 'status' in err ? err.message : 'Generation failed unexpectedly.';
|
||||
if (!(err instanceof AIError) && !(err instanceof Error && 'status' in err)) app.log('error', 'Generation failed', err);
|
||||
const current = app.db.get<{ status: string }>('SELECT status FROM drafts WHERE id = ?', draftId);
|
||||
if (current?.status === 'generating') {
|
||||
app.db.run(`UPDATE drafts SET status = 'failed', error = ?, updated_at = ? WHERE id = ?`, controller.signal.aborted ? 'Generation was cancelled.' : message, now(), draftId);
|
||||
try {
|
||||
const current = app.db.get<{ status: string }>('SELECT status FROM drafts WHERE id = ?', draftId);
|
||||
if (current?.status === 'generating') {
|
||||
app.db.run(`UPDATE drafts SET status = 'failed', error = ?, updated_at = ? WHERE id = ?`, controller.signal.aborted ? 'Generation was cancelled.' : message, now(), draftId);
|
||||
}
|
||||
} catch {
|
||||
/* the database was closed during shutdown; tidyDrafts marks the job failed on the next start */
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
|
|
@ -865,7 +869,11 @@ Return the questions in the same order, one output question per input question.$
|
|||
})()
|
||||
.catch((err) => {
|
||||
const message = err instanceof AIError || (err instanceof Error && 'status' in err) ? (err as Error).message : 'Improving the questions failed unexpectedly.';
|
||||
app.db.run(`UPDATE drafts SET status = 'failed', error = ?, updated_at = ? WHERE id = ? AND status = 'generating'`, message, now(), draftId);
|
||||
try {
|
||||
app.db.run(`UPDATE drafts SET status = 'failed', error = ?, updated_at = ? WHERE id = ? AND status = 'generating'`, message, now(), draftId);
|
||||
} catch {
|
||||
/* database closed during shutdown */
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
running.delete(draftId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue