Skip to content

Commit 2497662

Browse files
worktrunk-botclaude
andcommitted
fix(ci): let triage own all new issues, mention only handles edits
Previously, claude-mention triggered on `issues: [opened, edited]` while claude-issue-triage skipped issues mentioning @worktrunk-bot. This caused races when a user both commented on an existing issue and filed a new one — two workflows independently created fix PRs for the same bug (#1544/#1545). Now triage handles all new issues (including @worktrunk-bot mentions), and mention only triggers on issue edits. This eliminates the race for new issues while preserving the ability to summon the bot by editing an existing issue. Ref: #1548 (comment) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5e5dec4 commit 2497662

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

.github/CLAUDE.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,13 @@ This is why release secrets must be in a protected environment, not repo-level s
119119

120120
## Triage ↔ mention handoff
121121

122-
These two workflows explicitly exclude each other to avoid double-processing:
123-
- Issue body contains `@worktrunk-bot` → triage skips, mention handles it
124-
- Issue body does not contain `@worktrunk-bot` → triage handles it, mention ignores it
122+
New issues are always handled by the triage workflow — `claude-mention` only
123+
triggers on issue **edits** (not opens) to avoid two workflows racing to create
124+
fix PRs for the same bug.
125+
126+
- **New issue** (opened) → triage handles it, regardless of `@worktrunk-bot` mentions
127+
- **Issue edited** to add `@worktrunk-bot` → mention handles it
128+
- **Comment** on an issue/PR → mention handles it (via `issue_comment` trigger)
125129

126130
The mention workflow runs for any user who includes `@worktrunk-bot` — the merge restriction (ruleset) is the safety boundary, not access control on the workflow itself.
127131

@@ -132,10 +136,11 @@ The mention workflow runs for any user who includes `@worktrunk-bot` — the mer
132136
**Triggers a response:**
133137
- Non-draft PR opened or updated → automatic code review (`claude-review`)
134138
- Formal review submitted on a `worktrunk-bot`-authored PR, with body or non-approval → `claude-review` responds
135-
- `@worktrunk-bot` mentioned in an issue body → `claude-mention` responds
139+
- `@worktrunk-bot` mentioned in a new issue body → `claude-issue-triage` handles it (triage owns all new issues)
140+
- `@worktrunk-bot` mentioned via issue edit → `claude-mention` responds
136141
- `@worktrunk-bot` mentioned in any comment (issue or PR) → `claude-mention` responds
137142
- Any comment on a PR or issue that `worktrunk-bot` has engaged with (authored, mentioned in the issue body, reviewed, or commented on) → `claude-mention` runs (verify step confirms engagement via API), but the prompt instructs Claude to only respond if the comment needs bot input — otherwise exit silently. When the bot authored the PR/issue, it leans toward responding since commenters expect the author to engage.
138-
- Editing a comment or issue body re-triggers the same response
143+
- Editing a comment or issue body re-triggers the mention workflow
139144

140145
**Does not trigger:**
141146
- Issues authored by `worktrunk-bot` (prevents self-triggering when bot-created issues incidentally mention `@worktrunk-bot` in body text)

.github/workflows/claude-issue-triage.yaml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,17 @@ env:
1818

1919
jobs:
2020
triage:
21-
# Skip bot-created issues, @worktrunk-bot mentions (handled by claude-mention.yaml),
22-
# and issues from worktrunk-bot (nightly workflows, ci-fix, etc.). Nightly
23-
# workflows handle their own remediation because they have richer context
24-
# (session logs, aggregate diffs) that would be lost if the triager
25-
# re-derived it from the issue body alone.
21+
# Skip bot-created issues and issues from worktrunk-bot (nightly workflows,
22+
# ci-fix, etc.). Nightly workflows handle their own remediation because they
23+
# have richer context (session logs, aggregate diffs) that would be lost if
24+
# the triager re-derived it from the issue body alone.
25+
#
26+
# Issues mentioning @worktrunk-bot are handled here too — claude-mention
27+
# only triggers on issue edits (not opens) to avoid duplicate workflows
28+
# racing to create fix PRs.
2629
if: >-
2730
github.event.issue.user.type != 'Bot' &&
28-
github.event.issue.user.login != 'worktrunk-bot' &&
29-
!contains(github.event.issue.body, '@worktrunk-bot') &&
30-
!contains(github.event.issue.title, '@worktrunk-bot')
31+
github.event.issue.user.login != 'worktrunk-bot'
3132
runs-on: ubuntu-24.04
3233
permissions:
3334
contents: write

.github/workflows/claude-mention.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: claude-mention
33

44
on:
55
issues:
6-
types: [opened, edited]
6+
types: [edited]
77
issue_comment:
88
types: [created, edited]
99
pull_request_review_comment:
@@ -17,8 +17,10 @@ env:
1717

1818
jobs:
1919
claude:
20-
# Two triggers:
20+
# Three triggers:
2121
# 1. @worktrunk-bot mentions — explicit requests on any issue/PR.
22+
# New issues (opened) go to claude-issue-triage instead; this
23+
# workflow only handles issue edits that add @worktrunk-bot.
2224
# 2. Bot-engaged PRs/issues — any non-bot comment on a PR or issue
2325
# where the bot has authored, reviewed, or commented. The verify step
2426
# checks engagement via API and skips the job if the bot has not
@@ -61,7 +63,7 @@ jobs:
6163
# Verify bot engagement — gate for non-mention comments.
6264
#
6365
# Skipped (all subsequent steps run) when:
64-
# - Event is not a comment (issues opened/edited with @worktrunk-bot)
66+
# - Event is not a comment (issues edited with @worktrunk-bot)
6567
# - Comment body contains @worktrunk-bot (explicit mention)
6668
#
6769
# When it runs, checks engagement in order (first match exits 0):
@@ -211,7 +213,7 @@ jobs:
211213
# 1. Inline review comment (pull_request_review_comment) → reply in thread
212214
# 2. Explicit @worktrunk-bot mention in a comment → always respond
213215
# 3. Comment on bot-engaged issue/PR (no mention) → only if helpful
214-
# 4. Issue opened/edited with @worktrunk-bot mention → always respond
216+
# 4. Issue edited with @worktrunk-bot mention → always respond
215217
prompt: >-
216218
${{ github.event_name == 'pull_request_review_comment'
217219
&& (contains(github.event.comment.body, '@worktrunk-bot')
@@ -240,7 +242,7 @@ jobs:
240242
github.event.comment.html_url
241243
))
242244
|| format(
243-
'An issue was opened or updated with a mention of you ({0}). Read it and respond.',
245+
'An issue was updated with a mention of you ({0}). Read it and respond.',
244246
github.event.issue.html_url
245247
) }}
246248

0 commit comments

Comments
 (0)