Improve job status notifications

This commit is contained in:
2026-03-09 18:53:41 -04:00
parent 1a18ac825d
commit 12a9741eca
22 changed files with 2243 additions and 302 deletions

View File

@@ -15,6 +15,7 @@ import {
setTaskWorkflowRunId,
updateTaskNotificationState
} from '@/lib/server/repos/tasks';
import { buildTaskNotification } from '@/lib/server/task-notifications';
type EnqueueTaskInput = {
userId: string;
@@ -72,15 +73,21 @@ async function reconcileTaskWithWorkflow(task: Task) {
const updated = await setTaskStatusFromWorkflow(task.id, nextStatus, nextError);
return updated ?? {
const fallbackTask = {
...task,
status: nextStatus,
stage: nextStatus,
stage_detail: null,
stage_detail: nextStatus === 'failed' ? nextError : 'Workflow run completed.',
stage_context: null,
error: nextError,
finished_at: nextStatus === 'queued' || nextStatus === 'running'
? null
: task.finished_at ?? new Date().toISOString()
} satisfies Omit<Task, 'notification'>;
return updated ?? {
...fallbackTask,
notification: buildTaskNotification(fallbackTask)
};
} catch {
return task;