~/ravisvi/blog $ cat android-agent-visual-ui-checks.md
← Blog Home

Adding visual UI checks to my Android agent workflow

Android Jetpack Compose Robolectric TinyTeam

I'm building a personal Android fitness app (SimplyFit) using Antigravity and multiple models. The workflow ended up needing agents with distinct roles suited to each model, which turned into a small GitHub Actions harness (TinyTeam).

Once those agents started editing UI code, I needed a way to check visual changes in CI without booting an Android Emulator on every PR. I'm new to Android dev, so I hadn't come across Roborazzi or Paparazzi yet and didn't want to invest in a dedicated framework before knowing what I needed. Instead, I put together a small Robolectric + pure-Python PNG diff setup to learn how JVM rendering works. With current coding and multimodal models, getting the render tests, pixel differ, and inline PR summaries running was surprisingly painless.

Approach: Deterministic checks before LLM calls

Running a vision model on every screen on every commit gets noisy and expensive quickly, so I split the check into deterministic steps first and multimodal review only when pixels actually move:

Compose UI Test (Robolectric Native Graphics on JVM)
   │  └─ 0 tokens: >= 48dp touch-target & 1.3x font-scale checks + PNG renders
   ▼
Pure-Python Pixel Differ (visual_diff.py)
   │  └─ 0 tokens: diff vs. goldens; skip PNGs & LLM when 0 screens changed
   ▼
Before | After | Diff Composites on Orphan Branch (tinyteam-artifacts)
   │  └─ Embedded directly in the GitHub PR
   ▼
Multimodal Review (when visual diffs trigger, or on targeted UX passes)

On the Android side, turning on Robolectric's Native Graphics mode (@GraphicsMode(GraphicsMode.Mode.NATIVE)) and robolectric.pixelCopyRenderMode = "hardware" in app/build.gradle.kts lets Jetpack Compose draw onto an Android Canvas inside a normal JUnit test on standard ubuntu-latest GitHub Actions runners without an emulator or KVM.

In SimplyFitGoldenScreenshotTest.kt (since migrated to Roborazzi in PR #18), the test mounts the app shell at a Pixel viewport (w411dp-h891dp-xxhdpi), checks >= 48dp bottom-nav touch targets, clicks through the tabs, and dumps LocalView.current to PNG:

private fun captureSnapshot(screenName: String) {
    composeRule.waitForIdle()
    val view = checkNotNull(hostView)
    val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
    view.draw(Canvas(bitmap))
    writePng(File("build/outputs/snapshots", "$screenName.png"), bitmap)
    if (shouldRecordGoldens()) {
        writePng(File("src/test/snapshots", "$screenName.png"), bitmap)
    }
    bitmap.recycle()
}

Running Gradle with -PrecordSnapshots=true refreshes the committed goldens; a regular ./gradlew testDebugUnitTest just renders fresh PNGs into build/outputs/snapshots/.

For diffing, I wrote visual_diff.py using only Python's standard library (struct + zlib) so tinyteam stays dependency-free. It compares renders against goldens (channel tolerance 8, change threshold 0.25%) and writes Before | After | Pixel Diff composites to an orphan tinyteam-artifacts branch, keeping binary PNGs out of main while rendering them inline on GitHub PRs. Building it was fun, though making a custom differ fully effective needs quality iterations of its own.

Results

1. Inline PR diffs on Linux CI (ravisvi/fit#10 vs. #12)

When TinyTeam's developer agent implemented Feature Request #9 (surfacing the last-session recap and next-workout Coach focus across Today, Runs, and Strength), it opened PR #10, passed ubuntu-latest CI without an emulator, and attached the diff report automatically. As a control, PR #12 changed only docs and a policy test (no app UI code):

Metric PR #10 (UI Feature Change) PR #12 (README + Policy Test, no UI changes)
GitHub Actions CI (ubuntu-latest) PASS (2m 41s) PASS (3m 38s)
Suites / Tests 29 suites / 211 tests 29 suites / 212 tests
UI Visual Diffs 4 changed / 5 checked 0 changed / 5 checked

On PR #10, the 4 changed screens showed 14.24% to 40.31% pixel diffs, while the untouched Settings screen matched at 0 changed pixels out of 3.3 million. On PR #12, all 5 of 5 screens matched with zero false positives.

Here are the actual Before | After | Pixel Diff composites from PR #10:

SimplyFit Runs tab Before, After, and Pixel Diff from PR #10
Runs tab (dark mode): Before | After | Pixel Diff from PR #10 (40.31% pixels changed due to vertical shift).
SimplyFit Today tab (dark mode) Before, After, and Pixel Diff from PR #10
Today tab (dark mode): Before | After | Pixel Diff from PR #10 (14.24% pixels changed).
SimplyFit Today tab (light mode, 1.3x font scale) Before, After, and Pixel Diff from PR #10
Today tab (light mode, 1.3x font scale): Before | After | Pixel Diff from PR #10 (18.40% pixels changed).

I was surprised the review agents could make sense of these 3-panel diffs—or at least claimed they could when reviewing the PR. For me, the red highlight mostly acted as a quick marker of where to focus and what changed. A better test setup would diff individual subcomponents inside a screen instead of comparing the entire viewport at once.

2. Multimodal review nits on rendered screens

Pixel diffs show what moved, not whether the screen is readable. During SimplyFit's Phase 8 palette refresh, passing the JVM-rendered PNGs and UX spec to a multimodal review pass flagged a few visual issues that passed every unit test. Most were small nits around glanceability and keeping one consistent color per state (red for alerts, amber for caution, green for Zone 2 progress, neutral slate for defaults). I'm not sure how much of the color stuff jumps out right away to the human eye compared to an agent's eye, but as I use the app more I expect I'll subconsciously map colors to states, so keeping the design language consistent is worth it:

Tailor sheet (left = before, right = after): It was hard to tell at a glance which options were active, because the selected chips (Sore — Protect Run, 30-Min Express) blended into the dark background (1.26:1) while unselected outlined chips stood out more. The dark amber caution pill also sat close enough to red (1.08:1) that caution looked like an error state. Adding a blue border + ✓ and warming up the amber fixed both.

Tailor Workout Sheet Before (left) vs After (right) showing dark amber pill and selected filter chip contrast fixes
Tailor Workout Sheet: Before (left) vs. After (right) — selected chip contrast (1.26:1) and dark amber pill separation.

Today screen (left = before, right = after): Two more consistency nits: the red Cap ≤ 138 BPM box signaled a peak-soreness alert while its Why: line hid the squat-soreness reason, and neutral states (Streak: 0 wks, New routine) reused the same green meant for Zone 2 progress. Aligning the Why: copy and moving neutral pills to slate kept each color tied to one meaning.

Today screen Before (left) vs After (right) showing aligned red HR-cap explanation and neutral zero-streak badges
Today screen: Before (left) vs. After (right) — aligned HR-cap soreness explanation and neutral slate for zero-streak / new-routine pills.

Learnings

After getting this working, I looked up what Android teams normally use for JVM screenshot tests—mostly Paparazzi (Cash App) and Roborazzi:

Approach Engine Good at Trade-offs
Paparazzi Android Studio LayoutLib Fast static component renders and long-scroll captures. No full Android runtime, so multi-tab click flows are awkward; sensitive to AGP upgrades.
Roborazzi Robolectric Native Graphics Same JVM engine I used, plus Gradle record/verify tasks, perceptual diffing, and Compose helpers. Adds a Gradle plugin tied to Android/KMP rather than a stack-agnostic script.
Custom Robolectric + visual_diff.py Robolectric Native Graphics No extra Gradle plugins or Python deps; diff/composite script is reusable for Playwright or iOS later. Requires maintaining custom capture boilerplate and naive pixel diffing.

Skipping Paparazzi makes sense for SimplyFit since the tests click through live tabs. Roborazzi is much closer to what I built on the exact same engine, and its perceptual diffing helps with noisy diffs. I opened ravisvi/fit#16 for TinyTeam to evaluate migrating the capture layer while keeping PR-embedded Before | After | Diff composites and zero-emulator CI, and TinyTeam just implemented and merged that migration in PR #18.

Most of the UI issues I actually caught happened while using the app in the gym, and they were usability problems rather than visual ones. To make reporting those easier on the spot, I filed a feature request (ravisvi/fit#19) for an in-app button on every screen that attaches a screenshot and sanitized logs straight to a GitHub issue, and TinyTeam merged it in PR #35. Figuring out how to catch that kind of usability friction earlier is something I want to explore next.

Putting JVM rendering and pixel diffs in front of a multimodal model gave me a lightweight way to sanity-check agent UI changes on Linux CI. Full-screen diffs still get noisy on vertical shifts, Robolectric skips real keyboards and system dialogs, and macOS vs. Linux fonts can drift, so it does not replace real-device testing. As a starting point, though, it works well enough to catch real issues while I learn.

Next

Next up, I'm testing the new in-app gym issue reporter (PR #35) during real workouts, letting TinyTeam run unattended on SimplyFit to collect real cost, noise, and merge numbers, and adding Playwright and iOS adapters. If you're curious, check out both repos or follow the open issues on SimplyFit and TinyTeam.