Skip to content

Conversation

@newhook
Copy link
Owner

@newhook newhook commented Feb 1, 2026

Summary

This PR fixes an issue where multiple PR tasks were being created during review-fix loops, leading to duplicate work. Now:

  • Before creating a PR task, the system checks if one already exists for the work
  • If a pending/processing PR task exists, no new task is created
  • If a completed PR task exists (PR was already created), an update-pr-description task is created instead to update the existing PR's description with latest changes
  • Failed PR tasks are excluded from the check, allowing retry

Changes

Core Logic (cmd/orchestrate.go)

  • Enhanced createPRTask() to check for existing PR tasks before creating new ones
  • Added createUpdatePRDescriptionTask() for updating existing PR descriptions after subsequent reviews

Database Layer

  • sql/queries/tasks.sql: Added GetPRTaskForWork query to find PR tasks by work ID
  • internal/db/sqlc/: Regenerated SQLC code
  • internal/db/task.go: Added GetPRTaskForWork() wrapper returning *Task or nil

Tests

  • internal/db/task_test.go: Unit tests for the new database function
    • Tests basic retrieval across pending/processing/completed states
    • Verifies failed PR tasks are not returned
    • Ensures work isolation (PR task from work-1 not returned for work-2)
  • cmd/orchestrate_test.go: Integration tests for PR task creation flow
    • No existing PR task → creates PR task
    • Pending PR task exists → skips creation
    • Processing PR task exists → skips creation
    • Completed PR task exists → creates update-pr-description task
    • Failed PR task → allows new PR task
    • Review-fix loop creates only one PR task
    • Multiple review cycles create multiple update-pr-description tasks

Issues Resolved

  • ✅ ac-8dmv: Preventing duplicate PR tasks
  • ✅ ac-8dmv.1: Add check for existing PR task before creating new one
  • ✅ ac-8dmv.2: Add update_pr task type for updating PR descriptions
  • ✅ ac-8dmv.3: Add unit and integration tests for PR task creation flow

Test Plan

  • All existing tests pass
  • New unit tests for GetPRTaskForWork database function
  • New integration tests covering all PR task creation scenarios
  • Manual testing: Run co work review multiple times on a work with an existing PR

🤖 Generated with Claude Code

newhook and others added 3 commits February 1, 2026 16:41
Add GetPRTaskForWork query to check for existing PR tasks for a work unit.
When createPRTask is called:
- If a pending/processing PR task exists, skip creation
- If a completed PR task exists, create an update-pr-description task instead

This prevents the review-fix loop from creating multiple PR tasks and instead
updates the existing PR description when the PR has already been created.

Closes: ac-8dmv.1, ac-8dmv.2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add comprehensive unit tests for the createPRTask logic:
- Test PR task creation when no existing PR task
- Test skip behavior when pending PR task exists
- Test skip behavior when processing PR task exists
- Test update-pr-description creation when PR task is completed
- Test that failed PR tasks allow new PR creation
- Test review-fix loop creates only one PR task
- Test multiple review cycles create multiple update-pr-description tasks

These tests verify the duplicate PR task prevention logic and the
update-pr-description task type introduced in previous commits.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Display as 'pr-upd' in work overview task list
- Include in PR task count in work summary breakdown

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@newhook newhook merged commit 23bae67 into main Feb 1, 2026
3 checks passed
@newhook newhook deleted the feat/creating-duplicate-pr-tasks branch February 1, 2026 21:52
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