Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

chore: update tend workflows (#2241)

Worktrunk Bot6acc08f3d9c2
diff --git a/.github/workflows/tend-ci-fix.yaml b/.github/workflows/tend-ci-fix.yaml
index 1ca080d83..8276bba8b 100644
--- a/.github/workflows/tend-ci-fix.yaml
+++ b/.github/workflows/tend-ci-fix.yaml
@@ -17,7 +17,6 @@ jobs:
fix-ci:
if: github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
diff --git a/.github/workflows/tend-mention.yaml b/.github/workflows/tend-mention.yaml
index 870b20807..580631fb9 100644
--- a/.github/workflows/tend-mention.yaml
+++ b/.github/workflows/tend-mention.yaml
@@ -15,18 +15,36 @@ on:
# Works for same-repo PRs only; secrets unavailable on fork PRs (no _target variant exists)
pull_request_review:
types: [submitted]
+ # `created` is intentionally absent. Modern GitHub fires *both*
+ # pull_request_review and pull_request_review_comment for every newly-created
+ # inline comment (the standalone POST /pulls/PR/comments endpoint, the
+ # /replies endpoint, the "Add single comment" UI button, and reviews
+ # submitted with inline comments — all empirically verified). Subscribing to
+ # `created` would produce a duplicate workflow run that collides on the
+ # tend-mention-handle-PR concurrency group, with the loser cancelled and
+ # posted as a CANCELLED check_run on the PR head SHA — which renders the
+ # PR's statusCheckRollup as FAILURE even though the bot did its job from the
+ # sibling run. Edits have no sibling event (review submissions don't fire on
+ # edits), so we still need to listen for `edited` to catch edit-to-summon
+ # ("@bot" added to an existing comment after the fact).
pull_request_review_comment:
- types: [created, edited]
+ types: [edited]
jobs:
verify:
# Filter out fork PRs for review events — secrets are unavailable there
# (no _target variant exists). The notifications workflow polls for these.
+ # Skip comments on `tend-outage` issues: the action's Report-failure step
+ # auto-comments on those when Claude invocation fails, and without this
+ # guard those comments re-trigger tend-mention during a persistent outage
+ # (e.g. Anthropic 401), producing a self-sustaining ~1 run/minute loop
+ # until the outage clears. The prompt's self-loop guard can't help here
+ # because the model never executes — the action fails before Claude starts.
if: |
(github.event_name == 'issues' &&
contains(github.event.issue.body, '@worktrunk-bot')) ||
(github.event_name == 'issue_comment' &&
- github.event.comment.user.login != 'worktrunk-bot') ||
+ !contains(github.event.issue.labels.*.name, 'tend-outage')) ||
(github.event_name == 'pull_request_review_comment' &&
github.event.pull_request.head.repo.full_name == github.repository) ||
(github.event_name == 'pull_request_review' &&
@@ -49,6 +67,18 @@ jobs:
exit 0
fi
+ # pull_request_review payloads include review.body (checked above)
+ # but NOT the bodies of inline comments attached to the review.
+ # Fetch them so a first-contact @-mention inside an inline comment
+ # is detected on PRs where the bot has no prior engagement.
+ if [ "$EVENT_NAME" = "pull_request_review" ] && [ -n "$REVIEW_ID" ]; then
+ if gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$EVENT_PR_NUMBER/reviews/$REVIEW_ID/comments" \
+ --jq '.[].body' | grep -qF '@worktrunk-bot'; then
+ echo "should_run=true" >> "$GITHUB_OUTPUT"
+ exit 0
+ fi
+ fi
+
# Non-mention: check bot engagement
if [ "$EVENT_NAME" = "issue_comment" ]; then
ISSUE_NUMBER="$ISSUE_OR_PR_NUMBER"
@@ -60,7 +90,7 @@ jobs:
if printf '%s\n' "$ISSUE_BODY" | grep -qF '@worktrunk-bot'; then
echo "should_run=true" >> "$GITHUB_OUTPUT"; exit 0
fi
- BOT_COMMENTS=$(gh api "repos/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER/comments" \
+ BOT_COMMENTS=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER/comments" \
--jq '[.[] | select(.user.login == "worktrunk-bot")] | length')
if [ "$BOT_COMMENTS" -gt "0" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"; exit 0
@@ -78,13 +108,13 @@ jobs:
echo "should_run=true" >> "$GITHUB_OUTPUT"; exit 0
fi
- BOT_REVIEWS=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" \
+ BOT_REVIEWS=$(gh api --paginate "repos/$GITHUB_REPOSITORY/pulls/$PR_NUMBER/reviews" \
--jq '[.[] | select(.user.login == "worktrunk-bot")] | length')
if [ "$BOT_REVIEWS" -gt "0" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"; exit 0
fi
- BOT_COMMENTS=$(gh api "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
+ BOT_COMMENTS=$(gh api --paginate "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments" \
--jq '[.[] | select(.user.login == "worktrunk-bot")] | length')
if [ "$BOT_COMMENTS" -gt "0" ]; then
echo "should_run=true" >> "$GITHUB_OUTPUT"; exit 0
@@ -100,6 +130,7 @@ jobs:
ISSUE_AUTHOR: ${{ github.event.issue.user.login }}
PR_URL: ${{ github.event.issue.pull_request.url }}
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
+ REVIEW_ID: ${{ github.event.review.id }}
- name: React to mention
if: |
@@ -121,7 +152,6 @@ jobs:
group: ${{ github.workflow }}-handle-${{ github.event.issue.number || github.event.pull_request.number }}
cancel-in-progress: false
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
@@ -181,18 +211,14 @@ jobs:
${{ github.event_name == 'issues'
&& format('An issue was updated with a mention of you ({0}). Read it and respond.', github.event.issue.html_url)
|| (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@worktrunk-bot')
- && format('You were mentioned in an inline review comment on PR #{0} ({1}, review comment ID {2}). Read the full PR context (description, diff, recent comments, CI status) and respond. If they are requesting changes, make the changes, commit, and push. Reply in the review thread using `gh api repos/{3}/pulls/{0}/comments/{2}/replies -f body="..."` — do not create a new top-level comment.', (github.event_name == 'issue_comment' && github.event.issue.number || github.event.pull_request.number), github.event.comment.html_url, github.event.comment.id, github.repository))
+ && format('You were mentioned in an inline review comment on PR #{0} ({1}, comment ID {2}). Read the full context, then respond. If changes are requested, make them, commit, and push.', (github.event_name == 'issue_comment' && github.event.issue.number || github.event.pull_request.number), github.event.comment.html_url, github.event.comment.id))
|| (github.event_name == 'pull_request_review_comment'
- && format('A user left an inline review comment on a PR where you previously participated (PR #{0}, {1}, review comment ID {2}). Read the full context. Only respond if the comment is directed at you or requests changes. Reply in the review thread using `gh api repos/{3}/pulls/{0}/comments/{2}/replies -f body="..."`.', (github.event_name == 'issue_comment' && github.event.issue.number || github.event.pull_request.number), github.event.comment.html_url, github.event.comment.id, github.repository))
+ && format('An inline review comment was posted on a PR where you previously participated (PR #{0}, {1}, comment ID {2}). Read the full context. Only respond if the comment is directed at you or requests changes.', (github.event_name == 'issue_comment' && github.event.issue.number || github.event.pull_request.number), github.event.comment.html_url, github.event.comment.id))
|| (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@worktrunk-bot')
- && format('A review was submitted on PR #{0} that mentions you ({1}). Read the review and full PR context (description, diff, comments, CI status), then respond. If changes were requested, make them, commit, and push.', github.event.pull_request.number, github.event.review.html_url))
+ && format('A review was submitted on PR #{0} that mentions you ({1}, review ID {2}). Read the review and full context, then respond. If changes were requested, make them, commit, and push.', github.event.pull_request.number, github.event.review.html_url, github.event.review.id))
|| (github.event_name == 'pull_request_review'
- && format('A review was submitted on a PR where you previously participated (PR #{0}, {1}). Read the review and full PR context. If the review requests changes or asks questions, respond appropriately. If the review approves or is between humans, exit silently.', github.event.pull_request.number, github.event.review.html_url))
+ && format('A review was submitted on a PR where you previously participated (PR #{0}, {1}, review ID {2}). Read the review and full context. If the review requests changes or asks questions, respond appropriately. If the review approves or is between humans, exit silently.', github.event.pull_request.number, github.event.review.html_url, github.event.review.id))
|| (contains(github.event.comment.body, '@worktrunk-bot')
- && format('You were mentioned in a comment ({0}). Read the full issue or PR (description, diff, recent comments, CI status) and respond. If they are requesting changes, make the changes, commit, and push.', github.event.comment.html_url))
- || format('A user commented on an issue/PR where you previously participated ({0}). Read the full context. Only respond if the comment is directed at you, asks a question you can help with, or requests changes you can make. A comment that responds to concerns you raised in a review is directed at you — briefly acknowledge that the concerns are resolved (or explain why they are not). If the conversation is between other participants, exit silently. In multi-way conversations (other participants besides you and the commenter are active), apply a higher bar: only respond if you have something genuinely new to add — a code fix, reproduction, or specific technical detail no one else provided. Do not restate, agree with, or summarize what a maintainer said.', github.event.comment.html_url)
+ && format('You were mentioned in a comment ({0}). Read the full context and respond. If changes are requested, make them, commit, and push.', github.event.comment.html_url))
+ || format('A user commented on an issue/PR where you previously participated ({0}). Read the full context. Only respond if the comment is directed at you, asks a question you can help with, or requests changes you can make. If the conversation is between other participants, exit silently.', github.event.comment.html_url)
}}
-
- If you are responding to your own prior comment or review (not a human's reply to it), be cautious — only respond if there is a distinct role boundary (e.g., you are the reviewer on your own PR and need to address review feedback). If there is no such role distinction, exit silently to avoid self-conversation loops.
-
- If you are going to propose a code fix for a bug, load /tend-ci-runner:triage first — it contains reproduction and testing gates that apply to all fix attempts, not just initial triage.
diff --git a/.github/workflows/tend-nightly.yaml b/.github/workflows/tend-nightly.yaml
index a235086e2..b56d44551 100644
--- a/.github/workflows/tend-nightly.yaml
+++ b/.github/workflows/tend-nightly.yaml
@@ -15,7 +15,6 @@ on:
jobs:
nightly:
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
diff --git a/.github/workflows/tend-notifications.yaml b/.github/workflows/tend-notifications.yaml
index c14a4fd2e..044a43ca0 100644
--- a/.github/workflows/tend-notifications.yaml
+++ b/.github/workflows/tend-notifications.yaml
@@ -15,7 +15,6 @@ on:
jobs:
notifications:
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
@@ -27,11 +26,64 @@ jobs:
id: check
run: |
COUNT=$(gh api notifications --jq 'length')
- echo "count=$COUNT" >> "$GITHUB_OUTPUT"
if [ "$COUNT" = "0" ]; then
+ echo "count=0" >> "$GITHUB_OUTPUT"
echo "No unread notifications — skipping"
+ exit 0
+ fi
+
+ # --- Layer B: drop notifications shadowed by recent dedicated runs ---
+ # Event workflows mark their own notifications read via action.yaml's
+ # post-step on success; this sweeps the case where Claude failed
+ # (post-step is gated by `if: success()`) so the notification still
+ # gets cleared without burning Claude turns to rediscover it.
+ SINCE=$(date -u -d '30 minutes ago' +%Y-%m-%dT%H:%M:%SZ)
+ RECENT_PRS=$(gh api "repos/$GITHUB_REPOSITORY/actions/runs?created=>=$SINCE&per_page=50" --jq '[.workflow_runs[] | select(.name | test("^(tend-review|tend-mention|tend-triage|tend-ci-fix)$")) | .pull_requests[]?.number] | unique | .[]' || true)
+
+ if [ -n "$RECENT_PRS" ]; then
+ NOTIFS=$(gh api notifications)
+ for pr in $RECENT_PRS; do
+ echo "$NOTIFS" | jq -r --arg repo "$GITHUB_REPOSITORY" --arg pr "$pr" '.[] | select(.subject.url == "https://api.github.com/repos/" + $repo + "/pulls/" + $pr or .subject.url == "https://api.github.com/repos/" + $repo + "/issues/" + $pr) | .id' | while read -r tid; do
+ [ -n "$tid" ] || continue
+ gh api "notifications/threads/$tid" -X PATCH || true
+ done
+ done
+ fi
+
+ # --- Layer C: drop notifications on bot-authored closed PRs ---
+ # The bot auto-subscribes to its own PRs. After merge/close, leftover
+ # subscription notifications are pure noise — no action needed.
+ NOTIFS=$(gh api notifications)
+ echo "$NOTIFS" | jq -r --arg repo "$GITHUB_REPOSITORY" '.[] | select(.repository.full_name == $repo and .subject.type == "PullRequest") | .id' | while read -r tid; do
+ [ -n "$tid" ] || continue
+ PR_NUM=$(echo "$NOTIFS" | jq -r --arg tid "$tid" '.[] | select(.id == $tid) | .subject.url | split("/") | last')
+ PR_INFO=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$PR_NUM" --jq '"\(.user.login) \(.state)"' 2>/dev/null) || continue
+ PR_AUTHOR=${PR_INFO%% *}
+ PR_STATE=${PR_INFO##* }
+ if [ "$PR_AUTHOR" = "worktrunk-bot" ] && [ "$PR_STATE" = "closed" ]; then
+ gh api "notifications/threads/$tid" -X PATCH || true
+ fi
+ done
+
+ # --- Layer D: count processable notifications ---
+ # Same-repo notifications younger than 10 minutes are deferred: a
+ # dedicated workflow (tend-review/mention/triage/ci-fix) is likely
+ # still starting up or mid-flight and hasn't posted its response yet.
+ # Processing them now risks duplicating work. Cross-repo notifications
+ # are exempt — no dedicated workflow handles them.
+ CUTOFF=$(date -u -d '10 minutes ago' +%Y-%m-%dT%H:%M:%SZ)
+ REMAINING=$(gh api notifications)
+ COUNT=$(echo "$REMAINING" | jq --arg repo "$GITHUB_REPOSITORY" --arg cutoff "$CUTOFF" '[.[] | select(.repository.full_name != $repo or .updated_at <= $cutoff)] | length')
+ echo "count=$COUNT" >> "$GITHUB_OUTPUT"
+ if [ "$COUNT" = "0" ]; then
+ TOTAL=$(echo "$REMAINING" | jq 'length')
+ if [ "$TOTAL" = "0" ]; then
+ echo "All notifications handled by pre-checks — skipping"
+ else
+ echo "$TOTAL notification(s) remain but all are fresh same-repo (deferred) — skipping"
+ fi
else
- echo "$COUNT unread notification(s) — proceeding"
+ echo "$COUNT processable notification(s) — proceeding"
fi
env:
GH_TOKEN: ${{ secrets.WORKTRUNK_BOT_TOKEN }}
diff --git a/.github/workflows/tend-review-runs.yaml b/.github/workflows/tend-review-runs.yaml
index fb935bc58..5bdd0af59 100644
--- a/.github/workflows/tend-review-runs.yaml
+++ b/.github/workflows/tend-review-runs.yaml
@@ -15,7 +15,6 @@ on:
jobs:
review-runs:
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
diff --git a/.github/workflows/tend-review.yaml b/.github/workflows/tend-review.yaml
index 49da747c3..1e6f08812 100644
--- a/.github/workflows/tend-review.yaml
+++ b/.github/workflows/tend-review.yaml
@@ -19,7 +19,6 @@ jobs:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
diff --git a/.github/workflows/tend-triage.yaml b/.github/workflows/tend-triage.yaml
index 34f743f0a..9215b9c48 100644
--- a/.github/workflows/tend-triage.yaml
+++ b/.github/workflows/tend-triage.yaml
@@ -18,7 +18,6 @@ concurrency:
jobs:
triage:
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write
diff --git a/.github/workflows/tend-weekly.yaml b/.github/workflows/tend-weekly.yaml
index afb54a21e..74702ca1c 100644
--- a/.github/workflows/tend-weekly.yaml
+++ b/.github/workflows/tend-weekly.yaml
@@ -15,7 +15,6 @@ on:
jobs:
weekly:
runs-on: ubuntu-24.04
- timeout-minutes: 60
permissions:
contents: write
pull-requests: write