"use client"; function DiffLine({ line }: { line: string }) { if (line.startsWith("+ ")) { return
{line}
; } if (line.startsWith("- ")) { return
{line}
; } return
{line}
; } function CommandLine({ children }: { children: string }) { return (
$ {children}
); } function Terminal({ children }: { children: React.ReactNode }) { return (
{children}
); } function PageMockup({ label, buttonColor, diffMode, }: { label: string; buttonColor: string; diffMode?: boolean; }) { const dimOpacity = diffMode ? 0.15 : 1; return (
{label}
{/* Nav bar */} {/* Heading */} {/* Subtext */} {/* Input field */} {/* Button -- this is what changes */} {diffMode ? ( <> ) : ( )} Submit {/* Footer line */}
); } const snapshotDiffLines = [ " heading \"Sign Up\" [ref=e1]", " text \"Create your account\" [ref=e2]", "- textbox \"Email\" [ref=e3]", "+ textbox \"Email\" [ref=e3]: \"test@example.com\"", "- button \"Submit\" [ref=e4]", "+ button \"Submit\" [ref=e4] [disabled]", "+ status \"Sending...\" [ref=e7]", " link \"Already have an account?\" [ref=e5]", ]; export function DiffDemo() { return (
{/* Panel 1: Snapshot diff */}
Verify an action changed the page
agent-browser snapshot -i agent-browser fill @e3 "test@example.com" agent-browser click @e4
agent-browser diff snapshot
{snapshotDiffLines.map((line, i) => ( ))}
3 additions,{" "} 2 removals,{" "} 3 unchanged
{/* Panel 2: Screenshot diff */}
Catch a visual regression
agent-browser diff screenshot --baseline before-deploy.png
✗ 2.37% pixels differ
Diff image: ~/.agent-browser/tmp/diffs/diff-1708473621.png
1,137 different /{" "} 48,000 total pixels
); }