diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 0dc521b2..e79b66da 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -5,7 +5,7 @@ "plugins": [ { "name": "visualci", - "version": "0.1.46", + "version": "0.1.47", "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/", diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 78da2802..34ab9a4e 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "visualci", - "version": "0.1.46", + "version": "0.1.47", "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/", diff --git a/.cursor-plugin/plugin.json b/.cursor-plugin/plugin.json index 48895fdc..223f9a3b 100644 --- a/.cursor-plugin/plugin.json +++ b/.cursor-plugin/plugin.json @@ -1,7 +1,7 @@ { "name": "visualci", "displayName": "VisualCI", - "version": "0.1.46", + "version": "0.1.47", "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" diff --git a/app/src/domain/baselines.rs b/app/src/domain/baselines.rs index 77970602..ea784c48 100644 --- a/app/src/domain/baselines.rs +++ b/app/src/domain/baselines.rs @@ -10,6 +10,9 @@ //! build, commit, branch, environment and mode it came from. Rows newer than the anchor are laid on top: CI //! approvals on the build's ancestry, and any approval on the build's own branch. A local approval counts on its //! own branch only, never through ancestry. +//! 3. **Merges**: a pull request's approvals reach its base branch only when it merges ([`record_merge`] copies them +//! to the merge commit), and count through that commit's place in a build's history. Nothing is taken from an +//! unrelated branch, and only the default branch's first build is approved without review. //! //! Documents and text are the same everywhere and keep one shared set (environment `""`). Screenshots keep a set per //! environment: CI's comes from the anchor and CI approvals; a laptop's from its own approvals on the branch (or CI @@ -269,50 +272,6 @@ pub async fn resolve( } } - // Last: a snapshot this build sent that has no baseline on its history takes the suite's latest current CI - // approval of it from any branch. That's a squash-merged pull request's approval: its commits aren't ancestors of - // the default branch's, but what it approved is what the default branch now has. - let sent: Vec<(String, String, String)> = Snapshot::query() - .filter(Snapshot::build_id.eq(build.id) & Snapshot::carried_forward.eq(false)) - .get() - .await? - .into_iter() - .filter(|s| !is_config_item(s)) - .map(|s| (s.name, s.platform, s.environment)) - .collect(); - let missing: Vec<&(String, String, String)> = - sent.iter().filter(|(n, p, _)| !chosen.contains_key(&(n.clone(), p.clone()))).collect(); - if !missing.is_empty() { - let mut names: Vec = missing.iter().map(|(n, _, _)| n.clone()).collect(); - names.sort(); - names.dedup(); - let mut rows: Vec = Vec::new(); - for chunk in names.chunks(10_000) { - let chunk = chunk.to_vec(); - let found: Vec = db::query!( - "SELECT DISTINCT ON (name, platform, environment) * FROM baselines bl \ - WHERE project_id = {project_id} AND build_name = {build_name} AND build_id <> {id} AND mode = 'ci' \ - AND name IN ({...chunk}) \ - AND NOT EXISTS (SELECT 1 FROM baselines b2 WHERE b2.project_id = bl.project_id \ - AND b2.build_name = bl.build_name AND b2.name = bl.name AND b2.platform = bl.platform \ - AND b2.environment = bl.environment AND b2.branch = bl.branch AND b2.id > bl.id) \ - ORDER BY name, platform, environment, id DESC" - ) - .select_as() - .await?; - rows.extend(found); - } - for (name, platform, environment) in missing { - let order = search_order(environment); - let row = order.iter().find_map(|env| { - rows.iter().find(|r| &r.name == name && &r.platform == platform && &r.environment == env) - }); - if let Some(r) = row.filter(|r| r.snapshot_id.is_some()) { - chosen.insert((name.clone(), platform.clone()), (Some(r.clone()), r.snapshot_id)); - } - } - } - let ids: Vec = chosen.values().filter_map(|(_, id)| *id).collect(); let mut snapshots = load(&ids).await?; let resolved = chosen diff --git a/app/src/domain/compare.rs b/app/src/domain/compare.rs index fd2d7309..82619b04 100644 --- a/app/src/domain/compare.rs +++ b/app/src/domain/compare.rs @@ -13,9 +13,9 @@ use crate::models::{Blob, IgnoredChange, Project, Snapshot, Variant}; use crate::storage::BlobStore; /// The exact-match passes below take a baseline row `bl` only when it's current for the snapshot's build: the same -/// suite, a CI approval or one from the build's own branch (local approvals count on their own branch only), and not -/// superseded by a later approval of the same snapshot on the same branch and environment. (Rejected approvals are -/// deleted.) +/// suite, a CI approval on the default branch or one from the build's own branch (local approvals count on their own +/// branch only, and another branch's never count), and not superseded by a later approval of the same snapshot on the +/// same branch and environment. (Rejected approvals are deleted.) /// The snapshot's pages: a document's rendered pages, or an image or a text as a single page. /// /// # Errors @@ -216,14 +216,15 @@ async fn page_state( if base.text == head.text { return Ok(("unchanged", None, None)); } - // Exactly this text was approved for this snapshot elsewhere in the project (a squash-merged pull request's - // branch): it passes, as an image would. + // Exactly this text was approved for this snapshot on the build's own branch or the default branch (in + // another environment, or before a change since): it passes, as an image would. let fingerprint = snapshot.source_fingerprint.as_str(); let approved: Option = db::query!( "SELECT 1 FROM baselines bl JOIN snapshots s ON s.id = bl.snapshot_id \ WHERE bl.project_id = {project_id} AND bl.name = {name} AND bl.platform = {platform} \ AND s.source_fingerprint = {fingerprint} AND bl.build_name = (SELECT name FROM builds WHERE id = {build_id}) \ - AND (bl.mode = 'ci' OR bl.branch = (SELECT branch FROM builds WHERE id = {build_id})) \ + AND (bl.branch = (SELECT branch FROM builds WHERE id = {build_id}) \ + OR (bl.mode = 'ci' AND bl.branch = (SELECT default_branch FROM projects WHERE id = {project_id}))) \ AND NOT EXISTS (SELECT 1 FROM baselines b2 WHERE b2.project_id = bl.project_id \ AND b2.build_name = bl.build_name AND b2.name = bl.name AND b2.platform = bl.platform \ AND b2.environment = bl.environment AND b2.branch = bl.branch AND b2.id > bl.id) LIMIT 1" @@ -251,9 +252,10 @@ async fn page_state( if is_variant { return Ok(("variant", None, None)); } - // Approved before: a current baseline, in any environment, branch or commit of the suite, with exactly this image - // for this snapshot: its own environment's first, then CI's. Covers squash merges and other environments (a Linux - // agent's screenshot that matches the approved Mac one passes). + // Approved before: a current baseline, in any environment, on the build's own branch or the default branch, with + // exactly this image for this snapshot: its own environment's first, then CI's. Covers other environments (a Linux + // agent's screenshot that matches the approved Mac one passes). Another branch's approvals never count: a pull + // request's reach the default branch only at its merge (`baselines::record_merge`). let image = head.image.as_str(); let environment = snapshot.environment.as_str(); let approved: Option = db::query!( @@ -261,7 +263,8 @@ async fn page_state( JOIN snapshots s ON s.id = bl.snapshot_id JOIN snapshot_pages p ON p.snapshot_id = s.id \ WHERE bl.project_id = {project_id} AND bl.name = {name} AND bl.platform = {platform} AND p.head_image = {image} \ AND bl.build_name = (SELECT name FROM builds WHERE id = {build_id}) \ - AND (bl.mode = 'ci' OR bl.branch = (SELECT branch FROM builds WHERE id = {build_id})) \ + AND (bl.branch = (SELECT branch FROM builds WHERE id = {build_id}) \ + OR (bl.mode = 'ci' AND bl.branch = (SELECT default_branch FROM projects WHERE id = {project_id}))) \ AND NOT EXISTS (SELECT 1 FROM baselines b2 WHERE b2.project_id = bl.project_id \ AND b2.build_name = bl.build_name AND b2.name = bl.name AND b2.platform = bl.platform \ AND b2.environment = bl.environment AND b2.branch = bl.branch AND b2.id > bl.id) \ diff --git a/app/src/domain/processing.rs b/app/src/domain/processing.rs index 2e3457ad..68d505e8 100644 --- a/app/src/domain/processing.rs +++ b/app/src/domain/processing.rs @@ -500,9 +500,9 @@ pub async fn process(build: Build, store: &BlobStore, renderer_version: &str) -> let warnings = warnings.clone(); update!(build { warnings }).await?; - let build = conclude(build, base_build_id, has_base, sent).await?; + let build = conclude(build, &project.default_branch, base_build_id, has_base, sent).await?; if build.review_state == "auto_approved" { - // Nothing to review (or the project's first build): its changes are the baselines now. + // Nothing to review (or the default branch's first build): its changes are the baselines now. let all = super::snapshots::of_build(build.id).await?; let changes: Vec<&Snapshot> = all.iter().filter(|s| !is_config_item(s)).collect(); baselines::record(&build, &changes, None, None, "auto").await?; @@ -588,7 +588,13 @@ pub fn stats_of(snapshots: &[Snapshot]) -> Stats { /// Count snapshot states, set the conclusion and review state, and mark the build completed. `sent` is how many /// snapshots the build was sent itself: none means the upload found nothing, which mustn't pass as "unchanged". -async fn conclude(mut build: Build, base_build_id: Option, has_base: bool, sent: i64) -> laravel::Result { +async fn conclude( + mut build: Build, + default_branch: &str, + base_build_id: Option, + has_base: bool, + sent: i64, +) -> laravel::Result { let all = super::snapshots::of_build(build.id).await?; let stats = stats_of(&all); let empty = sent == 0 && !build.allow_empty; @@ -599,11 +605,15 @@ async fn conclude(mut build: Build, base_build_id: Option, has_base: bool, } else { "unchanged" }; - // A local run's changes always wait for review, even in a project's first build: approving one sets the baseline - // for its branch and environment. - let review_state = match (build.mode.as_str(), conclusion, has_base) { - (_, "failed", _) => "none", - (_, "unchanged", _) | ("ci", _, false) => "auto_approved", + // Nothing becomes a baseline unreviewed. Only a CI build on the default branch with nothing to compare against + // (the project's first) is approved as it is. Another branch's first build waits for review: its approvals reach + // the default branch only when its pull request merges (`baselines::record_merge`). A local run's changes always + // wait for review: approving one sets the baseline for its branch and environment. + let first_on_default = build.mode == "ci" && !has_base && build.branch == default_branch; + let review_state = match conclusion { + "failed" => "none", + "unchanged" => "auto_approved", + _ if first_on_default => "auto_approved", _ => "pending", }; let stats = serde_json::to_value(&stats).unwrap_or_default(); diff --git a/app/tests/baselines.rs b/app/tests/baselines.rs new file mode 100644 index 00000000..2ce816be --- /dev/null +++ b/app/tests/baselines.rs @@ -0,0 +1,203 @@ +//! Nothing becomes a baseline unreviewed: only the default branch's first build is approved on its own, a pull +//! request branch's first build waits for review, and a branch's approvals reach the default branch only when its pull +//! request merges (`baselines::record_merge`, at the merge commit). A build never takes another branch's approvals. + +use app::domain::{baselines, reviews}; +use app::models::{Build, Project}; +use app::testing::fixtures; +use laravel::db; +use laravel::testing::prelude::*; +use serde_json::json; + +fn png(rgb: [u8; 3]) -> Vec { + let img = image::RgbImage::from_pixel(8, 6, image::Rgb(rgb)); + let mut out = std::io::Cursor::new(Vec::new()); + img.write_to(&mut out, image::ImageFormat::Png).unwrap(); + out.into_inner() +} + +const RED: [u8; 3] = [255, 0, 0]; +const GREEN: [u8; 3] = [0, 255, 0]; + +struct World { + project: Project, + token: String, +} + +async fn world() -> laravel::Result { + fixtures::blob_store().await?; + let org = fixtures::organization(&format!("org-{}", &laravel::str::uuid7().simple().to_string()[24..])).await?; + let project = fixtures::project(&org, "web").await?; + assert_eq!(project.default_branch, "main"); + let token = format!("vci_{}", laravel::str::uuid7().simple()); + let (hash, project_id) = (app::models::token_hash(&token), project.id); + db::query!( + "INSERT INTO project_tokens (project_id, name, token_hash, token_prefix, created_at, updated_at) \ + VALUES ({project_id}, 'CI', {hash}, 'vci_ab', now(), now())" + ) + .insert() + .await?; + Ok(World { project, token }) +} + +impl World { + /// A finished CI build of these images on `branch` at `commit`, with these ancestor commits. + async fn build( + &self, + app: &Application, + commit: &str, + branch: &str, + parents: &[&str], + files: &[(&str, [u8; 3])], + ) -> Build { + // Boxed: the test's own future would otherwise outgrow a test thread's stack. + Box::pin(self.build_inner(app, commit, branch, parents, files)).await + } + + async fn build_inner( + &self, + app: &Application, + commit: &str, + branch: &str, + parents: &[&str], + files: &[(&str, [u8; 3])], + ) -> Build { + let auth = format!("Bearer {}", self.token); + let created = app + .post("/api/v1/builds") + .header("authorization", &auth) + .json(json!({ "commit": commit, "branch": branch, "parent_commits": parents })) + .await; + created.assert_ok(); + let id = created.json()["id"].as_str().unwrap().to_string(); + let mut list = Vec::new(); + let mut bodies = Vec::new(); + for (name, rgb) in files { + let bytes = png(*rgb); + let sha = visualci_core::sha256_hex(&bytes); + list.push(json!({ + "name": name, "kind": "image", "sha256": sha, "size": bytes.len(), "content_type": "image/png", + "fingerprint": visualci_core::image_hash::fingerprint_bytes(&bytes).unwrap(), + })); + bodies.push(bytes); + } + let registered = app + .post(format!("/api/v1/builds/{id}/snapshots")) + .header("authorization", &auth) + .json(json!({ "snapshots": list })) + .await; + registered.assert_ok(); + for (s, bytes) in registered.json()["snapshots"].as_array().unwrap().iter().zip(bodies) { + if let Some(url) = s["upload_url"].as_str() { + let r = reqwest::Client::new() + .put(url) + .header("content-type", "image/png") + .body(bytes) + .send() + .await + .unwrap(); + assert!(r.status().is_success()); + } + } + let done = app.post(format!("/api/v1/builds/{id}/finalize")).header("authorization", &auth).await; + assert_eq!(done.json()["state"], "completed", "{}", done.text()); + let pid: laravel::str::Uuid = id.parse().unwrap(); + Build::query().filter(Build::pid.eq(pid)).first().await.unwrap().unwrap() + } + + async fn approve(&self, build: Build) -> Build { + Box::pin(reviews::review(build, None, &reviews::Via::default(), "approve", None, None)).await.unwrap().unwrap() + } +} + +/// Each snapshot's state in a build, by name. +async fn states(build: &Build) -> laravel::Result> { + let mut out: Vec<(String, String)> = + app::domain::snapshots::of_build(build.id).await?.into_iter().map(|s| (s.name, s.state)).collect(); + out.sort(); + Ok(out) +} + +/// How many baseline rows a build recorded. +async fn recorded(build: &Build) -> laravel::Result { + let id = build.id; + Ok(db::query!("SELECT COUNT(*) FROM baselines WHERE build_id = {id}").scalar().await?.unwrap_or_default()) +} + +#[laravel::test] +async fn a_pull_request_branchs_first_build_waits_for_review_and_records_no_baselines( + app: Application, +) -> laravel::Result<()> { + let w = world().await?; + let first = w.build(&app, "f1", "feature", &["f0"], &[("web/home", RED), ("web/about", RED)]).await; + assert_eq!(first.conclusion.as_deref(), Some("changes")); + assert_eq!(first.review_state, "pending", "not auto_approved: nothing becomes a baseline unreviewed"); + assert_eq!(recorded(&first).await?, 0); + assert_eq!(states(&first).await?, vec![("web/about".into(), "added".into()), ("web/home".into(), "added".into())]); + Ok(()) +} + +#[laravel::test] +async fn the_default_branchs_first_build_is_approved_and_becomes_the_baseline(app: Application) -> laravel::Result<()> { + let w = world().await?; + let first = w.build(&app, "m1", "main", &["m0"], &[("web/home", RED), ("web/about", RED)]).await; + assert_eq!((first.conclusion.as_deref(), first.review_state.as_str()), (Some("changes"), "auto_approved")); + assert_eq!(recorded(&first).await?, 2); + let next = w.build(&app, "m2", "main", &["m1", "m0"], &[("web/home", RED), ("web/about", RED)]).await; + assert_eq!(next.conclusion.as_deref(), Some("unchanged")); + Ok(()) +} + +#[laravel::test] +async fn a_build_never_takes_an_unrelated_branchs_approvals(app: Application) -> laravel::Result<()> { + let w = world().await?; + let feature = w.build(&app, "f1", "feature", &["f0"], &[("web/home", RED), ("web/about", RED)]).await; + let feature = w.approve(feature).await; + assert_eq!(feature.review_state, "approved"); + assert_eq!(recorded(&feature).await?, 2); + + // Another branch with no history in common: what `feature` approved isn't its baseline. + let other = w.build(&app, "o1", "other", &["o0"], &[("web/home", RED), ("web/about", RED)]).await; + assert_eq!( + states(&other).await?, + vec![("web/about".into(), "added".into()), ("web/home".into(), "added".into())], + "added, not unchanged" + ); + assert_eq!((other.conclusion.as_deref(), other.review_state.as_str()), (Some("changes"), "pending")); + + // Nor is it the default branch's before the pull request merges. + let main = w.build(&app, "m1", "main", &["m0"], &[("web/home", RED), ("web/about", RED)]).await; + assert_eq!(states(&main).await?, vec![("web/about".into(), "added".into()), ("web/home".into(), "added".into())]); + Ok(()) +} + +#[laravel::test] +async fn a_squash_merged_pull_requests_approvals_reach_the_default_branch_at_the_merge( + app: Application, +) -> laravel::Result<()> { + let w = world().await?; + let m1 = w.build(&app, "m1", "main", &["m0"], &[("web/home", RED), ("web/about", RED)]).await; + assert_eq!(m1.review_state, "auto_approved"); + + // The pull request changes the home page, and its change is approved. + let f1 = w.build(&app, "f1", "feature", &["m1", "m0"], &[("web/home", GREEN), ("web/about", RED)]).await; + assert_eq!( + states(&f1).await?, + vec![("web/about".into(), "unchanged".into()), ("web/home".into(), "changed".into())] + ); + w.approve(f1).await; + + // Before the merge, main still compares with its own baseline. + let before = w.build(&app, "m2", "main", &["m1", "m0"], &[("web/home", GREEN), ("web/about", RED)]).await; + assert_eq!( + states(&before).await?, + vec![("web/about".into(), "unchanged".into()), ("web/home".into(), "changed".into())] + ); + + // Squash-merged as s1, a commit no feature build was on: the approvals move to main at s1. + let moved = baselines::record_merge(w.project.id, "feature", "main", "s1").await?; + assert_eq!(moved, 1); + let after = w.build(&app, "m3", "main", &["s1", "m1", "m0"], &[("web/home", GREEN), ("web/about", RED)]).await; + assert_eq!(after.conclusion.as_deref(), Some("unchanged"), "{:?}", states(&after).await?); + Ok(()) +} diff --git a/docs/design.md b/docs/design.md index fbcc5c47..dd12a7ed 100644 --- a/docs/design.md +++ b/docs/design.md @@ -197,12 +197,20 @@ the same way as a screenshot: a change keeps the GitHub check pending instead of CI approvals to the base branch at the merge commit (rows with approval `merged`). They count for builds whose history has the merge commit and whose anchor doesn't, so a squash merge doesn't ask for the same approvals again, and a later approval on the base branch wins. Installation events keep projects' installations current. + This is the only way a pull request's approvals reach its base branch: a build never takes approvals from a + branch outside its history. +- **Nothing becomes a baseline unreviewed.** A CI build with nothing to compare against is approved on its own only + on the project's default branch (`projects.default_branch`): that first build is the baseline. A pull request + branch's first build with no base waits for review like any change, and its approval reaches the default branch at + the merge. A build with no changes is approved on any branch (it records nothing). (An unreviewed pull request's + first build once became the baseline for unrelated branches, through first-build approval on any branch and a + fallback that took any branch's approvals.) - **Trust**: a local approval counts on its own branch only (never through ancestry), so CI on that branch matches a laptop's approved PDFs and text, with "approved locally by … on …" on the snapshot. From a working tree with uncommitted changes, an approval sets only that environment's screenshots. A local build can't use the `ci` - environment, nor a CI build a `local-*` one. Exact-match passes (an image or text approved anywhere in the suite, - which covers squash merges and other environments) use only current rows: CI approvals or the build's own branch's, - not superseded. + environment, nor a CI build a `local-*` one. Exact-match passes (an image or text approved in another environment) + use only current rows: CI approvals on the default branch or the build's own branch's, not superseded, never + another branch's. - **Environments**: `ci`, `local-mac`, `local-linux` (the CLI detects them: a CI provider or `CI=true` means `ci`, else the OS; `VISUALCI_ENVIRONMENT` overrides). Only client-made images (screenshots) keep a set per environment; documents are rendered on VisualCI's servers and text is the same everywhere, so they share one set diff --git a/gemini-extension.json b/gemini-extension.json index 648e042d..326ed8f5 100644 --- a/gemini-extension.json +++ b/gemini-extension.json @@ -1,6 +1,6 @@ { "name": "visualci", - "version": "0.1.46", + "version": "0.1.47", "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": { diff --git a/server/frontend/content/docs/quick-start.md b/server/frontend/content/docs/quick-start.md index 080f1585..a1124cea 100644 --- a/server/frontend/content/docs/quick-start.md +++ b/server/frontend/content/docs/quick-start.md @@ -47,9 +47,9 @@ Snapshot names come from file paths. `visualci build create` reads the commit, b ## 4. Review the changes -A build with nothing to compare against is approved automatically and becomes the baseline. After that, each build is compared with the approved build of its nearest ancestor commit, or the default branch's latest approved build. +The first build on your default branch has nothing to compare against, so it's approved automatically and becomes the baseline. After that, each build is compared with the approved build of its nearest ancestor commit, or the default branch's latest approved build. Nothing else becomes a baseline without a review: a pull request's first build, with nothing on the default branch to compare against, waits for review like any change. -When something changed, the CI job still passes and the GitHub check stays pending. Your agent reads the changes with `get_build` and `get_snapshot`, then approves them with `review`, or fixes the code and pushes again. Approved snapshots become the baseline for later builds on that branch. +When something changed, the CI job still passes and the GitHub check stays pending. Your agent reads the changes with `get_build` and `get_snapshot`, then approves them with `review`, or fixes the code and pushes again. Approved snapshots become the baseline for later builds on that branch, and reach the default branch when the pull request merges (squash merges too). Other branches never compare with them before then. Two things make that loop hold: [require the VisualCI check](/docs/agents/#make-the-check-block-merges), so a pull request can't merge before its review, and [add a VisualCI section to AGENTS.md](/docs/agents/#add-a-visualci-section-to-agents-md), so every agent working in the repository reviews its own builds. diff --git a/server/frontend/content/docs/snapshots/insta.md b/server/frontend/content/docs/snapshots/insta.md index 92336d87..3989aa05 100644 --- a/server/frontend/content/docs/snapshots/insta.md +++ b/server/frontend/content/docs/snapshots/insta.md @@ -16,7 +16,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t **/snapshots/*.snap.new ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/server/frontend/content/docs/snapshots/jest.md b/server/frontend/content/docs/snapshots/jest.md index 1680bfe5..272c496e 100644 --- a/server/frontend/content/docs/snapshots/jest.md +++ b/server/frontend/content/docs/snapshots/jest.md @@ -15,7 +15,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/server/frontend/content/docs/snapshots/laravel-rust.md b/server/frontend/content/docs/snapshots/laravel-rust.md index 61ae0374..f4c4839f 100644 --- a/server/frontend/content/docs/snapshots/laravel-rust.md +++ b/server/frontend/content/docs/snapshots/laravel-rust.md @@ -66,7 +66,7 @@ visualci test -- cargo test The crate tells the two apart by `VISUALCI_MODE` (`local` or `ci`), which `visualci test` sets from CLI 0.2.12 on, and otherwise by whether `CI` is set. Plain `cargo test` with `VISUALCI_TOKEN` set works too, but each test process then makes its own local build: `visualci test` puts the whole run in one. -With `VISUALCI_TOKEN` set, nothing is written to `tests/__snapshots__` or `tests/__screenshots__`: the baselines live on VisualCI. If you kept them in git before, remove those folders. The first build becomes the baseline, or in a project that already has builds, the snapshots show as added once, to approve. `VISUALCI_DISABLED=1` compares with the files again, without sending anything. +With `VISUALCI_TOKEN` set, nothing is written to `tests/__snapshots__` or `tests/__screenshots__`: the baselines live on VisualCI. If you kept them in git before, remove those folders. The first build on the default branch becomes the baseline (a pull request's first build waits for review), or in a project that already has builds, the snapshots show as added once, to approve. `VISUALCI_DISABLED=1` compares with the files again, without sending anything. On GitHub Actions: diff --git a/server/frontend/content/docs/snapshots/rspec-snapshot.md b/server/frontend/content/docs/snapshots/rspec-snapshot.md index 568af234..ff58695e 100644 --- a/server/frontend/content/docs/snapshots/rspec-snapshot.md +++ b/server/frontend/content/docs/snapshots/rspec-snapshot.md @@ -15,7 +15,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/server/frontend/content/docs/snapshots/syrupy.md b/server/frontend/content/docs/snapshots/syrupy.md index f4a97235..26d9a4c1 100644 --- a/server/frontend/content/docs/snapshots/syrupy.md +++ b/server/frontend/content/docs/snapshots/syrupy.md @@ -15,7 +15,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/server/frontend/content/docs/snapshots/vitest.md b/server/frontend/content/docs/snapshots/vitest.md index ed1e9b96..f7f0cefc 100644 --- a/server/frontend/content/docs/snapshots/vitest.md +++ b/server/frontend/content/docs/snapshots/vitest.md @@ -15,7 +15,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/skills/visualci-insta/SKILL.md b/skills/visualci-insta/SKILL.md index 6ea1561b..3fd88366 100644 --- a/skills/visualci-insta/SKILL.md +++ b/skills/visualci-insta/SKILL.md @@ -21,7 +21,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t **/snapshots/*.snap.new ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/skills/visualci-jest/SKILL.md b/skills/visualci-jest/SKILL.md index 0d567763..37b2ca99 100644 --- a/skills/visualci-jest/SKILL.md +++ b/skills/visualci-jest/SKILL.md @@ -20,7 +20,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/skills/visualci-laravel-rust/SKILL.md b/skills/visualci-laravel-rust/SKILL.md index be13842d..3a4549cf 100644 --- a/skills/visualci-laravel-rust/SKILL.md +++ b/skills/visualci-laravel-rust/SKILL.md @@ -71,7 +71,7 @@ visualci test -- cargo test The crate tells the two apart by `VISUALCI_MODE` (`local` or `ci`), which `visualci test` sets from CLI 0.2.12 on, and otherwise by whether `CI` is set. Plain `cargo test` with `VISUALCI_TOKEN` set works too, but each test process then makes its own local build: `visualci test` puts the whole run in one. -With `VISUALCI_TOKEN` set, nothing is written to `tests/__snapshots__` or `tests/__screenshots__`: the baselines live on VisualCI. If you kept them in git before, remove those folders. The first build becomes the baseline, or in a project that already has builds, the snapshots show as added once, to approve. `VISUALCI_DISABLED=1` compares with the files again, without sending anything. +With `VISUALCI_TOKEN` set, nothing is written to `tests/__snapshots__` or `tests/__screenshots__`: the baselines live on VisualCI. If you kept them in git before, remove those folders. The first build on the default branch becomes the baseline (a pull request's first build waits for review), or in a project that already has builds, the snapshots show as added once, to approve. `VISUALCI_DISABLED=1` compares with the files again, without sending anything. On GitHub Actions: diff --git a/skills/visualci-rspec-snapshot/SKILL.md b/skills/visualci-rspec-snapshot/SKILL.md index 2c11ad02..edb5037f 100644 --- a/skills/visualci-rspec-snapshot/SKILL.md +++ b/skills/visualci-rspec-snapshot/SKILL.md @@ -20,7 +20,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/skills/visualci-syrupy/SKILL.md b/skills/visualci-syrupy/SKILL.md index ec400345..96f32105 100644 --- a/skills/visualci-syrupy/SKILL.md +++ b/skills/visualci-syrupy/SKILL.md @@ -20,7 +20,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/skills/visualci-vitest/SKILL.md b/skills/visualci-vitest/SKILL.md index d686caed..cc2fe4b2 100644 --- a/skills/visualci-vitest/SKILL.md +++ b/skills/visualci-vitest/SKILL.md @@ -20,7 +20,7 @@ The baselines live on VisualCI, so the snapshot files don't belong in git. Add t __snapshots__/ ``` -Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build has nothing to compare against and becomes the baseline. In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. +Then remove the committed copies (`git rm -r --cached` on those paths). In a new project, the first build on the default branch has nothing to compare against and becomes the baseline (a pull request's first build waits for review). In a project that already has builds, the snapshots show as added the first time, for your agent to approve once. ## 2. Write snapshots instead of failing diff --git a/skills/visualci/SKILL.md b/skills/visualci/SKILL.md index 7a037650..7a407317 100644 --- a/skills/visualci/SKILL.md +++ b/skills/visualci/SKILL.md @@ -52,9 +52,9 @@ Snapshot names come from file paths. `visualci build create` reads the commit, b ## 4. Review the changes -A build with nothing to compare against is approved automatically and becomes the baseline. After that, each build is compared with the approved build of its nearest ancestor commit, or the default branch's latest approved build. +The first build on your default branch has nothing to compare against, so it's approved automatically and becomes the baseline. After that, each build is compared with the approved build of its nearest ancestor commit, or the default branch's latest approved build. Nothing else becomes a baseline without a review: a pull request's first build, with nothing on the default branch to compare against, waits for review like any change. -When something changed, the CI job still passes and the GitHub check stays pending. Your agent reads the changes with `get_build` and `get_snapshot`, then approves them with `review`, or fixes the code and pushes again. Approved snapshots become the baseline for later builds on that branch. +When something changed, the CI job still passes and the GitHub check stays pending. Your agent reads the changes with `get_build` and `get_snapshot`, then approves them with `review`, or fixes the code and pushes again. Approved snapshots become the baseline for later builds on that branch, and reach the default branch when the pull request merges (squash merges too). Other branches never compare with them before then. Two things make that loop hold: [require the VisualCI check](https://visualci.com/docs/agents.md#make-the-check-block-merges), so a pull request can't merge before its review, and [add a VisualCI section to AGENTS.md](https://visualci.com/docs/agents.md#add-a-visualci-section-to-agents-md), so every agent working in the repository reviews its own builds.