Skip to content

Conversation

@shuhuiluo
Copy link
Collaborator

@shuhuiluo shuhuiluo commented Dec 9, 2025

Prevents duplicate messages when creating retroactive anchors for closed/reopened PRs. The synthetic thread reply (e.g., "PR Merged") is now skipped if no anchor exists - the subsequent edit action will create the retroactive anchor instead.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved message delivery by preventing unnecessary thread replies from being created when specific conditions are not met, enhancing handling of certain notification scenarios.

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

Prevents duplicate messages when creating retroactive anchors for
closed/reopened PRs. The synthetic thread reply (e.g., "PR Merged")
is now skipped if no anchor exists - the subsequent edit action
will create the retroactive anchor instead.

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

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

coderabbitai bot commented Dec 9, 2025

Walkthrough

A new early-return guard clause is added to src/services/message-delivery-service.ts to skip creating synthetic thread replies when specific conditions are met. For "create" action events where the entity context is non-anchor (e.g., PR close events), the githubEntityType matches the parentType, and no threadId exists, the code logs a skip message and returns early. This control flow change occurs before the existing switch statement without modifying subsequent action handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with a localized guard clause
  • Straightforward conditional logic with early return pattern
  • No changes to exported APIs or function signatures
  • Requires verification that guard conditions are correct and thread reply skip is intentional

Possibly related PRs

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: adding a guard to skip synthetic thread replies when no anchor exists, which aligns with the core modification in message-delivery-service.ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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/retroactive-anchor-duplicate

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b6540f7 and 48c2b87.

📒 Files selected for processing (1)
  • src/services/message-delivery-service.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/services/message-delivery-service.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/services/message-delivery-service.ts
🔇 Additional comments (1)
src/services/message-delivery-service.ts (1)

81-96: Remove misleading explanation about retroactive anchor creation.

The guard correctly skips creating synthetic thread replies (like "PR Closed") when their parent anchor doesn't exist. However, the comment's claim that "Retroactive anchor will be created by subsequent 'edit' action" is misleading.

The synthetic thread reply itself (with isAnchor: false) is skipped and never created. The retroactive anchor creation (lines 203-215) applies only to anchor edits where isAnchor: true. These are separate entities: the guard prevents unnecessary synthetic reply creation, while the anchor edit (which always runs for closed/reopened events) handles creating the anchor if needed.

The logic is sound, but the explanation conflates two different entities and their purposes.

Likely an incorrect or invalid review comment.


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

@shuhuiluo shuhuiluo merged commit d699cc6 into main Dec 9, 2025
2 checks passed
@shuhuiluo shuhuiluo deleted the fix/retroactive-anchor-duplicate branch December 9, 2025 21:00
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