Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/event-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown> | undefined;
Expand Down Expand Up @@ -420,6 +416,35 @@ function handleComment(
}
}

// Handle replies: route to parent comment's author
const parentComment = event.data.parentComment as Record<string, unknown> | 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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const EVENT_LABELS: Record<string, string> = {
"issue.state_readded": "State Re-added",
"issue.priority_changed": "Priority Changed",
"comment.mention": "Mentioned",
"comment.reply": "Reply",
};

export function formatConsolidatedMessage(actions: RouterAction[]): string {
Expand All @@ -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> "
Expand Down
1 change: 1 addition & 0 deletions src/work-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const QUEUE_EVENT: Record<string, string> = {
"issue.assigned": "ticket",
"issue.state_readded": "ticket",
"comment.mention": "mention",
"comment.reply": "mention",
};

const REMOVAL_EVENTS = new Set([
Expand Down