Skip to content

feat: support pull request events in triage pipeline#39

Merged
Kavirubc merged 3 commits intosimiligh:mainfrom
mahsumaktas:feat/pr-support-issue-38
Feb 13, 2026
Merged

feat: support pull request events in triage pipeline#39
Kavirubc merged 3 commits intosimiligh:mainfrom
mahsumaktas:feat/pr-support-issue-38

Conversation

@mahsumaktas
Copy link
Copy Markdown
Contributor

@mahsumaktas mahsumaktas commented Feb 12, 2026

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

  • PR event parsing — Handles pull_request and pr_comment (PR-specific comments via issue.pull_request detection)
  • Similarity & duplicate detection — PRs are checked against the existing vector DB (issues + PRs together)
  • Smart pipeline guards — Transfer/routing steps are skipped for PRs (PRs cant be transferred)
  • Dry-run consistency — Transfer logging aligned with runtime behavior
  • Workflow configspull_request triggers + pull-requests: write permission added
  • Tests — 3 new tests (PR event, issue_comment, pr_comment detection)
  • Docs updated — All setup guides reflect issue + PR support

Design Decisions

Decision Rationale
Reuse existing pipeline No new collections, no new config — instant adoption
pr_comment event type GitHub sends PR comments as issue_comment with issue.pull_request set — we detect and differentiate
Skip transfer for PRs PRs cannot be transferred between repos (GitHub limitation)
Shared vector space Cross-scanning PRs ↔ Issues naturally (steipete request)

How 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:

  • Zero config change — works immediately for all existing users
  • Cross-scanning built-in — PRs and issues share the same vector space
  • Smaller surface area — 12 files changed vs 27, easier to review and maintain
  • PR comment awareness — Detects and handles PR-specific comments

Both approaches are valid. This one optimizes for backward compatibility and minimal friction.

Validation

  • go build ./...
  • go vet ./...
  • go test ./...
  • All CodeRabbit feedback addressed ✅

Summary by CodeRabbit

  • New Features

    • Automations now handle pull request events alongside issues; permissions updated to allow PR writes.
  • Bug Fixes / Behavior

    • Workflow triggers refined for issues (removed closed/deleted) and expanded for PR events (including synchronize) to reduce noisy runs.
  • Documentation

    • Setup guides and examples updated to reference combined issue+PR workflows and cross-repo PR handling.
  • Chores

    • Branding updated to "Issue & PR Intelligence"; UI wording changed to "Similar Threads".

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Workflows
DOCS/examples/multi-repo/caller-workflow.yml, DOCS/examples/multi-repo/shared-workflow.yml, DOCS/examples/single-repo/workflow.yml
Add pull_request triggers (opened, edited, reopened, synchronize); remove closed/deleted from issue triggers; add pull-requests: write permission.
Documentation
DOCS/multi-repo-org-setup.md, DOCS/single-repo-setup.md
Update examples and wording to reference issues + pull requests; rename example workflow filename reference.
Action metadata
action.yml
Rename action to include PRs and update description to mention pull requests.
Event parsing & tests
cmd/simili/commands/process.go, cmd/simili/commands/process_test.go
Extracted GitHub event parsing into enrichIssueFromGitHubEvent and populateIssuePayload; add PR payload/label support and unit tests for PR/comment events.
Runtime guards & steps
internal/steps/action_executor.go, internal/steps/command_handler.go, internal/steps/llm_router.go, internal/steps/pending_action_scheduler.go, internal/steps/transfer_check.go
Expand guards to treat pull_request and pr_comment appropriately (skip or alter transfers, LLM routing, pending actions, and command handling).
Responses & tests
internal/steps/response_builder.go, internal/steps/response_builder_test.go
Change "Similar Issues" → "Similar Threads"; duplicate message now uses "pull request" or "issue" based on event type and update test expectation.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰✨ I hopped through payloads of issue and PR,

I parse, I label, I stitch threads near and far,
Duplicates whisper, "Here are siblings to see",
Threads now called threads — neat as can be,
A rabbit's cheer for tidy PR harmony!

🚥 Pre-merge checks | ✅ 5 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: support pull request events in triage pipeline' accurately and clearly describes the main change, which is adding PR event support to the triage workflow.
Linked Issues check ✅ Passed All coding objectives from issue #38 are met: PR event parsing in process.go, duplicate detection support via response_builder.go, and intelligent routing through workflow and step modifications.
Out of Scope Changes check ✅ Passed All changes are directly aligned with PR event support: GitHub Actions workflows, documentation updates, core processing logic, and step handlers all focus on extending triage capabilities to PRs.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 removing synchronize from PR triggers.

The synchronize event 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 on EventType, but this test doesn't cover that path. Consider adding a test case with EventType: "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: --issue flag naming is now semantically misleading for PR events.

The --issue flag is used for both issues and PRs, which works functionally but may cause confusion. A future refactor could rename this to --event or --payload for clarity.

cmd/simili/commands/process_test.go (1)

1-84: Consider adding a test for plain issues events.

The current tests cover pull_request and issue_comment events. Adding a test for a standard issues event (without a comment) would complete coverage of the three main event paths in enrichIssueFromGitHubEvent.

📝 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)
	}
}

Comment thread cmd/simili/commands/process.go
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.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 | 🟡 Minor

Align 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.
Copy link
Copy Markdown
Contributor

@Kavirubc Kavirubc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mahsumaktas,

I have some changes to be made before merging but overall LGTM.

Thank you.

Kavirubc added a commit that referenced this pull request Feb 13, 2026
- 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>
@Kavirubc
Copy link
Copy Markdown
Contributor

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 synchronize from the PR workflow trigger to reduce noise, corrected the "Thread" column header in the similar results table, and added a clarifying comment in command_handler.go). I'm continuing this from a branch on the main repo to keep the merge clean.

Your work is fully credited and carried forward. Really appreciate the effort on this one! 🙏

@Kavirubc Kavirubc closed this Feb 13, 2026
@Kavirubc Kavirubc reopened this Feb 13, 2026
@Kavirubc Kavirubc merged commit 1e4a83b into similigh:main Feb 13, 2026
4 checks passed
Kavirubc added a commit that referenced this pull request Feb 13, 2026
- 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>
Kavirubc added a commit that referenced this pull request Feb 13, 2026
…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>
@Kavirubc Kavirubc mentioned this pull request Feb 13, 2026
17 tasks
@mahsumaktas
Copy link
Copy Markdown
Contributor Author

Thanks for the kind words and merge @Kavirubc :)
This is my first contribution and I hope to contribute much more in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Pull Request support

2 participants