watchSlots
uses tcmts.cli.running.slotsNow, which uses node:fs
Begin taking slotSamples, once for the studio's process (again, it does nothing).
import { slotsNow, slotWork } from "#codebase/tcmts/cli/running"; import { slotSamples } from "#codebase/tcmts/studio"; export function watchSlots(): void { const g = globalThis as unknown as Record<symbol, unknown>; if (g[Symbol.for("tcm.studio.slots")]) return; const sample = () => { const s = slotsNow(); const byRoot: Record<string, number> = {}; for (const h of s.held) { const root = slotWork(h.what).root ?? ""; byRoot[root] = (byRoot[root] ?? 0) + 1; } slotSamples.push({ at: Date.now(), size: s.size, held: s.held.length, waiting: s.waiting.reduce((n, w) => n + (w.want ?? 1), 0), byRoot, }); while (slotSamples.length > 360) slotSamples.shift(); }; sample(); g[Symbol.for("tcm.studio.slots")] = setInterval(sample, 5000).unref(); }