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.27",
"version": "0.1.28",
"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.27",
"version": "0.1.28",
"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.27",
"version": "0.1.28",
"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
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.27",
"version": "0.1.28",
"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
7 changes: 5 additions & 2 deletions server/frontend/content/docs/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ Pages that legitimately render two ways can be accepted as a variant with `revie

## Keeping approval with people

Some teams want agents to read builds and fix code, but leave approving changes to a person. Take the two review
tools away from the agent in its client:
Some teams want agents to read builds and fix code, but leave approving changes to a person. For agents in CI,
which use the project's token, turn off **Project tokens can approve** in the project's settings (or `update_project`
with `tokens_can_approve: false`): a project token can then still reject changes and comment, but approving, accepting
a variant or ignoring a change takes a person. For agents on people's machines, which use their own token, take the
two review tools away in the agent's client:

- **Claude Code:** deny them in `.claude/settings.json`, which the whole team shares through the repository:

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 @@ -230,6 +230,8 @@ export type ProjectSettings = {
forge_webhook_at: string | null
/** Whether the screenshots visualci.yml's `gallery` names are public. */
gallery_enabled: boolean
/** Whether project tokens (CI's agents) may approve changes; off keeps approving with people. */
tokens_can_approve: boolean
/** Anyone, signed in or not, can read its builds and diffs. */
public: boolean
/** GitHub says its repository is public (checked on linking and once a day). Only then can it be public. */
Expand Down
18 changes: 18 additions & 0 deletions server/frontend/src/pages/ProjectPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ const toDraft = (s: ProjectSettings): Draft => ({
threshold: s.threshold,
ignore_anti_aliasing: s.ignore_anti_aliasing,
gallery_enabled: s.gallery_enabled,
tokens_can_approve: s.tokens_can_approve,
public: s.public,
rules: s.ignore_rules.map((r) => ({
snapshots: r.snapshots,
Expand Down Expand Up @@ -532,6 +533,23 @@ function Settings({
</label>
))}
</div>
<label className="check">
<input
type="checkbox"
checked={draft.tokens_can_approve}
onChange={(e) => set('tokens_can_approve', e.target.checked)}
/>
<span>
<strong>
Project tokens can approve{' '}
<Help label="About approving with project tokens">
An agent in CI uses a project token. Turn this off to keep approving with people: a project token can
then still reject changes and comment, but approving, accepting a variant or ignoring a change takes a
person, in the web app or with their own token.
</Help>
</strong>
</span>
</label>
</fieldset>

<fieldset className="settings-group" disabled={!canEdit}>
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 @@ -39,6 +39,7 @@ mod m20261202_000030_stripe_order;
mod m20261202_000033_linked_by;
mod m20261202_000034_render_job_token;
mod m20261202_000035_invitation_for_user;
mod m20261202_000036_tokens_can_approve;

pub struct Migrator;

Expand Down Expand Up @@ -84,6 +85,7 @@ impl MigratorTrait for Migrator {
Box::new(m20261202_000033_linked_by::Migration),
Box::new(m20261202_000034_render_job_token::Migration),
Box::new(m20261202_000035_invitation_for_user::Migration),
Box::new(m20261202_000036_tokens_can_approve::Migration),
// inject-above (do not remove this comment)
]
}
Expand Down
26 changes: 26 additions & 0 deletions server/migration/src/m20261202_000036_tokens_can_approve.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//! A project can keep approving with people: with `tokens_can_approve` off, a project token (CI's) can't approve
//! changes, accept a variant or ignore a change over MCP; rejecting and commenting still work.
use sea_orm_migration::prelude::*;

pub struct Migration;

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

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.get_connection()
.execute_unprepared("ALTER TABLE projects ADD COLUMN tokens_can_approve BOOLEAN NOT NULL DEFAULT true;")
.await?;
Ok(())
}

async fn down(&self, m: &SchemaManager) -> Result<(), DbErr> {
m.get_connection().execute_unprepared("ALTER TABLE projects DROP COLUMN tokens_can_approve;").await?;
Ok(())
}
}
18 changes: 18 additions & 0 deletions server/src/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ impl VisualCi {
)))
}

/// Why a project token can't approve in this project (its `tokens_can_approve` is off), else `None`.
fn tokens_may_not_approve(&self, rc: &RequestContext<RoleServer>, project: &projects::Model) -> Option<String> {
(matches!(principal_of(rc), Some(Principal::Project(_))) && !project.tokens_can_approve).then(|| {
"this project keeps approving with people: a project token can't approve, accept a variant or ignore a \
change (rejecting and commenting still work); a person approves in the web app, or with their own \
token"
.to_string()
})
}

/// The project a tool works on: `org/project`, or the project token's own project.
async fn project(
&self,
Expand Down Expand Up @@ -1896,6 +1906,11 @@ impl VisualCi {
if let Err(e) = self.need_role(&rc, &project, Role::Member, "review builds").await? {
return Ok(tool_error(e));
}
if args.action == "approve"
&& let Some(refused) = self.tokens_may_not_approve(&rc, &project)
{
return Ok(tool_error(refused));
}
let Some(build) = self.find_build(&project, &args.build).await else {
return Ok(tool_error(format!("no build {} in this project", args.build)));
};
Expand Down Expand Up @@ -2151,6 +2166,9 @@ impl VisualCi {
if let Err(e) = self.need_role(&rc, &project, Role::Member, "review builds").await? {
return Ok(tool_error(e));
}
if let Some(refused) = self.tokens_may_not_approve(&rc, &project) {
return Ok(tool_error(refused));
}
let Some(build) = self.find_build(&project, &args.build).await else {
return Ok(tool_error(format!("no build {} in this project", args.build)));
};
Expand Down
2 changes: 2 additions & 0 deletions server/src/models/_entities/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub struct Model {
pub forge_installation: Option<String>,
/// Whether the gallery (visualci.yml's `gallery`) is public. On by default; nothing is public without a gallery.
pub gallery_enabled: bool,
/// Whether project tokens may approve changes over MCP (CI's agents); off keeps approving with people.
pub tokens_can_approve: bool,
#[sea_orm(column_type = "Text")]
pub default_branch: String,
#[sea_orm(column_type = "Text")]
Expand Down
8 changes: 8 additions & 0 deletions server/src/models/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ pub struct Settings {
pub forge_webhook_at: Option<String>,
/// Whether the screenshots visualci.yml's `gallery` names are public.
pub gallery_enabled: bool,
/// Whether project tokens may approve changes over MCP; off keeps approving with people.
pub tokens_can_approve: bool,
/// Whether anyone, signed in or not, can read the project's builds and diffs (open source). Settings, tokens and
/// reviewing stay with its members.
pub public: bool,
Expand Down Expand Up @@ -168,6 +170,7 @@ impl From<&Model> for Settings {
forge_app_installed: p.forge_installation.is_some(),
forge_webhook_at: p.forge_webhook_at.map(|d| d.to_rfc3339()),
gallery_enabled: p.gallery_enabled,
tokens_can_approve: p.tokens_can_approve,
public: p.public,
repository_public: p.repository_public,
open_source: p.open_source,
Expand Down Expand Up @@ -205,6 +208,8 @@ pub struct SettingsChange {
pub forge_token: Option<String>,
/// `false` takes the public gallery down (visualci.yml's `gallery` decides what's in it); `true` puts it back.
pub gallery_enabled: Option<bool>,
/// `false`: project tokens can't approve changes (people do); `true` lets CI's agents approve again.
pub tokens_can_approve: Option<bool>,
/// `true` lets anyone, signed in or not, read the project's builds and diffs (for open source projects);
/// settings, tokens and reviewing stay with its members. Only a project linked to a public repository can be
/// public. `false` makes it private again.
Expand Down Expand Up @@ -337,6 +342,9 @@ impl Model {
if let Some(v) = p.name {
a.name = Set(v);
}
if let Some(v) = p.tokens_can_approve {
a.tokens_can_approve = Set(v);
}
if let Some(v) = p.gallery_enabled {
a.gallery_enabled = Set(v);
}
Expand Down
34 changes: 34 additions & 0 deletions server/tests/requests/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,37 @@ async fn a_project_token_acts_as_a_member_not_an_admin() {
})
.await;
}

/// With "Tokens can approve" off, a project token can't approve, accept a variant or ignore a change; it can still
/// reject. A person's token can turn it off and on.
#[tokio::test]
#[serial]
async fn a_project_can_keep_approving_with_people() {
request::<App, _, _>(|request, ctx| async move {
let f = fixture(&ctx).await;
let project = format!("{}/pdfs", f.org);
let (err, s) = call(
&request,
&f.user_token,
"update_project",
serde_json::json!({ "project": project, "tokens_can_approve": false }),
)
.await;
assert!(!err && s["settings"]["tokens_can_approve"] == false, "{s}");
let t = &f.project_token;
let (err, r) = call(&request, t, "review", serde_json::json!({ "build": 1, "action": "approve" })).await;
assert!(err && r.to_string().contains("approving with people"), "{r}");
let (err, r) = call(
&request,
t,
"review_page",
serde_json::json!({ "build": 1, "name": "x", "position": 0, "action": "ignore" }),
)
.await;
assert!(err && r.to_string().contains("approving with people"), "{r}");
// Rejecting isn't approving: it reaches the build (there's none here).
let (err, r) = call(&request, t, "review", serde_json::json!({ "build": 1, "action": "reject" })).await;
assert!(err && r.to_string().contains("no build"), "{r}");
})
.await;
}
7 changes: 5 additions & 2 deletions skills/visualci-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ Pages that legitimately render two ways can be accepted as a variant with `revie

## Keeping approval with people

Some teams want agents to read builds and fix code, but leave approving changes to a person. Take the two review
tools away from the agent in its client:
Some teams want agents to read builds and fix code, but leave approving changes to a person. For agents in CI,
which use the project's token, turn off **Project tokens can approve** in the project's settings (or `update_project`
with `tokens_can_approve: false`): a project token can then still reject changes and comment, but approving, accepting
a variant or ignoring a change takes a person. For agents on people's machines, which use their own token, take the
two review tools away in the agent's client:

- **Claude Code:** deny them in `.claude/settings.json`, which the whole team shares through the repository:

Expand Down
Loading