Fix native provisioning scheduling and progress reporting

This commit is contained in:
2026-10-04 14:50:59 -04:00
parent 1bbee98b62
commit 2adadb0d05
18 changed files with 569 additions and 84 deletions
+16
View File
@@ -0,0 +1,16 @@
import type { WorkerActivity } from '../../provisioning-detail.js';
const active = new Map<string, WorkerActivity>();
let sequence = 0;
/** Live diagnostics only. Durable operation milestones belong in provisioning history. */
export function workerActivity(): WorkerActivity[] {
return [...active.values()].map(value => ({ ...value }));
}
export async function trackActivity<T>(key: string, label: string, work: () => Promise<T>): Promise<T> {
if (active.has(key)) key = `${key}:${++sequence}`;
active.set(key, { key, label, startedAt: new Date().toISOString() });
try { return await work(); }
finally { active.delete(key); }
}