← Back to Pull requests

fix: refetch SQL query "All" options on every dashboard refresh #3862

Open
unknown opened this pull request with 389 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 30, 2026 10:33 UTC
Author

Summary

A SQL query filter set to "All" now refetches its options on every dashboard refresh, so new values reach tiles. Stacked on #3861, which added "All" for SQL query filters.

  • Before, an options query that doesn't use the time range kept its cache key across refreshes, and the five-minute staleTime never triggers a fetch on its own. "All" kept the options from the first load, so new services or regions stayed out of tiles until the page reloaded.

  • The refresh button, auto-refresh in live mode and time range changes all move the time range, so the page-level expansion now refetches the options of every SQL query filter with "All" selected when the range changes. This also covers kiosk mode.

  • useSqlQueryFilterValues takes a refreshKey: when it changes, every query refetches, and a request already in flight is reused. The dropdown and the page share one cache entry, so each refresh issues one options request per filter, not two, including for queries whose key changes with the range anyway.

  • Dropdowns of filters not set to "All" keep their cached options as before.
  • How to test

    Use the test dashboard from #3861, and:

    1. Click "Edit filters", then "Add filter", and choose "SQL query values". Name it Minute, pick the connection, enter SELECT toString(toStartOfMinute(now())), set the variable name to minute, tick "Include "All" option" and save.
    2. Add a Markdown tile with the text Minute: $minute. Pick "All" in the Minute dropdown. The tile shows the current minute.
    3. Wait for the next minute and click the refresh button. The tile shows the new minute.

    References

  • Linear Issue: Closes HDX-6191

  • Related PRs: #3830, #3847, #3861
  • <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    Dashboard filter caching/refresh behavior only; no auth, security, or data-write paths. Risk is mainly extra ClickHouse options queries on refresh.

    > Overview

    SQL query dashboard filters with "All" selected now refetch their options on every dashboard refresh (time range change), even when the options SQL ignores $__timeFilter, so tiles pick up newly appearing values instead of staying on the first load until a full page reload.

    > useSqlQueryFilterValues gains an optional refreshKey: when it changes, all options queries are refetched via refetch({ cancelRefetch: false }), including queries whose react-query key is unchanged. useExpandedSqlQueryVariables passes a key derived from the start/end timestamps of the dashboard date range (equal range by value does not refetch). Filter bar and tile expansion share the same query cache, so each refresh still issues one request per filter, not duplicate fetches.

    > New integration tests cover refresh with time-agnostic SQL, time-filtered SQL, unchanged range, and dependent-variable changes.

    > <sup>Reviewed by Cursor Bugbot for commit 2b909780be03e961c8a28d490670bcde206ee60a. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    Diff: 389 lines (+291 / -98) across 4 files Reviewer: pulpdrew Review duration: 5226m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 389 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.357
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #3862"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.1% (MEDIUM) · Higher = larger blast radius
    43.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.0% · Safe to merge
    23.0%