INNER CODE UNIT · JavaScript
captureScreenshot
figranium/figranium · src/agent/figranite/index.js:353
const captureScreenshot = async (label) => {
const capturesDir = await ensureCapturesDir();
const safeLabel = label ? String(label).replace(/[^a-zA-Z0-9_-]/g, '').slice(0, 24) : '';
const nameSuffix = safeLabel ? `_${safeLabel}` : '';
const screenshotName = `${captureRunId}_agent_${Date.now()}${nameSuffix}.png`;
const screenshotPath = path.join(capturesDir, screenshotName);
await page.screenshot({ path: screenshotPath, fullPage: false });
return `/captures/${screenshotName}`;
};
// ⚡ Bolt: Pre-calculate which actions need {$html} or loop.html to avoid repeated JSON.stringify (O(N) instead of O(N^2))
const actionNeedsHtml = new Array(actions.length);
const actionNeedsLoopHtml = new Array(actions.length);
for (let i = 0; i < actions.length; i++) {
const s = JSON.stringify(actions[i]);
actionNeedsHtml[i] = s.includes('{$html}');
actionNeedsLoopHtml[i] = s.includes('loop.html');
}