# A Video on Every Flutter App MR, Made by an Agent on a Fly.io Sprite

> Every merge request on a Flutter app gets a video of the new feature, recorded by an agent on a Fly.io Sprite. flutter test turns into video frames, connectors hold the GitHub token, and each video costs about US$ 0.40 of model.

- HTML version: https://tiagodanin.com/post/a-video-on-every-flutter-mr-made-by-an-agent-on-a-fly-io-sprite/
- Site index for AI assistants: https://tiagodanin.com/llms.txt

- Date: 2026-11
- Language: English
- Tags: Flutter, Testing, Tools, Article
- Originally published at: https://www.linkedin.com/pulse/um-v%C3%ADdeo-em-cada-mr-de-app-flutter-gerado-por-agente-num-tiago-danin-qcarf/

![A video on every Flutter app MR, made by an agent on a Fly.io Sprite](/images/posts/um-video-em-cada-mr-de-app-flutter-gerado-por-um-agente-num-sprite-do-fly-io/cover-en.png)

A year ago I built an agent that controls my phone, so I could test my apps and generate artifacts for me: [Android-Debug-Bridge-MCP](https://github.com/TiagoDanin/Android-Debug-Bridge-MCP), with the [adb-cli](https://github.com/TiagoDanin/Android-Debug-Bridge-MCP/blob/main/skills/adb-cli/SKILL.md) skill. I have used it since, but a new need showed up. I work on a banking app and, sometimes, three screenshots are not enough to show what was fixed. Sometimes I need to record a video. Recording that from inside an emulator, using that skill, is not fast.

Before getting to the video, it is worth separating the kinds of test, because the solution came from one of them:

- **Black box:** sees the app only through the interface, without knowing the code. It is real: the app installed on an emulator or a device. My example: the ADB agent.
- **White box:** has access to the code and swaps parts for fakes. It is fictional. My example: `flutter test` with `find.byType` and fake plugins.
- **Gray box:** mixes both, with real screens, controlled data and user gestures. It is fictional, but with the real interface. My example: the video.

I have already tested my apps this way. I know coverage exists, so I started wondering how I could make a video out of it.

## How Flutter-MR-Video-Agent was born

I kept thinking about it until, recently, Fly.io, where I usually host my projects, launched a contest to use the Sprite to build an agent: [Fly.io Hacksgiving 2026](https://fly.io/hacksgiving/). So I thought, what if every MR had an agent that generated videos automatically, whether it is mine or someone else's? That is how I started [Flutter-MR-Video-Agent](https://github.com/TiagoDanin/Flutter-MR-Video-Agent).

## Turning the test screenshots into a video

Something I have been studying is that `flutter test` can simulate screenshots. That is how [`matchesGoldenFile`](https://api.flutter.dev/flutter/flutter_test/matchesGoldenFile.html) compares the screen with a stored image. I thought, what if I could turn those simulated captures into a video? That is exactly what I did.

The one doing it is the director, the `DemoDirector` class. It advances the test clock in steps of one thirtieth of a second, captures each frame and hands the pixels to ffmpeg:

```dart
Future<void> _captureFrame() async {
  final boundary =
      boundaryKey.currentContext!.findRenderObject()! as RenderRepaintBoundary;

  await tester.runAsync(() async {
    final image = await boundary.toImage();
    final bytes = await image.toByteData(format: ui.ImageByteFormat.rawRgba);
    image.dispose();
    encoder.stdin.add(bytes!.buffer.asUint8List());
    await encoder.stdin.flush();
  });
  framesWritten++;
}
```

The `encoder` is an ffmpeg process that the test itself opens. It receives the raw frames and already encodes them as H.264. The video time comes from the frame count (`framesWritten / framesPerSecond`) and not from the machine clock, so the test can run slower or faster than the video and the result comes out the same. The director also records the instant of each tap and each swipe, and that list is what the sound is mixed from afterwards.

The skill installs these files in the app, under `tool/demo_video/`:

- `demo_director.dart`: the director, with caption, zoom camera, tap, swipe and wait.
- `demo_stage.dart`: the 1080x1920 stage, with a phone frame, a visible finger and the first screen.
- `demo_runner.dart`: loads the fonts, opens ffmpeg and runs the script inside a `testWidgets`.
- `demo_logo_png.dart` and `demo_logo_svg.dart`: the app logo.
- `demo_app.dart`: the only file per app, with the screen, the plugin fakes and the script.

Only `demo_app.dart` changes from one MR to the next, and it is the only file Claude Code edits. It reads the diff, picks the real screen the feature touched, swaps for fakes the plugins that do not exist in the test and writes the script. The first screen of the video shows the app logo, the title of the change, the MR number and who opened it:

![First screen of the video in four apps: Virtual Pocket, Scoreboard, Mini Cenários and Poker Trainer](/images/posts/um-video-em-cada-mr-de-app-flutter-gerado-por-um-agente-num-sprite-do-fly-io/01-primeira-tela.png)

## What a Sprite is and why I used one

Okay Tiago, but where does the Sprite come in? A Sprite is a Fly.io microVM with a persistent disk. It wakes up when it receives a request, sleeps when it has no activity, and does not bill compute while idle. If I were to build this to record video, I would have three places to run it:

- **GitHub Actions:** bills per minute (about US$ 0.012 for a 2-minute job). The MR code runs on a clean VM, destroyed at the end of the job, and the API credential sits as a secret inside the job.
- **Fly.io Sprite:** bills per use (about US$ 0.0055 for a 2-minute job, assuming 2 CPUs and 4 GB in average use). The code runs in an isolated microVM, away from my files, and the credential sits in a connector, outside the machine.
- **My machine:** free. The MR code runs where my files and keys are, and the token sits in my environment.

Sources: [GitHub](https://docs.github.com/en/billing/reference/actions-runner-pricing) and [Fly.io](https://fly.io/sprites/). The Sprite figure is a calculation with a profile I assumed (2 CPUs and 4 GB), because I did not measure the usage of each job.

On my machine it is free, but there is the risk of running code that someone opened in an MR, and that is nothing more than a script that may be malicious. On GitHub CI I would have to connect Claude Code and install the skill every time. [OWASP](https://cheatsheetseries.owasp.org/cheatsheets/GitHub_Actions_Security_Cheat_Sheet.html) recommends not using self-hosted runners on public repositories for the same reason: whoever opens a PR can run code on them. Fly.io is the solution: sandbox, low price, persistent, and I can send the bot in there.

It also has connectors, which let me use APIs without exposing my authentication token. The connector keeps the credential in Fly's gateway, and the machine only says the path:

```bash
curl -s "https://api.sprites.dev/v1/gateway/github/<connection_id>/repos/OWNER/REPO/pulls/33"
```

There is no authorization header: the gateway recognizes that the call comes from inside the Sprite and adds the credential. I use two connectors, a GitHub one with OAuth to read the MR and comment, and another of the Custom API type to upload the video, since the attachment lives at `uploads.github.com`.

## Calling the Sprite when I open an MR

Since the Sprite works on demand, I needed someone to call my machine to wake it up. The caller is a GitHub Action that lasts seconds: it sends a request to the Sprite's public URL and ends, without waiting for the work.

```yaml
on:
  pull_request:
    types: [opened, synchronize, reopened]
...
jobs:
  trigger:
    ...
    steps:
      - name: Wake the Sprite
        env:
          SPRITE_URL: ${{ secrets.SPRITE_URL }}
          SPRITE_SECRET: ${{ secrets.SPRITE_SECRET }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          HEAD_SHA: ${{ github.event.pull_request.head.sha }}
        run: |
          curl --fail-with-body -sS --max-time 30 -X POST "$SPRITE_URL/jobs" \
            -H "X-Webhook-Secret: $SPRITE_SECRET" -H "Content-Type: application/json" \
            -d "$(jq -n --arg repo "$GITHUB_REPOSITORY" --argjson number "$PR_NUMBER" --arg sha "$HEAD_SHA" \
                  '{repo: $repo, number: $number, sha: $sha}')"
```

In the demo video I told this as a scene. When someone opens an MR, without the tool all I have to read is the diff. With the tool, as soon as the MR opens the Sprite already comments on it that it is generating the video. The comment appears before any work is done, so the person who opened the MR and the person who will review it both know the video is on its way.

![Demo video frame: back on the MR conversation, a comment says "Generating a demo video of this pull request" and that it will be replaced by the video](/images/posts/um-video-em-cada-mr-de-app-flutter-gerado-por-um-agente-num-sprite-do-fly-io/05-comentario-gerando.png)

The Sprite does the work, and everything it says to GitHub goes through the connectors. It reads the MR through the GitHub connector, Claude Code writes the script, `flutter test` and ffmpeg record, the video goes up through the upload connector, and the comment that said "generating" is edited and becomes the video. At the end the Sprite deletes the code and the video and goes back to sleep.

![Demo video frame: the GitHub Actions card, the Sprite card with the steps done and the "video" and "comment" packets going back to the MR through the connectors](/images/posts/um-video-em-cada-mr-de-app-flutter-gerado-por-um-agente-num-sprite-do-fly-io/06-sprite-e-conectores.png)

The whole flow looks like this:

1. I open the MR.
2. The GitHub Action calls the Sprite URL and ends.
3. The Sprite wakes up and comments on the MR: generating the video.
4. It reads the MR and the diff through the GitHub connector.
5. Claude Code edits only `demo_app.dart`.
6. In `flutter test`, the director captures the frames.
7. ffmpeg builds the video and mixes the music and the sounds.
8. The video goes up through the upload connector.
9. The same comment is edited, now with the video.
10. The Sprite deletes the code and the video and goes back to sleep.

## The video at work

This is the video of Mini Cenários MR #3, which adds an overall progress bar to the achievements screen: the new bar starts at 0 of 12 and goes to 2 of 12 after two goals are claimed.

![Mini Cenários MR video as a GIF: the achievements screen with the progress bar going from 0 of 12 to 2 of 12](/images/posts/um-video-em-cada-mr-de-app-flutter-gerado-por-um-agente-num-sprite-do-fly-io/02-video-mini-cenarios.gif)

The video is 26 seconds long, and the job that made it finished in three attempts, because Claude Code writes the script and sometimes gets the first one wrong.

## What each MR cost

I opened six test MRs across four apps. The cost of each comes from the report Claude Code delivers at the end of the job:

- Virtual Pocket #33, fan speed button: 2 attempts, US$ 0.28.
- Scoreboard #3, lead badge on the score: 2 attempts, US$ 0.45.
- Scoreboard #4, tie badge: 1 attempt, US$ 0.27.
- Mini Cenários #3, progress bar: 3 attempts, US$ 0.55.
- Poker Trainer #5, lesson rating: 3 attempts, US$ 0.49.
- Poker Trainer #6, medal in the ranking: 2 attempts, US$ 0.35.

The model was always Sonnet 5.5 at low effort, and this value is calculated with the API prices. I used Claude Code, which is much cheaper than the API, so it is worth comparing the two ways of paying:

- **Without Claude Code (API per token):** billed per million tokens, US$ 2 input and US$ 10 output on Sonnet 5.5 (cache read at US$ 0.10). The six MRs cost US$ 2.39.
- **With Claude Code (plan):** a monthly fee of US$ 20 (Pro), US$ 100 (Max) or US$ 200 (Ultra). Nothing per token: usage counts against the plan limit. The six MRs equal 12% of Pro, 2.4% of Max or 1.2% of Ultra.

Sources: [API pricing](https://platform.claude.com/docs/en/about-claude/pricing) and [plans](https://claude.com/pricing). `claude -p` logged in with the plan account still consumes the subscription limit. The fraction of the monthly fee is only an order of magnitude, because Anthropic measures the plan limit in usage and not in dollars.

## Conclusion

I wanted to show what a new feature solved without recording from inside an emulator and without running, on my machine, the code someone opened in an MR. Today, as soon as I open an MR, it gets a comment saying the video is being generated, and that same comment becomes a vertical video of under 30 seconds, made from the tests the app already has, for about US$ 0.40 of model (nothing per token with the Claude Code plan), and the machine cost cents on Fly.io.

The video shows the real interface of the app, but it is not a device. It does not replace the ADB agent or QA on a device. Another limit is security: the MR code runs as the same user as the server, so a malicious MR could read the Claude Code token. That is why the server ignores fork MRs and only accepts the repositories on its list.

The next step is GitLab, because the server only talks to GitHub for now. Meanwhile, the repository has a sample app and MRs open on it so you can see the result: [#1](https://github.com/TiagoDanin/Flutter-MR-Video-Agent/pull/1) with the up and down arrows, [#2](https://github.com/TiagoDanin/Flutter-MR-Video-Agent/pull/2) with the bigger add button and [#3](https://github.com/TiagoDanin/Flutter-MR-Video-Agent/pull/3) with the undo button. The code and the video demo are at [github.com/TiagoDanin/Flutter-MR-Video-Agent](https://github.com/TiagoDanin/Flutter-MR-Video-Agent).

---

Published by Tiago Danin. Free to quote with attribution and a link to https://tiagodanin.com.
