Skip to content

feat: auto refresh dashboard#37459

Open
richardfogaca wants to merge 57 commits intoapache:masterfrom
richardfogaca:feat/auto-refresh-dashboard
Open

feat: auto refresh dashboard#37459
richardfogaca wants to merge 57 commits intoapache:masterfrom
richardfogaca:feat/auto-refresh-dashboard

Conversation

@richardfogaca
Copy link
Contributor

@richardfogaca richardfogaca commented Jan 27, 2026

Summary

Implements real-time dashboard auto-refresh with visual status feedback, pause controls, and flicker-free updates.

Key Features

  1. Auto-Refresh Status Indicator
  • Colored dot in the dashboard header shows current refresh state:
    • 🟢 Green: Refreshed successfully on schedule
    • 🔵 Blue: Fetching data or waiting for first refresh
    • 🟡 Yellow: Delayed or 1 consecutive error
    • 🔴 Red: 2+ consecutive errors
    • ⚪ White: Paused (manually or by tab visibility)
  • Tooltip on hover shows last refresh time, configured interval, and error counts
  1. Pause/Resume Controls
  • Play/pause button next to the status indicator
  • Immediate refresh when resuming before timer restarts
  • Pause state is independent of tab visibility pause
  1. Tab Visibility Auto-Pause (Opt-in)
  • Automatically pauses auto-refresh when browser tab becomes inactive
  • Immediately fetches data when user returns, then restarts timer
  • Respects manual pause state - won't auto-resume if manually paused
  1. Flicker Prevention
  • Loading spinner suppression: Charts maintain previous data during refresh
  • FiltersBadge preservation: Filter indicators remain visible during refresh
  • Stable series ordering: Secondary sort prevents legend reordering in ECharts
  • Tree chart animation control: Disabled animations during refresh
  • Status dot debouncing: Smooth color transitions

Before/After

Before: Auto-refresh showed toast notifications on each cycle, charts flickered with loading spinners, no status indicator, no pause control.

After:

  • Clean status indicator dot with informative tooltip
  • Pause/play controls for manual control
  • Smooth refresh without flickering or loading spinners
  • Optional tab visibility pause with immediate refresh on return
Screenshot 2026-01-26 at 20 56 03 Screenshot 2026-01-26 at 20 56 18 Screenshot 2026-01-26 at 21 18 30

Testing Instructions

Basic Auto-Refresh Status:

  1. Open a dashboard and set an auto-refresh interval (e.g., 10 seconds)
  2. Observe the status indicator dot appears next to the refresh controls
  3. Watch the dot turn blue during fetch, then green on success
  4. Hover over the indicator to see tooltip with last refresh time and interval

Pause/Resume:

  1. With auto-refresh enabled, click the pause button
  2. Observe the dot turns white (paused state)
  3. Click play to resume - charts should refresh immediately
  4. Verify the timer restarts after resuming

Tab Visibility Pause:

  1. Enable the "Pause on inactive tab" option in refresh settings
  2. Switch to another browser tab for longer than the refresh interval
  3. Return to the dashboard tab
  4. Verify data refreshes immediately and timer restarts

Flickering Prevention:

  1. Set a short refresh interval (e.g., 10 seconds)
  2. Observe that charts don't show loading spinners during auto-refresh
  3. Verify filter badges remain visible during refresh
  4. Check that chart legends don't flicker or reorder

Error Handling:

  1. Simulate network issues or chart errors
  2. Verify the status dot turns yellow on first error, red on 2+ errors
  3. Verify tooltip shows error information and count

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Comprehensive exploratory analysis for implementing near real-time
dashboard auto-refresh optimizations with 5-second intervals.

Includes:
- Current implementation analysis of auto-refresh, spinners, filters
- 10 detailed implementation tasks with file locations
- Recommended implementation order (4 phases)
- Open design questions and risks
…eature

Add 10 detailed implementation plan documents covering:
- Task 1: State management for auto-refresh status tracking
- Task 2: Auto-refresh status indicator component
- Task 3: Pause/resume controls
- Task 4: Tab visibility auto-pause
- Task 5: Spinner suppression during auto-refresh
- Task 6: FiltersBadge flickering fix
- Task 7: Toast notification suppression
- Task 8: Chart animation reduction
- Task 9: 5-second refresh interval option
- Task 10: Comprehensive testing & integration

These plans detail the codebase exploration, file modifications needed,
code examples, and testing strategies for implementing optimized
auto-refresh behavior for near real-time analytics dashboards.
- Add GAP_ANALYSIS.md documenting gaps between requirements and plans
- Fix Task 1: Add autoRefreshFetchStartTime for delay detection
- Fix Task 2: Change paused state to WHITE, add checkmark for success
- Fix Task 3: Add manual refresh icon behavior section
Update GAP_ANALYSIS.md to reflect that all 4 critical gaps have been
addressed in Tasks 1, 2, and 3:
- Paused state WHITE color (Task 2)
- Checkmark icon for success state (Task 2)
- Delayed state detection logic (Task 1)
- Manual refresh icon behavior (Task 3)
Second pass review of requirements identified and fixed additional gaps:

Task 1 fixes:
- Add SET_AUTO_REFRESH_FETCH_START_TIME action, creator, and reducer handler

Task 2 fixes:
- Update delayed tooltip to show fetch elapsed time per requirements
- Update error tooltip to show BOTH timestamp AND error message
- Add autoRefreshFetchStartTime to StatusTooltipContentProps

Task 3 fixes:
- Clarify pause button is REQUIRED in header (not optional)

Task 10 fixes:
- Fix paused state test to expect WHITE color (not yellow)
- Add E2E test for non-real-time dashboard (no status indicator)

Gap Analysis updated to mark all second-pass items as resolved.
Design decisions from the design team:

Question apache#4: Tab inactive status indicator
- Answer: YES - Always show white/paused state when tab inactive

Question apache#5: Error thresholds
- Answer: YES - Confirmed:
  - Delayed (Yellow): 1-2 errors OR fetch > 50% interval
  - Error (Red): 3+ consecutive errors

Question apache#6: Auto-pause configurability
- Answer: Configurable via checkbox in RefreshIntervalModal
  - Label: "Pause auto refresh if tab is inactive"
  - Default: OFF

Question apache#7: Session persistence
- Answer: YES - Manual refresh preserves auto-refresh settings

Implementation updates:
- Task 1: Add autoRefreshPauseOnInactiveTab state, action, selector
- Task 4: Update hook to respect new setting (default OFF)
- Task 9: Add checkbox to RefreshIntervalModal
- GAP_ANALYSIS: Document all design decisions
Per designer screenshot review:
- Update Task 2 tooltip to show two-line format:
  - Line 1: "Dashboard updated X ago"
  - Line 2: "Auto refresh set to X seconds"
  - Line 3 (optional): Error/delay details
- Add design verification section to GAP_ANALYSIS.md
  - Question pending: Green dot checkmark still needed?
  - Question pending: Checkbox placement in modal
Implements core auto-refresh infrastructure for real-time dashboards:

State Management (Task 1):
- Add AutoRefreshStatus enum and AutoRefreshState interface
- Create Redux actions for status, pause, success/error tracking
- Update dashboardState reducer with auto-refresh handlers
- Add useRealTimeDashboard hook with computed selectors

Status Indicator (Task 2):
- Create StatusIndicatorDot with color-coded status display
- Add StatusTooltipContent with two-line format per design
- Implement debouncing to prevent status flicker
- Support states: success, fetching, delayed, error, paused

Pause/Resume Controls (Task 3):
- Create AutoRefreshControls component for pause/resume
- Integrate with Header component
- Track fetch status in startPeriodicRender

UI Enhancements (Task 9):
- Add 5-second refresh option
- Add "Pause on inactive tab" checkbox
- Update minimum refresh interval to 5 seconds
- Fix import name: setPauseOnInactiveTab -> setAutoRefreshPauseOnInactiveTab
- Add auto-refresh state fields to DashboardState type
- Remove unused imports (AutoRefreshStatus, waitFor) from test files
- Prefix unused ariaLabel parameter with underscore
- Apply Prettier formatting fixes
Task 4: Automatically pause auto-refresh when browser tab is inactive.

New hooks:
- useTabVisibility: Generic hook to track Page Visibility API state
- useAutoRefreshTabPause: Integrates tab visibility with auto-refresh

Features:
- Stops refresh timer when tab becomes hidden (if setting enabled)
- Resumes and immediately refreshes when tab becomes visible
- Respects manual pause state - won't auto-resume if manually paused
- Shows "(tab inactive)" in tooltip when paused due to tab visibility
- Controlled by "Pause on inactive tab" checkbox in RefreshIntervalModal

Integration:
- Add isPausedByTab selector to useRealTimeDashboard hook
- Update Header to use useAutoRefreshTabPause hook
- Update StatusTooltipContent to show tab-paused message

TDD approach with comprehensive test coverage for both hooks.
Task 5: Hide chart loading spinners during auto-refresh cycles while
keeping them for initial load and manual refresh.

New components:
- AutoRefreshContext: Tracks whether an auto-refresh is in progress
- AutoRefreshProvider: Context provider for dashboard page
- useAutoRefreshContext/useIsAutoRefreshing hooks: Access context

Integration:
- Wrap DashboardPage with AutoRefreshProvider
- Header uses startAutoRefresh/endAutoRefresh around periodic refresh
- ChartHolder passes suppressLoadingSpinner to Chart
- Chart.tsx accepts and uses suppressLoadingSpinner prop

Behavior:
- During auto-refresh: Charts show previous data (no spinner flicker)
- During manual refresh: Normal spinner behavior
- During initial load: Normal spinner behavior

TDD approach with test coverage for the context.
Task 6: Preserve filter indicators during auto-refresh cycles to prevent
the FiltersBadge from flickering as charts go into loading state.

Uses the AutoRefreshContext from Task 5 to detect when auto-refresh is
active and skip clearing indicators during the loading phase.

Also renames useAutoRefreshTabPause.test.ts to .tsx for proper JSX support.
Task 7: Remove the warning toast that appeared during every auto-refresh
cycle. The status indicator (Task 2) now provides continuous, non-intrusive
visual feedback about auto-refresh state, making toasts redundant and
distracting at high refresh frequencies.

Also removes unused extendedDayjs import that was only used for toast
message formatting.
Task 8: Add isRefreshing prop to EchartsProps and update Echart component
to disable animations when this prop is true. This reduces visual noise
during auto-refresh cycles.

The infrastructure is in place for animation control. Many ECharts charts
already have animations disabled (Pie, Radar, Gantt, Sankey), and this
provides the foundation for further optimization.
Task 9: Add 5-second auto-refresh interval to support real-time dashboard
use cases. Includes:
- Backend config update with 5-second option and documentation
- Enhanced warning message for low refresh intervals (5-10 seconds)
  to alert users about potential server performance impact
@github-actions github-actions bot removed dependencies:npm github_actions Pull requests that update GitHub Actions code labels Feb 9, 2026
@richardfogaca richardfogaca force-pushed the feat/auto-refresh-dashboard branch 4 times, most recently from bce8743 to 1ce5e7f Compare February 10, 2026 00:08
@richardfogaca richardfogaca force-pushed the feat/auto-refresh-dashboard branch from 1ce5e7f to a6963bf Compare February 10, 2026 00:16
@msyavuz
Copy link
Member

msyavuz commented Feb 10, 2026

@richardfogaca Can't you use the new async task framework to track these dashboard refreshes?

The connection would be:

  • Dashboard refresh operations could be tracked as async tasks in the GTF
  • Users could monitor refresh status, progress, and errors in the unified task list UI
  • Failed refreshes could be retried/cancelled through the task management interface
  • The GTF's deduplication would prevent redundant refresh requests

@msyavuz
Copy link
Member

msyavuz commented Feb 10, 2026

Or do you think a new implementation using GTF would be overkill for this?

@richardfogaca
Copy link
Contributor Author

richardfogaca commented Feb 10, 2026

Thanks for the detailed review, @msyavuz!

You raise a good point about GTF—it's definitely powerful for server-side task orchestration. However, auto-refresh here is a client-side feature: we're just re-querying existing dashboards on a timer. GTF's overhead (task scheduling, coordination, state management) is optimized for complex dependencies and workflows, not for repetitive client-initiated queries. That's why we kept it simple with native browser intervals.

That said, your suggestions on code quality are spot-on—I'll tidy up the sort ordering and extract that repeated buildQuery pattern into a helper. Thanks for the thorough review! 🙏

@richardfogaca richardfogaca marked this pull request as draft February 11, 2026 01:28
@richardfogaca richardfogaca marked this pull request as ready for review February 11, 2026 01:28
@dosubot dosubot bot added the dashboard:performance Related to Dashboard performance label Feb 11, 2026
@richardfogaca richardfogaca force-pushed the feat/auto-refresh-dashboard branch from 0b5b487 to 75607d6 Compare February 11, 2026 01:30
- Reset 6 pure-noise files to master
- Cleaned 18 mixed files to retain only auto-refresh changes
- Reverted DashboardInfo reorganization and type widening noise
- Fixed legend crash when echarts merges undefined selected state
  (default legendState to {} to prevent hasOwnProperty on undefined)
@github-actions github-actions bot removed the doc Namespace | Anything related to documentation label Feb 12, 2026
richardfogaca and others added 2 commits February 12, 2026 12:27
…ashboard

# Conflicts:
#	superset-frontend/src/dashboard/components/FiltersBadge/FiltersBadge.test.tsx
The DashboardInfo type improvements (TagType[], Role[]) were mistakenly
reverted as noise but are required by the Header's save logic. Also
updates legend test expectations for the legendState ?? {} fix and
applies prettier formatting to FiltersBadge.test.tsx.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard:performance Related to Dashboard performance dashboard:refresh Related to the refresh frequency of the Dashboard dashboard Namespace | Anything related to the Dashboard packages plugins size/XXL testenv-up 🎪 ⌛ 48h Environment expires after 48 hours (default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants