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

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.30",
"version": "0.1.31",
"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.30",
"version": "0.1.31",
"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.30",
"version": "0.1.31",
"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
4 changes: 4 additions & 0 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ the same way as a screenshot: a change keeps the GitHub check pending instead of
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).
- A pull request build compared on top of an unreviewed default-branch build shows that build's changes again. Those
that are exactly the base build's unreviewed change (the same snapshot and new content) are marked
(`models::inherited`, `on_main_unreviewed`) and the build says "N changes are already on main and unreviewed (build
#X)", linking there. Approval and the check still go by approved baselines (sc-8770).
- 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.30",
"version": "0.1.31",
"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 @@ -195,7 +195,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. 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`: 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. On a pull request's build whose base is a default-branch build nobody has reviewed yet, the changes that are main's own unreviewed ones are marked `on_main_unreviewed`, and `get_build`'s `inherited` says how many and which build: review those on main's build, and the pull request's own changes here.
- `review_page`: accept one page as a variant, or ignore one exact change in later builds too.

**Running a comparison**
Expand Down
4 changes: 4 additions & 0 deletions server/frontend/src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ export type SnapshotRow = {
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
/** This pull request build's change is the default branch's own unreviewed change: review it on main's build. */
on_main_unreviewed?: boolean
thumbnail_url: string | null
/** Its content flipped back and forth over the branch's recent builds: a hint only. */
flaky: boolean
Expand All @@ -320,6 +322,8 @@ export type SnapshotRow = {
export type BuildDetail = BuildSummary & {
/** What changed, computed from the comparison ("invoice: page 1 changed (2 regions); 3 added"). */
summary: string | null
/** A pull request build's changes that are the default branch's own unreviewed ones ("3 changes are already on main and unreviewed (build #77)"). */
inherited?: { build: number; branch: string; count: number; note: string } | null
base_build_number: number | null
ci_mode: CiMode
error: string | null
Expand Down
9 changes: 9 additions & 0 deletions server/frontend/src/pages/BuildPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ export function BuildPage() {
<strong>visualci.yml:</strong> {w}
</p>
))}
{build.inherited && (
<p className="notice">
<strong>Not this pull request&rsquo;s:</strong> {build.inherited.note}.{' '}
<Link to="/$org/$project/builds/$number" params={{ org, project, number: build.inherited.build }}>
Review them on #{build.inherited.build}
</Link>
</p>
)}
{build.summary && <p className="build-summary">{build.summary}</p>}

<nav className="stat-strip" aria-label="Snapshots by state">
Expand Down Expand Up @@ -450,6 +458,7 @@ 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.on_main_unreviewed && <span className="snap-sub muted">Already on {build.inherited?.branch ?? 'main'}, unreviewed</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)}
Expand Down
5 changes: 5 additions & 0 deletions server/src/controllers/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,8 @@ struct SnapshotRow {
flaky: bool,
/// A change made only of changes a merged pull request approved (`models::matching`): a hint only.
matches: Option<crate::models::matching::Matches>,
/// A pull request build's change that's the default branch's own unreviewed change (`models::inherited`).
on_main_unreviewed: bool,
}

#[debug_handler]
Expand All @@ -796,6 +798,7 @@ async fn show_build(
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?;
let inherited = crate::models::inherited::of_build(&ctx.db, &build, &project).await?;
for s in list {
let pages = snapshot_pages::Entity::find()
.filter(snapshot_pages::Column::SnapshotId.eq(s.id))
Expand Down Expand Up @@ -846,6 +849,7 @@ async fn show_build(
thumbnail_url: thumb,
flaky: is_flaky,
matches: matching.remove(&s.id),
on_main_unreviewed: inherited.as_ref().is_some_and(|i| i.snapshot_ids.contains(&s.id)),
});
}
let mut summary = serde_json::to_value(BuildSummary::for_viewer(&build, member)).unwrap_or_default();
Expand All @@ -857,6 +861,7 @@ async fn show_build(
summary["error"] = serde_json::json!(build.error);
// What changed, computed from the comparison.
summary["summary"] = serde_json::json!(crate::summary::summary_line(&ctx.db, &build).await?);
summary["inherited"] = serde_json::json!(inherited.as_ref().map(crate::models::inherited::Inherited::json));
format::json(serde_json::json!({
"build": summary, "snapshots": rows, "reviews": reviews_of(&ctx, build.id).await?,
// Read-only members and visitors to a public project (the demo) see no review buttons.
Expand Down
11 changes: 10 additions & 1 deletion server/src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1462,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. `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\"`.",
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. On a pull request's build, `on_main_unreviewed: true` marks a change that's the default branch's own unreviewed change (its newest build, still waiting for review, has it too), and `inherited` counts them: review those on main's build. `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 @@ -1487,6 +1487,7 @@ impl VisualCi {
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 inherited = crate::models::inherited::of_build(&self.ctx.db, &build, &project).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 @@ -1532,6 +1533,10 @@ 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 inherited.as_ref().is_some_and(|i| i.snapshot_ids.contains(&s.id)) {
// Not this pull request's change: the base build on the default branch has it too, unreviewed.
item["on_main_unreviewed"] = json!(true);
}
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.
Expand Down Expand Up @@ -1575,6 +1580,10 @@ impl VisualCi {
out["next_offset"] = json!((offset + limit < total).then_some(offset + limit));
}
out["snapshots"] = json!(items);
if let Some(i) = &inherited {
// "3 changes are already on main and unreviewed (build #77)": they're main's, not this pull request's.
out["inherited"] = i.json();
}
// Open comment threads on this build's branch: each blocks approving its snapshot until it's resolved.
let threads = crate::models::comments::list(&self.ctx.db, project.id, &build.branch, None, false)
.await
Expand Down
99 changes: 99 additions & 0 deletions server/src/models/inherited.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
//! Changes a pull request build only inherited from its base branch. When the default branch's newest build (the one a
//! PR build is compared on top of) is still waiting for review, its changes aren't baselines yet, so every PR build
//! made after it shows them again: a reviewer can't tell the PR's own changes from main's backlog (2 Dec 2026, PR 3:
//! 98 changes, none of them the PR's). A PR build's change that's exactly the base build's unreviewed change (the same
//! snapshot, the same new content) is marked inherited, and the build says "N changes are already on main and
//! unreviewed (build #X)". Approval and the check still go by approved baselines: this only says where a change came
//! from.

use std::collections::{HashMap, HashSet};

use loco_rs::prelude::*;

use super::{builds, projects, snapshots};

/// A PR build's inherited changes: the base build they're unreviewed in, and which of this build's snapshots they are.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct Inherited {
pub build: i32,
pub branch: String,
pub snapshot_ids: HashSet<i64>,
}

impl Inherited {
/// "3 changes are already on main and unreviewed (build #77)".
#[must_use]
pub fn note(&self) -> String {
let n = self.snapshot_ids.len();
let changes = if n == 1 { "change is" } else { "changes are" };
format!("{n} {changes} already on {} and unreviewed (build #{})", self.branch, self.build)
}

/// For an API answer: the base build, how many, and the sentence.
#[must_use]
pub fn json(&self) -> serde_json::Value {
serde_json::json!({ "build": self.build, "branch": self.branch, "count": self.snapshot_ids.len(), "note": self.note() })
}
}

/// The build's changes that are its base build's unreviewed changes, when its base is an unreviewed build of the
/// default branch and this build isn't on that branch. `None` when there are none.
///
/// # Errors
/// On a database error.
pub async fn of_build(
db: &DatabaseConnection,
build: &builds::Model,
project: &projects::Model,
) -> ModelResult<Option<Inherited>> {
if build.branch == project.default_branch {
return Ok(None);
}
let Some(base_id) = build.base_build_id else { return Ok(None) };
let Ok(base) = builds::Model::find_by_id(db, base_id).await else { return Ok(None) };
if base.branch != project.default_branch || base.review_state != "pending" {
return Ok(None);
}
// The base build's changes that nobody has approved, by snapshot.
let pending: HashMap<(String, String), snapshots::Model> = snapshots::Model::for_build(db, base.id)
.await?
.into_iter()
.filter(|s| s.is_change() && !s.is_config_item() && s.review.as_deref() != Some("approved"))
.map(|s| ((s.name.clone(), s.platform.clone()), s))
.collect();
if pending.is_empty() {
return Ok(None);
}
let snapshot_ids: HashSet<i64> = snapshots::Model::for_build(db, build.id)
.await?
.into_iter()
.filter(|s| s.is_change() && !s.is_config_item())
.filter(|s| {
pending.get(&(s.name.clone(), s.platform.clone())).is_some_and(|p| {
if s.state == "removed" {
p.state == "removed"
} else {
p.state != "removed" && p.source_fingerprint == s.source_fingerprint
}
})
})
.map(|s| s.id)
.collect();
if snapshot_ids.is_empty() {
return Ok(None);
}
Ok(Some(Inherited { build: base.number, branch: base.branch, snapshot_ids }))
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn says_how_many_and_where() {
let one = Inherited { build: 77, branch: "main".into(), snapshot_ids: [1].into_iter().collect() };
assert_eq!(one.note(), "1 change is already on main and unreviewed (build #77)");
let three = Inherited { build: 77, branch: "main".into(), snapshot_ids: [1, 2, 3].into_iter().collect() };
assert_eq!(three.note(), "3 changes are already on main and unreviewed (build #77)");
}
}
1 change: 1 addition & 0 deletions server/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub mod gitlab_instances;
pub mod heard_about;
pub mod identities;
pub mod ignored_changes;
pub mod inherited;
pub mod invitations;
pub mod matching;
pub mod memberships;
Expand Down
Loading
Loading