# Review Pull Requests on a Blazor Web App

Yes. For each pull request the agent builds the Blazor app, checks migrations and formatting, opens the changed pages in a browser and posts one review.

[Run this on Rush](https://cloud.getrush.ai/run/review-pull-requests/blazor/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

Many Blazor mistakes compile. A button with `@onclick` on a page that has no render mode builds cleanly and does nothing when clicked; a model property added without a migration builds cleanly and fails on the first query. The agent therefore reads the app's conventions before the diff. In an app like `10.0/BlazorWebAppMovies` in dotnet/blazor-samples, the project file targets `net10.0` with `Nullable` enabled; `Program.cs` registers a context factory over SQL Server and maps Razor components with interactive server rendering; `Components/Pages/MoviePages/Index.razor` is the one movie page that declares `@rendermode InteractiveServer`, while `Create.razor`, `Edit.razor` and `Delete.razor` are static forms marked `Enhance` with a `FormName`, and the first two bind a `[SupplyParameterFromForm]` property. The repository has an `.editorconfig`, a `Migrations` folder with a model snapshot, no test project, and no workflow that builds this app.

With nothing in CI to lean on, the agent runs the checks itself on the pull request branch. `dotnet build --configuration Release` surfaces nullable warnings the diff introduces. `dotnet ef migrations has-pending-model-changes` fails when a change to `Models/Movie.cs`, whose attributes such as `[StringLength(60, MinimumLength = 3)]` and `[Column(TypeName = "decimal(18, 2)")]` define the schema, arrives without a migration. `dotnet format --verify-no-changes` is run on the base branch and on the pull request branch and only the difference is reported: the `.editorconfig` asks for `end_of_line = crlf`, so on a Linux checkout the whole tree can be flagged and the raw output would bury the author's two real issues.

Then it reads the diff against the patterns the existing pages follow. Every page takes `IDbContextFactory` and creates a context per operation with `using var`; a change that injects the context itself into an interactive component gives it the lifetime of the user's circuit, with stale tracked entities to match. The list filters with `context.Movie.Where(...)` on an `IQueryable` so QuickGrid pages in the database; a `ToList()` added upstream, or a C# method the provider cannot translate, moves that work into memory or throws at run time. The edit form binds the whole `Movie` from the posted form and saves it with `EntityState.Modified`, under a comment in the file about overposting, so a new property on the model becomes something any user can post unless the diff also restricts binding. Pages that load by id call `NavigationManager.NotFound()` when the row is missing, and a new one should too.

Finally it looks at the result. The sandbox has no Docker, so the agent installs it with `sudo apt-get install -y docker.io`, starts `dockerd`, runs Microsoft's SQL Server image for Linux, applies the migrations including any the pull request adds, starts the app and opens each changed page in the sandbox's browser. It exercises what the diff touched, a new column in the grid, a new field in a form with a valid and an invalid value, and takes a screenshot of each state.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Review this pull request to our Blazor Web App. Read the .csproj, Program.cs, .editorconfig, Models, Data, the Migrations folder with its model snapshot, Components/_Imports.razor and every page under Components/Pages first, and note each page's render mode and how it gets its DbContext. On the pull request branch run dotnet restore, dotnet build --configuration Release and dotnet ef migrations has-pending-model-changes, and quote every warning and error with file and line. Run dotnet format --verify-no-changes on the base branch and on the pull request branch and report only what the pull request adds. Then read the diff: an event handler or @bind on a component with no interactive render mode; a DbContext injected directly instead of created from the factory per operation; a query that leaves IQueryable before paging or uses a method EF Core cannot translate; a form that binds a model property users must not set; a static form missing FormName, the antiforgery-protected EditForm or SupplyParameterFromForm; a page that loads by id and does not handle a missing row; a model change with no migration, or a migration whose Down does not reverse its Up. Install Docker in the sandbox, start SQL Server from Microsoft's Linux image, apply the migrations, run the app and open every changed page in the browser; exercise what the diff changed with one valid and one invalid input and attach a screenshot of each. Post one review on the pull request with file and line for every finding and the command output quoted. Do not push commits.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app/pull/42"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

One review on the pull request. It starts with four lines, build, pending model changes, formatting and the browser pass, each marked pass or fail, with new compiler warnings quoted in full. Findings follow by file and line. Each one names the existing page that shows the pattern being departed from, for example that `Index.razor` disposes its context in `DisposeAsync` while the new component never does. Screenshots of the changed pages, in their valid and invalid states, are attached so a reviewer sees the result without checking out the branch.

Where the agent ran something to settle a question, the review says what it ran. A claim that a query cannot be translated comes with the exception text from the running app; a claim that a migration does not roll back comes with the output of applying and reverting it against the sandbox database. The complete command record is on the session, readable with `GET /o/{org}/sessions/{id}/messages`.

The review comments and does not approve. A person still judges what a sandbox cannot: whether the feature is wanted, whether a new column's type suits data the test database does not hold, and how the page behaves for a user on a slow connection whose circuit drops mid-edit.

## Run it on every pull request opened

Create an automation in the Project that holds the repository, with this prompt, read-only switched on, and a `github` trigger on `pull_request.opened` and `pull_request.synchronize`. Read-only runs can read the repository and comment but cannot push. The trigger adds the pull request after the prompt and substitutes nothing into it; `branch_patterns` limits it to pull requests whose base is your main branch.

Dependency bots are worth a thought here. A repository with a `dependabot.yml` that groups NuGet updates weekly gets pull requests from a bot, and the `github` trigger never fires for bot senders or forks, only for an owner, member or collaborator. A bot's pull request is reviewed when a maintainer starts a run by hand, with the pull request URL in `resources` as in the request above. A fork's pull request keeps its branch in the fork, so a maintainer pushes the contributor's commits to a branch in the repository itself and opens the pull request from there.

## Why run it on Rush?

A human reviewer of a Blazor change usually reads the diff and trusts the build, because checking out the branch, pointing it at a database, migrating and clicking through the changed page costs more than the review seems worth. That is exactly where render mode mistakes and untranslatable queries get through, since neither is visible in a diff. The agent has its own sandbox with a database and a browser for each pull request, so running the page is part of every review, not a step skipped under time pressure.

Several pull requests open at once each get their own sandbox and their own database, so a migration under review in one cannot disturb another. What comes back is a review whose every finding has a file, a line and, where it was run, the output, plus screenshots that show the page as it would ship.

## Frequently asked questions

### Can it tell when a component needs an interactive render mode?

Yes. It reads which pages and layouts declare a render mode and flags event handlers and two-way bindings on components that would render statically. It then confirms in the browser: a control that does nothing when used is recorded with a screenshot and the missing directive named.

### Does this work for Blazor WebAssembly or Auto render modes?

The same review applies, with extra checks. For components that can run in the browser the agent also looks for server-only services injected into them and for code in a `.Client` project that reaches the database directly, and it loads the page long enough for the WebAssembly runtime to take over before judging behaviour.

### The app has no tests. Is a review still worth running?

That is when it helps most, because building, checking migrations and opening the page are then the only verification the change gets. The review states at the top that there is no test project, so nobody reads a pass as more than it is.

### Why does it run dotnet format on the base branch as well?

To separate the author's formatting issues from the repository's. Line ending rules in an `.editorconfig` can flag every file on a machine that checked the code out with different endings, and reporting only what the pull request adds keeps the review about the change.

## More Blazor jobs

- [Write bUnit Tests for a Blazor Web App](https://getrush.ai/run/write-bunit-tests/blazor/)
- [Write Playwright Tests for a Blazor Web App](https://getrush.ai/run/write-playwright-tests/blazor/)
- [Add CSV Export to a Blazor Web App](https://getrush.ai/run/add-csv-export/blazor/)

## The same job on other stacks

- [Review Pull Requests on a Chrome Extension Project](https://getrush.ai/run/review-pull-requests/chrome-extension/)
- [Review Pull Requests on a Cloudflare Workers Project](https://getrush.ai/run/review-pull-requests/cloudflare-workers/)
- [Review Pull Requests on a CMake C++ Library](https://getrush.ai/run/review-pull-requests/cmake/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
