Skip to content

feat: add GitHub webhook support and AI review trigger functionality: - #273

Open
yashdev9274 wants to merge 1 commit into
mainfrom
supercode-cli
Open

feat: add GitHub webhook support and AI review trigger functionality:#273
yashdev9274 wants to merge 1 commit into
mainfrom
supercode-cli

Conversation

@yashdev9274

Copy link
Copy Markdown
Owner

Description

  • Introduced a new API route for manually triggering AI reviews via POST requests, allowing users to queue reviews for connected repositories.
  • Enhanced GitHub webhook handling to verify signatures and process pull request events, ensuring secure and reliable integration with GitHub.
  • Updated environment configuration to include necessary keys for GitHub webhooks and AI review services.
  • Improved the dashboard logs page to display AI review history, providing users with insights into review activities and statuses.
  • Refactored existing code for better organization and maintainability, ensuring a cleaner architecture for future enhancements.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • bun test passes
  • bun run typecheck passes
  • bun run lint passes (if applicable)

Checklist:

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

- Introduced a new API route for manually triggering AI reviews via POST requests, allowing users to queue reviews for connected repositories.
- Enhanced GitHub webhook handling to verify signatures and process pull request events, ensuring secure and reliable integration with GitHub.
- Updated environment configuration to include necessary keys for GitHub webhooks and AI review services.
- Improved the dashboard logs page to display AI review history, providing users with insights into review activities and statuses.
- Refactored existing code for better organization and maintainability, ensuring a cleaner architecture for future enhancements.
@vercel

vercel Bot commented Aug 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
supercli Ready Ready Preview Aug 24, 2026 10:42am
supercli-client Ready Ready Preview Aug 24, 2026 10:42am
supercli-docs Ready Ready Preview Aug 24, 2026 10:42am

@greptile-apps

greptile-apps Bot commented Aug 24, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds authenticated manual review triggering, expands signed GitHub webhook processing, moves AI review generation into a richer retrying Inngest workflow, and displays recent review status on the dashboard.

  • Adds a manual API endpoint that queues reviews for repositories owned by the current user.
  • Handles additional pull-request webhook actions and configures repository webhooks.
  • Generates, posts, and persists structured AI reviews with repository context.
  • Replaces the empty logs screen with the latest 50 review records.

Confidence Score: 2/5

This PR should not merge until webhook verification fails closed, terminal worker failures update persisted status, and manual trigger input requires an integer pull-request number.

Missing webhook configuration currently bypasses the request-authenticity boundary, worker retry exhaustion leaves user-visible records permanently pending, and malformed fractional PR identifiers pass the new route's validation.

Files Needing Attention: apps/web/app/api/webhooks/github/route.ts, apps/web/inngest/functions/ai-review.ts, apps/web/app/api/reviews/trigger/route.ts

Security Review

The webhook endpoint accepts unsigned payloads whenever GITHUB_WEBHOOK_SECRET is absent, allowing unauthenticated callers to trigger AI work and GitHub-side effects for connected repositories. How this was verified: The missing-secret branch was traced from the public webhook route through reviewPullRequest to the worker that uses the repository owner's token and posts the generated review.

Important Files Changed

Filename Overview
apps/web/app/api/webhooks/github/route.ts Expands pull-request event handling but accepts unauthenticated deliveries whenever the webhook secret is missing.
apps/web/inngest/functions/ai-review.ts Adds a richer retrying AI-review workflow, but exhausted failures leave persisted reviews indefinitely pending.
apps/web/app/api/reviews/trigger/route.ts Adds an authenticated manual trigger scoped to the user's repository, but permits fractional pull-request numbers.
apps/web/modules/ai/action/index.ts Queues reviews and persists initial status, while only enqueue-time failures are recorded as failed.
apps/web/modules/github/lib/github.ts Adds webhook refresh, richer PR metadata, sticky comments, and formal reviews, but permits webhook configuration without a signing secret.
apps/web/app/dashboard/logs/page.tsx Displays the latest review records scoped to the authenticated user's connected repositories.

Sequence Diagram

sequenceDiagram
    participant G as GitHub or Caller
    participant W as Webhook or Trigger API
    participant D as Database
    participant I as Inngest
    participant A as AI Gateway
    participant P as GitHub PR
    G->>W: Pull request event or manual request
    W->>D: Resolve connected repository
    W->>D: Mark review pending
    W->>I: Send pr.review.requested
    I->>P: Fetch PR metadata and diff
    I->>A: Generate review
    A-->>I: Review markdown
    I->>P: Upsert comment and submit review
    I->>D: Mark review completed
Loading

Reviews (1): Last reviewed commit: "feat: add GitHub webhook support and AI ..." | Re-trigger Greptile

Comment on lines +39 to 46
console.error("[webhook/github] invalid signature")
return NextResponse.json({ error: "Invalid signature" }, { status: 401 })
}
} else {
console.warn(
"[webhook/github] GITHUB_WEBHOOK_SECRET is not set — accepting unsigned payloads (dev only)",
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Unsigned webhooks trigger reviews

If GITHUB_WEBHOOK_SECRET is absent in a public deployment, this branch accepts unsigned pull-request payloads and forwards attacker-controlled repository and PR identifiers into the review workflow, allowing unauthenticated callers to consume AI resources and post reviews using a connected user's GitHub token. How this was verified: The unsigned request path was traced through reviewPullRequest to the worker that loads the repository owner's token and posts the generated review.

Comment on lines 94 to +99
export const generateReview = inngest.createFunction(
{
id: "generate-review",
concurrency: 5,
retries: 2,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Failed reviews remain pending

When PR fetching, AI generation, comment posting, or persistence exhausts these retries, no failure handler transitions the already-created review record to failed, causing the dashboard to report a terminally failed review as in progress indefinitely.

const repo = String(body.repo ?? "").trim()
const prNumber = Number(body.prNumber)

if (!owner || !repo || !Number.isFinite(prNumber) || prNumber <= 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Fractional PR numbers pass validation

When an authenticated caller supplies a positive fractional value such as 1.5, this validation accepts it and forwards it to the GitHub API, causing an invalid job or internal error instead of returning a client validation error.

Suggested change
if (!owner || !repo || !Number.isFinite(prNumber) || prNumber <= 0) {
if (!owner || !repo || !Number.isInteger(prNumber) || prNumber <= 0) {

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant