Fix 0/0 hover for ubb#314651
Merged
Merged
Conversation
Contributor
Screenshot ChangesBase: Changed (9) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses an incorrect quota hover display in the Chat Status dashboard where usage-based billing (UBB) quotas with entitlement: 0 could show a misleading 0 / 0 “credits used” fraction on hover.
Changes:
- Adds a regression test ensuring hover does not change the displayed quota value when
entitlementis zero. - Adjusts the dashboard hover behavior to avoid showing credit fractions when
entitlementis falsy.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/chatStatusDashboard.test.ts | Adds a new test for the entitlement: 0 hover scenario to prevent 0 / 0 display regressions. |
| src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.ts | Changes hover/focus “show credits” logic to skip credit fraction rendering when entitlement is falsy. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/browser/chatStatus/chatStatusDashboard.ts:716
showCredits()now checkscurrentQuota.entitlementfor truthiness. This makes the hover/focus display logic dependent on JS truthiness and means that whenentitlementis0orundefined,showCredits()becomes a no-op. Becauseupdate()callsshowCredits()wheneverisHoveredis true, quota updates that arrive while the element is hovered/focused will not refresh the displayed percentage/label. Consider using an explicit numeric check (e.g.typeof entitlement === 'number' && entitlement > 0) and falling back toshowPercentage()when credits can't be shown so the UI still updates while hovered/focused.
const showCredits = () => {
if (typeof currentQuota !== 'string' && currentQuota.entitlement) {
const total = currentQuota.entitlement;
const used = total * (100 - currentQuota.percentRemaining) / 100;
const usedFormatted = this.quotaCreditsFormatter.value.format(used);
const totalFormatted = this.quotaCreditsFormatter.value.format(total);
quotaValue.textContent = localize('quotaCreditsDisplay', "{0} / {1}", usedFormatted, totalFormatted);
quotaValueSuffix.textContent = ` ${localize('quotaUsed', "used")}`;
}
};
- Files reviewed: 2/2 changed files
- Comments generated: 1
DonJayamanne
previously approved these changes
May 6, 2026
chrmarti
approved these changes
May 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 #314558