Coding Agent UI: Closed pull requests are not detected as closed#8485
Merged
Coding Agent UI: Closed pull requests are not detected as closed#8485
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #8482 where closed pull requests are incorrectly shown as open in the Coding Agent UI. The root cause is that GitHub's search API can return stale results that don't match the requested state qualifier. The fix adds a post-filtering step to ensure only PRs with the correct state are displayed.
Changes:
- Added
getStateFromQuery()utility function to parse state qualifiers from GitHub search queries - Post-filter PR search results to exclude PRs whose state doesn't match the query
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/github/utils.ts | Added getStateFromQuery() function to extract state qualifier (open/closed/merged) from search queries using regex pattern matching |
| src/github/folderRepositoryManager.ts | Added post-filtering logic in getPullRequestsForCategory() to filter PRs based on the state extracted from the query |
Comments suppressed due to low confidence (1)
src/github/utils.ts:1668
- The new getStateFromQuery function lacks test coverage. Given that the codebase has tests for other utility functions in src/test/github/utils.test.ts (e.g., getPRFetchQuery and sanitizeIssueTitle), tests should be added for this new function. Consider adding test cases for:
- Queries with is:open, is:closed, and is:merged
- Queries without a state qualifier
- Queries with state qualifiers in different positions (start, middle, end)
- Case insensitivity (IS:OPEN, Is:Closed, etc.)
- Queries with multiple state qualifiers (should match the first one)
- Edge cases like "is:opened" or "is:merge" (should return undefined)
export function getStateFromQuery(query: string): GithubItemStateEnum | undefined {
const match = query.match(/(?:^|\s)is:(?<state>open|closed|merged)(?:\s|$)/i);
if (!match?.groups?.state) {
return undefined;
}
switch (match.groups.state.toLowerCase()) {
case 'open':
return GithubItemStateEnum.Open;
case 'closed':
return GithubItemStateEnum.Closed;
case 'merged':
return GithubItemStateEnum.Merged;
default:
return undefined;
}
}
chrmarti
approved these changes
Feb 6, 2026
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.
Fixes #8482