Skip to content

fix: AI title suggestion fails when clone has no visible diff from base branch #1019

@myakove

Description

@myakove

Description

The AI conventional title suggestion fails to produce a valid title when the cloned repository shows no visible diff from the base branch (e.g., after force-push/amend where the worktree looks identical to main from the AI's perspective).

The AI returns a descriptive sentence like "The PR branch is identical to main with no code changes" instead of a proper conventional title.

Root Cause

The current prompt tells the AI to "look at the recent commits and changes" but doesn't provide the actual PR diff or context directly. When the clone state doesn't clearly show PR changes, the AI has nothing to work with.

Proposed Fix

Include the PR diff directly in the prompt text instead of relying on the AI to discover it from the repo. The webhook server already has access to the PR diff (via PyGithub or git diff against the base branch). Embedding the diff in the prompt ensures the AI always has the context it needs, regardless of the clone's checkout state.

Options:

  1. Fetch PR diff via PyGithub (pull_request.get_diff() or compare API) and include in prompt
  2. Run git diff origin/{base_ref}...HEAD in the clone and include the output in prompt
  3. Pass the PR title + list of changed files as minimum context if diff is too large

Observed Behavior

### AI Auto-Fix Skipped

AI suggested: `The PR branch is identical to main with no code changes. This appears to be a test PR with no actual modifications.`
Suggestion was invalid or unchanged.

Expected Behavior

AI should receive enough context to always suggest a valid conventional title based on the actual PR changes.

Deliverables

  • Code changes
  • Add/update tests
  • Update CLAUDE.md (if codebase structure changes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions