-
Notifications
You must be signed in to change notification settings - Fork 0
feat: default to using a single function for both pr review and summa… #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,13 @@ import { prisma } from "@/lib/prisma"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function reviewPullRequest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prNumber: number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prNumber: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installationId: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseSha: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headSha: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| changedFiles: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| additions: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deletions: number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
7
to
17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type safety issue: function signature doesn't match actual usage. The function signature declares 🔎 Proposed fix: Make parameters optional export async function reviewPullRequest(
owner: string,
repo: string,
prNumber: number,
- installationId: number,
- baseSha: string,
- headSha: string,
- changedFiles: number,
- additions: number,
- deletions: number
+ installationId?: number,
+ baseSha?: string,
+ headSha?: string,
+ changedFiles?: number,
+ additions?: number,
+ deletions?: number
) { |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repository = await prisma.repo.findFirst({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -90,6 +96,25 @@ export async function reviewPullRequest( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await inngest.send({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "pr.summary.requested", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: `review-${repository.id}-${prNumber}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prNumber, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: title ?? "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: description ?? "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accountId: githubAccount.accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installationId: installationId ?? null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseSha, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headSha, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| changedFiles: changedFiles ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| additions: additions ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deletions: deletions ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Summary — Inngest event-ID deduplication / idempotency
Sources: Inngest docs — Sending events / Deduplication; Handling idempotency (function-level). [1][2] 🏁 Script executed: # Search for pr.review.requested event and its ID in the codebase
rg "pr\.review\.requested" -A 5 -B 5Repository: afuhflynn/code-reverb Length of output: 1165 Event ID collision: both events use the same ID causing deduplication. Both the Use distinct event IDs for each event type: await inngest.send({
name: "pr.summary.requested",
- id: `review-${repository.id}-${prNumber}`,
+ id: `summary-${repository.id}-${prNumber}`,
data: {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await inngest.send({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "pr.review.requested", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: `review-${repository.id}-${prNumber}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -136,69 +161,3 @@ export async function reviewPullRequest( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function generatePullRequestSummary( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repoName: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prNumber: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installationId: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseSha: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headSha: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| changedFiles: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| additions: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deletions: number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const repository = await prisma.repo.findFirst({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| where: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: repoName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fullName: `${owner}/${repoName}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| include: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| include: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accounts: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| where: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerId: "github", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!repository) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| throw new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `Repository ${owner}/${repoName} not found in databse. Please reconnect the repository.` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const githubAccount = repository.owner.accounts[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await inngest.send({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "pr.summary.requested", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: `review-${repository.id}-${prNumber}`, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo: repoName, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prNumber, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: title ?? "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: description ?? "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| accountId: githubAccount.accountId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| installationId: installationId ?? null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseSha, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| headSha, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| changedFiles: changedFiles ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| additions: additions ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| deletions: deletions ?? 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sucess: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| message: "PR Summary Queued", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error("Failed to post PR Summary ", error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 719
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 938
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 4512
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 1608
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 284
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 506
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 1139
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 2026
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 943
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 190
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 47
🏁 Script executed:
Repository: afuhflynn/code-reverb
Length of output: 994
Fix TypeScript type safety: parameters passed to
reviewPullRequestmay be undefined.The function signature in
lib/ai/actions/index.ts(lines 7-16) requires non-optional parameters (installationId: number,baseSha: string, etc.), but the webhook call passes potentially undefined values via optional chaining. While GitHub webhook payloads guarantee these fields exist foropenedandsynchronizedpull_request events, TypeScript's strict mode will reject this mismatch.Either add non-null assertions (
!), validate before the call, or update the function signature to accept optional parameters with appropriate fallbacks.🤖 Prompt for AI Agents