From 09728d97cc772cb63b58aab53ae19aff9c531ccb Mon Sep 17 00:00:00 2001 From: Dustin Hilgaertner Date: Sun, 5 Apr 2026 15:09:37 -0500 Subject: [PATCH] Fix session not completing when linked issue is closed (#77) The `autoCompleteFinishedSessions` method received all issues including recently-closed "done" issues, so closed issue URLs were in the "open" set and the check was skipped. Filter to only truly-open issues before passing them in. Also expand candidate sessions to include paused and inReview statuses so closing an issue completes the session regardless of its current non-completed state. Co-Authored-By: Claude Opus 4.6 (1M context) --- Sources/Crow/App/IssueTracker.swift | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sources/Crow/App/IssueTracker.swift b/Sources/Crow/App/IssueTracker.swift index a9972ca..5fe121e 100644 --- a/Sources/Crow/App/IssueTracker.swift +++ b/Sources/Crow/App/IssueTracker.swift @@ -93,7 +93,7 @@ final class IssueTracker { syncInReviewSessions(issues: allIssues) // Auto-complete sessions whose linked issue/PR is no longer open - await autoCompleteFinishedSessions(openIssues: allIssues) + await autoCompleteFinishedSessions(openIssues: allIssues.filter { $0.state == "open" }) } // MARK: - GitHub @@ -403,7 +403,11 @@ final class IssueTracker { private func autoCompleteFinishedSessions(openIssues: [AssignedIssue]) async { let openIssueURLs = Set(openIssues.map(\.url)) - for session in appState.activeSessions { + let candidateSessions = appState.sessions.filter { + $0.id != AppState.managerSessionID && + ($0.status == .active || $0.status == .paused || $0.status == .inReview) + } + for session in candidateSessions { guard let ticketURL = session.ticketURL else { continue } // If the issue is still in the open list, it's not finished