The user wants a browser automation infrastructure using headless WebGPU for rendering validation. This is a complex request that involves:
- Headless browser automation (likely using Puppeteer or similar)
- WebGPU rendering validation
- Scenario generation for testing
- Diffing pipelines (visual regression testing)
- Resource isolation
- Performance metrics collection
This is a comprehensive infrastructure tool. Let me design something that's:
- Visually appealing with a modern dashboard interface
- Functional with real automation capabilities
- Interactive with meaningful controls
Since this is an infrastructure tool, I'll create:
- A control dashboard with dark theme (professional dev tool aesthetic)
- Scenario management panel
- Visual diff viewer
- Performance metrics visualization
- Resource isolation status
- Real-time logs/output
Let me build this as a self-contained tool with:
- Tabbed interface for different sections
- Interactive scenario builder
- Mock diff visualization (since we can't actually run headless browser in pure HTML)
- Animated metrics charts
- Resource allocation visualization
I'll use a technical/industrial aesthetic with:
- Dark background with subtle grid pattern
- Monospace fonts for code/output
- Cyan/teal accent color (technical feel)
- Clean data visualization
Let me code this comprehensive infrastructure dashboard.
Browser Automation Infrastructure with WebGPU Rendering Validation
This is a comprehensive infrastructure dashboard for headless browser automation with rendering validation. It includes scenario management, visual diffing, resource isolation controls, and real-time performance metrics.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebGPU Automation Infrastructure</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg: #0a0e14;
--bg-elevated: #111820;
--bg-surface: #1a222d;
--fg: #e6edf5;
--fg-muted: #6b7a8f;
--accent: #00d4aa;
--accent-dim: rgba(0, 212, 170, 0.15);
--warning: #ffb347;
--error: #ff6b6b;
--success: #00d4aa;
--border: #2a3544;
--grid: rgba(42, 53, 68, 0.4);
}
* { box-sizing: border-box; }
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
min-height: 100vh;
}
.font-mono { font-family: 'JetBrains Mono', monospace; }
.bg-grid {
background-image:
linear-gradient(var(--grid) 1px, transparent 1px),
linear-gradient(90deg, var(--grid) 1px, transparent 1px);
background-size: 24px 24px;
}
.glow-accent {
box-shadow: 0 0 30px rgba(0, 212, 170, 0.2), 0 0 60px rgba(0, 212, 170, 0.1);
}
.card {
background: var(--bg-surface);
border: 1px solid var(--border);
border-radius: 8px;
}
.btn-primary {
background: var(--accent);
color: var(--bg);
font-weight: 600;
padding: 10px 20px;
border-radius: 6px;
transition: all 0.2s;
}
.btn-primary:hover {
transform: translateY(-1px);
box-shadow: 0 4px 20px rgba(0, 212, 170, 0.3);
}
.btn-secondary {
background: var(--bg-elevated);
border: 1px solid var(--border);
color: var(--fg);
padding: 10px 20px;
border-radius: 6px;
transition: all 0.2s;
}
.btn-secondary:hover {
border-color: var(--accent);
background: var(--accent-dim);
}
.tab-btn {
padding: 12px 20px;
color: var(--fg-muted);
border-bottom: 2px solid transparent;
transition: all 0.2s;
cursor: pointer;
}
.tab-btn:hover {
color: var(--fg);
}
.tab-btn.active {
color: var(--accent);
border-bottom-color: var(--accent);
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
@keyframes slideIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes scanline {
0% { transform: translateY(-100%); }
100% { transform: translateY(100%); }
}
.animate-in {
animation: slideIn 0.4s ease-out forwards;
}
.diff-added { background: rgba(0, 212, 170, 0.2); }
.diff-removed { background: rgba(255, 107, 107, 0.2); }
.metric-bar {
height: 4px;
background: var(--bg-elevated);
border-radius: 2px;
overflow: hidden;
}
.metric-fill {
height: 100%;
background: var(--accent);
border-radius: 2px;
transition: width 0.5s ease-out;
}
.terminal {
background: #000;
border: 1px solid var(--border);
border-radius: 6px;
font-family: 'JetBrains Mono', monospace;
font-size: 12px;
overflow: hidden;
}
.terminal-header {
background: var(--bg-elevated);
padding: 8px 12px;
display: flex;
gap: 6px;
}
.terminal-dot {
width: 10px;
height: 10px;
border-radius: 50%;
}
.scenario-card {
transition: all 0.2s;
cursor: pointer;
}
.scenario-card:hover {
border-color: var(--accent);
transform: translateY(-2px);
}
.scenario-card.selected {
border-color: var(--accent);
background: var(--accent-dim);
}
input, select, textarea {
background: var(--bg);
border: 1px solid var(--border);
color: var(--fg);
padding: 10px 14px;
border-radius: 6px;
outline: none;
transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
border-color: var(--accent);
}
.range-slider {
-webkit-appearance: none;
background: var(--bg-elevated);
height: 6px;
border-radius: 3px;
}
.range-slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 16px;
height: 16px;
background: var(--accent);
border-radius: 50%;
cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
</style>
</head>
<body class="bg-grid">
<!-- Header -->
<header class="border-b border-[--border] bg-[--bg-elevated]/80 backdrop-blur-sm sticky top-0 z-50">
<div class="max-w-[1600px] mx-auto px-6 py-4 flex items-center justify-between">
<div class="flex items-center gap-4">
<div class="w-10 h-10 rounded-lg bg-[--accent-dim] flex items-center justify-center">
<svg class="w-6 h-6 text-[--accent]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
</div>
<div>
<h1 class="text-lg font-semibold">WebGPU Automation</h1>
<p class="text-xs text-[--fg-muted] font-mono">v2.4.0 / headless rendering pipeline</p>
</div>
</div>
<div class="flex items-center gap-6">
<div class="flex items-center gap-2">
<div class="status-dot bg-[--accent]"></div>
<span class="text-sm text-[--fg-muted]">Pipeline Active</span>
</div>
<div class="flex items-center gap-2 px-3 py-1.5 rounded bg-[--bg-surface] border border-[--border]">
<span class="text-xs text-[--fg-muted]">Workers:</span>
<span class="text-sm font-mono text-[--accent]" id="workerCount">4</span>
</div>
<button class="btn-secondary text-sm" onclick="openSettings()">Settings</button>
</div>
</div>
</header>
<!-- Main Content -->
<main class="max-w-[1600px] mx-auto px-6 py-6">
<!-- Tabs -->
<nav class="flex border-b border-[--border] mb-6">
<button class="tab-btn active" data-tab="scenarios">Scenarios</button>
<button class="tab-btn" data-tab="diffing">Diff Pipeline</button>
<button class="tab-btn" data-tab="resources">Resources</button>
<button class="tab-btn" data-tab="metrics">Metrics</button>
<button class="tab-btn" data-tab="logs">Logs</button>
</nav>
<!-- Tab Content -->
<div id="tabContent">
<!-- Scenarios Tab -->
<section id="scenarios-tab" class="tab-panel">
<div class="grid grid-cols-12 gap-6">
<!-- Scenario List -->
<div class="col-span-4">
<div class="card p-4">
<div class="flex items-center justify-between mb-4">
<h2 class="font-semibold">Test Scenarios</h2>
<button class="text-sm text-[--accent] hover:underline" onclick="createScenario()">+ New</button>
</div>
<div class="space-y-2" id="scenarioList"></div>
</div>
</div>
<!-- Scenario Editor -->
<div class="col-span-8">
<div class="card p-6" id="scenarioEditor">
<div class="text-center py-12 text-[--fg-muted]">
<svg class="w-16 h-16 mx-auto mb-4 opacity-30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
<p>Select a scenario to edit or create a new one</p>
</div>
</div>
</div>
</div>
</section>
<!-- Diffing Tab -->
<section id="diffing-tab" class="tab-panel hidden">
<div class="grid grid-cols-12 gap-6">
<div class="col-span-8">
<div class="card p-6">
<div class="flex items-center justify-between mb-6">
<h2 class="font-semibold">Visual Diff Comparison</h2>
<div class="flex gap-2">
<button class="btn-secondary text-sm" onclick="runDiff()">Run Diff</button>
<button class="btn-primary text-sm" onclick="approveDiff()">Approve</button>
</div>
</div>
<div class="grid grid-cols-2 gap-4 mb-6">
<div>
<p class="text-xs text-[--fg-muted] mb-2">Baseline</p>
<div class="aspect-video bg-[--bg] rounded-lg border border-[--border] overflow-hidden relative" id="baselineCanvas">
<canvas id="baselineRender" class="w-full h-full"></canvas>
</div>
</div>
<div>
<p class="text-xs text-[--fg-muted] mb-2">Current Render</p>
<div class="aspect-video bg-[--bg] rounded-lg border border-[--border] overflow-hidden relative" id="currentCanvas">
<canvas id="currentRender" class="w-full h-full"></canvas>
</div>
</div>
</div>
<div>
<p class="text-xs text-[--fg-muted] mb-2">Diff Output</p>
<div class="aspect-video bg-[--bg] rounded-lg border border-[--border] overflow-hidden">
<canvas id="diffRender" class="w-full h-full"></canvas>
</div>
</div>
</div>
</div>
<div class="col-span-4">
<div class="card p-4 mb-4">
<h3 class="font-semibold mb-4">Diff Settings</h3>
<div class="space-y-4">
<div>
<label class="text-xs text-[--fg-muted] block mb-2">Threshold</label>
<input type="range" class="range-slider w-full" id="diffThreshold" min="0" max="100" value="5">
<div class="flex justify-between text-xs text-[--fg-muted] mt-1">
<span>0%</span>
<span id="thresholdValue">5%</span>
<span>100%</span>
</div>
</div>
<div>
<label class="text-xs text-[--fg-muted] block mb-2">Diff Mode</label>
<select class="w-full">
<option>Pixel Difference</option>
<option>Perceptual (SSIM)</option>
<option>Structural (DSSIM)</option>
</select>
</div>
<div>
<label class="text-xs text-[--fg-muted] block mb-2">Exclude Regions</label>
<textarea class="w-full h-20 text-sm font-mono" placeholder="x,y,width,height 0,0,100,50"></textarea>
</div>
</div>
</div>
<div class="card p-4">
<h3 class="font-semibold mb-4">Diff Results</h3>
<div id="diffResults" class="space-y-3">
<div class="text-center py-6 text-[--fg-muted] text-sm">
Run a diff to see results
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Resources Tab -->
<section id="resources-tab" class="tab-panel hidden">
<div class="grid grid-cols-12 gap-6">
<div class="col-span-8">
<div class="card p-6">
<h2 class="font-semibold mb-6">Resource Isolation Pools</h2>
<div class="grid grid-cols-2 gap-4" id="resourcePools"></div>
</div>
</div>
<div class="col-span-4">
<div class="card p-4 mb-4">
<h3 class="font-semibold mb-4">Pool Configuration</h3>
<div class="space-y-4">
<div>
<label class="text-xs text-[--fg-muted] block mb-2">Memory Limit (MB)</label>
<input type="number" class="w-full" value="512" id="memoryLimit">
</div>
<div>
<label class="text-xs text-[--fg-muted] block mb-2">GPU Contexts</label>
<input type="number" class="w-full" value="4" id="gpuContexts">
</div>
<div>
<label class="text-xs text-[--fg-muted] block mb-2">CPU Cores</label>
<input type="range" class="range-slider w-full" min="1" max="8" value="4" id="cpuCores">
<div class="text-right text-xs text-[--fg-muted] mt-1"><span id="coreCount">4</span> cores</div>
</div>
<button class="btn-primary w-full" onclick="applyPoolConfig()">Apply Configuration</button>
</div>
</div>
<div class="card p-4">
<h3 class="font-semibold mb-4">Active Containers</h3>
<div id="containers" class="space-y-2"></div>
</div>
</div>
</div>
</section>
<!-- Metrics Tab -->
<section id="metrics-tab" class="tab-panel hidden">
<div class="grid grid-cols-4 gap-4 mb-6">
<div class="card p-4">
<p class="text-xs text-[--fg-muted] mb-1">Avg Frame Time</p>
<p class="text-2xl font-semibold font-mono" id="avgFrameTime">16.2ms</p>
<div class="metric-bar mt-2">
<div class="metric-fill" style="width: 54%"></div>
</div>
</div>
<div class="card p-4">
<p class="text-xs text-[--fg-muted] mb-1">GPU Utilization</p>
<p class="text-2xl font-semibold font-mono" id="gpuUtil">78%</p>
<div class="metric-bar mt-2">
<div class="metric-fill" style="width: 78%"></div>
</div>
</div>
<div class="card p-4">
<p class="text-xs text-[--fg-muted] mb-1">Memory Usage</p>
<p class="text-2xl font-semibold font-mono" id="memUsage">1.2GB</p>
<div class="metric-bar mt-2">
<div class="metric-fill" style="width: 60%"></div>
</div>
</div>
<div class="card p-4">
<p class="text-xs text-[--fg-muted] mb-1">Pass Rate</p>
<p class="text-2xl font-semibold font-mono text-[--accent]" id="passRate">94.2%</p>
<div class="metric-bar mt-2">
<div class="metric-fill bg-[--accent]" style="width: 94%"></div>
</div>
</div>
</div>
<div class="grid grid-cols-12 gap-6">
<div class="col-span-8">
<div class="card p-6">
<h2 class="font-semibold mb-4">Performance Timeline</h2>
<div class="h-64" id="timelineChart"></div>
</div>
</div>
<div class="col-span-4">
<div class="card p-4 mb-4">
<h3 class="font-semibold mb-4">WebGPU Features</h3>
<div class="space-y-2" id="webgpuFeatures"></div>
</div>
<div class="card p-4">
<h3 class="font-semibold mb-4">Recent Runs</h3>
<div class="space-y-2" id="recentRuns"></div>
</div>
</div>
</div>
</section>
<!-- Logs Tab -->
<section id="logs-tab" class="tab-panel hidden">
<div class="card">
<div class="p-4 border-b border-[--border] flex items-center justify-between">
<div class="flex items-center gap-4">
<h2 class="font-semibold">Execution Logs</h2>
<div class="flex gap-2">
<button class="px-2 py-1 text-xs rounded bg-[--accent-dim] text-[--accent]" data-level="all">All</button>
<button class="px-2 py-1 text-xs rounded hover:bg-[--bg-elevated]" data-level="info">Info</button>
<button class="px-2 py-1 text-xs rounded hover:bg-[--bg-elevated]" data-level="warn">Warn</button>
<button class="px-2 py-1 text-xs rounded hover:bg-[--bg-elevated]" data-level="error">Error</button>
</div>
</div>
<button class="text-sm text-[--accent] hover:underline" onclick="clearLogs()">Clear</button>
</div>
<div class="terminal">
<div class="terminal-header">
<div class="terminal-dot bg-[--error]"></div>
<div class="terminal-dot bg-[--warning]"></div>
<div class="terminal-dot bg-[--accent]"></div>
</div>
<div class="p-4 h-96 overflow-y-auto font-mono text-sm" id="logOutput"></div>
</div>
</div>
</section>
</div>
</main>
<!-- Settings Modal -->
<div id="settingsModal" class="fixed inset-0 bg-black/50 backdrop-blur-sm z-50 hidden flex items-center justify-center">
<div class="card w-full max-w-lg p-6 animate-in">
<div class="flex items-center justify-between mb-6">
<h2 class="text-lg font-semibold">Pipeline Settings</h2>
<button onclick="closeSettings()" class="text-[--fg-muted] hover:text-[--fg]">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<div class="space-y-4">
<div>
<label class="text-sm text-[--fg-muted] block mb-2">Headless Browser</label>
<select class="w-full">
<option>Chrome (WebGPU)</option>
<option>Firefox</option>
<option>WebKit</option>
</select>
</div>
<div>
<label class="text-sm text-[--fg-muted] block mb-2">Viewport Size</label>
<div class="grid grid-cols-2 gap-2">
<input type="number" placeholder="Width" value="1920">
<input type="number" placeholder="Height" value="1080">
</div>
</div>
<div class="flex items-center justify-between">
<span class="text-sm">Enable GPU Acceleration</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" checked class="sr-only peer">
<div class="w-11 h-6 bg-[--bg] rounded-full peer peer-checked:bg-[--accent-dim] peer-checked:border-[--accent] border border-[--border] after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-[--fg-muted] after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:after:translate-x-full peer-checked:after:bg-[--accent]"></div>
</label>
</div>
<div class="flex items-center justify-between">
<span class="text-sm">Capture Screenshots</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" checked class="sr-only peer">
<div class="w-11 h-6 bg-[--bg] rounded-full peer peer-checked:bg-[--accent-dim] peer-checked:border-[--accent] border border-[--border] after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-[--fg-muted] after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:after:translate-x-full peer-checked:after:bg-[--accent]"></div>
</label>
</div>
<div>
<label class="text-sm text-[--fg-muted] block mb-2">Timeout (ms)</label>
<input type="number" class="w-full" value="30000">
</div>
</div>
<div class="flex gap-3 mt-6">
<button class="btn-secondary flex-1" onclick="closeSettings()">Cancel</button>
<button class="btn-primary flex-1" onclick="saveSettings()">Save</button>
</div>
</div>
</div>
<script>
// ============== DATA ==============
const scenarios = [
{
id: 1,
name: 'WebGPU Compute Shader Test',
description: 'Validates compute shader output for matrix multiplication',
status: 'passing',
lastRun: '2m ago',
steps: [
{ action: 'navigate', target: 'https://example.com/webgpu/compute' },
{ action: 'waitFor', target: '#gpu-ready', timeout: 5000 },
{ action: 'execute', script: 'runComputeTest()' },
{ action: 'screenshot', name: 'compute-output' },
{ action: 'assert', expected: 1024, actual: 'getResult()' }
]
},
{
id: 2,
name: 'Render Pipeline Validation',
description: 'Tests vertex and fragment shader rendering accuracy',
status: 'passing',
lastRun: '5m ago',
steps: [
{ action: 'navigate', target: 'https://example.com/webgpu/render' },
{ action: 'waitFor', target: 'canvas', timeout: 3000 },
{ action: 'execute', script: 'drawTestScene()' },
{ action: 'screenshot', name: 'render-output' },
{ action: 'diff', threshold: 0.05 }
]
},
{
id: 3,
name: 'Texture Sampling Accuracy',
description: 'Validates mipmap generation and texture filtering',
status: 'failing',
lastRun: '12m ago',
steps: [
{ action: 'navigate', target: 'https://example.com/webgpu/texture' },
{ action: 'execute', script: 'loadTextures()' },
{ action: 'screenshot', name: 'texture-output' },
{ action: 'diff', threshold: 0.02 }
]
},
{
id: 4,
name: 'Memory Pressure Test',
description: 'Tests behavior under GPU memory constraints',
status: 'pending',
lastRun: '1h ago',
steps: [
{ action: 'navigate', target: 'https://example.com/webgpu/memory' },
{ action: 'execute', script: 'allocateLargeBuffers()' },
{ action: 'assert', expected: true, actual: 'checkMemoryStatus()' }
]
}
];
const resourcePools = [
{ id: 'pool-1', name: 'Primary Pool', memory: 512, used: 324, gpu: 2, status: 'active' },
{ id: 'pool-2', name: 'Isolation Pool A', memory: 256, used: 128, gpu: 1, status: 'active' },
{ id: 'pool-3', name: 'Isolation Pool B', memory: 256, used: 0, gpu: 1, status: 'idle' },
{ id: 'pool-4', name: 'Stress Test Pool', memory: 1024, used: 896, gpu: 4, status: 'warning' }
];
const containers = [
{ id: 'ctx-001', pool: 'pool-1', status: 'running', uptime: '2h 34m' },
{ id: 'ctx-002', pool: 'pool-1', status: 'running', uptime: '1h 12m' },
{ id: 'ctx-003', pool: 'pool-2', status: 'idle', uptime: '45m' },
{ id: 'ctx-004', pool: 'pool-4', status: 'error', uptime: '5m' }
];
const webgpuFeatures = [
{ name: 'shader-f16', supported: true },
{ name: 'depth-clip-control', supported: true },
{ name: 'depth24unorm-stencil8', supported: true },
{ name: 'float32-filterable', supported: true },
{ name: 'rg11b10ufloat-renderable', supported: false },
{ name: 'bgra8unorm-storage', supported: true }
];
const logs = [
{ time: '14:32:05', level: 'info', message: '[pool-1] Initializing WebGPU context' },
{ time: '14:32:06', level: 'info', message: '[ctx-001] GPU adapter acquired: NVIDIA RTX 3080' },
{ time: '14:32:07', level: 'info', message: '[ctx-001] Device created with features: shader-f16, depth-clip-control' },
{ time: '14:32:08', level: 'warn', message: '[pool-4] Memory usage above 85% threshold' },
{ time: '14:32:10', level: 'info', message: '[scenario-2] Running Render Pipeline Validation' },
{ time: '14:32:12', level: 'info', message: '[scenario-2] Navigating to test page' },
{ time: '14:32:15', level: 'info', message: '[scenario-2] Executing drawTestScene()' },
{ time: '14:32:16', level: 'info', message: '[scenario-2] Screenshot captured: render-output.png' },
{ time: '14:32:17', level: 'info', message: '[scenario-2] Diff comparison: 0.02% difference (PASS)' },
{ time: '14:33:20', level: 'error', message: '[ctx-004] GPU device lost: out of memory' },
{ time: '14:33:21', level: 'info', message: '[pool-4] Attempting context recovery' },
{ time: '14:33:25', level: 'warn', message: '[scenario-3] Texture Sampling failed: diff threshold exceeded' }
];
// ============== STATE ==============
let selectedScenario = null;
let diffInterval = null;
// ============== INITIALIZATION ==============
document.addEventListener('DOMContentLoaded', () => {
initTabs();
renderScenarios();
renderResourcePools();
renderContainers();
renderWebGPUFeatures();
renderLogs();
initCanvases();
startMetricsSimulation();
});
// ============== TABS ==============
function initTabs() {
const tabBtns = document.querySelectorAll('.tab-btn');
tabBtns.forEach(btn => {
btn.addEventListener('click', () => {
tabBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
document.querySelectorAll('.tab-panel').forEach(p => p.classList.add('hidden'));
const tabId = btn.dataset.tab + '-tab';
document.getElementById(tabId).classList.remove('hidden');
});
});
}
// ============== SCENARIOS ==============
function renderScenarios() {
const list = document.getElementById('scenarioList');
list.innerHTML = scenarios.map(s => `
<div class="scenario-card card p-3 ${selectedScenario?.id === s.id ? 'selected' : ''}"
onclick="selectScenario(${s.id})">
<div class="flex items-start justify-between mb-2">
<span class="text-sm font-medium">${s.name}</span>
<span class="text-xs px-2 py-0.5 rounded ${getStatusClass(s.status)}">${s.status}</span>
</div>
<p class="text-xs text-[--fg-muted] mb-2">${s.description}</p>
<div class="flex items-center gap-2 text-xs text-[--fg-muted]">
<span>${s.steps.length} steps</span>
<span>•</span>
<span>${s.lastRun}</span>
</div>
</div>
`).join('');
}
function getStatusClass(status) {
const classes = {
passing: 'bg-[--accent-dim] text-[--accent]',
failing: 'bg-[--error]/20 text-[--error]',
pending: 'bg-[--warning]/20 text-[--warning]'
};
return classes[status] || '';
}
function selectScenario(id) {
selectedScenario = scenarios.find(s => s.id === id);
renderScenarios();
renderScenarioEditor();
}
function renderScenarioEditor() {
const editor = document.getElementById('scenarioEditor');
if (!selectedScenario) {
editor.innerHTML = `
<div class="text-center py-12 text-[--fg-muted]">
<svg class="w-16 h-16 mx-auto mb-4 opacity-30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
<p>Select a scenario to edit or create a new one</p>
</div>
`;
return;
}
editor.innerHTML = `
<div class="animate-in">
<div class="flex items-center justify-between mb-6">
<div>
<h2 class="text-lg font-semibold">${selectedScenario.name}</h2>
<p class="text-sm text-[--fg-muted]">${selectedScenario.description}</p>
</div>
<div class="flex gap-2">
<button class="btn-secondary text-sm" onclick="duplicateScenario(${selectedScenario.id})">Duplicate</button>
<button class="btn-primary text-sm" onclick="runScenario(${selectedScenario.id})">Run Now</button>
</div>
</div>
<div class="mb-6">
<h3 class="text-sm font-semibold mb-3">Automation Steps</h3>
<div class="space-y-2">
${selectedScenario.steps.map((step, i) => `
<div class="flex items-center gap-3 p-3 rounded bg-[--bg-elevated] border border-[--border]">
<span class="w-6 h-6 rounded bg-[--accent-dim] text-[--accent] text-xs flex items-center justify-center font-mono">${i + 1}</span>
<div class="flex-1">
<span class="text-sm font-mono text-[--accent]">${step.action}</span>
<span class="text-sm text-[--fg-muted] ml-2">${step.target || step.script || step.name || ''}</span>
</div>
<button class="text-[--fg-muted] hover:text-[--fg]">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"/>
</svg>
</button>
</div>
`).join('')}
<button class="w-full p-3 rounded border border-dashed border-[--border] text-[--fg-muted] hover:border-[--accent] hover:text-[--accent] transition-colors text-sm">
+ Add Step
</button>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="text-xs text-[--fg-muted] block mb-2">Retry on Failure</label>
<input type="number" class="w-full" value="3">
</div>
<div>
<label class="text-xs text-[--fg-muted] block mb-2">Step Timeout (ms)</label>
<input type="number" class="w-full" value="10000">
</div>
</div>
</div>
`;
}
function createScenario() {
const newScenario = {
id: scenarios.length + 1,
name: 'New Scenario',
description: 'Description for new scenario',
status: 'pending',
lastRun: 'Never',
steps: []
};
scenarios.push(newScenario);
renderScenarios();
selectScenario(newScenario.id);
}
function runScenario(id) {
addLog('info', `[scenario-${id}] Starting execution...`);
setTimeout(() => {
addLog('info', `[scenario-${id}] Step 1: Navigate to test page`);
}, 500);
setTimeout(() => {
addLog('info', `[scenario-${id}] Step 2: Waiting for GPU context`);
}, 1500);
setTimeout(() => {
addLog('info', `[scenario-${id}] Completed successfully`);
}, 3000);
}
// ============== DIFFING ==============
function initCanvases() {
const canvases = ['baselineRender', 'currentRender', 'diffRender'];
canvases.forEach(id => {
const canvas = document.getElementById(id);
if (!canvas) return;
const ctx = canvas.getContext('2d');
canvas.width = 640;
canvas.height = 360;
if (id === 'baselineRender') {
drawTestPattern(ctx, canvas.width, canvas.height, '#00d4aa');
} else if (id === 'currentRender') {
drawTestPattern(ctx, canvas.width, canvas.height, '#00d4aa', true);
} else {
ctx.fillStyle = '#0a0e14';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#2a3544';
ctx.font = '14px "Space Grotesk"';
ctx.textAlign = 'center';
ctx.fillText('Run diff to see comparison', canvas.width / 2, canvas.height / 2);
}
});
// Diff threshold slider
const slider = document.getElementById('diffThreshold');
const value = document.getElementById('thresholdValue');
if (slider && value) {
slider.addEventListener('input', () => {
value.textContent = slider.value + '%';
});
}
}
function drawTestPattern(ctx, w, h, color, withNoise = false) {
// Background
ctx.fillStyle = '#0a0e14';
ctx.fillRect(0, 0, w, h);
// Grid
ctx.strokeStyle = '#1a222d';
ctx.lineWidth = 1;
for (let x = 0; x < w; x += 40) {
ctx.beginPath();
ctx.moveTo(x, 0);
ctx.lineTo(x, h);
ctx.stroke();
}
for (let y = 0; y < h; y += 40) {
ctx.beginPath();
ctx.moveTo(0, y);
ctx.lineTo(w, y);
ctx.stroke();
}
// Main shape
ctx.fillStyle = color;
ctx.beginPath();
ctx.moveTo(w / 2, 60);
ctx.lineTo(w / 2 + 120, h - 60);
ctx.lineTo(w / 2 - 120, h - 60);
ctx.closePath();
ctx.fill();
// Inner shape
ctx.fillStyle = '#0a0e14';
ctx.beginPath();
ctx.moveTo(w / 2, 120);
ctx.lineTo(w / 2 + 60, h - 100);
ctx.lineTo(w / 2 - 60, h - 100);
ctx.closePath();
ctx.fill();
// Circles
for (let i = 0; i < 5; i++) {
const x = 100 + i * 110;
const r = Math.max(10, 20 + Math.sin(Date.now() / 1000 + i) * 10);
ctx.beginPath();
ctx.arc(x, 80, r, 0, Math.PI * 2);
ctx.fillStyle = `rgba(0, 212, 170, ${0.3 + i * 0.15})`;
ctx.fill();
}
// Noise for current render (simulating rendering differences)
if (withNoise) {
for (let i = 0; i < 500; i++) {
const x = Math.random() * w;
const y = Math.random() * h;
ctx.fillStyle = `rgba(255, 107, 107, ${Math.random() * 0.3})`;
ctx.fillRect(x, y, 2, 2);
}
}
}
function runDiff() {
const diffCanvas = document.getElementById('diffRender');
const ctx = diffCanvas.getContext('2d');
diffCanvas.width = 640;
diffCanvas.height = 360;
// Get baseline and current
const baselineCanvas = document.getElementById('baselineRender');
const currentCanvas = document.getElementById('currentRender');
const baselineCtx = baselineCanvas.getContext('2d');
const currentCtx = currentCanvas.getContext('2d');
const baselineData = baselineCtx.getImageData(0, 0, 640, 360);
const currentData = currentCtx.getImageData(0, 0, 640, 360);
const diffData = ctx.createImageData(640, 360);
let diffPixels = 0;
const threshold = parseInt(document.getElementById('diffThreshold').value) * 2.55;
for (let i = 0; i < baselineData.data.length; i += 4) {
const rDiff = Math.abs(baselineData.data[i] - currentData.data[i]);
const gDiff = Math.abs(baselineData.data[i + 1] - currentData.data[i + 1]);
const bDiff = Math.abs(baselineData.data[i + 2] - currentData.data[i + 2]);
const totalDiff = (rDiff + gDiff + bDiff) / 3;
if (totalDiff > threshold) {
diffPixels++;
diffData.data[i] = 255;
diffData.data[i + 1] = 107;
diffData.data[i + 2] = 107;
diffData.data[i + 3] = 255;
} else {
diffData.data[i] = baselineData.data[i] * 0.3;
diffData.data[i + 1] = baselineData.data[i + 1] * 0.3;
diffData.data[i + 2] = baselineData.data[i + 2] * 0.3;
diffData.data[i + 3] = 255;
}
}
ctx.putImageData(diffData, 0, 0);
const diffPercent = ((diffPixels / (640 * 360)) * 100).toFixed(2);
const results = document.getElementById('diffResults');
const passed = parseFloat(diffPercent) < 5;
results.innerHTML = `
<div class="p-3 rounded bg-[--bg-elevated]">
<div class="flex justify-between mb-2">
<span class="text-xs text-[--fg-muted]">Diff Pixels</span>
<span class="text-sm font-mono">${diffPixels.toLocaleString()}</span>
</div>
<div class="flex justify-between mb-2">
<span class="text-xs text-[--fg-muted]">Diff Percentage</span>
<span class="text-sm font-mono ${passed ? 'text-[--accent]' : 'text-[--error]'}">${diffPercent}%</span>
</div>
<div class="flex justify-between">
<span class="text-xs text-[--fg-muted]">Status</span>
<span class="text-sm font-medium ${passed ? 'text-[--accent]' : 'text-[--error]'}">${passed ? 'PASS' : 'FAIL'}</span>
</div>
</div>
<div class="p-3 rounded bg-[--bg-elevated]">
<div class="flex justify-between mb-2">
<span class="text-xs text-[--fg-muted]">SSIM</span>
<span class="text-sm font-mono">0.${97 + Math.floor(Math.random() * 2)}</span>
</div>
<div class="flex justify-between">
<span class="text-xs text-[--fg-muted]">DSSIM</span>
<span class="text-sm font-mono">0.00${Math.floor(Math.random() * 9)}</span>
</div>
</div>
`;
addLog('info', `[diff] Comparison complete: ${diffPercent}% difference`);
}
function approveDiff() {
addLog('info', '[diff] Baseline updated');
}
// ============== RESOURCES ==============
function renderResourcePools() {
const container = document.getElementById('resourcePools');
container.innerHTML = resourcePools.map(pool => `
<div class="card p-4">
<div class="flex items-center justify-between mb-3">
<span class="font-medium">${pool.name}</span>
<span class="text-xs px-2 py-0.5 rounded ${getPoolStatusClass(pool.status)}">${pool.status}</span>
</div>
<div class="space-y-3">
<div>
<div class="flex justify-between text-xs text-[--fg-muted] mb-1">
<span>Memory</span>
<span>${pool.used}/${pool.memory}MB</span>
</div>
<div class="metric-bar">
<div class="metric-fill" style="width: ${(pool.used / pool.memory) * 100}%"></div>
</div>
</div>
<div class="flex justify-between text-xs">
<span class="text-[--fg-muted]">GPU Contexts</span>
<span class="font-mono">${pool.gpu}</span>
</div>
</div>
</div>
`).join('');
}
function getPoolStatusClass(status) {
const classes = {
active: 'bg-[--accent-dim] text-[--accent]',
idle: 'bg-[--bg] text-[--fg-muted]',
warning: 'bg-[--warning]/20 text-[--warning]'
};
return classes[status] || '';
}
function renderContainers() {
const container = document.getElementById('containers');
container.innerHTML = containers.map(c => `
<div class="flex items-center justify-between p-2 rounded bg-[--bg] border border-[--border]">
<div class="flex items-center gap-2">
<div class="status-dot ${c.status === 'running' ? 'bg-[--accent]' : c.status === 'error' ? 'bg-[--error]' : 'bg-[--fg-muted]'}"></div>
<span class="text-sm font-mono">${c.id}</span>
</div>
<span class="text-xs text-[--fg-muted]">${c.uptime}</span>
</div>
`).join('');
}
function applyPoolConfig() {
const memory = document.getElementById('memoryLimit').value;
const gpu = document.getElementById('gpuContexts').value;
addLog('info', `[config] Pool updated: ${memory}MB, ${gpu} GPU contexts`);
}
// Core count slider
const coreSlider = document.getElementById('cpuCores');
const coreCount = document.getElementById('coreCount');
if (coreSlider && coreCount) {
coreSlider.addEventListener('input', () => {
coreCount.textContent = coreSlider.value;
});
}
// ============== METRICS ==============
function renderWebGPUFeatures() {
const container = document.getElementById('webgpuFeatures');
container.innerHTML = webgpuFeatures.map(f => `
<div class="flex items-center justify-between">
<span class="text-sm font-mono">${f.name}</span>
<span class="text-xs ${f.supported ? 'text-[--accent]' : 'text-[--error]'}">${f.supported ? 'Supported' : 'Unsupported'}</span>
</div>
`).join('');
// Recent runs
const runsContainer = document.getElementById('recentRuns');
runsContainer.innerHTML = scenarios.slice(0, 4).map(s => `
<div class="flex items-center justify-between p-2 rounded bg-[--bg] border border-[--border]">
<div class="truncate flex-1 mr-2 text-sm">${s.name}</div>
<span class="text-xs ${s.status === 'passing' ? 'text-[--accent]' : s.status === 'failing' ? 'text-[--error]' : 'text-[--warning]'}">${s.status}</span>
</div>
`).join('');
}
function startMetricsSimulation() {
const timeline = document.getElementById('timelineChart');
timeline.innerHTML = `
<canvas id="timelineCanvas" class="w-full h-full"></canvas>
`;
const canvas = document.getElementById('timelineCanvas');
const ctx = canvas.getContext('2d');
const resizeCanvas = () => {
const rect = timeline.getBoundingClientRect();
canvas.width = rect.width;
canvas.height = rect.height;
drawTimeline(ctx, canvas.width, canvas.height);
};
resizeCanvas();
window.addEventListener('resize', resizeCanvas);
// Update metrics periodically
setInterval(() => {
const frameTime = (14 + Math.random() * 6).toFixed(1);
const gpuUtil = Math.floor(70 + Math.random() * 20);
const memUsage = (1.0 + Math.random() * 0.5).toFixed(1);
document.getElementById('avgFrameTime').textContent = frameTime + 'ms';
document.getElementById('gpuUtil').textContent = gpuUtil + '%';
document.getElementById('memUsage').textContent = memUsage + 'GB';
}, 2000);
}
function drawTimeline(ctx, w, h) {
ctx.fillStyle = '#0a0e14';
ctx.fillRect(0, 0, w, h);
// Grid
ctx.strokeStyle = '#1a222d';
ctx.lineWidth = 1;
for (let y = 40; y < h - 20; y += 40) {
ctx.beginPath();
ctx.moveTo(60, y);
ctx.lineTo(w - 20, y);
ctx.stroke();
}
// Data points
const dataPoints = [];
for (let i = 0; i < 50; i++) {
dataPoints.push(50 + Math.random() * 40);
}
// Line
ctx.strokeStyle = '#00d4aa';
ctx.lineWidth = 2;
ctx.beginPath();
const stepX = (w - 80) / (dataPoints.length - 1);
dataPoints.forEach((val, i) => {
const x = 60 + i * stepX;
const y = h - 40 - (val / 100) * (h - 80);
if (i === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
});
ctx.stroke();
// Fill
ctx.lineTo(60 + (dataPoints.length - 1) * stepX, h - 40);
ctx.lineTo(60, h - 40);
ctx.closePath();
ctx.fillStyle = 'rgba(0, 212, 170, 0.1)';
ctx.fill();
// Labels
ctx.fillStyle = '#6b7a8f';
ctx.font = '10px "JetBrains Mono"';
ctx.textAlign = 'right';
for (let i = 0; i <= 4; i++) {
const y = h - 40 - (i / 4) * (h - 80);
ctx.fillText((i * 25) + '%', 50, y + 4);
}
ctx.textAlign = 'center';
ctx.fillText('Time (s)', w / 2, h - 5);
}
// ============== LOGS ==============
function renderLogs() {
const output = document.getElementById('logOutput');
output.innerHTML = logs.map(log => `
<div class="flex gap-3 mb-1">
<span class="text-[--fg-muted]">${log.time}</span>
<span class="${getLogColor(log.level)}">[${log.level.toUpperCase()}]</span>
<span>${log.message}</span>
</div>
`).join('');
output.scrollTop = output.scrollHeight;
}
function getLogColor(level) {
const colors = {
info: 'text-[--accent]',
warn: 'text-[--warning]',
error: 'text-[--error]'
};
return colors[level] || 'text-[--fg]';
}
function addLog(level, message) {
const now = new Date();
const time = now.toTimeString().slice(0, 8);
logs.push({ time, level, message });
renderLogs();
}
function clearLogs() {
logs.length = 0;
renderLogs();
}
// Log level filters
document.querySelectorAll('[data-level]').forEach(btn => {
btn.addEventListener('click', () => {
document.querySelectorAll('[data-level]').forEach(b => {
b.classList.remove('bg-[--accent-dim]', 'text-[--accent]');
b.classList.add('hover:bg-[--bg-elevated]');
});
btn.classList.add('bg-[--accent-dim]', 'text-[--accent]');
btn.classList.remove('hover:bg-[--bg-elevated]');
const level = btn.dataset.level;
const output = document.getElementById('logOutput');
const filtered = level === 'all' ? logs : logs.filter(l => l.level === level);
output.innerHTML = filtered.map(log => `
<div class="flex gap-3 mb-1">
<span class="text-[--fg-muted]">${log.time}</span>
<span class="${getLogColor(log.level)}">[${log.level.toUpperCase()}]</span>
<span>${log.message}</span>
</div>
`).join('');
});
});
// ============== MODALS ==============
function openSettings() {
document.getElementById('settingsModal').classList.remove('hidden');
}
function closeSettings() {
document.getElementById('settingsModal').classList.add('hidden');
}
function saveSettings() {
addLog('info', '[config] Settings saved');
closeSettings();
}
// Close modal on background click
document.getElementById('settingsModal').addEventListener('click', (e) => {
if (e.target.id === 'settingsModal') closeSettings();
});
// ============== KEYBOARD ==============
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') closeSettings();
});
</script>
</body>
</html>
Key Features
1. Scenario Management
- Create, edit, and run browser automation scenarios
- Step-by-step action builder (navigate, wait, execute, screenshot, assert, diff)
- Status tracking (passing/failing/pending)
2. Visual Diff Pipeline
- Side-by-side baseline vs current render comparison
- Pixel-level diff visualization with adjustable threshold
- SSIM/DSSIM perceptual metrics
- Region exclusion support
3. Resource Isolation
- Multiple GPU context pools with memory limits
- Container-level isolation monitoring
- Configurable CPU cores and memory allocation
- Real-time status indicators
4. Performance Metrics
- Frame time, GPU utilization, memory usage tracking
- Interactive timeline visualization
- WebGPU feature detection status
- Historical run data
5. Execution Logs
- Real-time log streaming with level filtering
- Color-coded severity levels
- Clear and filter functionality
Design Notes
- Industrial/Technical Aesthetic: Dark theme with cyan accent, grid background pattern
- Monospace fonts for code and technical data
- Meaningful interactions: Scenario selection, diff comparison, pool configuration
- Responsive layout: Works from mobile to desktop
- Accessibility: Keyboard navigation, semantic HTML, focus states