feat: support pull request events in triage pipeline#39
feat: support pull request events in triage pipeline#39Kavirubc merged 3 commits intosimiligh:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds Pull Request support across CI workflows, docs, CLI parsing, runtime guards, response text, and tests: workflows now trigger on PR events; event parsing refactored to handle pull_request payloads; multiple internal steps made PR-aware; action metadata and docs updated. Changes
Sequence Diagram(s)sequenceDiagram
participant GitHub as "GitHub (Event)"
participant Ingest as "Simili CLI / process.go"
participant Router as "LLM Router"
participant Scheduler as "PendingActionScheduler"
participant Builder as "ResponseBuilder"
GitHub->>Ingest: deliver issue or pull_request payload
Ingest->>Ingest: enrichIssueFromGitHubEvent()/populateIssuePayload()
alt Event is issue
Ingest->>Router: route to LLM Router
Router-->>Ingest: routing result
Ingest->>Scheduler: schedule pending actions
else Event is pull_request or pr_comment
Ingest->>Ingest: skip Router/Scheduler (PR-aware guards)
end
Ingest->>Builder: build response (phrasing depends on event type)
Builder->>GitHub: post comment / take action
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@cmd/simili/commands/process.go`:
- Around line 285-295: The code currently leaves issue.EventType as
"issue_comment" for PR comments because GitHub sends comment payloads with an
"issue" that contains a "pull_request" field rather than a top-level
"pull_request"; update the logic after populateIssuePayload (and where
raw["issue"] is processed) to detect PR-related comments by checking the
presence of a "pull_request" key inside the parsed issue map (e.g., inspect
iss["pull_request"] or the populated issue.PullRequest/URL field) and if present
set issue.EventType to "pull_request" (or another distinct PR-comment event
type) so downstream components (quality_checker, llm_router, command_handler,
duplicate_detector, response_builder) can differentiate PR comments from issue
comments; keep the existing handling for real issue events unchanged.
🧹 Nitpick comments (5)
DOCS/examples/multi-repo/caller-workflow.yml (1)
6-7: Consider removingsynchronizefrom PR triggers.The
synchronizeevent fires every time commits are pushed to the PR branch. This could cause excessive workflow runs and redundant triage comments, since the PR's title/body typically don't change on push. Unless the intent is to re-analyze based on code changes, consider removing it to avoid noise.Suggested change
pull_request: - types: [opened, edited, reopened, synchronize] + types: [opened, edited, reopened]internal/steps/action_executor.go (1)
44-46: Optional: Consider PR-aware dry-run logging.The dry-run block logs "Would transfer to..." even for pull requests, which could be misleading since PRs won't actually be transferred. For consistency, consider adding the same EventType check here.
Suggested change
- if ctx.TransferTarget != "" { + if ctx.TransferTarget != "" && ctx.Issue.EventType != "pull_request" { log.Printf("[action_executor] DRY RUN: Would transfer to %s", ctx.TransferTarget) }internal/steps/response_builder_test.go (1)
13-85: Consider adding test coverage for PR-specific duplicate messaging.The new logic in
response_builder.go(Lines 270-274) dynamically uses "pull request" vs "issue" in duplicate warnings based onEventType, but this test doesn't cover that path. Consider adding a test case withEventType: "pull_request"and a mock duplicate result to verify the message says "This pull request might be a duplicate...".Example test case to add
func TestResponseBuilder_buildDuplicateSection_PullRequest(t *testing.T) { deps := &pipeline.Dependencies{} builder := NewResponseBuilder(deps) ctx := &pipeline.Context{ Issue: &pipeline.Issue{ Org: "similigh", Repo: "simili-bot", Number: 456, EventType: "pull_request", }, Config: &config.Config{}, Metadata: make(map[string]interface{}), } ctx.Metadata["duplicate_result"] = &gemini.DuplicateResult{ IsDuplicate: true, DuplicateOf: 123, Confidence: 0.90, Reasoning: "Same feature implementation", } section := builder.buildDuplicateSection(ctx) if !strings.Contains(section, "This pull request might be a duplicate") { t.Errorf("Expected 'pull request' in duplicate message, got: %s", section) } }action.yml (1)
34-35: Consider:--issueflag naming is now semantically misleading for PR events.The
--issueflag is used for both issues and PRs, which works functionally but may cause confusion. A future refactor could rename this to--eventor--payloadfor clarity.cmd/simili/commands/process_test.go (1)
1-84: Consider adding a test for plainissuesevents.The current tests cover
pull_requestandissue_commentevents. Adding a test for a standardissuesevent (without a comment) would complete coverage of the three main event paths inenrichIssueFromGitHubEvent.📝 Example test case
func TestEnrichIssueFromGitHubEvent_Issues(t *testing.T) { issue := &pipeline.Issue{} raw := map[string]interface{}{ "action": "opened", "issue": map[string]interface{}{ "number": float64(10), "title": "Bug: something broken", "body": "Details here", "state": "open", "html_url": "https://github.com/similigh/simili-bot/issues/10", "user": map[string]interface{}{"login": "reporter"}, }, "repository": map[string]interface{}{ "name": "simili-bot", "owner": map[string]interface{}{"login": "similigh"}, }, } enrichIssueFromGitHubEvent(issue, raw) if issue.EventType != "issues" { t.Fatalf("expected issues event type, got %q", issue.EventType) } if issue.Number != 10 { t.Fatalf("expected issue number 10, got %d", issue.Number) } }
CodeRabbit review feedback: GitHub sends PR comments as issue_comment events with issue.pull_request set. Detect this and set EventType to pr_comment so downstream steps handle them correctly. Added test for pr_comment detection.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/steps/action_executor.go (1)
40-46:⚠️ Potential issue | 🟡 MinorAlign dry‑run transfer logging with PR skip logic.
Dry‑run currently logs a transfer for PR events that will be skipped in real runs, which can mislead tests and operators. Mirror the new event‑type guard in the dry‑run branch.
🔧 Suggested fix
- if ctx.TransferTarget != "" { + if ctx.TransferTarget != "" && ctx.Issue.EventType != "pull_request" && ctx.Issue.EventType != "pr_comment" { log.Printf("[action_executor] DRY RUN: Would transfer to %s", ctx.TransferTarget) }Also applies to: 68-69
CodeRabbit feedback: dry-run was logging transfer for PR events that would be skipped in real runs. Added event type guard.
- Remove `synchronize` from pull_request workflow triggers to avoid running triage on every commit push to a PR (opened/edited/reopened only) - Fix "Issue" column header to "Thread" in Similar Threads table so it correctly describes both issues and PRs - Add comment in command_handler.go explaining why issue_comment events bypass analyzeHistoryForLoops (they are fully handled earlier in the fn) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Thank you for this contribution @mahsumaktas! The approach here is exactly right — lightweight, zero-config, and backward compatible. I've iterated on your branch with a few small fixes (removed Your work is fully credited and carried forward. Really appreciate the effort on this one! 🙏 |
- Remove `synchronize` from pull_request workflow triggers to avoid running triage on every commit push to a PR (opened/edited/reopened only) - Fix "Issue" column header to "Thread" in Similar Threads table so it correctly describes both issues and PRs - Add comment in command_handler.go explaining why issue_comment events bypass analyzeHistoryForLoops (they are fully handled earlier in the fn) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…omment clarity) (#41) * fix: review feedback on PR #39 - Remove `synchronize` from pull_request workflow triggers to avoid running triage on every commit push to a PR (opened/edited/reopened only) - Fix "Issue" column header to "Thread" in Similar Threads table so it correctly describes both issues and PRs - Add comment in command_handler.go explaining why issue_comment events bypass analyzeHistoryForLoops (they are fully handled earlier in the fn) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * fix: reword command_handler comment to accurately describe event routing - pr_comment does reach analyzeHistoryForLoops (was wrongly excluded) - unknown /commands log and return nil, not 'dispatched' - clarify that issue_comment never reaches the loop-prevention check Addresses Copilot review on PR #41 --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Thanks for the kind words and merge @Kavirubc :) |
PR Support for Existing Pipeline — Zero-Config, Backward Compatible
Closes #38 | Ref: steipete tweet
Approach: Lightweight Integration
This PR takes a minimal, non-breaking approach — PR events flow through the existing issue pipeline with smart guards, requiring zero configuration changes for existing users.
What It Does
pull_requestandpr_comment(PR-specific comments viaissue.pull_requestdetection)pull_requesttriggers +pull-requests: writepermission addedDesign Decisions
pr_commentevent typeissue_commentwithissue.pull_requestset — we detect and differentiateHow It Differs from #40
PR #40 introduces a separate PR indexing system with dedicated collections and diff analysis. This PR instead integrates PR support directly into the existing pipeline:
Both approaches are valid. This one optimizes for backward compatibility and minimal friction.
Validation
go build ./...✅go vet ./...✅go test ./...✅Summary by CodeRabbit
New Features
Bug Fixes / Behavior
Documentation
Chores