Add filters and context to host operation history

This commit is contained in:
2026-10-05 13:23:11 -04:00
parent e6912ceb57
commit a6c40cde9b
16 changed files with 417 additions and 46 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import type { WorkerActivity } from '../../provisioning-detail.js';
import { currentOperationSource, withOperationSource } from '../hosts/operation-context.js';
const active = new Map<string, WorkerActivity>();
let sequence = 0;
@@ -11,6 +12,6 @@ export function workerActivity(): WorkerActivity[] {
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(); }
try { return await withOperationSource(currentOperationSource() ?? label, work); }
finally { active.delete(key); }
}