Skip to content

feat(#137): improve state cleanup to detect merged PRs and auto-remove - #141

Merged
admarble merged 2 commits into
mainfrom
feature/137-improve-state-cleanup-to-detect-merged-prs-and-aut
Jan 20, 2026
Merged

admarble merged 2 commits into
mainfrom
feature/137-improve-state-cleanup-to-detect-merged-prs-and-aut

Conversation

@admarble

Copy link
Copy Markdown
Contributor

Summary

  • Add checkPRMergeStatus() helper to check PR merge status via gh CLI
  • Enhance cleanupStaleEntries() to detect merged PRs and auto-remove them
  • Orphaned entries with merged PRs are automatically removed (status = "merged")
  • Orphaned entries without merged PRs are marked as "abandoned" (kept for review)
  • Add --all flag to remove both merged and abandoned entries in one step
  • Add comprehensive unit tests for PR merge detection and cleanup behavior

Test Plan

  • All existing tests pass (456 tests)
  • New unit tests for checkPRMergeStatus() function
  • New unit tests for merged PR detection in cleanupStaleEntries()
  • New unit tests for --removeAll flag behavior
  • Build succeeds with no TypeScript errors

Acceptance Criteria Coverage

  • AC-1: --cleanup checks gh pr view <N> --json state for each orphaned entry with PR info
  • AC-2: Orphaned entries with merged PRs get status merged and are removed automatically
  • AC-3: Orphaned entries without merged PRs get status abandoned (kept for review)
  • AC-4: --max-age still works for removing old abandoned entries
  • AC-5: Add --all flag to remove both merged and abandoned orphaned entries in one step

Closes #137

🤖 Generated with Claude Code

- Add checkPRMergeStatus() helper to check PR merge status via gh CLI
- Enhance cleanupStaleEntries() to detect merged PRs and auto-remove them
- Orphaned entries with merged PRs are automatically removed
- Orphaned entries without merged PRs are marked as "abandoned"
- Add --all flag to remove both merged and abandoned entries in one step
- Add unit tests for PR merge detection and cleanup behavior

Closes #137

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Remove unused type imports that were causing lint warnings:
- WorkflowState, RunLog from state-utils.ts
- DiscoverResult from state.ts
- StateManagerOptions from run.ts (pre-existing)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@admarble
admarble merged commit 1ffafc9 into main Jan 20, 2026
@admarble
admarble deleted the feature/137-improve-state-cleanup-to-detect-merged-prs-and-aut branch January 20, 2026 22:19
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.

Improve state cleanup to detect merged PRs and auto-remove

1 participant