Skip to content

Commit d699cc6

Browse files
shuhuiluoclaude
andauthored
fix: skip synthetic thread replies when anchor doesn't exist (#94)
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>
1 parent b6540f7 commit d699cc6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/services/message-delivery-service.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ export class MessageDeliveryService {
7878
)) ?? undefined)
7979
: undefined;
8080

81+
// Skip synthetic thread replies (closed/reopened) when anchor doesn't exist
82+
// These have githubEntityType === parentType (e.g., "pr" for PR close event)
83+
// Real entities like comments have different types (e.g., "comment" with parent "pr")
84+
// (Retroactive anchor will be created by subsequent "edit" action)
85+
if (
86+
action === "create" &&
87+
entityContext &&
88+
!entityContext.isAnchor &&
89+
entityContext.githubEntityType === entityContext.parentType &&
90+
!threadId
91+
) {
92+
console.log(
93+
`Skipping thread reply for ${entityContext.githubEntityType}:${entityContext.githubEntityId} - no anchor exists`
94+
);
95+
return;
96+
}
97+
8198
switch (action) {
8299
case "delete":
83100
if (!entityContext) {

0 commit comments

Comments
 (0)