Skip to content

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

Go

fix(comment): set trigger_comment_id to actual reply, not thread root (#871)

Bohan Jiang0b60f78e8a2c
diff --git a/server/internal/handler/comment.go b/server/internal/handler/comment.go
index 03729018f3..d4bbdb20ee 100644
--- a/server/internal/handler/comment.go
+++ b/server/internal/handler/comment.go
@@ -409,12 +409,9 @@ func (h *Handler) enqueueMentionedAgentTasks(ctx context.Context, issue db.Issue
if err != nil || hasPending {
continue
}
- // Resolve thread root for reply threading.
- replyTo := comment.ID
- if comment.ParentID.Valid {
- replyTo = comment.ParentID
- }
- if _, err := h.TaskService.EnqueueTaskForMention(ctx, issue, agentUUID, replyTo); err != nil {
+ // Always use the current comment as the trigger so the agent reads the
+ // actual reply that mentioned it, not the thread root.
+ if _, err := h.TaskService.EnqueueTaskForMention(ctx, issue, agentUUID, comment.ID); err != nil {
slog.Warn("enqueue mention agent task failed", "issue_id", uuidToString(issue.ID), "agent_id", m.ID, "error", err)
}
}
diff --git a/server/internal/service/task.go b/server/internal/service/task.go
index f0ff5b3bee..518bfe2c98 100644
--- a/server/internal/service/task.go
+++ b/server/internal/service/task.go
@@ -561,6 +561,13 @@ func (s *TaskService) createAgentComment(ctx context.Context, issueID, agentID p
if err != nil {
return
}
+ // Resolve thread root: if parentID points to a reply (has its own parent),
+ // use that parent instead so the comment lands in the top-level thread.
+ if parentID.Valid {
+ if parent, err := s.Queries.GetComment(ctx, parentID); err == nil && parent.ParentID.Valid {
+ parentID = parent.ParentID
+ }
+ }
// Expand bare issue identifiers (e.g. MUL-117) into mention links.
content = mention.ExpandIssueIdentifiers(ctx, s.Queries, issue.WorkspaceID, content)
comment, err := s.Queries.CreateComment(ctx, db.CreateCommentParams{