Skip to content

Conversation

@newhook
Copy link
Owner

@newhook newhook commented Jan 27, 2026

Summary

Adds automatic detection and display of merge conflicts in PRs:

  • Introduces FeedbackTypeConflict to categorize merge conflict feedback
  • Detects when GitHub's mergeStateStatus is "DIRTY" and creates actionable feedback items
  • Stores and tracks mergeable_state in the works database table
  • Displays merge status in the TUI with color-coded indicators

Changes

Core Conflict Detection

  • Added FeedbackTypeConflict constant (internal/github/feedback.go)
  • Added processConflicts() method that checks for MergeableState == "DIRTY" and creates feedback items with priority 1 (High)
  • Updated GetBeadType() to map conflict feedback to "bug" type for high-priority handling
  • Updated getPriorityForType() to return priority 1 for conflicts (blocks merging)

Database & Schema

  • Added mergeable_state column to works table via migration 003_mergeable_state.sql
  • Updated all SQLC queries to include the new column
  • Added MergeableState field to Work struct and WorkProgress

TUI Display

  • Added merge status to PR Status section in WorkSummaryPanel
  • Color-coded display for different states:
    • CLEAN → ✓ Ready to merge (green)
    • DIRTY → ⚠ Has conflicts (red)
    • BLOCKED → ⏸ Blocked by checks (yellow)
    • BEHIND → ↓ Behind main (dim)
    • DRAFT → 📝 Draft PR (dim)
    • UNSTABLE → ⚠ CI unstable (yellow)

Feedback Status Tracking

  • Updated ExtractStatusFromPRStatus() to include mergeable state
  • Updated UpdatePRStatusIfChanged() to detect and log mergeable state changes
  • Added MergeableState to PRStatusInfo struct

Issues Resolved

  • ac-nago: Detect conflicts in PR
  • ac-nago.1: Add FeedbackTypeConflict constant
  • ac-nago.2: Add processConflicts method to FeedbackProcessor
  • ac-nago.3: Update GetBeadType mapping for conflict feedback
  • ac-nago.4: Update getPriorityForType for conflict feedback
  • ac-nago.5: Add tests for conflict detection
  • ac-nago.6: Store and display PR merge state in TUI

Testing

  • Added unit tests for processConflicts() covering all merge states (DIRTY, CLEAN, BLOCKED, UNSTABLE, empty)
  • Added test for getPriorityForType() with conflict type
  • All existing tests continue to pass

Files Changed

  • internal/github/feedback.go - New feedback type constant
  • internal/feedback/processor.go - Conflict processing and priority handling
  • internal/feedback/processor_test.go - Unit tests
  • internal/feedback/integration.go - Bead type mapping
  • internal/feedback/status.go - PR status extraction and change detection
  • internal/db/db.go - Mergeable state constants
  • internal/db/schema.sql - Schema update
  • internal/db/migrations/003_mergeable_state.sql - Migration
  • internal/db/work.go - Work struct and update function
  • internal/db/sqlc/ - Regenerated SQLC code
  • internal/progress/ - Progress types and fetching
  • internal/tui/tui_panel_work_summary.go - TUI display
  • sql/queries/works.sql - Updated SQL queries

🤖 Generated with Claude Code

newhook and others added 7 commits January 27, 2026 09:15
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Returns priority 1 (High) since conflicts block PR merging.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Conflicts are treated as high-priority blockers that prevent merging.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Detects merge conflicts by checking if MergeableState is "DIRTY" (GitHub's
mergeStateStatus value for conflicts). Creates a FeedbackItem with:
- Type: FeedbackTypeConflict
- Priority 1 (High) since conflicts block merging
- Actionable: true

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Tests cover:
- processConflicts returns FeedbackItem when MergeableState is "DIRTY"
- processConflicts returns empty slice for CLEAN, BLOCKED, UNSTABLE, and empty states
- getPriorityForType returns priority 1 for FeedbackTypeConflict

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add mergeable_state column to works table via migration
- Update SQLC queries to include the new column
- Add MergeableState field to db.Work and progress.WorkProgress
- Update feedback processor to extract and store MergeableState from GitHub API
- Add merge status display in TUI PR Status section with color-coded icons:
  - CLEAN: ✓ Ready to merge (green)
  - DIRTY: ⚠ Has conflicts (red)
  - BLOCKED: ⏸ Blocked by checks (yellow)
  - BEHIND: ↓ Behind main (dim)
  - DRAFT: 📝 Draft PR (dim)
  - UNSTABLE: ⚠ CI unstable (yellow)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
newhook and others added 2 commits January 27, 2026 09:29
Replace hardcoded "DIRTY" string with db.MergeableStateDirty constant
in processConflicts for consistency with other mergeable state checks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace string literals with db.MergeableStateClean, db.MergeableStateDirty,
db.MergeableStateBlocked, and db.MergeableStateUnstable constants in
TestProcessConflicts for consistency with the rest of the codebase.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@newhook newhook merged commit c263550 into main Jan 27, 2026
3 checks passed
@newhook newhook deleted the feat/detect-conflicts-in-pr branch January 27, 2026 14:34
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.

2 participants