fix: Weekly Fable widget forces every usage widget into an error state#7
Open
BenIsLegit wants to merge 1 commit into
Open
fix: Weekly Fable widget forces every usage widget into an error state#7BenIsLegit wants to merge 1 commit into
BenIsLegit wants to merge 1 commit into
Conversation
The weekly-fable-usage widget registered weeklyFableUsage as a hard fetch requirement, but the usage API only returns a per-model limits entry once that model has been used. For accounts without Fable usage the field is permanently absent, so hasRequiredUsageFields() rejected every fresh and stale cache, converting valid data into a persistent error state across all usage widgets on machines where the API token is unavailable. Two changes: weeklyFableUsage is now an optional field that never gates cache validity or stale-data fallback, and a successful response whose limits array simply lacks a Fable entry is parsed as 0% instead of undefined, so the widget renders 0.0% rather than silently disappearing for light users. Regression tests cover both shapes (no limits key, and limits without a Fable entry).
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.
Adding the Weekly Fable widget breaks every usage widget for anyone who hasn't used Fable.
weeklyFableUsagewas a hard fetch requirement, but the API only returns a Fablelimitsentry once you've actually used Fable. On accounts that haven't, the field is always absent, sohasRequiredUsageFields()rejects every fresh and stale cache and turns good data into an error. Every usage widget then renders that error ([No credentials],[Timeout], whatever fits).Two changes:
weeklyFableUsageno longer gates cache validity or the stale fallback, and a successful response whoselimitsarray just lacks a Fable entry parses as0instead ofundefined, so the widget shows0.0%rather than quietly vanishing for light users.Regression tests cover both shapes (no
limitskey, andlimitspresent without Fable).