fix(menubar): explicit observation dependency for the budget flame#507
Merged
Conversation
… crossings The menubar refresh observation block read displayMetric and the two budget values, but not the derived isOverDailyBudget (which also depends on todayPayload). It worked only because payload/menubarPayload happened to touch the same cache storage. Read isOverDailyBudget explicitly so the flame re-tints when today's usage crosses the budget, and so the dependency survives any future cache refactor.
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.
Follow-up hardening from an independent multi-agent validation of #505/#506.
What
The menubar
withObservationTrackingblock readdisplayMetric,dailyBudget, anddailyTokenBudget, but not the derivedisOverDailyBudget(which also depends ontodayPayload). Today it still works becausepayload/menubarPayloadregister a dependency on the same underlyingcachestorage, so a today-usage write fires the re-tint. But that is incidental: if the cache is ever refactored ortodayPayloadmemoized separately, the flame would silently stop updating on budget crossings.This reads
isOverDailyBudgetin the tracking block, making the dependency explicit and intent-proof.Validation context
Three independent validators reviewed #505/#506: build clean, quota-over-budget tint precedence preserved, no leftover cost-only comparisons, token units consistent, sentinel/parsing/persistence correct, no SwiftUI focus-loss or feedback loop, no metric-switch desync. This was the one low-risk robustness gap they converged on. Remaining items they noted are pre-existing or minor UX (see PR discussion).
Verification
swift buildpasses.