Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(trigger): skip parent mention inheritance when reply @mentions only members (#421)

Jiayuan Zhang0771c15a5985
diff --git a/server/cmd/server/comment_trigger_integration_test.go b/server/cmd/server/comment_trigger_integration_test.go
index 1dfbc72356..e2ead5e538 100644
--- a/server/cmd/server/comment_trigger_integration_test.go
+++ b/server/cmd/server/comment_trigger_integration_test.go
@@ -381,6 +381,34 @@ func TestCommentTriggerThreadInheritedMention(t *testing.T) {
t.Errorf("expected 1 pending task (no duplicate), got %d", n)
}
})
+
+ t.Run("reply mentioning only a member does not inherit agent mention", func(t *testing.T) {
+ clearTasks(t, issueID)
+ // Top-level comment @mentions the agent.
+ content := fmt.Sprintf("[@Agent](mention://agent/%s) can you help?", agentID)
+ threadID := postComment(t, issueID, content, nil)
+ clearTasks(t, issueID)
+ // Reply mentions only a member — should NOT inherit parent's agent mention.
+ reply := fmt.Sprintf("cc [@Someone](mention://member/%s)", testUserID)
+ postComment(t, issueID, reply, strPtr(threadID))
+ if n := countPendingTasks(t, issueID); n != 0 {
+ t.Errorf("expected 0 pending tasks (member-only reply should not inherit agent mention), got %d", n)
+ }
+ })
+
+ t.Run("reply mentioning agent and member still inherits", func(t *testing.T) {
+ clearTasks(t, issueID)
+ // Top-level comment @mentions the agent.
+ content := fmt.Sprintf("[@Agent](mention://agent/%s) review this", agentID)
+ threadID := postComment(t, issueID, content, nil)
+ clearTasks(t, issueID)
+ // Reply mentions both agent and member — should still trigger.
+ reply := fmt.Sprintf("[@Agent](mention://agent/%s) and cc [@Someone](mention://member/%s)", agentID, testUserID)
+ postComment(t, issueID, reply, strPtr(threadID))
+ if n := countPendingTasks(t, issueID); n != 1 {
+ t.Errorf("expected 1 pending task (reply mentions agent explicitly), got %d", n)
+ }
+ })
}
// TestCommentTriggerCoalescing verifies that rapid-fire comments don't create
diff --git a/server/internal/handler/comment.go b/server/internal/handler/comment.go
index d5d3415dab..4902f64622 100644
--- a/server/internal/handler/comment.go
+++ b/server/internal/handler/comment.go
@@ -354,7 +354,9 @@ func (h *Handler) isReplyToMemberThread(parent *db.Comment, content string, issu
// enqueues a task for each mentioned agent. When parentComment is non-nil
// (i.e. the comment is a reply), mentions from the parent (thread root) are
// also included so that agents mentioned in the top-level comment are
-// re-triggered by subsequent replies in the same thread.
+// re-triggered by subsequent replies in the same thread — unless the reply
+// explicitly @mentions only non-agent entities (members, issues), which
+// signals the user is talking to other people and not the agent.
// Skips self-mentions, agents that are already the issue's assignee (handled
// by on_comment), agents with on_mention trigger disabled, and private agents
// mentioned by non-owner members (only the agent owner or workspace
@@ -366,17 +368,31 @@ func (h *Handler) enqueueMentionedAgentTasks(ctx context.Context, issue db.Issue
mentions := util.ParseMentions(comment.Content)
// When replying in a thread, also include mentions from the parent comment
// so that agents mentioned in the thread root are triggered by replies.
+ // However, skip inheritance when the reply explicitly @mentions only
+ // non-agent entities (members, issues) — the user is directing the reply
+ // at other people, not requesting work from agents in the parent thread.
if parentComment != nil {
- parentMentions := util.ParseMentions(parentComment.Content)
- seen := make(map[string]bool, len(mentions))
+ hasAgentMention := false
+ hasNonAgentMention := false
for _, m := range mentions {
- seen[m.Type+":"+m.ID] = true
+ if m.Type == "agent" {
+ hasAgentMention = true
+ } else {
+ hasNonAgentMention = true
+ }
}
- for _, m := range parentMentions {
- if !seen[m.Type+":"+m.ID] {
- mentions = append(mentions, m)
+ if hasAgentMention || !hasNonAgentMention {
+ parentMentions := util.ParseMentions(parentComment.Content)
+ seen := make(map[string]bool, len(mentions))
+ for _, m := range mentions {
seen[m.Type+":"+m.ID] = true
}
+ for _, m := range parentMentions {
+ if !seen[m.Type+":"+m.ID] {
+ mentions = append(mentions, m)
+ seen[m.Type+":"+m.ID] = true
+ }
+ }
}
}
for _, m := range mentions {