Skip to content

Commit e6bbc36

Browse files
fatmcgavGavin Williamsbrendan-kellam
authored
feat(web): GitLab MR Review Agent (#1104)
* feat(web): GitLab MR Review Agent Adds support for the AI Review Agent to review GitLab Merge Requests, mirroring the existing GitHub PR review functionality. Also fixes several bugs discovered during implementation and improves the shared review pipeline. --- ## New files ### `packages/web/src/features/agents/review-agent/nodes/gitlabMrParser.ts` Parses a GitLab MR webhook payload into the shared `sourcebot_pr_payload` format. Calls `MergeRequests.show()` and `MergeRequests.allDiffs()` in parallel — the API response is used for `title`, `description`, `sha`, and `diff_refs` (which can be absent in webhook payloads for `update` action events), while per-file diffs are parsed using the existing `parse-diff` library. ### `packages/web/src/features/agents/review-agent/nodes/gitlabPushMrReviews.ts` Posts review comments back to GitLab using `MergeRequestDiscussions.create()` with a position object carrying `base_sha`, `head_sha`, and `start_sha`. Falls back to `MergeRequestNotes.create()` (a general MR note) if the inline comment is rejected by the API (e.g. the line is not within the diff), ensuring reviews are always surfaced even when precise positioning fails. ### Test files (4 new files, 34 tests total) - `githubPrParser.test.ts` — diff parsing and metadata mapping for the GitHub parser - `githubPushPrReviews.test.ts` — single-line vs multi-line comment parameters, error resilience - `gitlabMrParser.test.ts` — API call arguments, metadata mapping, diff parsing, edge cases (empty diffs, nested groups, null description, API failures) - `gitlabPushMrReviews.test.ts` — inline comment posting, fallback behaviour, missing `diff_refs` guard, multi-file iteration --- ## Modified files ### `packages/web/src/features/agents/review-agent/types.ts` - Added `sourcebot_diff_refs` schema/type (`base_sha`, `head_sha`, `start_sha`) and an optional `diff_refs` field on `sourcebot_pr_payload` - Added `GitLabMergeRequestPayload` and `GitLabNotePayload` interfaces for webhook event typing ### `packages/web/src/features/agents/review-agent/app.ts` - Added `processGitLabMergeRequest()` function mirroring `processGitHubPullRequest()`: sets up logging, runs the GitLab parser, generates reviews via the shared LLM pipeline, and pushes results - Removed stale `OPENAI_API_KEY` guards (model availability is now enforced inside `invokeDiffReviewLlm`) ### `packages/web/src/features/agents/review-agent/nodes/invokeDiffReviewLlm.ts` **Replaces the hardcoded OpenAI client** with the Vercel AI SDK's `generateText` and the shared `getAISDKLanguageModelAndOptions` / `getConfiguredLanguageModels` utilities from `chat/utils.server.ts`. The review agent now uses whichever language model is configured in `config.json`, supporting all providers (Anthropic, Bedrock, Azure, etc.). - `REVIEW_AGENT_MODEL` env var (matched against `displayName`) selects a specific model when multiple are configured; falls back to `models[0]` with a warning if the name is not found - Prompt is passed via the `system` parameter with a `"Review the code changes."` user turn, satisfying providers (e.g. Bedrock/Anthropic) that require conversations to begin with a user message ### `packages/web/src/features/agents/review-agent/nodes/fetchFileContent.ts` **Fixes "Not authenticated" error** when the review agent calls `getFileSource`. The original implementation used `withOptionalAuth`, which reads a session cookie — absent in webhook handlers. Now calls `getFileSourceForRepo` directly with `__unsafePrisma` and the single-tenant org, bypassing the session-based auth layer. The webhook handler has already authenticated the request via its own mechanism (GitHub App signature / GitLab token). ### `packages/web/src/features/git/getFileSourceApi.ts` - Extracted the core repo-lookup + git + language-detection logic into a new exported `getFileSourceForRepo({ path, repo, ref }, { org, prisma })` function - `getFileSource` now handles auth and audit logging then delegates to `getFileSourceForRepo` — all existing callers are unchanged ### `packages/web/src/app/api/(server)/webhook/route.ts` - Added GitLab webhook handling alongside the existing GitHub branch - Verifies `x-gitlab-token` against `GITLAB_REVIEW_AGENT_WEBHOOK_SECRET` - Handles `Merge Request Hook` events (auto-review on `open`, `update`, `reopen`) and `Note Hook` events (manual `/review` command on MR comments) - Initialises a `Gitlab` client at module load if `GITLAB_REVIEW_AGENT_TOKEN` is set ### `packages/web/src/app/(app)/agents/page.tsx` - Split the single "Review Agent" card into two separate cards: **GitHub Review Agent** and **GitLab Review Agent**, each showing its own configuration status - Removed `OPENAI_API_KEY` from the GitHub card's required env vars (no longer applicable) ### `packages/web/src/app/(app)/components/navigationMenu/navigationItems.tsx` & `index.tsx` - Added an **Agents** nav item (with `BotIcon`) between Repositories and Settings - Visible when the user is authenticated **and** at least one agent is configured (GitHub App triple or GitLab token pair), computed in the server component and passed down as `isAgentsVisible` ### `packages/shared/src/env.server.ts` Added four new environment variables: | Variable | Purpose | |---|---| | `GITLAB_REVIEW_AGENT_WEBHOOK_SECRET` | Verifies the `x-gitlab-token` header on incoming webhooks | | `GITLAB_REVIEW_AGENT_TOKEN` | Personal or project access token used for GitLab API calls | | `GITLAB_REVIEW_AGENT_HOST` | GitLab hostname (defaults to `gitlab.com`; set for self-hosted instances) | | `REVIEW_AGENT_MODEL` | `displayName` of the configured language model to use for reviews; falls back to the first model if unset or not matched | ### `packages/web/package.json` Added `@gitbeaker/rest` dependency (already used in `packages/backend`). --- ## Bug fixes | Bug | Fix | |---|---| | `"Not authenticated"` when fetching file content from the review agent | `fetchFileContent` now calls `getFileSourceForRepo` directly instead of `getFileSource` (which gates on session auth) | | `"diff_refs is missing"` when posting GitLab MR reviews | `gitlabMrParser` now fetches the full MR via `MergeRequests.show()` instead of relying on the webhook payload, which omits `diff_refs` on `update` events | | Bedrock/Anthropic rejection: `"A conversation must start with a user message"` | `invokeDiffReviewLlm` now passes the prompt via `system` + a `prompt` user turn instead of a `system`-role entry inside `messages` | | Review agent silently used `models[0]` with no way to specify a different model | New `REVIEW_AGENT_MODEL` env var selects by `displayName` | * Add CHANGELOG.md entry * Address coderabbit review comments * Update `review-agent` docs * Add `zod` schema to Gitlab events * Fix `repoName` calculation for Gitlab MRs * Add type annotation * Make sure that `GITLAB_REVIEW_AGENT_HOST` is valid hostname * Address final Coderabbit comments * Include the security fixes from #1134 --------- Co-authored-by: Gavin Williams <gavin.williams@getchip.uk> Co-authored-by: Brendan Kellam <brendan@sourcebot.dev>
1 parent acbf07d commit e6bbc36

File tree

21 files changed

+1409
-148
lines changed

21 files changed

+1409
-148
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,11 @@ dist
160160

161161
# End of https://www.toptal.com/developers/gitignore/api/yarn,node
162162

163+
.claude
163164
.sourcebot
164165
/bin
165166
/config.json
166167
.DS_Store
167168
oss-licenses.json
168169
oss-license-summary.json
169-
license-audit-result.json
170+
license-audit-result.json

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4343

4444
### Added
4545
- Added `thinkingLevel` and `thinkingBudget` configuration options for Google Generative AI and Google Vertex providers. [#1110](https://github.com/sourcebot-dev/sourcebot/pull/1110)
46+
- Support Gitlab MRs in the AI Code Review Agent [#1104](https://github.com/sourcebot-dev/sourcebot/pull/1104)
4647

4748
### Changed
4849
- Deprecated `GOOGLE_VERTEX_THINKING_BUDGET_TOKENS` environment variable in favor of per-model `thinkingBudget` config. [#1110](https://github.com/sourcebot-dev/sourcebot/pull/1110)

docs/docs/features/agents/review-agent.mdx

Lines changed: 101 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,55 @@ title: AI Code Review Agent
33
sidebarTitle: AI code review agent
44
---
55

6-
<Note>
7-
This agent sends data to OpenAI (through an API key you supply) to perform code reviews. This data includes code from the PR being reviewed, as well as additional relevant context from your
8-
codebase that the agent may fetch to perform the review.
9-
</Note>
6+
This agent provides codebase-aware reviews for your GitHub PRs and GitLab MRs. For each diff, the agent fetches relevant context from your indexed codebase and feeds it into a configured language model for a detailed review.
107

11-
This agent provides codebase-aware reviews for your PRs. For each diff, this agent fetches relevant context from Sourcebot and feeds it into an LLM for a detailed review of your changes.
12-
13-
The AI Code Review Agent is [fair source](https://github.com/sourcebot-dev/sourcebot/tree/main/packages/web/src/features/agents/review-agent) and packaged in [Sourcebot](https://github.com/sourcebot-dev/sourcebot). To get started using this agent, [deploy Sourcebot](/docs/deployment/docker-compose)
14-
and then follow the configuration instructions below.
8+
The AI Code Review Agent is [fair source](https://github.com/sourcebot-dev/sourcebot/tree/main/packages/web/src/features/agents/review-agent) and packaged in [Sourcebot](https://github.com/sourcebot-dev/sourcebot). To get started, [deploy Sourcebot](/docs/deployment/docker-compose) and follow the configuration instructions below.
159

1610
![AI Code Review Agent Example](/images/review_agent_example.png)
1711

18-
# Configure
12+
# Language model
13+
14+
The review agent uses whichever language model you have configured in your `config.json`. All providers supported by Sourcebot (OpenAI, Anthropic, AWS Bedrock, Azure OpenAI, and others) work out of the box.
1915

20-
This agent currently only supports reviewing GitHub PRs. You configure the agent by creating a GitHub app, installing it into your GitHub organization, and then giving your app info to Sourcebot.
16+
If you have multiple models configured, set `REVIEW_AGENT_MODEL` to the `displayName` of the model you want the agent to use. If this variable is unset, the agent uses the first configured model.
2117

22-
Before you get started, make sure you have an OpenAPI account that you can create an OpenAPI key with.
18+
# GitHub
2319

2420
<Steps>
2521
<Step title="Register a GitHub app">
26-
Follow the official GitHub guide for [registering a GitHub app](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app)
27-
28-
- GitHub App name: You can make this whatever you want (ex. Sourcebot Review Agent)
29-
- Homepage URL: You can make this whatever you want (ex. https://www.sourcebot.dev/)
30-
- Webhook URL (**IMPORTANT**): You must set this to point to your Sourcebot deployment at /api/webhook (ex. https://sourcebot.aperture.com/api/webhook). Your Sourcebot deployment must be able to accept requests from GitHub
31-
(either github.com or your self-hosted enterprise server) for this to work. If you're running Sourcebot locally, you can [use smee](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-2-get-a-webhook-proxy-url) to [forward webhooks](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-6-start-your-server) to your local deployment.
32-
- Webook Secret: This can be any string (ex. generate a random string `python -c "import secrets; print(secrets.token_hex(10))"`). You'll provide this to Sourcebot to be able to read webhook events from your app.
33-
- Permissions
22+
Follow the official GitHub guide for [registering a GitHub app](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app).
23+
24+
- **GitHub App name**: Any name you choose (e.g. Sourcebot Review Agent)
25+
- **Homepage URL**: Any URL you choose (e.g. `https://www.sourcebot.dev/`)
26+
- **Webhook URL** (required): Your Sourcebot deployment URL at `/api/webhook` (e.g. `https://sourcebot.example.com/api/webhook`). Your deployment must be reachable from GitHub. If you are running Sourcebot locally, use [smee](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-2-get-a-webhook-proxy-url) to [forward webhooks](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#step-6-start-your-server) to your local deployment.
27+
- **Webhook Secret**: Any string (e.g. generate one with `python -c "import secrets; print(secrets.token_hex(10))"`)
28+
- **Permissions**
3429
- Pull requests: Read & Write
3530
- Issues: Read & Write
3631
- Contents: Read
37-
- Events:
32+
- **Events**
3833
- Pull request
3934
- Issue comment
4035
</Step>
4136
<Step title="Install the GitHub app in your organization">
42-
Navigate to your new [GitHub app's page](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) and press `Install`
37+
Navigate to your new [GitHub app's page](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) and press **Install**.
4338
</Step>
44-
<Step title="Configure the environment variables in Sourcebot">
45-
Sourcebot requires the following environment variables to begin reviewing PRs through your new GitHub app:
46-
47-
- `GITHUB_REVIEW_AGENT_APP_ID`: The client ID of your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings)
48-
- `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET`: The webhook secret you defined in your GitHub app. Can be found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings)
49-
- `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH`: The path to your app's private key. If you're running Sourcebot from a container, this is the path to this file from within your container
50-
(ex `/data/review-agent-key.pem`). You must copy the private key file into the directory you mount to Sourcebot (similar to the config file).
51-
52-
You can generate a private key file for your app in the [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings). You must copy this private key file into the
53-
directory that you mount to Sourcebot
54-
![GitHub App Private Key](/images/github_app_private_key.png)
55-
- `OPENAI_API_KEY`: Your OpenAI API key
56-
- `REVIEW_AGENT_API_KEY`: The Sourcebot API key that the review agent uses to hit the Sourcebot API to fetch code context
57-
- `REVIEW_AGENT_AUTO_REVIEW_ENABLED` (default: `false`): If enabled, the review agent will automatically review any new or updated PR. If disabled, you must invoke it using the command defined by `REVIEW_AGENT_REVIEW_COMMAND`
58-
- `REVIEW_AGENT_REVIEW_COMMAND` (default: `review`): The command that invokes the review agent (ex. `/review`) when a user comments on the PR. Don't include the slash character in this value.
59-
60-
You can find an example docker compose file below.
61-
- This docker compose file is placed in `~/sourcebot_review_agent_workspace`, and I'm mounting that directory to Sourcebot
62-
- The config and the app private key files are placed in this directory
63-
- The paths to these files are given to Sourcebot relative to `/data` since that's the directory in Sourcebot that I'm mounting to
39+
<Step title="Configure environment variables">
40+
Set the following environment variables in your Sourcebot deployment:
41+
42+
| Variable | Description |
43+
|---|---|
44+
| `GITHUB_REVIEW_AGENT_APP_ID` | The client ID of your GitHub app, found in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings) |
45+
| `GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET` | The webhook secret you set when registering the app |
46+
| `GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH` | Path to your app's private key file inside the container (e.g. `/data/review-agent-key.pem`). Copy the key file into the directory you mount to Sourcebot. |
47+
48+
You can generate a private key in your [app settings](https://docs.github.com/en/apps/creating-github-apps/writing-code-for-a-github-app/quickstart#navigate-to-your-app-settings).
49+
50+
<Frame>
51+
<img src="/images/github_app_private_key.png" alt="GitHub App Private Key" />
52+
</Frame>
53+
54+
Example `docker-compose.yml`:
6455

6556
```yaml
6657
services:
@@ -71,26 +62,86 @@ Before you get started, make sure you have an OpenAPI account that you can creat
7162
ports:
7263
- "3000:3000"
7364
volumes:
74-
- "/Users/michael/sourcebot_review_agent_workspace:/data"
65+
- "/home/user/sourcebot_workspace:/data"
7566
environment:
7667
CONFIG_PATH: "/data/config.json"
7768
GITHUB_REVIEW_AGENT_APP_ID: "my-github-app-id"
78-
GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET: "my-github-app-webhook-secret"
69+
GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET: "my-webhook-secret"
7970
GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH: "/data/review-agent-key.pem"
80-
REVIEW_AGENT_API_KEY: "sourcebot-my-key"
81-
OPENAI_API_KEY: "sk-proj-my-open-api-key"
8271
```
8372
</Step>
8473
<Step title="Verify configuration">
85-
Navigate to the agents page by pressing `Agents` in the Sourcebot nav menu. If you've configured your environment variables correctly you'll see the following:
74+
Navigate to **Agents** in the Sourcebot nav menu. If your environment variables are set correctly, the GitHub Review Agent card shows a confirmation that the agent is configured and accepting requests.
8675
87-
![Review Agent Configured](/images/review_agent_configured.png)
76+
<Frame>
77+
<img src="/images/review_agent_configured.png" alt="Review Agent Configured" />
78+
</Frame>
79+
</Step>
80+
</Steps>
81+
82+
# GitLab
83+
84+
<Steps>
85+
<Step title="Create a GitLab access token">
86+
Create a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) or [project access token](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) with the following scope:
87+
88+
- `api`
89+
90+
Keep a note of the token value — you will need it in the next step.
91+
</Step>
92+
<Step title="Configure a webhook in GitLab">
93+
In your GitLab project, go to **Settings → Webhooks** and add a new webhook:
94+
95+
- **URL**: Your Sourcebot deployment URL at `/api/webhook` (e.g. `https://sourcebot.example.com/api/webhook`)
96+
- **Secret token**: Any string (e.g. generate one with `python -c "import secrets; print(secrets.token_hex(10))"`)
97+
- **Trigger events**: Merge request events, Comments
98+
99+
Save the webhook.
100+
</Step>
101+
<Step title="Configure environment variables">
102+
Set the following environment variables in your Sourcebot deployment:
103+
104+
| Variable | Description |
105+
|---|---|
106+
| `GITLAB_REVIEW_AGENT_WEBHOOK_SECRET` | The secret token you set on the GitLab webhook |
107+
| `GITLAB_REVIEW_AGENT_TOKEN` | The GitLab personal or project access token |
108+
| `GITLAB_REVIEW_AGENT_HOST` | Your GitLab hostname. Defaults to `gitlab.com`. Set this for self-hosted GitLab instances (e.g. `gitlab.example.com`). |
109+
110+
Example `docker-compose.yml`:
111+
112+
```yaml
113+
services:
114+
sourcebot:
115+
image: ghcr.io/sourcebot-dev/sourcebot:latest
116+
pull_policy: always
117+
container_name: sourcebot
118+
ports:
119+
- "3000:3000"
120+
volumes:
121+
- "/home/user/sourcebot_workspace:/data"
122+
environment:
123+
CONFIG_PATH: "/data/config.json"
124+
GITLAB_REVIEW_AGENT_WEBHOOK_SECRET: "my-webhook-secret"
125+
GITLAB_REVIEW_AGENT_TOKEN: "glpat-my-token"
126+
GITLAB_REVIEW_AGENT_HOST: "gitlab.example.com"
127+
```
128+
</Step>
129+
<Step title="Verify configuration">
130+
Navigate to **Agents** in the Sourcebot nav menu. If your environment variables are set correctly, the GitLab Review Agent card shows a confirmation that the agent is configured and accepting requests.
88131
</Step>
89132
</Steps>
90133

91134
# Using the agent
92135

93-
The review agent will not automatically review your PRs by default. To enable this feature, set the `REVIEW_AGENT_AUTO_REVIEW_ENABLED` environment variable to true.
136+
By default, the agent does not review PRs and MRs automatically. To enable automatic reviews on every new or updated PR/MR, set `REVIEW_AGENT_AUTO_REVIEW_ENABLED` to `true`.
137+
138+
You can also trigger a review manually by commenting `/review` on any PR or MR. To use a different command, set `REVIEW_AGENT_REVIEW_COMMAND` to your preferred value (without the leading slash).
139+
140+
# Environment variable reference
94141

95-
You can invoke the review agent manually by commenting `/review` on the PR you'd like it to review. You can configure the command that triggers the agent by changing
96-
the `REVIEW_AGENT_REVIEW_COMMAND` environment variable.
142+
| Variable | Default | Description |
143+
|---|---|---|
144+
| `REVIEW_AGENT_AUTO_REVIEW_ENABLED` | `false` | Automatically review new and updated PRs/MRs |
145+
| `REVIEW_AGENT_REVIEW_COMMAND` | `review` | Comment command that triggers a manual review (without the `/`) |
146+
| `REVIEW_AGENT_MODEL` | first configured model | `displayName` of the language model to use for reviews |
147+
| `REVIEW_AGENT_LOGGING_ENABLED` | unset | Write prompt and response logs to disk for debugging |

packages/shared/src/env.server.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,12 @@ const options = {
195195
GITHUB_REVIEW_AGENT_APP_ID: z.string().optional(),
196196
GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET: z.string().optional(),
197197
GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH: z.string().optional(),
198+
// GitLab for review agent
199+
GITLAB_REVIEW_AGENT_WEBHOOK_SECRET: z.string().optional(),
200+
GITLAB_REVIEW_AGENT_TOKEN: z.string().optional(),
201+
GITLAB_REVIEW_AGENT_HOST: z.string().default('gitlab.com').transform(s => s.replace(/^https?:\/\//, '').replace(/\/+$/, '')).refine(s => /^[a-z0-9.-]+$/i.test(s), { message: 'invalid hostname' }),
202+
// Review agent config
203+
REVIEW_AGENT_MODEL: z.string().optional(),
198204
REVIEW_AGENT_API_KEY: z.string().optional(),
199205
REVIEW_AGENT_LOGGING_ENABLED: booleanSchema.default('true'),
200206
REVIEW_AGENT_AUTO_REVIEW_ENABLED: booleanSchema.default('false'),
@@ -438,4 +444,4 @@ const options = {
438444
// See: https://github.com/microsoft/TypeScript/issues/62309
439445
export const env = createEnv(options) as unknown as {
440446
[K in keyof typeof options['server']]: z.output<(typeof options['server'])[K]>
441-
}
447+
}

packages/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"@codemirror/state": "^6.4.1",
5555
"@codemirror/view": "^6.33.0",
5656
"@floating-ui/react": "^0.27.2",
57+
"@gitbeaker/rest": "^40.5.1",
5758
"@grpc/grpc-js": "^1.14.1",
5859
"@grpc/proto-loader": "^0.8.0",
5960
"@hookform/resolvers": "^3.9.0",

packages/web/src/app/(app)/agents/page.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ import { env } from "@sourcebot/shared";
55

66
const agents = [
77
{
8-
id: "review-agent",
9-
name: "Review Agent",
10-
description: "An AI code review agent that reviews your PRs. Uses the code indexed on Sourcebot to provide codebase-wide context.",
11-
requiredEnvVars: ["GITHUB_REVIEW_AGENT_APP_ID", "GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET", "GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH", "OPENAI_API_KEY"],
8+
id: "github-review-agent",
9+
name: "GitHub Review Agent",
10+
description: "An AI code review agent that reviews your GitHub PRs. Uses the code indexed on Sourcebot to provide codebase-wide context.",
11+
requiredEnvVars: ["GITHUB_REVIEW_AGENT_APP_ID", "GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET", "GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH"],
12+
configureUrl: "https://docs.sourcebot.dev/docs/features/agents/review-agent"
13+
},
14+
{
15+
id: "gitlab-review-agent",
16+
name: "GitLab Review Agent",
17+
description: "An AI code review agent that reviews your GitLab MRs. Uses the code indexed on Sourcebot to provide codebase-wide context.",
18+
requiredEnvVars: ["GITLAB_REVIEW_AGENT_WEBHOOK_SECRET", "GITLAB_REVIEW_AGENT_TOKEN"],
1219
configureUrl: "https://docs.sourcebot.dev/docs/features/agents/review-agent"
1320
},
1421
];
@@ -18,21 +25,11 @@ export default async function AgentsPage() {
1825
<div className="flex flex-col items-center overflow-hidden min-h-screen">
1926
<NavigationMenu />
2027
<div className="w-full max-w-6xl px-4 mt-12 mb-24">
21-
<div
22-
className={
23-
agents.length === 1
24-
? "flex justify-center items-center min-h-[60vh]"
25-
: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10"
26-
}
27-
>
28+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-10">
2829
{agents.map((agent) => (
2930
<div
3031
key={agent.id}
31-
className={
32-
agents.length === 1
33-
? "relative flex flex-col items-center border border-border rounded-2xl p-8 bg-card shadow-xl w-full max-w-xl"
34-
: "relative flex flex-col items-center border border-border rounded-2xl p-8 bg-card shadow-xl"
35-
}
32+
className="relative flex flex-col items-center border border-border rounded-2xl p-8 bg-card shadow-xl"
3633
>
3734
{/* Name and description */}
3835
<div className="flex flex-col items-center w-full">

packages/web/src/app/(app)/components/navigationMenu/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Separator } from "@/components/ui/separator";
77
import { ServiceErrorException } from "@/lib/serviceError";
88
import { isServiceError } from "@/lib/utils";
99
import { OrgRole, RepoIndexingJobStatus, RepoIndexingJobType } from "@sourcebot/db";
10+
import { env } from "@sourcebot/shared";
1011
import Link from "next/link";
1112
import { MeControlDropdownMenu } from "../meControlDropdownMenu";
1213
import WhatsNewIndicator from "../whatsNewIndicator";
@@ -103,6 +104,10 @@ export const NavigationMenu = async () => {
103104
) : false
104105
}
105106
isAuthenticated={isAuthenticated}
107+
isAgentsVisible={isAuthenticated && (
108+
!!(env.GITHUB_REVIEW_AGENT_APP_ID && env.GITHUB_REVIEW_AGENT_APP_WEBHOOK_SECRET && env.GITHUB_REVIEW_AGENT_APP_PRIVATE_KEY_PATH) ||
109+
!!(env.GITLAB_REVIEW_AGENT_WEBHOOK_SECRET && env.GITLAB_REVIEW_AGENT_TOKEN)
110+
)}
106111
/>
107112
</NavigationMenuBase>
108113
</div>

0 commit comments

Comments
 (0)