You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve state cleanup to detect merged PRs and auto-remove #137
The current sequant status --cleanup behavior requires two steps to fully remove orphaned entries and doesn't distinguish between merged vs abandoned work.
Current Behavior
sequant status --cleanup marks orphaned entries (missing worktree) as abandoned
sequant status --cleanup --max-age 0 is required to actually remove them
All orphaned entries get abandoned status, even if the PR was successfully merged
Proposed Behavior
--cleanup checks GitHub to detect if the associated PR was merged
Sets status to merged (not abandoned) for successfully merged PRs
Auto-removes orphaned entries with merged status immediately
Reserves abandoned status for truly abandoned work (issue closed without merge, PR closed without merge)
Acceptance Criteria
--cleanup checks gh pr list --state merged --search "<issue-number>" for each orphaned entry
Orphaned entries with merged PRs get status merged and are removed automatically
Orphaned entries without merged PRs get status abandoned (kept for review)
--max-age still works for removing old abandoned entries
Add --cleanup --all or similar to remove both merged and abandoned in one step
Technical Notes
cleanupStaleEntries() in src/lib/workflow/state-utils.ts
May need to batch GitHub API calls to avoid rate limiting for many issues
Consider caching merge status to avoid repeated API calls
Activity
admarble commentedon Jan 20, 2026
📋 Implementation Plan
Acceptance Criteria Checklist
--cleanupchecksgh pr view <N> --json statefor each orphaned entry with PR infomergedand are removed automaticallyabandoned(kept for review)--max-agestill works for removing oldabandonedentries--allflag to remove both merged and abandoned orphaned entries in one stepVerification Methods
gh pr viewreturning "MERGED" state--cleanup --allremoves all orphaned entriesImplementation Phases
Phase 1: PR merge detection (
state-utils.ts)checkPRMergeStatus(prNumber)helper usinggh pr viewPhase 2: Enhance cleanup logic (
state-utils.ts:254-281)removeAlloption to remove abandoned entries tooPhase 3: CLI interface (
state.ts,status.ts,cli.ts)--allflag tosequant state clean--allflag tosequant status --cleanupPhase 4: Tests (
state-utils.test.ts)Assumptions to Validate
state.issues[N].pr)gh auth statusshould be checked before API callsOpen Questions
gh pr list --state mergedfirst--allscope: Only affects orphaned entries, not active worktreesEffort Breakdown
📝 Generated by
/specworkflowfeat(#137): improve state cleanup to detect merged PRs and auto-remove
admarble commentedon Jan 20, 2026
Implementation Complete ✅
AC Coverage Summary
checkPRMergeStatus()helper checksgh pr view <N> --json statefor each orphaned entry with PR infomergedand are removed automaticallyabandoned(kept for review)--max-agestill works for removing oldabandonedentries--allflag to remove both merged and abandoned orphaned entries in one stepKey Files Changed
src/lib/workflow/state-utils.ts- AddedcheckPRMergeStatus()helper and enhancedcleanupStaleEntries()src/commands/status.ts- Added--allflag support tohandleCleanup()src/commands/state.ts- Added--allflag support tostateCleanCommand()bin/cli.ts- Added--alloption to status commandsrc/lib/workflow/state-utils.test.ts- Added comprehensive unit testsTest Results
PR Status
🤖 Generated by
/execworkflowadmarble commentedon Jan 20, 2026
QA Review Complete ✅
AC Coverage: 5/5 MET
--cleanupchecksgh pr view <N> --json statefor each orphaned entry with PR infomergedand are removed automaticallyabandoned(kept for review)--max-agestill works for removing oldabandonedentries--allflag to remove both merged and abandoned orphaned entries in one stepQuality Metrics
Code Review Summary
Strengths:
checkPRMergeStatus()helper with proper typingVerdict: READY_FOR_MERGE 🎉
All AC items fully met with high code quality. Only suggestion is to add a CHANGELOG entry for the new
--allflag and PR merge detection behavior.🤖 Generated by
/qaworkflowadmarble commentedon Jan 20, 2026
QA Review Complete
AC Coverage: 5/5 MET ✅
--cleanupchecksgh pr view <N> --json statefor each orphaned entry with PR infomergedand are removed automaticallyabandoned(kept for review)--max-agestill works for removing oldabandonedentries--allflag to remove both merged and abandoned orphaned entries in one stepQuality Metrics
Verdict: AC_MET_BUT_NOT_A_PLUS
All acceptance criteria fully implemented with comprehensive tests. However, CI is failing due to lint warnings (unused imports):
state-utils.ts:21-WorkflowStateunusedstate-utils.ts:28-RunLogunusedstate.ts:17-DiscoverResultunusedNext Steps
--allflag and PR merge detection🤖 Generated by
/qaworkflowadmarble commentedon Jan 20, 2026
QA Review: READY_FOR_MERGE ✅
AC Coverage: 5/5 MET
--cleanupchecksgh pr view <N> --json stateabandoned--max-agestill works--allflag implementedQuality Metrics
Verdict: READY_FOR_MERGE 🎉
All acceptance criteria fully met with high code quality. Lint issues fixed, CI passing.
Suggested: Add CHANGELOG entry for
--allflag before merging.🤖 Generated by
/qaworkflowdocs(#137): add CHANGELOG entry for smart cleanup with PR merge detec…
docs(#137): update state-command.md with PR merge detection and --all…