Add gh run watch integration for immediate CI notification#260
Merged
Conversation
Implement WatchWorkflowRun task type that uses `gh run watch` to block until a workflow run completes, then immediately triggers a PRFeedback task. This replaces polling for in-progress workflow runs. Changes: - Add TaskTypeWatchWorkflowRun to scheduler task types - Create handler_watch_run.go with HandleWatchWorkflowRunTask handler - Add ScheduleWatchWorkflowRun helper with idempotency key for dedup - Modify handler_pr_feedback.go to spawn watchers for in-progress runs - Register WatchWorkflowRun handler in ControlPlane.GetTaskHandlers - Add comprehensive tests for the new handler The flow: PRFeedback detects in-progress runs → schedules WatchWorkflowRun tasks → watchers block on `gh run watch` → completion triggers PRFeedback immediately. Uses run_id as idempotency key to prevent duplicate watchers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
newhook
commented
Jan 31, 2026
newhook
commented
Jan 31, 2026
- Export ParsePRURL and add ExtractRepoFromPRURL helper function - Add WatchWorkflowRun method to ClientInterface and Client - Add GitHubClient field to ControlPlane for dependency injection - Update handler_pr_feedback.go to use github.ExtractRepoFromPRURL - Update handler_watch_run.go to use cp.GitHubClient.WatchWorkflowRun This consolidates GitHub API operations in the github package for better testability and consistency. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Changed spawnWorkflowWatchers from standalone function to ControlPlane method - Use cp.GitHubClient.GetPRStatus() instead of creating new github.NewClient() - Updated test to provide mock for GetPRStatus This fixes the dependency injection pattern, making the code testable and consistent with other ControlPlane methods. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces polling-based CI status checking with
gh run watchfor immediate notification when workflow runs complete. This reduces CI feedback latency from the poll interval (default 10 minutes) to immediate notification.Before: Poll every 10 minutes, check if runs complete, fetch results
After: Watch runs directly with
gh run watch, fetch results exactly once when doneChanges
New Components
internal/db/scheduler.go): New scheduled task type for watching workflow runsinternal/control/): Handler that:gh run watch <run-id> --exit-statuswhich blocks until completionwatch_run_<id>) to prevent duplicate watchersModified Components
Documentation & Tooling
How It Works
Issues Resolved
Testing
handler_watch_run_test.go:All tests passing:
Notes
gh run watchreplaces polling only for CI/workflow runs. Periodic polling is still needed for:🤖 Generated with Claude Code