feat(github): support user-defined PR labels
Add a setting in the GitHub integration screen that lets the admin specify a label that should be applied to all Open Inspect-generated PRs. The use case here is tracking Open Inspect-generated PRs separately from the rest of the PRs (whether human or agent created).
Setting the label in Settings > Integrations > GitHub Bot:
Resulting PR:
Summary by CodeRabbit
Summary by CodeRabbit
-
New Features
- Added a global PR Label default for GitHub integrations.
- Agent-created PRs can now include the configured label.
-
Bug Fixes
- PR label input is trimmed before saving; empty values are treated as unset.
- Label creation is best-effort—PR creation continues even if label lookup/creation fails or resolved settings can’t be retrieved.
-
Validation
- Added validation for the optional PR Label configuration to ensure it is a string.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f45636e1-44da-428b-9d05-42a4c34a2fbd
📥 Commits
Reviewing files that changed from the base of the PR and between 6709ba0fb4f42a31e4ccc05ee4cd033f73db9994 and 9f5fdb4bd5d70f238dae0283c8ad24e48ce2113d.
📒 Files selected for processing (7)
packages/control-plane/src/db/integration-settings.tspackages/control-plane/src/routes/integration-settings.tspackages/control-plane/src/session/durable-object.tspackages/control-plane/src/session/pull-request-service.tspackages/control-plane/src/source-control/providers/github-provider.tspackages/shared/src/types/integrations.tspackages/web/src/components/settings/integrations/github-integration-settings.tsx
🚧 Files skipped from review as they are similar to previous changes (7)
- packages/control-plane/src/routes/integration-settings.ts
- packages/shared/src/types/integrations.ts
- packages/control-plane/src/db/integration-settings.ts
- packages/control-plane/src/session/durable-object.ts
- packages/control-plane/src/session/pull-request-service.ts
- packages/web/src/components/settings/integrations/github-integration-settings.tsx
- packages/control-plane/src/source-control/providers/github-provider.ts
📝 Walkthrough
Walkthrough
Adds an optional prLabel field to GitHub integration settings. It is validated and normalized in the DB layer, exposed in resolved config, read during PR creation, passed to the GitHub provider, and surfaced in the web settings UI.
Changes
PR Label for GitHub Integration
| Layer / File(s) | Summary |
|---|---|
Shared type and DB validation packages/shared/src/types/integrations.ts, packages/control-plane/src/db/integration-settings.ts |
GitHubBotSettings gains optional prLabel; validation trims and normalizes it. |
Resolved config API and PR service contract packages/control-plane/src/routes/integration-settings.ts, packages/control-plane/src/session/pull-request-service.ts |
Resolved config endpoint exposes prLabel; PullRequestServiceDeps adds optional prLabel; PR creation conditionally passes labels to the provider. |
SessionDO prLabel lookup and wiring packages/control-plane/src/session/durable-object.ts |
createPullRequest performs a best-effort D1 lookup of resolved GitHub settings to extract prLabel, then passes it into SessionPullRequestService. |
GitHub provider ensureLabels packages/control-plane/src/source-control/providers/github-provider.ts |
Before attaching labels to a PR, a new ensureLabels helper best-effort POSTs each label to the GitHub labels endpoint, ignoring 422 and logging other failures without throwing. |
PR Label settings UI packages/web/src/components/settings/integrations/github-integration-settings.tsx |
GlobalSettingsSection adds prLabel state, initializes/resets/saves it, and renders a new PR Label input field. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
- ColeMurray
Poem
🐇 A label for every PR, neat and new, From settings to GitHub, it travels through. I trim it, I save it, I hop along bright, And ensure it exists before taking flight. 🏷️
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly matches the main change: adding user-defined PR labels for GitHub-created pull requests. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Premature add here. We'll shake this out at CompanyCam and then I'll resubmit it for upstream inclusion.
OK, confirmed this feature works in our fork. I'll flesh out the body of the PR with more information.
This setting might make sense in a new 'Source Code Management' setting category (pending in #762) where it applies equally to GitHub and GitLab.
https://github.com/ColeMurray/background-agents/pull/762#issuecomment-4768850228