diff --git a/src/event-router.ts b/src/event-router.ts index 1fb9c9f..c1f6028 100644 --- a/src/event-router.ts +++ b/src/event-router.ts @@ -384,10 +384,6 @@ function handleComment( const bodyData = event.data.bodyData; const mentionedIds = extractMentionedUserIds(body, bodyData, config.agentMapping); - if (mentionedIds.length === 0) { - return []; - } - const actions: RouterAction[] = []; const issueRef = event.data.issue as Record | undefined; @@ -420,6 +416,35 @@ function handleComment( } } + // Handle replies: route to parent comment's author + const parentComment = event.data.parentComment as Record | undefined; + if (parentComment) { + const parentUserId = parentComment.userId as string | undefined; + if (parentUserId) { + const agentId = config.agentMapping[parentUserId]; + // Skip if parent author was already notified via mention + const alreadyNotified = mentionedIds.includes(parentUserId); + if (agentId && !alreadyNotified) { + actions.push({ + type: "wake", + agentId, + event: "comment.reply", + detail: `Reply to comment on issue ${issueLabel}\n\n> ${body}`, + issueId, + issueLabel, + identifier, + issuePriority, + linearUserId: parentUserId, + commentId, + }); + } else if (!agentId) { + config.logger.info( + `Unmapped Linear user ${parentUserId} is parent comment author on ${issueId}`, + ); + } + } + } + return actions; } diff --git a/src/index.ts b/src/index.ts index aa803d7..06d53f2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,6 +23,7 @@ const EVENT_LABELS: Record = { "issue.state_readded": "State Re-added", "issue.priority_changed": "Priority Changed", "comment.mention": "Mentioned", + "comment.reply": "Reply", }; export function formatConsolidatedMessage(actions: RouterAction[]): string { @@ -40,7 +41,7 @@ export function formatConsolidatedMessage(actions: RouterAction[]): string { } function formatActionSummary(action: RouterAction): string { - if (action.event === "comment.mention") { + if (action.event === "comment.mention" || action.event === "comment.reply") { const bodyStart = action.detail.indexOf("\n\n> "); if (bodyStart !== -1) { const quote = action.detail.slice(bodyStart + 4); // skip "\n\n> " diff --git a/src/work-queue.ts b/src/work-queue.ts index 9745e26..56e78b5 100644 --- a/src/work-queue.ts +++ b/src/work-queue.ts @@ -27,6 +27,7 @@ export const QUEUE_EVENT: Record = { "issue.assigned": "ticket", "issue.state_readded": "ticket", "comment.mention": "mention", + "comment.reply": "mention", }; const REMOVAL_EVENTS = new Set([