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
8 changes: 6 additions & 2 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
# CodeRabbit reviews every pull request. It reads AGENTS.md on its own, as one of its default code
# guidelines; the path instructions point it at what reviews of StableBar keep catching.
# CodeRabbit reviews pull requests labeled deep-review, and cubic reviews every pull request
# (cubic.yaml). .github/workflows/deep-review.yml adds the label to big or risky changes, and anyone
# can add it by hand. CodeRabbit reads AGENTS.md on its own, as one of its default code guidelines;
# the path instructions point it at what reviews of StableBar keep catching.
language: en-US
reviews:
# Only the most important findings go inline. Each one is a thread to resolve before merging.
Expand All @@ -18,6 +20,8 @@ reviews:
auto_review:
enabled: true
drafts: false
# Adding the label starts a review.
labels: ["deep-review"]
# Every base branch, so pull requests stacked on another branch are reviewed too.
base_branches: [".*"]
# Keep reviewing every push: by default reviews pause after five reviewed commits, silently
Expand Down
24 changes: 24 additions & 0 deletions .github/deep-review-paths
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Sources/StableBar/PrivateAPI.swift
Comment thread
M4n0x marked this conversation as resolved.
Resolved
Sources/StableBar/AppUpdate.swift
Sources/StableBar/UpdateRelease.swift
Sources/StableBar/ICloudSync*.swift
Sources/StableBar/Uninstall*.swift
Sources/StableBar/ConfigurationLoader.swift
Sources/StableBar/PackageSecrets.swift
Comment thread
Seb-GRAF marked this conversation as resolved.
Resolved
Sources/StableBar/PackageSourceFetching.swift
Resources/Info.plist
Resources/StableBar.entitlements
.github/workflows/**
Comment thread
Seb-GRAF marked this conversation as resolved.
Resolved
.github/scripts/**
.github/deep-review-paths
.github/CODEOWNERS
.github/dependabot.yml
.coderabbit.yaml
cubic.yaml
.githooks/**
scripts/**
.releaserc.json
Package.swift
Package.resolved
package.json
package-lock.json
20 changes: 20 additions & 0 deletions .github/scripts/deep-review.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Decides whether a pull request gets the deep-review label, which starts a CodeRabbit review.
// .github/workflows/deep-review.yml runs the default branch's copy of this module, so a pull request
// never runs its own.
import { readFileSync } from "node:fs";
import { matchesGlob } from "node:path";

export const deepReviewPaths = readFileSync(new URL("../deep-review-paths", import.meta.url), "utf8").trim().split("\n");

export function needsDeepReview(files, changedLines) {
return changedLines > 400 || files.some((file) => deepReviewPaths.some((path) => matchesGlob(file, path)));
}

// Whether to add the label anew, which asks CodeRabbit again: at least 30 minutes ago, its summary
// comment said it hit the review limit on the head commit. CodeRabbit doesn't retry by itself, and
// drops the notice once it reviews.
export function needsRetry({ headSha, comments, now }) {
return comments.some((comment) => comment.user.login === "coderabbitai[bot]"
&& comment.body.includes("rate limited by coderabbit.ai") && comment.body.includes(headSha)
&& now - Date.parse(comment.updated_at) >= 30 * 60 * 1000);
}
39 changes: 39 additions & 0 deletions .github/scripts/deep-review.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { test } from "node:test";
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { matchesGlob } from "node:path";
import { deepReviewPaths, needsDeepReview, needsRetry } from "./deep-review.mjs";

test("needsDeepReview asks for more than 400 changed lines", () => {
assert.equal(needsDeepReview(["docs/widgets.md"], 400), false);
assert.equal(needsDeepReview(["docs/widgets.md"], 401), true);
});

test("needsDeepReview matches the listed paths", () => {
for (const file of ["Sources/StableBar/PrivateAPI.swift", "Sources/StableBar/ICloudSyncSettings.swift",
".github/workflows/ci.yml", ".github/scripts/fixtures/screens.json", "scripts/build.sh", "Package.resolved"])
assert.equal(needsDeepReview(["docs/widgets.md", file], 10), true, file);
for (const file of ["Sources/StableBar/BarStore.swift", "Sources/StableBar/Settings/PrivateAPI.swift",
"docs/scripts.md", "Tests/StableBarTests/UninstallTests.swift"])
assert.equal(needsDeepReview([file], 10), false, file);
});

test("every listed path matches a file", () => {
const files = execFileSync("git", ["ls-files"],
{ cwd: new URL("../..", import.meta.url), encoding: "utf8", timeout: 60_000 }).split("\n");
for (const path of deepReviewPaths) assert.ok(files.some((file) => matchesGlob(file, path)), path);
});

test("needsRetry asks CodeRabbit again 30 minutes after its review limit held back the head commit", () => {
const limited = (user, head) => ({ user: { login: user }, updated_at: "2026-11-17T09:00:00Z",
body: `<!-- This is an auto-generated comment: rate limited by coderabbit.ai -->\nbetween a1 and ${head}.` });
const summary = { user: { login: "coderabbitai[bot]" }, updated_at: "2026-11-17T09:00:00Z",
body: "<!-- This is an auto-generated comment: summarize by coderabbit.ai -->\nbetween a1 and b2." };
const pr = { headSha: "b2", comments: [limited("coderabbitai[bot]", "b2")], now: Date.parse("2026-11-17T09:30:00Z") };
assert.equal(needsRetry(pr), true);
assert.equal(needsRetry({ ...pr, now: Date.parse("2026-11-17T09:29:00Z") }), false);
assert.equal(needsRetry({ ...pr, headSha: "c3" }), false);
assert.equal(needsRetry({ ...pr, comments: [summary] }), false);
assert.equal(needsRetry({ ...pr, comments: [limited("cubic-dev-ai[bot]", "b2")] }), false);
assert.equal(needsRetry({ ...pr, comments: [] }), false);
});
4 changes: 2 additions & 2 deletions .github/scripts/pull-request-checks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ const keywords = "close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved"
const sectionNames = ["Problem", "Changes", "Testing"];
const attributionHint = 'End it with the model and harness that did the work, such as "Claude Opus 5.5 via Claude Code", or with "No agent".';

// The text GitHub shows, following CommonMark: auto-generated summaries and comments are hidden,
// The text GitHub shows, following CommonMark: auto-generated blocks and comments are hidden,
// code is shown as written, a comment that starts a line hides everything up to its "-->" (or the
// rest of the description when it never closes), and an unclosed "<!--" inside a line is text.
export function visibleText(body) {
const text = (body ?? "")
.replace(/\r\n/g, "\n")
.replace(/<!-- This is an auto-generated comment[\s\S]*?<!-- end of auto-generated comment[\s\S]*?-->/g, "");
.replace(/<!-- This is an auto-generated (?:comment|description)[\s\S]*?<!-- end of auto-generated (?:comment|description)[\s\S]*?-->/gi, "");
const shown = [];
let paragraph = [];
let fence = null;
Expand Down
5 changes: 5 additions & 0 deletions .github/scripts/pull-request-checks.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ const filled = ["## Problem", "The clock disappears on a notched display.", "",
"## Merging", "Rebase merge.", "", attribution].join("\n");
const summary = "\n<!-- This is an auto-generated comment: release notes by coderabbit.ai -->\n" +
"## Summary by CodeRabbit\n* New stuff\n<!-- end of auto-generated comment: release notes by coderabbit.ai -->";
const cubicButtons = "\n\n<!-- This is an auto-generated description by cubic. -->\n" +
'<a href="https://cubic.dev/pr/Seb-GRAF/StableBar/pull/1"><img alt="View guided diff" src="review.svg"></a>\n' +
"<!-- End of auto-generated description by cubic. -->\n";
const everything = ["Problem", "Changes", "Testing", "attribution line"];

test("visibleText drops comments, auto-generated blocks and carriage returns", () => {
assert.equal(visibleText("a <!-- x --> b <!-- y\nz --> c"), "a b c");
assert.equal(visibleText("a\n<!-- never closed\nb"), "a\n");
assert.equal(visibleText("a\r\nb"), "a\nb");
assert.equal(visibleText("text\n" + summary.trimStart()), "text\n");
assert.equal(visibleText("text" + cubicButtons), "text\n\n\n");
assert.equal(visibleText(null), "");
});

Expand Down Expand Up @@ -68,6 +72,7 @@ test("checkDescription wants Problem, Changes, Testing and a last attribution li
assert.deepEqual(checkDescription(filled.replace("swift test --filter Clock passes.", "<!-- later -->")).missing, ["Testing"]);
assert.deepEqual(checkDescription(filled.replace("## Testing", "## testing")).missing, []);
assert.deepEqual(checkDescription(filled + summary).missing, []);
assert.deepEqual(checkDescription(filled + cubicButtons).missing, []);
assert.deepEqual(checkDescription(filled.replace("Keep it left of the notch.", "Handle the literal `<!--` token.")).missing, []);
assert.deepEqual(checkDescription(filled.replace("swift test --filter Clock passes.", "```html\n<!-- example\n```")).missing, []);
assert.deepEqual(checkDescription(filled.replace("Keep it left of the notch.", "<!-- unterminated")).missing,
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/deep-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Deep review

# Adds the deep-review label, which starts a CodeRabbit review, and every hour asks CodeRabbit again
# where its review limit held a review back. pull_request_target runs the default branch's copy of
# this workflow and of .github/scripts, so a pull request never runs its own code here. The logic and
# its tests are in .github/scripts/deep-review.mjs.
on:
pull_request_target:
types: [opened, reopened, synchronize, ready_for_review]
schedule:
- cron: "17 * * * *"
workflow_dispatch:

permissions:
contents: read
pull-requests: write
Comment thread
Seb-GRAF marked this conversation as resolved.
Resolved

concurrency:
group: deep-review-${{ github.event.pull_request.number }}
# A retry run that stopped between removing and adding the label would leave the label off.
cancel-in-progress: ${{ github.event_name == 'pull_request_target' }}

jobs:
label:
name: Deep review label
if: >-
Comment thread
M4n0x marked this conversation as resolved.
Resolved
github.event_name == 'pull_request_target' && !github.event.pull_request.draft
&& !contains(github.event.pull_request.labels.*.name, 'deep-review')
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch }}
sparse-checkout: .github/scripts
persist-credentials: false
- uses: actions/github-script@v9
with:
script: |
const { needsDeepReview } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/deep-review.mjs`);
const { owner, repo } = context.repo;
const pr = context.payload.pull_request;
const files = await github.paginate(github.rest.pulls.listFiles, { owner, repo, pull_number: pr.number, per_page: 100 });
const paths = files.flatMap((file) => file.previous_filename ? [file.filename, file.previous_filename] : [file.filename]);
if (needsDeepReview(paths, pr.additions + pr.deletions))
await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] });

retry:
name: Ask CodeRabbit again
if: github.event_name != 'pull_request_target'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.repository.default_branch }}
sparse-checkout: .github/scripts
persist-credentials: false
- uses: actions/github-script@v9
with:
script: |
const { needsRetry } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/deep-review.mjs`);
const { owner, repo } = context.repo;
const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: "open", sort: "created", direction: "asc", per_page: 100 });
// CodeRabbit allows each pull request author two reviews an hour; the oldest go first.
const asked = new Map();
for (const pr of pulls.filter((pr) => !pr.draft && pr.labels.some((label) => label.name === "deep-review"))) {
if (asked.get(pr.user.login) === 2) continue;
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number: pr.number, per_page: 100 });
if (!needsRetry({ headSha: pr.head.sha, comments, now: Date.now() })) continue;
asked.set(pr.user.login, (asked.get(pr.user.login) ?? 0) + 1);
core.info(`Asking CodeRabbit again on #${pr.number}.`);
try {
await github.rest.issues.removeLabel({ owner, repo, issue_number: pr.number, name: "deep-review" });
} finally {
await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] });
}
}
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ A configuration change rarely lives in one place. Before calling one done, say w
- A `fix`, `feat` or `perf` pull request needs an issue. Before opening it, search with the `triage` skill. If an open issue covers the problem, link it. If none does, file one with `triage` (the request for the pull request covers filing it) and link that. If triage finds the problem already fixed or declined, tell the developer before going on. Other types, such as `ci`, `test`, `docs` or `chore`, can skip the issue.
- Titles follow Conventional Commits in plain words, such as `fix: keep the clock visible on a notched display`. Every commit message is checked too, and the types of the commits that reach `main` decide the next release (see [Commits and releases](CONTRIBUTING.md#commits-and-releases)).
- Fill in the [pull request template](.github/pull_request_template.md), and end the description with the model and harness that did the work. The `Description` check fails without that line, and `Linked issue` fails a `fix`, `feat` or `perf` pull request that closes no issue.
- CodeRabbit reviews every pull request. Answer each of its comments by fixing the code or replying why not, then resolve the thread: unresolved threads block merging.
- cubic reviews every pull request, and CodeRabbit reviews those labeled `deep-review`. The label is added automatically when a pull request changes more than 400 lines or a file in [.github/deep-review-paths](.github/deep-review-paths); add it yourself, or ask a maintainer to, when a change is risky, such as when cubic's review points out a risk. Answer each comment from either by fixing the code or replying why not, then resolve the thread: unresolved threads block merging. Don't post `@coderabbitai review`: each request uses up one of the pull request author's few CodeRabbit reviews per hour, and the Deep review workflow already asks CodeRabbit again every hour when its limit held a review back.
- Upload screenshots and recordings to the pull request; never commit them. The images in `docs/images` are the exception: they illustrate the README and the guide, and CI draws them (see [Docs images](CONTRIBUTING.md#docs-images)).
- Keep to one problem per pull request.

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ There is no web view or custom drawing loop. Private macOS API, for hiding and r

Reviews are requested automatically from the people listed in [CODEOWNERS](.github/CODEOWNERS), but they are not required. Ask for one when a change is risky or outside your usual area.

[CodeRabbit](https://coderabbit.ai) also reviews every pull request once it is out of draft, and comments only on what matters most. Fix each comment or reply why not, then resolve its thread: unresolved conversations block merging. Its rules come from [AGENTS.md](AGENTS.md) and [.coderabbit.yaml](.coderabbit.yaml).
[cubic](https://cubic.dev) also reviews every pull request once it is out of draft. [CodeRabbit](https://coderabbit.ai) reviews pull requests labeled `deep-review`: the label is added automatically when a pull request changes more than 400 lines or a file listed in [.github/deep-review-paths](.github/deep-review-paths), and you can add it yourself, or ask a maintainer to, when a change is risky. Fix each comment from either or reply why not, then resolve its thread: unresolved conversations block merging. Their rules come from [AGENTS.md](AGENTS.md), [cubic.yaml](cubic.yaml) and [.coderabbit.yaml](.coderabbit.yaml). CodeRabbit allows each pull request author only a few reviews per hour. When its limit holds a review back, the Deep review workflow asks it again every hour, so there's no need to ask with `@coderabbitai review`.

[DECISIONS.md](DECISIONS.md) lists the lasting decisions about releases, reviews and code. A pull request that sets a new rule or policy adds an entry there.

Expand Down
4 changes: 3 additions & 1 deletion DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Add an entry when a pull request sets a rule, a policy or a choice not to do som

## Reviews and checks

- **CodeRabbit reviews every pull request** (2026-10-31, [#391]). It's free for open source, its quiet profile posts only what matters, and it reviews every push. No paid review tools or API keys.
- **cubic reviews every pull request, CodeRabbit the risky ones** (2026-11-17, [#772], [#773]). CodeRabbit's free plan allows each author two reviews an hour, so pull requests opened together went unreviewed. cubic is free for public repositories and resolves its own threads. CodeRabbit, which had reviewed every pull request since 2026-10-31 ([#391]), now reviews those labeled `deep-review`: more than 400 changed lines, a file in `.github/deep-review-paths`, or added by hand. A workflow asks it again every hour when its limit held a review back. No paid review tools or API keys.
Comment thread
Seb-GRAF marked this conversation as resolved.
Resolved
- **No auto-merge** (2026-10-31). The rules need no approval, but a maintainer merges; nothing merges itself.
- **A person approves changed screens** (2026-10-31, [#395], [#397]). CI draws before/after screens, and any maintainer, the author too, adds `visual-ok` after looking. A visible change also shows screenshots in its pull request description (2026-11-08, [#484]).
- **Pull requests compare with `main`'s own screens** (2026-11-17). Each push to `main` draws its screens once, and a pull request uses those of its base, drawing from the base only the scenes it adds or edits, instead of drawing the whole base again in every run. Docs images drawn from one commit on different CI Macs, and on two runner images, matched byte for byte. A cancelled draw leaves Visual review pending, not failed.
Expand Down Expand Up @@ -82,3 +82,5 @@ Add an entry when a pull request sets a rule, a policy or a choice not to do som
[#618]: https://github.com/Seb-GRAF/StableBar/issues/618
[#664]: https://github.com/Seb-GRAF/StableBar/issues/664
[#676]: https://github.com/Seb-GRAF/StableBar/issues/676
[#772]: https://github.com/Seb-GRAF/StableBar/issues/772
[#773]: https://github.com/Seb-GRAF/StableBar/pull/773
Loading
Loading