Resolve Replied Greptile Comments
Resolve all Greptile bot review comment threads on a GitHub PR that already have human replies. This avoids cluttering the PR conversation view with already-addressed bot feedback.
How it works
- Parse the PR URL or number from
$ARGUMENTSto extractowner,repo, andpr_number - Fetch all review threads via GitHub GraphQL API
- Identify threads started by
greptile-appsthat have reply comments (i.e., already addressed) - Resolve those threads, skipping any already resolved
- Report what was done
Step 1: Parse PR reference
Extract owner, repo, and PR number from $ARGUMENTS. Supports formats:
- Full URL:
https://github.com/OWNER/REPO/pull/NUMBER - Short:
OWNER/REPO#NUMBER - Number only:
NUMBER(requires--repoflag or defaults to current repo viagh repo view)
# Example parsing
PR_URL="$ARGUMENTS"
# Extract from URL pattern
if echo "$PR_URL" | grep -qE 'github\.com/'; then
OWNER=$(echo "$PR_URL" | sed -E 's|.*github\.com/([^/]+)/([^/]+)/pull/([0-9]+).*|\1|')
REPO=$(echo "$PR_URL" | sed -E 's|.*github\.com/([^/]+)/([^/]+)/pull/([0-9]+).*|\2|')
PR_NUMBER=$(echo "$PR_URL" | sed -E 's|.*github\.com/([^/]+)/([^/]+)/pull/([0-9]+).*|\3|')
elif echo "$PR_URL" | grep -qE '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+#[0-9]+$'; then
OWNER=$(echo "$PR_URL" | cut -d/ -f1)
REPO=$(echo "$PR_URL" | cut -d/ -f2 | cut -d# -f1)
PR_NUMBER=$(echo "$PR_URL" | cut -d# -f2)
else
PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+')
# Get owner/repo from current git remote
OWNER=$(gh repo view --json owner -q '.owner.login')
REPO=$(gh repo view --json name -q '.name')
fiStep 2: Fetch review threads and identify Greptile threads with replies
Use the GraphQL API to get all review threads, filtering for ones started by greptile-apps that are not yet resolved.
gh api graphql -f query='
{
repository(owner: "'"$OWNER"'", name: "'"$REPO"'") {
pullRequest(number: '"$PR_NUMBER"') {
reviewThreads(first: 100) {
nodes {
id
isResolved
comments(first: 2) {
totalCount
nodes {
author { login }
}
}
}
}
}
}
}'Filter the results to find threads where:
- First comment author is
greptile-apps(the bot) totalCount > 1(has at least one reply)isResolvedisfalse
Step 3: Resolve the threads
For each matching thread ID, call the resolve mutation:
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "THREAD_NODE_ID"}) {
thread { isResolved }
}
}'Step 4: Report
Print a summary:
- How many Greptile threads were found total
- How many were already resolved
- How many were resolved now
- How many had no replies (left unresolved)