Skip to content

bugs-tab - Fix count on repos that use types inconsistently - #10086

Merged
fregante merged 11 commits into
refined-github:mainfrom
erenbati:fix/bugs-tab-exact-count-8579
Sep 22, 2026
Merged

fregante merged 11 commits into
refined-github:mainfrom
erenbati:fix/bugs-tab-exact-count-8579

Conversation

@erenbati

@erenbati erenbati commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #8579

The Bugs tab currently approximates the union of bug-labeled issues and type:Bug issues with Math.max(), which can undercount repositories where the two sets only partially overlap.

This keeps the existing first request on the critical path so the tab can appear as quickly as before.

After the tab is added and the approximate count is shown, an exact search runs asynchronously using the same query as the Bugs tab:

is:issue state:open (label:<bug label> OR type:Bug)

When that request completes, it updates the counter with the exact issueCount. The exact result is cached per repository and bug label.

If the exact request fails, the existing approximate count remains in place, so the extra request does not block or remove the tab.

Test URLs

https://github.com/microsoft/vscode/issues?q=sort%3Aupdated-desc+is%3Aissue+state%3Aopen+%28label%3Abug+OR+type%3ABug%29

At the time of visual verification:

  • label:bug: 6,121
  • type:Bug: 106
  • exact union: 6,136
  • previous approximation: 6,121

All CI checks pass on the revised implementation: Format, Lint, Types, Vitest, Verify, Security, Ubuntu Build, and Windows Build.

Screenshot

screen

@github-actions github-actions Bot added the bug label Sep 14, 2026
@erenbati
erenbati marked this pull request as ready for review September 14, 2026 18:27
Comment thread source/features/bugs-tab.tsx Resolved
Comment thread source/features/bugs-tab.tsx Outdated
return {
// Label might not be found if the repo uses a non-standard bug label name
label: label?.name ?? 'bug',
label: label ? label.name : 'bug',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the one above are unnecessary and should be reverted

Comment thread source/features/bugs-tab.tsx Outdated
Comment on lines +131 to +136
// Exact counting needs the selected bug label, but it should not delay the tab
void exactBugs.get(label)
.then(exactCount => {
counter.set(exactCount);
})
.catch(() => undefined);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved outside the current try/catch, and use await with try/catch instead of then/catch

Comment thread source/features/bugs-tab.tsx Outdated
}

async function countExactBugs(label: string): Promise<number> {
const query = `repo:${getRepo()!.nameWithOwner} is:issue state:open ${getFullSearchQuery(label)}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to create this again here because it's already generated in

const {href} = new SearchQuery(buildRepoUrl('issues'))
.append(getFullSearchQuery(await getBugsLabel()));

You can alter that line to:

	const {href, query} = new SearchQuery(buildRepoUrl('issues'))
		.append(getFullSearchQuery(await getBugsLabel()));

and then pass the full query to countExactBugs

@fregante fregante changed the title Fix exact Bugs tab count across labels and issue types bugs-tab - Fix count on repos that use types inconsistently Sep 18, 2026
@erenbati

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. I addressed all three points:

  • Reverted the two unnecessary changes.
  • Reused the existing SearchQuery query for the exact count.
  • Moved the exact-count request outside the initial try/catch and switched it to await with its own try/catch.

CI is green on the latest revision. Could you take another look when you have a chance?

@fregante fregante left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to go. Thank you!

@fregante
fregante merged commit 1628187 into refined-github:main Sep 22, 2026
14 checks passed
}

const {href} = new SearchQuery(buildRepoUrl('issues'))
const {href, query} = new SearchQuery(buildRepoUrl('issues'))

@fregante fregante Sep 24, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fregante

Copy link
Copy Markdown
Member

It seems to me that this was not tested at all, you just let the error through without verifying that the bug was fixed. The API always returned zero

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

bugs-tab undercounts bugs if repo uses labels and types inconsistently

2 participants