Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ while still_open; do
# --slurp + a standalone jq with `add`: combine all pages before counting (gh forbids
# --slurp with --jq, so pipe to jq; plain --paginate --jq counts per page).
new=$(gh api "repos/$REPO/issues/$PR/comments" --paginate --slurp \
| jq "add | map(select(.user.login==\"coderabbitai[bot]\" and .created_at > \"$since\" and (.body|contains(\"rate limited by coderabbit.ai\")|not))) | length")
| jq "add | map(select(.user.login==\"coderabbitai[bot]\" and ((.updated_at // .created_at) > \"$since\") and ((.body // \"\")|ascii_downcase|contains(\"rate limited by coderabbit.ai\")|not))) | length")
rev=$(gh api "repos/$REPO/pulls/$PR/reviews" --paginate --slurp \
| jq "add | map(select(.user.login==\"coderabbitai[bot]\" and .submitted_at > \"$since\")) | length")
{ [ "${new:-0}" -gt 0 ] || [ "${rev:-0}" -gt 0 ]; } && { got=1; break; }
Expand Down
11 changes: 9 additions & 2 deletions crq
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ _warning_latest() {
ue="$(iso2epoch "$u")"; reset="$(parse_available_in "$b" "$ue")" || continue
[ -n "$reset" ] || continue
if [ "$ue" -gt "$best_u" ]; then best_u="$ue"; best_reset="$reset"; found=1; fi
done < <(gh search prs --owner "$owner" --state open --archived=false --limit "$CRQ_WARNING_SCAN_LIMIT" --json number,repository \
done < <(gh search prs --owner "$owner" --state open --archived=false --sort updated --limit "$CRQ_WARNING_SCAN_LIMIT" --json number,repository \
--jq '.[]|"\(.repository.nameWithOwner) \(.number)"' 2>/dev/null)
done
[ "$found" = "1" ] && echo "${best_u}|${best_reset}"
Expand Down Expand Up @@ -942,7 +942,7 @@ cmd_autoreview() {
sleep "$CRQ_AUTOREVIEW_POLL"
done
log "crq autoreview leader for $CRQ_REPO ($_LEADER_ID)"
local repo pr head crrev crrev_raw reviewed reviewed_raw json present key firedsha rlc scanned idx deferred scan_cursor=0 searched
local repo pr head crrev crrev_raw reviewed reviewed_raw prbody json present key firedsha rlc scanned idx deferred scan_cursor=0 searched
local search_targets search_flag target
while true; do
# Re-assert leadership each pass (also our heartbeat). If a stale period let another host
Expand Down Expand Up @@ -1007,6 +1007,13 @@ cmd_autoreview() {
# and enqueue a redundant review (the comment scan is the only guard here) (crq:972).
if ! reviewed_raw="$(gh api "repos/$repo/issues/$pr/comments" --paginate --slurp 2>/dev/null)"; then continue; fi
reviewed="$(printf '%s' "$reviewed_raw" | jq --arg bot "$CRQ_BOT" --arg m "$CRQ_REVIEW_DONE_MARKER" 'add | map(select(.user.login==$bot and ((.body//"")|contains($m)))) | length' 2>/dev/null)"
# CodeRabbit's default summary is written into the PR DESCRIPTION, not an issue comment —
# check the body too before deciding a no-incremental PR is unreviewed (crq:1009). If the
# body lookup itself FAILS, skip rather than enqueue on an unknown (same guard as above) (crq:1012).
if [ "${reviewed:-0}" -le 0 ]; then
if ! prbody="$(gh api "repos/$repo/pulls/$pr" --jq '.body // ""' 2>/dev/null)"; then continue; fi
printf '%s' "$prbody" | grep -qF "$CRQ_REVIEW_DONE_MARKER" && reviewed=1
fi
[ "${reviewed:-0}" -gt 0 ] || { ( cmd_enqueue "$repo" "$pr" ) || true; }
fi
else
Expand Down
4 changes: 3 additions & 1 deletion examples/monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ bot_count() {
# runs the filter per page, so a new (non-bot) page could shift the string and false-wake the loop.
# Exclude rate-limit WARNING posts from EVERY counter (case-insensitive) — they're not review
# feedback and would otherwise wake the loop as NEW_FEEDBACK when no actual review arrived.
local f='add|map(select(.user.login==$bot and ((.body//"")|ascii_downcase|contains(($rl|ascii_downcase))|not)))|length'
# Emit "count@latest-timestamp" so an EDITED bot comment (CodeRabbit refreshes its summary/walkthrough
# in place — count unchanged) still changes the signature and wakes the loop (monitor:55).
local f='add|map(select(.user.login==$bot and ((.body//"")|ascii_downcase|contains(($rl|ascii_downcase))|not))) | "\(length)@\((map(.updated_at // .submitted_at // "")|max) // "")"'
c=$(gh api "repos/$REPO/pulls/$PR/comments" --paginate --slurp 2>/dev/null | jq --arg bot "$BOT" --arg rl "$RL" "$f" 2>/dev/null)
r=$(gh api "repos/$REPO/pulls/$PR/reviews" --paginate --slurp 2>/dev/null | jq --arg bot "$BOT" --arg rl "$RL" "$f" 2>/dev/null)
i=$(gh api "repos/$REPO/issues/$PR/comments" --paginate --slurp 2>/dev/null | jq --arg bot "$BOT" --arg rl "$RL" "$f" 2>/dev/null)
Expand Down