← Back to Roadmap

Priority 0C: Visual Verification & Testing Layer

P0C — Critical 5-7 days Backend + Frontend dev

What This Is

After an agent finishes its task (code, UI, fix, feature), it should prove its work visually. Not just "here's a diff" — but "here's what the app looks like now, here's the test passing, here's the before and after."

The user experience: Agent completes task → AO automatically captures screenshots, test recordings, before/after visuals → Dashboard shows: "I did this. Here's proof. Approve or reject?"

Think of it like a contractor showing you photos of the finished room before you sign off. Right now AO agents finish silently — you have to go check yourself.

Why This Matters

Trust problem: Users don't trust agent output they can't see. A diff is not proof. A screenshot of the working feature IS proof. Without visual verification, every PR needs manual review before merge. That defeats the purpose of autonomous agents.

What Competitors Do

ToolVisual VerificationHow
DevinFull browser in workspaceBuilt-in browser shows live app state. User sees what agent sees.
1codeLive browser previews"Preview dev branches in a real browser" — each worktree gets a live preview URL.
OpenHandsBrowser tool + workspaceAgent can browse, take screenshots, interact with the app it's building.
GoosePartial — via MCPCan use browser-use MCP server for web interaction. No built-in visual proof.
oh-my-claudecodeQA phase validationMulti-perspective review (architect + security + code reviewer) but no visual.
AONothingAgent creates PR. No proof of what it looks like. No approval flow.

The Verification Flow

Agent completes task

↓

AO verification layer kicks in

↓

Captures evidence:

↓

Dashboard shows verification card

"I completed issue #42. Here's what it looks like: [screenshot gallery]. Tests: 14/14 passing. Build: OK. Approve / Request Changes / Reject"

Implementation Steps

Phase 1: Screenshot Capture (2-3 days)

Add Playwright as optional dependency

Playwright can take screenshots and record videos of web apps headlessly. It's the standard for browser automation.

# In packages/core/package.json
"optionalDependencies": {
  "playwright": "^1.40.0"
}

If Playwright isn't installed, skip visual verification gracefully (just run tests, capture diffs).

Create VerificationService

// packages/core/src/verification-service.ts

interface VerificationResult {
  sessionId: string;
  timestamp: string;
  status: 'passed' | 'failed' | 'needs-review';
  
  // Evidence
  screenshots: ScreenshotArtifact[];
  testResults: TestResultArtifact | null;
  buildStatus: 'success' | 'failure' | 'skipped';
  diffSummary: DiffSummaryArtifact;
  videoRecording: string | null;  // path to .webm
  
  // Approval
  approvalStatus: 'pending' | 'approved' | 'rejected' | 'changes-requested';
  approvedBy: string | null;
  approvedAt: string | null;
}

interface ScreenshotArtifact {
  name: string;       // e.g. "homepage-after", "login-page-before"
  path: string;       // path to .png
  viewport: string;   // e.g. "1280x720", "375x812"
  type: 'before' | 'after' | 'comparison';
}

interface VerificationService {
  runVerification(sessionId: string, config: VerificationConfig): Promise<VerificationResult>;
  getVerification(sessionId: string): Promise<VerificationResult | null>;
  approve(sessionId: string, userId: string): Promise<void>;
  reject(sessionId: string, userId: string, reason: string): Promise<void>;
  requestChanges(sessionId: string, userId: string, comments: string): Promise<void>;
}

Implement screenshot capture for web projects

After agent pushes code:

  1. Detect if project has a dev server command (check package.json scripts for dev, start, serve)
  2. Start the dev server in the agent's worktree on a random port
  3. Wait for server ready (poll http://localhost:{port})
  4. Take screenshots using Playwright:
    • Desktop viewport (1280x720)
    • Mobile viewport (375x812)
    • Key pages (homepage, any pages mentioned in issue)
  5. Stop dev server
  6. Store screenshots as session artifacts
// Simplified screenshot capture
async function captureScreenshots(worktreePath: string, port: number): Promise<ScreenshotArtifact[]> {
  const browser = await playwright.chromium.launch({ headless: true });
  const page = await browser.newPage();
  
  const screenshots: ScreenshotArtifact[] = [];
  
  // Desktop
  await page.setViewportSize({ width: 1280, height: 720 });
  await page.goto(\`http://localhost:\${port}\`);
  await page.waitForLoadState('networkidle');
  const desktopPath = path.join(artifactDir, 'screenshot-desktop.png');
  await page.screenshot({ path: desktopPath, fullPage: true });
  screenshots.push({ name: 'desktop', path: desktopPath, viewport: '1280x720', type: 'after' });
  
  // Mobile
  await page.setViewportSize({ width: 375, height: 812 });
  const mobilePath = path.join(artifactDir, 'screenshot-mobile.png');
  await page.screenshot({ path: mobilePath, fullPage: true });
  screenshots.push({ name: 'mobile', path: mobilePath, viewport: '375x812', type: 'after' });
  
  await browser.close();
  return screenshots;
}

Before/after comparison

Take screenshots of the main branch BEFORE spawning the agent (baseline). After agent completes, take new screenshots. Store both and generate a visual diff.

Tools for visual diff: pixelmatch (lightweight), jest-image-snapshot, or simple side-by-side display.

Phase 2: Test Execution & Recording (1-2 days)

Auto-detect and run tests

After agent pushes, run the project's test suite:

  • Detect test runner: check package.json for test script, or look for pytest, cargo test, go test
  • Run tests in the agent's worktree
  • Capture: pass count, fail count, coverage %, output log
  • Store as test result artifact
interface TestResultArtifact {
  runner: string;       // 'vitest', 'jest', 'pytest', etc.
  total: number;
  passed: number;
  failed: number;
  skipped: number;
  coverage: number | null;  // percentage
  duration: number;     // ms
  output: string;       // truncated test output
  failedTests: string[];  // names of failing tests
}

Video recording of feature walkthrough

For UI changes, record a short video (5-15 seconds) of the feature in action:

  • Use Playwright's page.video() API
  • Navigate to the relevant page, interact with the feature
  • Generate a simple interaction script from the issue description (LLM-generated)
  • Store as .webm artifact

This gives the user a "demo video" of what the agent built — just like a developer would screen-record a feature for a PR review.

Phase 3: Approval Flow in Dashboard (2 days)

Verification card in session detail

New section in SessionDetail.tsx — the verification card:

  • Screenshot gallery: Before/after side-by-side, click to zoom
  • Test results: Green/red bar with pass/fail count
  • Build status: Compiled successfully or not
  • Video: Embedded video player (if recorded)
  • Diff summary: Files changed count, insertions, deletions

Approval buttons

Three actions:

  • Approve → Merge PR automatically (or mark ready-to-merge)
  • Request Changes → Send feedback to agent, agent iterates
  • Reject → Close PR, mark session as rejected

This closes the loop: agent works → proves it → human approves → PR merges. No context-switching to GitHub.

Notification on verification complete

When verification finishes, notify the user:

  • Dashboard: badge on session card ("Awaiting approval")
  • Slack/Discord: "Session #42 completed. Screenshots + tests ready for review."
  • Mobile (PWA): Push notification

Phase 4: Smart Verification Config (1 day)

Configurable verification per project

# ao.yaml
verification:
  screenshots:
    enabled: true
    viewports:
      - { width: 1280, height: 720, name: desktop }
      - { width: 375, height: 812, name: mobile }
    pages:
      - /
      - /login
      - /dashboard
  tests:
    enabled: true
    command: npm test       # override auto-detected
    coverageThreshold: 80   # minimum % to pass
  video:
    enabled: false          # opt-in, resource-intensive
    duration: 15            # max seconds
  build:
    enabled: true
    command: npm run build
  autoApprove:
    enabled: false          # if ALL checks pass, auto-merge
    requireCoverage: 80
    requireAllTestsPassing: true

Technology Choices

ComponentToolWhy
Browser automationPlaywrightBest headless browser API. Supports screenshots, video, multiple viewports. Used by 1code.
Visual diffpixelmatchZero deps, fast, lightweight pixel comparison
Video encodingPlaywright built-inpage.video() outputs .webm natively
Test detectionCustom (read package.json)Simple heuristic: check for vitest/jest/pytest/cargo test

How This Changes the User Experience

Before (current AO)

  1. Assign issue to AO
  2. Agent works... creates PR
  3. User gets notification: "PR created"
  4. User opens GitHub, reviews diff, checks out branch, starts dev server, tests manually
  5. User approves or requests changes

10-15 minutes per PR review, mostly manual.

After (with verification layer)

  1. Assign issue to AO
  2. Agent works... creates PR
  3. AO auto-captures: screenshots (desktop + mobile), test results, build status, video demo
  4. User gets notification: "PR ready for review — 14/14 tests passing, screenshots attached"
  5. User opens dashboard, sees screenshots + video + test results, clicks Approve
  6. PR merges automatically

30 seconds per PR review. Visual proof. One click to merge.

Acceptance Criteria