Skip to content

feat(review): wire up existing pixel-diff into a 'Diff' column (self-host) #3674

Description

@JSONbored

Context

Phase 2 of the visual-evidence upgrade (epic #3607, following #3667's full-page screenshot fix). A complete, tested pixel-diff implementation already exists at src/visual-agent/visual-diff.ts (compareRouteScreenshots/compareVisualCaptureSets — pixelmatch + pngjs, changed-pixel %, diff-PNG output, full coverage in test/unit/visual-diff.test.ts) but has zero production callers. It was ported during the reviewbot→gittensory convergence and never wired up.

Constraint (already verified, not a new investigation)

test/unit/worker-entry-boundary.test.ts statically asserts visual-agent/pixelmatch/pngjs are unreachable from the Worker bundle entry (src/index.ts) — this is deliberate (Node Buffer-dependent code, not guaranteed in the Workers runtime), not an oversight. The test only walks the import graph from src/index.ts, so any code path reachable only from src/server.ts (self-host) is unaffected by the boundary.

Deliverables

  • Call compareRouteScreenshots/compareVisualCaptureSets from a self-host-only code path (reachable only from src/server.ts, confirmed never reachable from src/index.ts) — reuse the existing module as-is, do not reimplement.
  • Extend unified-comment-bridge.ts's buildBeforeAfterCollapsible (currently a hardcoded 4-column table: Route | Viewport | Before | After) with a 5th "Diff" column, showing the diff-PNG when changedPixelPercent clears the module's noise threshold (default 0.05%), a dash otherwise. Match the existing column's cell-escaping/link pattern (attr() helper, <a href><img></a>).
  • Explicitly self-host-only for this phase — hosted-mode (Cloudflare Workers) diff-overlay needs its own follow-up investigation (a Workers-compatible PNG-decode path, e.g. DecompressionStream("deflate") feeding raw pixels into pixelmatch directly, since pixelmatch itself has no Node dependency).
  • Confirm worker-entry-boundary.test.ts still passes after wiring (proves the boundary wasn't violated).

Expected outcome

The "Visual preview" comment gains a Diff column making a visual change self-evident (a highlighted diff image) rather than requiring a reviewer to eyeball two full-page images side by side — for self-hosted repos (which covers the maintainer's own gittensory + metagraphed reviews today).

Part of #3607.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.roadmapOn the Wave-2 agent-layer roadmap board (project 9)visualUI/web visual work — owner-led, NOT for Gittensor contributors (extensions excepted)

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions