Skip to content

Conversation

@shuhuiluo
Copy link
Collaborator

@shuhuiluo shuhuiluo commented Dec 3, 2025

  • Add PullRequestReviewCommentPayload type
  • Add formatPullRequestReviewComment formatter
  • Add onPullRequestReviewComment handler in EventProcessor
  • Register pull_request_review_comment webhook

Now review_comments events are delivered via webhooks (previously polling-only).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Pull request review comments are now processed and distributed as events alongside other pull request activities.
    • Added branch-based filtering support for review comment events to enable targeted routing to appropriate workflows based on the target branch.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add PullRequestReviewCommentPayload type
- Add formatPullRequestReviewComment formatter
- Add onPullRequestReviewComment handler in EventProcessor
- Register pull_request_review_comment webhook

Now review_comments events are delivered via webhooks (previously polling-only).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Walkthrough

The PR adds support for processing pull request review comment webhook events across the application. It introduces a new type PullRequestReviewCommentPayload in the types module, a new formatter function formatPullRequestReviewComment for formatting review comment events when the action is "created", a corresponding event handler onPullRequestReviewComment in the event processor with branch filtering support, and registers the webhook handler in the main entry point to route incoming pull_request_review_comment events to the processor.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Changes follow established patterns in the codebase for adding new event types
  • Type addition is straightforward (simple alias)
  • Formatter mirrors existing review comment formatting style
  • Event handler uses existing processEvent infrastructure with standard branch filtering
  • Homogeneous changes across files with consistent structure

Possibly related PRs

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: adding a missing webhook handler for pull_request_review_comment events to enable webhook delivery instead of polling-only.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/review-comments-webhook

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/formatters/webhook-events.ts (1)

183-201: Review comment formatter aligns with existing patterns; minor reuse opportunity

The formatPullRequestReviewComment implementation correctly:

  • Handles only "created" actions.
  • Builds a concise, first-line, 100-char preview.
  • Uses the same markdown style as other formatters.

There’s some duplication with formatIssueComment in how comments are truncated; you could later extract a small helper for “shortComment” formatting if this pattern spreads further, but it’s not required now.

src/github-app/event-processor.ts (1)

12-13: Review comment handler is consistent with existing PR event handling

The additions cleanly extend the processor:

  • Imports formatPullRequestReviewComment and PullRequestReviewCommentPayload alongside existing PR/ review types.
  • onPullRequestReviewComment mirrors onPullRequestReview, using the PR’s base branch for filtering and wiring through processEvent with event type "review_comments" and an appropriate log context.

This keeps behavior and branch filtering for review comments aligned with other PR-related events. If you see more PR-based event types accumulating, you might later factor out the repeated “base branch + processEvent” pattern, but it’s fine as-is.

Also applies to: 30-36, 237-251

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d53461 and 5465b09.

📒 Files selected for processing (4)
  • src/formatters/webhook-events.ts (2 hunks)
  • src/github-app/event-processor.ts (3 hunks)
  • src/index.ts (1 hunks)
  • src/types/webhooks.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.ts

📄 CodeRabbit inference engine (AGENTS.md)

**/*.ts: Store context externally - maintain stateless bot architecture with no message history, thread context, or conversation memory
Use <@{userId}> for mentions in messages AND add mentions in sendMessage options - do not use @username format
Implement event handlers for onMessage, onSlashCommand, onReaction, onTip, and onInteractionResponse to respond to Towns Protocol events
Define slash commands in src/commands.ts as a const array with name and description properties, then register handlers using bot.onSlashCommand()
Set ID in interaction requests and match ID in responses to correlate form submissions, button clicks, and transaction/signature responses
Use readContract for reading smart contract state, writeContract for SimpleAccount operations, and execute() for external contract interactions
Fund bot.appAddress (Smart Account) for on-chain operations, not bot.botId (Gas Wallet/EOA)
Use bot.* handler methods directly (outside event handlers) for unprompted messages via webhooks, timers, or tasks - requires channelId, spaceId, or other context stored externally
Always check permissions using handler.hasAdminPermission() before performing admin operations like ban, redact, or pin
User IDs are hex addresses in format 0x..., not usernames - use them consistently throughout event handling and message sending
Slash commands do not trigger onMessage - register slash command handlers using bot.onSlashCommand() instead
Use getSmartAccountFromUserId() to retrieve a user's wallet address from their userId
Include required environment variables: APP_PRIVATE_DATA (bot credentials) and JWT_SECRET (webhook security token)

Files:

  • src/formatters/webhook-events.ts
  • src/types/webhooks.ts
  • src/index.ts
  • src/github-app/event-processor.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Provide alt text for image attachments and use appropriate MIME types for chunked attachments (videos, screenshots)

Files:

  • src/formatters/webhook-events.ts
  • src/types/webhooks.ts
  • src/index.ts
  • src/github-app/event-processor.ts
🧬 Code graph analysis (2)
src/formatters/webhook-events.ts (1)
src/types/webhooks.ts (1)
  • PullRequestReviewCommentPayload (21-22)
src/github-app/event-processor.ts (2)
src/types/webhooks.ts (1)
  • PullRequestReviewCommentPayload (21-22)
src/formatters/webhook-events.ts (1)
  • formatPullRequestReviewComment (183-201)
🔇 Additional comments (3)
src/index.ts (1)

106-108: Webhook wiring for review comments matches existing pattern

The new pull_request_review_comment webhook handler cleanly mirrors the other webhook registrations and correctly delegates to eventProcessor.onPullRequestReviewComment(payload). No issues from this change alone.

src/formatters/webhook-events.ts (1)

6-19: Type import extension is consistent with existing payload imports

Including PullRequestReviewCommentPayload in the type-only import list keeps this file’s typing pattern uniform with other webhook payloads.

src/types/webhooks.ts (1)

21-22: New payload alias follows established webhook type pattern

PullRequestReviewCommentPayload mirrors the other WebhookPayload<...> aliases and cleanly exposes the new event type.

@shuhuiluo shuhuiluo merged commit 431da9f into main Dec 3, 2025
2 checks passed
@shuhuiluo shuhuiluo deleted the fix/review-comments-webhook branch December 3, 2025 09:18
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.

2 participants