Skip to content

Make tasks reflect PR state reactively#70

Merged
bborn merged 2 commits intomainfrom
task/136-make-sure-tasks-refelect-pr-state
Jan 9, 2026
Merged

Make tasks reflect PR state reactively#70
bborn merged 2 commits intomainfrom
task/136-make-sure-tasks-refelect-pr-state

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 9, 2026

Summary

This PR implements reactive checking of PR state to automatically close tasks when their PRs are merged. The implementation ensures that tasks are updated immediately when users interact with them, providing a better user experience.

Key Changes

1. Executor Enhancements (internal/executor/executor.go)

  • Added PRCache to Executor struct for caching GitHub PR status
  • New CheckPRStateAndUpdateTask() public method to check PR state on demand
  • Enhanced isBranchMerged() to prioritize GitHub PR status check via gh CLI
  • Added PR cache initialization in both New() and NewWithLogging()

2. UI Integration (internal/ui/app.go)

  • Check PR state when opening task detail view via loadTask()
  • Check PR state when closing task detail view (Back key handler)
  • Check PR state when manually closing a task (Close key handler)
  • Batch check all task PR states when loading dashboard
  • Force fresh PR info fetch when opening task details

3. Automatic Task Closure

  • Tasks are automatically closed when PR is detected as merged
  • Works reactively on:
    • View open/close
    • Dashboard refresh
    • Background check cycle (every 30 seconds)
  • Logs the reason for automatic closure for transparency

Test Plan

  • Build succeeds without errors
  • Code follows existing patterns in the codebase
  • Test with a task that has a merged PR
  • Verify task closes when opening detail view
  • Verify task closes when returning to dashboard
  • Verify dashboard batch check works

Impact

This addresses the issue where tasks with merged PRs would remain in non-done states until the next background check cycle (30 seconds). Now tasks are checked reactively whenever the user views them or navigates the UI.

🤖 Generated with Claude Code

bborn and others added 2 commits January 9, 2026 14:07
This commit implements reactive checking of PR state to automatically
close tasks when their PRs are merged. The changes ensure that tasks
are updated immediately when users interact with them, providing a
better user experience.

Key changes:

1. **Executor enhancements**:
   - Added PRCache to Executor for caching GitHub PR status
   - New CheckPRStateAndUpdateTask() method to check PR state on demand
   - Enhanced isBranchMerged() to prioritize GitHub PR status check
   - Checks PR state via gh CLI before falling back to git branch checks

2. **UI integration**:
   - Check PR state when opening task detail view (loadTask)
   - Check PR state when closing task detail view (Back key)
   - Check PR state when manually closing a task (Close key)
   - Batch check all task PR states when loading dashboard
   - Force fresh PR info fetch when opening task details

3. **Automatic task closure**:
   - Tasks are automatically closed when PR is detected as merged
   - Works reactively on view open/close and dashboard refresh
   - Works periodically via existing background check (every 30s)
   - Logs the reason for automatic closure

This addresses the issue where tasks with merged PRs would remain
in non-done states until the next background check cycle.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Resolved conflicts in executor.go by combining TASK_SESSION_ID support
from main with --chrome flag additions from this branch.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bborn bborn merged commit 8ec408d into main Jan 9, 2026
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.

1 participant