Visual validation is the cornerstone of PixelForge AI. Rather than assuming generated code matches the design, PixelForge renders the software in a real browser, captures photographic evidence, and verifies layout fidelity through perceptual diffing.
The browser runtime engine operates on a strict multi-tier priority model:
┌─────────────────────────────────────────────────────────┐
│ Capability Check │
└────────────────────────────┬────────────────────────────┘
│
┌────────────────┴────────────────┐
│ Has Agent Native Browser Tool? │
└───────┬─────────────────┬───────┘
│ YES │ NO
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│ Priority 1 │ │ Priority 2 │
│ Built-in Browser │ │ Playwright │
│ Provider │ │ Fallback Runtime │
└──────────────────┘ └──────────────────┘
Whenever the Agent runtime provides an integrated browser environment (such as OpenCode openchamber_web, Claude Code browser tools, or Model Context Protocol browser servers), PixelForge routes navigation and screenshot requests through this built-in capability. This eliminates unnecessary subprocess overhead and utilizes the agent's active sandbox.
If no agent-native browser is active, PixelForge autonomously falls back to a standalone headless Playwright Chromium runtime. Playwright is treated as an independent fallback, ensuring the project remains fully functional across headless CI pipelines and terminal CLI environments.
PixelForge tests interfaces across standardized viewport configurations:
| Preset | Dimensions | Device Scale | Intended Verification Target |
|---|---|---|---|
desktop-large |
2560 x 1440 px | 1x | Ultra-wide monitors (verifies no awkward right-side blanks) |
desktop |
1440 x 900 px | 1x | Standard laptop/desktop widescreen UI |
laptop |
1280 x 800 px | 1x | Compact laptops (MacBook Air 13") |
tablet |
768 x 1024 px | 2x | iPad / Tablet portrait viewports |
mobile |
390 x 844 px | 3x | Modern mobile smartphone viewports (iPhone 14/15/16) |
Run npm run cli:capture -- --target <url_or_file> --out ./validation --viewport multi to automatically produce all 5 canonical viewports and verify there are zero horizontal scrollbars or layout fractures.
When discrepancies are detected, PixelForge follows a strict hierarchy of fixes:
- Priority 1 (Layout & Viewport): Viewport occupancy (
100vw,min-h-screen), root wrappers, columns, and grid architecture. - Priority 2 (Component Geometry & Spacing): Component widths, min-heights, flex auto-margins, paddings, and section gaps.
- Priority 3 (Typography): Font family, font weight, line-height, letter spacing, and fluid
clamp()rules. - Priority 4 (Colors & Contrast): Background palettes, radial gradients, glassmorphism, and border contrasts.
- Priority 5 (Micro Details): SVG icon precision, border radii, elevation shadows, and hover animations.
Never optimize minor icons or shadows while major layout breaks or right-side blank areas exist.
PixelForge utilizes the pixelmatch anti-aliasing aware comparison algorithm combined with pngjs data stream normalization:
PixelForge filters font smoothing and sub-pixel edge rendering variations to avoid false-positive mismatches caused by browser font rasterizers.
Diff pixels are aggregated into spatial clusters using a 32x32 block grid. Clusters identify whether discrepancies are concentrated in headers, hero elements, cards, or footers.
When similarity is below the benchmark target (95.0%):
- The
DiffAnalyzerconverts pixel clusters into semantic diagnoses. - The agent reads the diagnosis (e.g.
Top Navigation: py-4 should be py-6). - The agent applies a surgical edit to the component.
- The browser re-renders and validates.
- The loop repeats (up to 3 times) until convergence.