diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json
index 09457da1..5e30db86 100644
--- a/.claude-plugin/marketplace.json
+++ b/.claude-plugin/marketplace.json
@@ -5,7 +5,7 @@
"plugins": [
{
"name": "visualci",
- "version": "0.1.32",
+ "version": "0.1.33",
"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 adfa0daf..b04c1584 100644
--- a/.claude-plugin/plugin.json
+++ b/.claude-plugin/plugin.json
@@ -1,6 +1,6 @@
{
"name": "visualci",
- "version": "0.1.32",
+ "version": "0.1.33",
"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 cf4cb403..5656560c 100644
--- a/.cursor-plugin/plugin.json
+++ b/.cursor-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "visualci",
"displayName": "VisualCI",
- "version": "0.1.32",
+ "version": "0.1.33",
"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/gemini-extension.json b/gemini-extension.json
index b921712a..5683630e 100644
--- a/gemini-extension.json
+++ b/gemini-extension.json
@@ -1,6 +1,6 @@
{
"name": "visualci",
- "version": "0.1.32",
+ "version": "0.1.33",
"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/agents.md b/server/frontend/content/docs/agents.md
index 86af8f5d..d20ec647 100644
--- a/server/frontend/content/docs/agents.md
+++ b/server/frontend/content/docs/agents.md
@@ -171,7 +171,8 @@ unreviewed changes can pile up on main without anyone noticing. Three things kee
- The commit's VisualCI check stays pending until the build is reviewed, as on a pull request.
- `whoami` lists the newest builds waiting for a review, and `list_builds` with `waiting_for_review: true` lists a
- project's. Add a line to your agents' instructions: after a push, review its VisualCI build.
+ project's. A pull request closed without merging, or a deleted branch, takes its builds off those lists: they
+ become `closed` (reopening the pull request puts its newest build back). Add a line to your agents' instructions: after a push, review its VisualCI build.
- To hold the push's CI run until the review, set `ci_mode: wait` in [visualci.yml](/docs/reference/config/) and
finish with `visualci build finalize --wait`: CI waits (up to `--timeout`) while the agent reviews, then passes or
fails on the result. `strict` fails the run on any unreviewed change instead.
diff --git a/server/frontend/src/api/types.ts b/server/frontend/src/api/types.ts
index 8db9bb32..1a41d5a3 100644
--- a/server/frontend/src/api/types.ts
+++ b/server/frontend/src/api/types.ts
@@ -146,7 +146,7 @@ export type StaffFeedback = {
}
export type BuildState = 'receiving' | 'processing' | 'completed' | 'failed'
-export type ReviewState = 'none' | 'pending' | 'approved' | 'rejected' | 'auto_approved' | 'superseded'
+export type ReviewState = 'none' | 'pending' | 'approved' | 'rejected' | 'auto_approved' | 'superseded' | 'closed'
export type Conclusion = 'unchanged' | 'changes' | 'failed' | null
export type Stats = {
diff --git a/server/frontend/src/components/ui.tsx b/server/frontend/src/components/ui.tsx
index 78485c4f..c9fd2bfa 100644
--- a/server/frontend/src/components/ui.tsx
+++ b/server/frontend/src/components/ui.tsx
@@ -40,6 +40,8 @@ export function ReviewPill({ review }: { review: ReviewState | SnapshotReview })
return auto-approved
case 'superseded':
return superseded
+ case 'closed':
+ return closed
default:
return null
}
diff --git a/server/migration/src/lib.rs b/server/migration/src/lib.rs
index 96da73cd..0728c611 100644
--- a/server/migration/src/lib.rs
+++ b/server/migration/src/lib.rs
@@ -43,6 +43,7 @@ mod m20261202_000036_tokens_can_approve;
mod m20261202_000037_review_source;
mod m20261202_000038_matches_approved;
mod m20261202_000039_repository_id;
+mod m20261202_000040_closed_builds;
pub struct Migrator;
@@ -92,6 +93,7 @@ impl MigratorTrait for Migrator {
Box::new(m20261202_000037_review_source::Migration),
Box::new(m20261202_000038_matches_approved::Migration),
Box::new(m20261202_000039_repository_id::Migration),
+ Box::new(m20261202_000040_closed_builds::Migration),
// inject-above (do not remove this comment)
]
}
diff --git a/server/migration/src/m20261202_000040_closed_builds.rs b/server/migration/src/m20261202_000040_closed_builds.rs
new file mode 100644
index 00000000..767e0d7a
--- /dev/null
+++ b/server/migration/src/m20261202_000040_closed_builds.rs
@@ -0,0 +1,43 @@
+//! A build waiting for review whose pull request was closed without merging, or whose branch was deleted, stops
+//! waiting: its review state is `closed` (`builds::Model::close_waiting`). `branch_checks` records when the forge
+//! sync last asked whether a branch with builds waiting still exists, so each is asked at most once a day.
+use sea_orm_migration::prelude::*;
+
+pub struct Migration;
+
+impl MigrationName for Migration {
+ fn name(&self) -> &str {
+ "m20261202_000040_closed_builds"
+ }
+}
+
+#[async_trait::async_trait]
+impl MigrationTrait for Migration {
+ async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
+ m.get_connection()
+ .execute_unprepared(
+ "ALTER TABLE builds DROP CONSTRAINT builds_review_state_check, \
+ ADD CONSTRAINT builds_review_state_check CHECK (review_state IN \
+ ('none', 'pending', 'approved', 'rejected', 'auto_approved', 'superseded', 'closed')); \
+ CREATE TABLE branch_checks ( \
+ project_id BIGINT NOT NULL REFERENCES projects(id) ON DELETE CASCADE, \
+ branch TEXT NOT NULL, \
+ checked_at TIMESTAMPTZ NOT NULL DEFAULT now(), \
+ PRIMARY KEY (project_id, branch));",
+ )
+ .await?;
+ Ok(())
+ }
+
+ async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
+ m.get_connection()
+ .execute_unprepared(
+ "DROP TABLE branch_checks; UPDATE builds SET review_state = 'pending' WHERE review_state = 'closed'; \
+ ALTER TABLE builds DROP CONSTRAINT builds_review_state_check, \
+ ADD CONSTRAINT builds_review_state_check CHECK (review_state IN \
+ ('none', 'pending', 'approved', 'rejected', 'auto_approved', 'superseded'));",
+ )
+ .await?;
+ Ok(())
+ }
+}
diff --git a/server/src/access.rs b/server/src/access.rs
index b182aae6..4032a9ee 100644
--- a/server/src/access.rs
+++ b/server/src/access.rs
@@ -761,6 +761,22 @@ pub async fn handle_event(ctx: &AppContext, forge: &Forge, event: ForgeEvent) ->
tracing::info!(repo = repository.path, head, base, merge_commit, recorded, "pull request merged");
serde_json::json!({ "recorded": recorded })
}
+ ForgeEvent::Closed { repository, branch, why } => {
+ let mut closed = 0;
+ for project in linked(db, &repository).await? {
+ closed += crate::workers::close_branch(ctx, project.id, &branch, why).await?;
+ }
+ tracing::info!(repo = repository.path, branch, why, closed, "branch closed");
+ serde_json::json!({ "closed": closed })
+ }
+ ForgeEvent::Reopened { repository, branch } => {
+ let mut reopened = 0;
+ for project in linked(db, &repository).await? {
+ reopened += crate::workers::reopen_branch(ctx, project.id, &branch).await?;
+ }
+ tracing::info!(repo = repository.path, branch, reopened, "pull request reopened");
+ serde_json::json!({ "reopened": reopened })
+ }
ForgeEvent::Installation { installation, previous, repositories } => {
let mut changed = 0;
let mut affected = HashSet::new();
diff --git a/server/src/controllers/forge_webhooks.rs b/server/src/controllers/forge_webhooks.rs
index bfd38b35..7a1cee3b 100644
--- a/server/src/controllers/forge_webhooks.rs
+++ b/server/src/controllers/forge_webhooks.rs
@@ -85,6 +85,13 @@ async fn gitlab_project(
crate::models::baselines::record_merge(&ctx.db, project.id, &head, &base, &merge_commit).await?;
serde_json::json!({ "recorded": recorded })
}
+ // This project only, like merges: the hook belongs to it.
+ crate::forge::ForgeEvent::Closed { branch, why, .. } => {
+ serde_json::json!({ "closed": crate::workers::close_branch(&ctx, project.id, &branch, why).await? })
+ }
+ crate::forge::ForgeEvent::Reopened { branch, .. } => {
+ serde_json::json!({ "reopened": crate::workers::reopen_branch(&ctx, project.id, &branch).await? })
+ }
other => access::handle_event(&ctx, &forge, other).await?,
};
tracing::info!(forge = "gitlab", kind, repo = repository.path, project = %project.pid, outcome = %outcome, "webhook");
diff --git a/server/src/forge.rs b/server/src/forge.rs
index 6a50a3c4..112ac2e4 100644
--- a/server/src/forge.rs
+++ b/server/src/forge.rs
@@ -268,6 +268,11 @@ pub struct SignIn {
pub enum ForgeEvent {
/// A pull request merged: its approvals become the base branch's at the merge commit.
Merged { repository: Repository, head: String, base: String, merge_commit: String },
+ /// A pull request closed without merging (`why` "pull_request"), or a branch deleted ("branch_deleted"): the
+ /// branch's builds waiting for review stop waiting (`closed`).
+ Closed { repository: Repository, branch: String, why: &'static str },
+ /// A closed pull request reopened: its branch's newest closed build waits for review again.
+ Reopened { repository: Repository, branch: String },
/// The forge app was installed on these repositories (`installation` set) or removed from them (`None`).
Installation { installation: Option, previous: Option, repositories: Vec },
/// These people's access may have changed (forge user IDs).
@@ -453,6 +458,24 @@ impl Forge {
}
}
+ /// Whether a branch still exists (`None` when the repository can't be seen).
+ ///
+ /// # Errors
+ /// When the forge can't be reached or refuses the app's credentials.
+ pub async fn branch_exists(
+ &self,
+ repository: &Repository,
+ installation: &str,
+ branch: &str,
+ ) -> Result