Skip to content
Merged
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
10 changes: 7 additions & 3 deletions .agents/scripts/draft-response-helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -832,15 +832,19 @@ cmd_check_approvals() {
fi
fi

# Check for user comments on this notification issue
# Check for comments from ANY non-bot user on this notification issue.
# The safety net should NOT auto-decline if any human has commented —
# not just the repo owner ($username). A comment from any non-bot user
# indicates human engagement that should block auto-decline.
# (GH#5559: was incorrectly filtering to only $username's comments)
local sa_comments
sa_comments=$(gh api --paginate "repos/${slug}/issues/${sa_issue_number}/comments?per_page=100" \
--jq "[.[] | select(.user.login == \"${username}\") | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \
--jq '[.[] | select(.user.login | test("\\[bot\\]$"; "i") | not)]' \
2>/dev/null) || sa_comments="[]"
local sa_user_comment_count
sa_user_comment_count=$(echo "$sa_comments" | jq 'length' 2>/dev/null) || sa_user_comment_count=0
Comment on lines 840 to 845
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For efficiency, you can get the count of non-bot comments directly within the gh api call, avoiding an intermediate variable and a second jq process. Additionally, the 2>/dev/null suppression has been removed from the suggestion, as it's generally best to avoid suppressing stderr on commands that parse configuration files like jq to prevent hiding syntax errors and making debugging difficult.

Suggested change
local sa_comments
sa_comments=$(gh api --paginate "repos/${slug}/issues/${sa_issue_number}/comments?per_page=100" \
--jq "[.[] | select(.user.login == \"${username}\") | select(.user.login | test(\"\\\\[bot\\\\]\$\"; \"i\") | not)]" \
--jq '[.[] | select(.user.login | test("\\[bot\\]$"; "i") | not)]' \
2>/dev/null) || sa_comments="[]"
local sa_user_comment_count
sa_user_comment_count=$(echo "$sa_comments" | jq 'length' 2>/dev/null) || sa_user_comment_count=0
local sa_user_comment_count
sa_user_comment_count=$(gh api --paginate "repos/${slug}/issues/${sa_issue_number}/comments?per_page=100" \
--jq '([.[] | select(.user.login | test("\\[bot\\]\[bot\]|actions-user|github-actions\\[bot\\]$"; "i") | not)] | length)') || sa_user_comment_count=0
References
  1. Consolidate multiple 'jq' calls into a single pass where possible to improve performance and script efficiency.
  2. Avoid suppressing stderr with 2>/dev/null on commands that parse configuration files (e.g., jq), as it can hide syntax errors and make debugging difficult.


# Only auto-decline if no user comment exists
# Only auto-decline if no non-bot user comment exists
if [[ "$sa_user_comment_count" -gt 0 ]]; then
continue
fi
Expand Down
Loading