Follow a running production every few seconds
A started production kept showing "AI picks new topics" for a minute or more: each schedule's status was read once a minute, and the refresh right after starting got the read kept from before the start. That read is now dropped when a production starts, and while the latest production is under way its status is read every five seconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -397,9 +397,9 @@ export function planProgress(plan: ContentPlan) {
|
||||
// from the last half minute, or one still on its way, answers both. forgetReads drops them after an action.
|
||||
const PRODUCTION_FRESH = 30_000
|
||||
const productionReads = new Map<number, { at: number; read: Promise<ProductionStatus> }>()
|
||||
export function productionStatus(id: number): Promise<ProductionStatus> {
|
||||
export function productionStatus(id: number, maxAge = PRODUCTION_FRESH): Promise<ProductionStatus> {
|
||||
const kept = productionReads.get(id)
|
||||
if (kept && Date.now() - kept.at < PRODUCTION_FRESH) return kept.read
|
||||
if (kept && Date.now() - kept.at < maxAge) return kept.read
|
||||
const read = request<ProductionStatus>(`${AGENTS}/${id}/content`)
|
||||
productionReads.set(id, { at: Date.now(), read })
|
||||
read.catch(() => { if (productionReads.get(id)?.read === read) productionReads.delete(id) })
|
||||
|
||||
Reference in New Issue
Block a user