fix(webapp): resolve env name & skip empty panels in usage breakdown#6704
Draft
macko911 wants to merge 2 commits into
Draft
fix(webapp): resolve env name & skip empty panels in usage breakdown#6704macko911 wants to merge 2 commits into
macko911 wants to merge 2 commits into
Conversation
Contributor
Preview Deploy
|
Contributor
There was a problem hiding this comment.
1 issue found across 8 files
Confidence score: 3/5
- In
packages/webapp/src/hooks/usePlan.tsx, the “Apply to all” flow can readtop-dimension-valuescached from a previous environment, so it may clear/apply panel filters using the wrong value set after an environment switch; this risks incorrect filter state for users until refreshed. Update the availability/cache lookup to includeenv(and invalidate old entries) before merging.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/webapp/src/hooks/usePlan.tsx">
<violation number="1" location="packages/webapp/src/hooks/usePlan.tsx:293">
P2: After switching environments, “Apply to all” can reuse `top-dimension-values` cached for the previous environment and clear/apply panel filters from the wrong value set. The new availability lookup should include `env` in the query key used by both `cachedHasValue` and `ensureHasValue` (and the existing top-dimension-values callers) so the cache is scoped to the request.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| async (metric: UsageMetric, dimension: string, value: string): Promise<boolean> => { | ||
| const data = await queryClient.ensureQueryData({ | ||
| staleTime: TOP_DIMENSION_VALUES_STALE_TIME, | ||
| queryKey: topDimensionValuesQueryKey(timeframe, metric, dimension, limit), |
Contributor
There was a problem hiding this comment.
P2: After switching environments, “Apply to all” can reuse top-dimension-values cached for the previous environment and clear/apply panel filters from the wrong value set. The new availability lookup should include env in the query key used by both cachedHasValue and ensureHasValue (and the existing top-dimension-values callers) so the cache is scoped to the request.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/webapp/src/hooks/usePlan.tsx, line 293:
<comment>After switching environments, “Apply to all” can reuse `top-dimension-values` cached for the previous environment and clear/apply panel filters from the wrong value set. The new availability lookup should include `env` in the query key used by both `cachedHasValue` and `ensureHasValue` (and the existing top-dimension-values callers) so the cache is scoped to the request.</comment>
<file context>
@@ -266,6 +266,40 @@ export function useApiGetBillingUsageTopDimensionValues<M extends UsageMetric>(
+ async (metric: UsageMetric, dimension: string, value: string): Promise<boolean> => {
+ const data = await queryClient.ensureQueryData({
+ staleTime: TOP_DIMENSION_VALUES_STALE_TIME,
+ queryKey: topDimensionValuesQueryKey(timeframe, metric, dimension, limit),
+ queryFn: fetchTopDimensionValues(env, metric, dimension, timeframe, limit)
+ });
</file context>
12ce39b to
f91e214
Compare
Base automatically changed from
matej/nan-6038-reach-any-value-when-filtering-usage-not-just-the-top-n
to
master
July 9, 2026 10:18
Applying an environment (or other fully-enumerated) filter to all panels fanned it onto every metric, including those with no data for the value. Those panels rendered the raw env id with a "No data" chart instead of staying unfiltered. Apply to all now only sets an enumerated-dimension filter on panels that actually hold the value and clears it on the rest, so panels without data fall back to their unfiltered chart. The button also dismisses itself once applied instead of persisting against panels that can never match. Open-ended dimensions keep the previous fan-out, since a value being absent from the fetched top-N there does not reliably mean "no data".
The usage chart legend showed the raw environment id (e.g. "105") while the filter chip correctly resolved it to the name (e.g. "dev"). Environment values are stored and returned as ids; only top-dimension-values carries the display name. Resolve env ids to names in the chart layer too, reusing the same top-dimension-values query the chip already warms, for both the filtered single-series and grouped-by-environment cases. The raw id is preserved on the series so a drill-in still builds a valid filter param.
f91e214 to
c4d5437
Compare
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.
Problem
On the billing usage dashboard, "Apply to all" fanned an environment (or other fully-enumerated) filter onto every metric panel, including ones with no data for that value — those rendered the raw env id with a "No data" chart instead of staying unfiltered. Separately, the chart legend showed the raw environment id (e.g.
105) even though the filter chip resolved it to the name (e.g.dev).Solution
top-dimension-valuesquery the filter chip already warms; the raw id is kept on the series for drill-in.Fixes NAN-6168
Testing
isFullyEnumeratedDimensionand thetoChartSerieslabel resolver.