import { traceLogsRequested } from "../utils/traceLogs.js"; const STAGE_LABELS: Record = { browser: "Launching browser...", navigate: "Loading page...", extract: "Extracting HTML & CSS...", tokens: "Extracting design tokens...", screenshots: "Capturing screenshots...", assets: "Downloading assets...", style: "Generating visual style...", done: "Done", }; // A detail that is itself a step ("Launching headless Chrome...") replaces the label rather than repeating it. export function captureProgressLine(stage: string, detail?: string): string { const label = STAGE_LABELS[stage]; const text = detail?.trim(); if (!text) return ` ${label ?? stage}`; if (!label || stage === "done" || text.endsWith("...") || text.endsWith("…")) return ` ${text}`; return ` ${label} ${text}`; } // HYPERFRAMES_CAPTURE_PHASE records are for a watchdog reading a `--json` run. export function shouldEmitCapturePhases( json: boolean, env: NodeJS.ProcessEnv = process.env, ): boolean { return json || traceLogsRequested(env); }