Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plugins": [
{
"name": "visualci",
"version": "0.1.29",
"version": "0.1.30",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"author": { "name": "DocSpring", "url": "https://visualci.com" },
"homepage": "https://visualci.com/docs/skills/",
Expand Down
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "visualci",
"version": "0.1.29",
"version": "0.1.30",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"author": { "name": "DocSpring", "url": "https://visualci.com" },
"homepage": "https://visualci.com/docs/skills/",
Expand Down
2 changes: 1 addition & 1 deletion .cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "visualci",
"displayName": "VisualCI",
"version": "0.1.29",
"version": "0.1.30",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"author": {
"name": "DocSpring"
Expand Down
5 changes: 5 additions & 0 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ the same way as a screenshot: a change keeps the GitHub check pending instead of
`get_build`, the PR comment, the check summary) it reads "Claude Code for Ada Lovelace", "Ada Lovelace" (the web app)
or "a project token (CI)" (`models::reviews::by`): VisualCI is mostly used by agents, so an agent's approval never
reads as the person's own (Nathan, 2 Dec 2026).
- Two pull requests that change the same snapshot and merge separately leave an image neither showed. Between merged
approvals in a build's history the nearer merge wins, and a change whose every region is exactly a region a merged
PR's build changed and approved (the same box, the same old and new pixels) points at that build
(`snapshots.matches_build_id`, `models::matching`, found while processing): "matches PR #8's approved change", a hint
that approves nothing; `review` with `only: "matching"` approves those (sc-8785).
- Partial approval per snapshot. "Accept as variant" adds the image to the name's variants without replacing the
baseline. "Ignore this change" stores the diff fingerprint.
- GitHub App: check run per project and build name, named `VisualCI` (default build name) or `VisualCI: <name>`, so a
Expand Down
2 changes: 1 addition & 1 deletion gemini-extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "visualci",
"version": "0.1.29",
"version": "0.1.30",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"mcpServers": {
"visualci": {
Expand Down
2 changes: 1 addition & 1 deletion server/frontend/content/docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ failing in the repository instead of sending them.

**Reviews**

- `review`: approve or reject a build's changes, some snapshots' changes (`snapshots`), or only its new or only its changed snapshots (`only: "added"` or `"changed"`). Add a `note` saying why ("The new header, as the issue asked"): it's kept with the review and shown in the build's reviews, `get_build` and the pull request comment. Every review says who made it and how: "Claude Code for Ada Lovelace" for an agent signed in as its person, "Ada Lovelace" in the web app, or "a project token (CI)", so an agent's approval never reads as the person's own.
- `review`: approve or reject a build's changes, some snapshots' changes (`snapshots`), or only its new or only its changed snapshots (`only: "added"` or `"changed"`). Add a `note` saying why ("The new header, as the issue asked"): it's kept with the review and shown in the build's reviews, `get_build` and the pull request comment. Every review says who made it and how: "Claude Code for Ada Lovelace" for an agent signed in as its person, "Ada Lovelace" in the web app, or "a project token (CI)", so an agent's approval never reads as the person's own. When two pull requests change the same screen and merge separately, the screen after both is one neither showed, so it shows as changed until someone reviews it. If the change is exactly another pull request's approved change (the same regions, from the same old pixels to the same new ones), `get_build` marks it `matches` ("matches PR #8's approved change"), and `only: "matching"` approves those in one call.
- `review_page`: accept one page as a variant, or ignore one exact change in later builds too.

**Running a comparison**
Expand Down
2 changes: 1 addition & 1 deletion server/frontend/src/api/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ function useBuildAction<V>(org: string, project: string, n: number, fn: (v: V) =
}

export function useReview(org: string, project: string, n: number) {
return useBuildAction(org, project, n, (v: { action: 'approve' | 'reject'; snapshot_ids?: string[]; only?: 'added' | 'changed' }) =>
return useBuildAction(org, project, n, (v: { action: 'approve' | 'reject'; snapshot_ids?: string[]; only?: 'added' | 'changed' | 'matching' }) =>
post<BuildSummary>(`${buildPath(org, project, n)}/review`, v),
)
}
Expand Down
2 changes: 2 additions & 0 deletions server/frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ export type SnapshotRow = {
change: { fraction: number; amount: number } | null
/** The same new version was already approved on another branch. A hint: it approves nothing here. */
approved_elsewhere: ApprovedElsewhere | null
/** Every changed region is exactly a change a merged pull request approved: "matches PR #8's approved change". */
matches?: { build: number; branch: string; pr_number: number | null; label: string } | null
thumbnail_url: string | null
/** Its content flipped back and forth over the branch's recent builds: a hint only. */
flaky: boolean
Expand Down
16 changes: 16 additions & 0 deletions server/frontend/src/pages/BuildPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,17 @@ export function BuildPage() {
<CheckIcon size={14} weight="bold" /> Approve all {g.state}
</Button>
)}
{canReviewBuild && g.state === 'changed' && list.filter((s) => s.matches && !s.review).length > 1 && (
<Button
size="sm"
variant="ghost"
loading={review.isPending && review.variables?.only === 'matching'}
onClick={() => review.mutate({ action: 'approve', only: 'matching' })}
title="Changes made only of changes merged pull requests approved"
>
<CheckIcon size={14} weight="bold" /> Approve all matching
</Button>
)}
</div>
<ul className="snap-list">
{list.map((s) => (
Expand Down Expand Up @@ -439,6 +450,11 @@ function SnapshotItem({
<span className="snap-sub muted">matched {environmentLabel(s.matched_environment)}</span>
)}
{s.baseline_note && <span className="snap-sub muted">Baseline {s.baseline_note}</span>}
{s.matches && (
<span className="snap-sub snap-elsewhere">
<CheckIcon size={13} weight="bold" aria-hidden /> {s.matches.label[0].toUpperCase() + s.matches.label.slice(1)}
</span>
)}
{s.approved_elsewhere && (
<span className="snap-sub snap-elsewhere">
<CheckIcon size={13} weight="bold" aria-hidden /> {approvedElsewhereLabel(s.approved_elsewhere)}
Expand Down
2 changes: 2 additions & 0 deletions server/migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod m20261202_000034_render_job_token;
mod m20261202_000035_invitation_for_user;
mod m20261202_000036_tokens_can_approve;
mod m20261202_000037_review_source;
mod m20261202_000038_matches_approved;

pub struct Migrator;

Expand Down Expand Up @@ -88,6 +89,7 @@ impl MigratorTrait for Migrator {
Box::new(m20261202_000035_invitation_for_user::Migration),
Box::new(m20261202_000036_tokens_can_approve::Migration),
Box::new(m20261202_000037_review_source::Migration),
Box::new(m20261202_000038_matches_approved::Migration),
// inject-above (do not remove this comment)
]
}
Expand Down
29 changes: 29 additions & 0 deletions server/migration/src/m20261202_000038_matches_approved.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//! A changed snapshot whose every changed region is exactly a change another pull request had approved (merged into
//! this build's history) points at that PR's build: "matches PR #8's approved change". A hint, and what
//! `review only: "matching"` approves; it approves nothing by itself.
use sea_orm_migration::prelude::*;

pub struct Migration;

impl MigrationName for Migration {
fn name(&self) -> &str {
"m20261202_000038_matches_approved"
}
}

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.get_connection()
.execute_unprepared(
"ALTER TABLE snapshots ADD COLUMN matches_build_id BIGINT REFERENCES builds(id) ON DELETE SET NULL;",
)
.await?;
Ok(())
}

async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.get_connection().execute_unprepared("ALTER TABLE snapshots DROP COLUMN matches_build_id;").await?;
Ok(())
}
}
4 changes: 4 additions & 0 deletions server/src/controllers/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ struct SnapshotRow {
thumbnail_url: Option<String>,
/// A change whose content flipped back and forth over the branch's recent builds (`flaky_in`): a hint only.
flaky: bool,
/// A change made only of changes a merged pull request approved (`models::matching`): a hint only.
matches: Option<crate::models::matching::Matches>,
}

#[debug_handler]
Expand All @@ -793,6 +795,7 @@ async fn show_build(
let ids: Vec<i64> = list.iter().filter_map(|s| s.baseline_id).collect();
let notes = crate::models::baselines::local_notes(&ctx.db, &ids).await?;
let flaky = snapshots::Model::flaky_in(&ctx.db, &build).await?;
let mut matching = crate::models::matching::of_build(&ctx.db, build.id).await?;
for s in list {
let pages = snapshot_pages::Entity::find()
.filter(snapshot_pages::Column::SnapshotId.eq(s.id))
Expand Down Expand Up @@ -842,6 +845,7 @@ async fn show_build(
approved_elsewhere: elsewhere.remove(&s.id),
thumbnail_url: thumb,
flaky: is_flaky,
matches: matching.remove(&s.id),
});
}
let mut summary = serde_json::to_value(BuildSummary::for_viewer(&build, member)).unwrap_or_default();
Expand Down
11 changes: 9 additions & 2 deletions server/src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ pub struct ReviewArgs {
pub action: String,
/// Snapshot names to review; all changed snapshots when left out.
pub snapshots: Option<Vec<String>>,
/// Only the build's `added` (new) snapshots, or only its `changed` ones, in one call. Not with `snapshots`.
/// Only the build's `added` (new) snapshots, only its `changed` ones, or only its `matching` ones (changes made
/// only of changes merged pull requests approved: `get_build`'s `matches`), in one call. Not with `snapshots`.
pub only: Option<String>,
/// With `reject`: why, as a comment thread on each rejected snapshot (Markdown), so the next person or agent sees
/// what's wrong. Approving a snapshot with an open thread is refused until the thread is resolved.
Expand Down Expand Up @@ -1461,7 +1462,7 @@ impl VisualCi {
}

#[tool(
description = "A build's status and its snapshots that need attention, 30 at a time (offset and limit page through; longer lists also come grouped by state and name prefix) (changed, added, removed, failed), with how many pages changed in each, the largest change first (order: name to sort by name), and approved_elsewhere when the same new version was already approved on another branch (a hint: it approves nothing). Unchanged snapshots are only counted unless include_unchanged is set. `config` is the visualci.yml the build was sent (null when it had none: the project's settings applied). `flaky: true` marks a change whose content flipped back and forth over the branch's recent builds: often something that differs between runs (the time, an animation, a late font) rather than a real change, so check it before approving, and make the test deterministic.",
description = "A build's status and its snapshots that need attention, 30 at a time (offset and limit page through; longer lists also come grouped by state and name prefix) (changed, added, removed, failed), with how many pages changed in each, the largest change first (order: name to sort by name), and approved_elsewhere when the same new version was already approved on another branch (a hint: it approves nothing). Unchanged snapshots are only counted unless include_unchanged is set. `config` is the visualci.yml the build was sent (null when it had none: the project's settings applied). `flaky: true` marks a change whose content flipped back and forth over the branch's recent builds: often something that differs between runs (the time, an animation, a late font) rather than a real change, so check it before approving, and make the test deterministic. `matches` marks a change made only of changes a merged pull request approved (two PRs that changed the same screen and merged separately): approve those with `review` and `only: \"matching\"`.",
annotations(title = "Get build", read_only_hint = true, idempotent_hint = true, open_world_hint = false)
)]
async fn get_build(
Expand All @@ -1485,6 +1486,7 @@ impl VisualCi {
let sizes = snapshots::change_sizes(&self.ctx.db, build.id).await.map_err(internal)?;
snapshots::sort_for_review(&mut listed, &sizes, args.order);
let elsewhere = crate::models::baselines::approved_elsewhere(&self.ctx.db, build.id).await.map_err(internal)?;
let matching = crate::models::matching::of_build(&self.ctx.db, build.id).await.map_err(internal)?;
let project_url = format!("{}/{org}/{}", self.settings()?.app_url(), project.slug);
let snapshot_url = |e: &crate::models::baselines::ApprovedElsewhere| {
format!("{project_url}/builds/{}/snapshots/{}", e.build, e.snapshot_id)
Expand Down Expand Up @@ -1530,6 +1532,11 @@ impl VisualCi {
"changed_pages": pages.map(|p| p.iter().filter(|p| p.state == "changed").count()),
"moved_lines": detail.as_ref().map_or(0, |d| d.moved.len()),
});
if let Some(m) = matching.get(&s.id) {
// Every changed region is exactly a change a merged pull request approved: `review` with
// `only: "matching"` approves these. A hint: it approves nothing by itself.
item["matches"] = json!(m);
}
if s.is_change() && flaky.contains(&(s.name.clone(), s.platform.clone())) {
// Its content flipped back and forth over the branch's recent builds: a hint, not a verdict.
item["flaky"] = json!(true);
Expand Down
2 changes: 2 additions & 0 deletions server/src/models/_entities/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub struct Model {
#[sea_orm(column_type = "Text")]
pub state: String,
pub base_snapshot_id: Option<i64>,
/// The pull request build whose approved change this change exactly matches (`models::matching`).
pub matches_build_id: Option<i64>,
#[sea_orm(column_type = "Text", nullable)]
pub review: Option<String>,
#[sea_orm(column_type = "Text", nullable)]
Expand Down
13 changes: 12 additions & 1 deletion server/src/models/baselines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,20 @@ pub async fn resolve(
// default-branch ones.
let mut latest: HashMap<(String, String, String), Model> = HashMap::new();
let rank = |r: &Model| (r.build_id > after || r.branch == build.branch || merged_and_new(r), r.id);
// Between two merged pull requests' approvals, the nearer merge in this build's history wins (it was merged
// later on this line), whatever order the webhooks arrived in.
let history = ancestry(build);
let nearness = |r: &Model| history.iter().position(|c| c == &r.commit_sha).unwrap_or(usize::MAX);
let better = |new: &Model, old: &Model| {
if new.approval == "merged" && old.approval == "merged" && nearness(new) != nearness(old) {
nearness(new) < nearness(old)
} else {
rank(old) < rank(new)
}
};
for row in rows {
let key = (row.name.clone(), row.platform.clone(), row.environment.clone());
if latest.get(&key).is_none_or(|existing| rank(existing) < rank(&row)) {
if latest.get(&key).is_none_or(|existing| better(&row, existing)) {
latest.insert(key, row);
}
}
Expand Down
6 changes: 6 additions & 0 deletions server/src/models/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ impl Model {
}
}

// Changes made only of changes merged pull requests approved say so (a hint; `models::matching`). A failure
// here costs the hint, never the build.
if let Err(e) = super::matching::mark(db, store, &self).await {
tracing::warn!(build = self.id, error = %e, "matching approved changes");
}

let has_base = !base_snapshots.is_empty();
let mut active = self.into_active_model();
active.warnings = Set(serde_json::json!(warnings));
Expand Down
Loading
Loading