Skip to content

feat: add auto-refresh toggle for dashboard metrics#301

Open
A69SHUBHAM wants to merge 1 commit into
volcano-sh:mainfrom
A69SHUBHAM:dashboard-auto-refresh-toggle
Open

feat: add auto-refresh toggle for dashboard metrics#301
A69SHUBHAM wants to merge 1 commit into
volcano-sh:mainfrom
A69SHUBHAM:dashboard-auto-refresh-toggle

Conversation

@A69SHUBHAM

Copy link
Copy Markdown

Summary

This PR adds an auto-refresh toggle for dashboard metrics.

Users can now enable or disable automatic refreshing of dashboard data without manually reloading the page.

Changes

  • Added an auto-refresh toggle to the dashboard.
  • Integrated periodic data refresh using existing query mechanisms.
  • Preserved existing behavior when auto-refresh is disabled.
  • Reused existing UI components and project conventions.

Verification

  • Verified dashboard loads successfully.
  • Verified metrics refresh automatically when enabled.
  • Verified metrics stop refreshing when disabled.
  • Verified TypeScript validation passes.
  • Verified production build succeeds.

Motivation

This improves the observability experience by allowing users to monitor dashboard metrics in near real-time while maintaining control over refresh behavior.

Closes #300

Signed-off-by: A69SHUBHAM <spacekrai0@gmail.com>
@volcano-sh-bot volcano-sh-bot requested review from Monokaix and de6p June 13, 2026 07:16
@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign monokaix for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an auto-refresh feature to the dashboard, allowing users to toggle automatic data refetching every 30 seconds for the summary, job status, and queue metrics. The feedback suggests a user experience improvement: instead of spinning the refresh icon continuously when auto-refresh is enabled, the icon should only animate when a background fetch is actively in progress. This can be achieved by extracting and combining the isFetching state from the tRPC queries.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +77 to 90
const { data: summary, isLoading: summaryLoading } =
trpc.dashboardRouter.getSummary.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const { data: jobStatusMetrics, isLoading: jobStatusLoading } =
trpc.dashboardRouter.getJobStatusMetrics.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const { data: queueMetrics, isLoading: queueMetricsLoading } =
trpc.dashboardRouter.getQueueMetrics.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});

const isLoading = summaryLoading || jobStatusLoading || queueMetricsLoading;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve the user experience, we should only animate the refresh icon when a background fetch is actively in progress, rather than spinning continuously while auto-refresh is enabled. To do this, we can extract the isFetching state from each of the tRPC queries and combine them.

Suggested change
const { data: summary, isLoading: summaryLoading } =
trpc.dashboardRouter.getSummary.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const { data: jobStatusMetrics, isLoading: jobStatusLoading } =
trpc.dashboardRouter.getJobStatusMetrics.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const { data: queueMetrics, isLoading: queueMetricsLoading } =
trpc.dashboardRouter.getQueueMetrics.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const isLoading = summaryLoading || jobStatusLoading || queueMetricsLoading;
const { data: summary, isLoading: summaryLoading, isFetching: summaryFetching } =
trpc.dashboardRouter.getSummary.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const { data: jobStatusMetrics, isLoading: jobStatusLoading, isFetching: jobStatusFetching } =
trpc.dashboardRouter.getJobStatusMetrics.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const { data: queueMetrics, isLoading: queueMetricsLoading, isFetching: queueMetricsFetching } =
trpc.dashboardRouter.getQueueMetrics.useQuery(undefined, {
refetchInterval: autoRefresh ? REFRESH_INTERVAL_MS : false,
});
const isLoading = summaryLoading || jobStatusLoading || queueMetricsLoading;
const isFetching = summaryFetching || jobStatusFetching || queueMetricsFetching;

Comment on lines +164 to +169
<RefreshCw
className={`h-4 w-4 transition-transform ${
autoRefresh ? "animate-spin" : ""
}`}
aria-hidden="true"
/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use the combined isFetching state to control the spin animation. This ensures the icon only spins when data is actively being loaded in the background, providing a much cleaner and less distracting user experience.

Suggested change
<RefreshCw
className={`h-4 w-4 transition-transform ${
autoRefresh ? "animate-spin" : ""
}`}
aria-hidden="true"
/>
<RefreshCw
className={`h-4 w-4 transition-transform ${
isFetching ? "animate-spin" : ""
}`}
aria-hidden="true"
/>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add auto-refresh toggle for dashboard metrics

2 participants