Skip to content

Comments

refactor: consolidate Devin session logic into reusable action#26843

Merged
keithwillcode merged 5 commits intomainfrom
devin/fix-stale-pr-session-reuse-1768408436
Jan 14, 2026
Merged

refactor: consolidate Devin session logic into reusable action#26843
keithwillcode merged 5 commits intomainfrom
devin/fix-stale-pr-session-reuse-1768408436

Conversation

@keithwillcode
Copy link
Contributor

@keithwillcode keithwillcode commented Jan 14, 2026

What does this PR do?

This PR consolidates duplicated Devin session management logic from three workflows into a single reusable GitHub action. Originally, the Stale Community PR Devin Completion workflow was creating duplicate sessions (as seen in PR #22542), and the fix revealed significant code duplication across workflows.

Changes

  1. New reusable action (.github/actions/devin-session/action.yml):

    • Checks if PR was created by a Devin session (from PR body)
    • Searches PR comments for existing Devin sessions
    • Verifies session is active (working, blocked, or resumed status) for both PR body and comment-based sessions
    • Returns session info for reuse or signals to create new session
  2. Updated workflows to use the new action:

    • stale-pr-devin-completion.yml - now reuses existing sessions
    • cubic-devin-review.yml - refactored to use action
    • devin-conflict-resolver.yml - refactored to use action

Updates since last revision

  • Fixed Cubic AI feedback (confidence 9/10): Added active status check for PR body sessions. Previously, sessions found from PR body weren't verified as active before reuse, unlike comment-based sessions. Now both code paths consistently check for working, blocked, or resumed status.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - workflow/action changes only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works. N/A - GitHub Actions workflows, tested by triggering.

How should this be tested?

  1. Test session reuse on stale PR workflow:

    • Find a PR with an existing Devin session comment
    • Add the stale label
    • Verify the workflow sends a message to the existing session (comment should say "existing Devin session has been notified")
  2. Test session reuse on conflict resolver:

    • Find a PR with conflicts and an existing Devin session
    • Add the devin-conflict-resolution label
    • Verify session reuse behavior
  3. Test Cubic AI review workflow:

    • Trigger a Cubic AI review on a PR with existing Devin session
    • Verify session reuse

Human Review Checklist

  • Verify checkout step is placed before the action usage in all workflows (required for local composite actions)
  • Confirm the session patterns in the action cover all three use cases: stale PR, Cubic AI, conflict resolution
  • Verify the action outputs (has-existing-session, session-id, session-url) are correctly consumed
  • Verify active status check is applied to PR body sessions (Fixed per Cubic AI feedback)
  • Note: ~83 lines removed from duplicated logic across workflows

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

- Create .github/actions/devin-session composite action for session checking
- Update stale-pr-devin-completion.yml to use the new action
- Update cubic-devin-review.yml to use the new action
- Update devin-conflict-resolver.yml to use the new action
- Rename workflows to 'PR Labeled' with descriptive job names

The new action checks for existing Devin sessions by:
1. Looking for session URLs in PR body (for PRs created by Devin)
2. Searching PR comments for known Devin session patterns
3. Verifying session is active (working, blocked, or resumed status)

This eliminates duplicated session checking logic across all three workflows.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration devin-ai-integration bot changed the title fix: reuse existing Devin sessions in stale PR completion workflow refactor: consolidate Devin session logic into reusable action Jan 14, 2026
Reverted workflow names back to descriptive names:
- 'Stale Community PR Devin Completion' (was 'PR Labeled')
- 'Devin PR Conflict Resolver' (was 'PR Labeled')

Descriptive names are the recommended convention as they appear in
GitHub Actions tab, status checks, and notifications.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@keithwillcode keithwillcode self-assigned this Jan 14, 2026
@keithwillcode keithwillcode added this to the v6.1 milestone Jan 14, 2026
@keithwillcode keithwillcode marked this pull request as ready for review January 14, 2026 17:01
@keithwillcode keithwillcode requested a review from a team as a code owner January 14, 2026 17:01
@graphite-app graphite-app bot added foundation core area: core, team members only labels Jan 14, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name=".github/actions/devin-session/action.yml">

<violation number="1" location=".github/actions/devin-session/action.yml:70">
P1: Missing active status check for PR body sessions. When a session is found from the PR body, the code doesn't verify if it's active (`working`, `blocked`, or `resumed`), unlike the comment-based session check below. This could cause workflows to try reusing completed or failed sessions.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Contributor

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session

Addresses Cubic AI feedback (confidence 9/10): PR body sessions
now verify the session is active (working, blocked, or resumed)
before reusing, matching the behavior of comment-based session checks.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

E2E results are ready!

@keithwillcode keithwillcode enabled auto-merge (squash) January 14, 2026 17:25
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@keithwillcode keithwillcode merged commit ea3bab5 into main Jan 14, 2026
82 of 84 checks passed
@keithwillcode keithwillcode deleted the devin/fix-stale-pr-session-reuse-1768408436 branch January 14, 2026 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants