Files
PAGIVA/src/lib/ai/post-queue-shared.ts
T
Loma Bot Ops 4c691b5dde Show milestone progress bar for post generation queue jobs
Add percentage-by-stage progress in the queue UI, a progress rendering
test script, and clearer Chrome focus error details in the ChatGPT worker.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 15:36:52 +07:00

34 lines
1.3 KiB
TypeScript

export const POST_JOB_STATUS = {
QUEUED: "รอคิว",
RUNNING: "กำลังสร้าง",
COMPLETED: "พร้อมตรวจฉบับร่าง",
FAILED: "สร้างไม่สำเร็จ",
CANCELLED: "ยกเลิกแล้ว",
} as const;
export const POST_JOB_STAGE: Record<string, string> = {
queued: "รอเริ่มสร้างโพสต์",
content: "Codex กำลังเขียนเนื้อหาและพรอมต์ภาพ",
image: "ChatGPT กำลังสร้างภาพ",
saving: "กำลังบันทึกฉบับร่าง",
};
export interface PostJobView {
id: string;
topic: string;
status: keyof typeof POST_JOB_STATUS;
stage: string;
postId: string | null;
error: string | null;
createdAt: string;
startedAt: string | null;
finishedAt: string | null;
}
/** Milestones, not an estimate of the image model's internal rendering progress. */
export function postJobProgress(job: Pick<PostJobView, "status" | "stage">): number {
if (job.status === "COMPLETED") return 100;
if (job.status === "QUEUED" || job.status === "CANCELLED") return 0;
return ({ content: 10, image: 50, saving: 90 } as Record<string, number>)[job.stage] ?? 0;
}