Skip to content

[dashboard, docs] feat: make telemetry refresh opt-in - #184

Merged
Wangmerlyn merged 3 commits into
mainfrom
codex/dashboard-refresh-controls
Jun 30, 2026
Merged

[dashboard, docs] feat: make telemetry refresh opt-in#184
Wangmerlyn merged 3 commits into
mainfrom
codex/dashboard-refresh-controls

Conversation

@Wangmerlyn

@Wangmerlyn Wangmerlyn commented Jun 30, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace always-on 3-second dashboard telemetry polling with manual refresh by default and explicit visible-tab auto refresh.
  • Force a fresh post-mutation refresh after start/release actions so the UI does not reuse stale in-flight reads.
  • Update README, dashboard guides, AGENTS guidance, plan notes, tests, and packaged static assets.

Test Plan

  • npm --prefix web/dashboard test
  • npm --prefix web/dashboard run build
  • npm --prefix web/dashboard test
  • PYTHONPATH=$PWD/src pytest tests/mcp/test_http_api.py -q
  • PYTHONPATH=$PWD/src mkdocs build
  • pre-commit run --all-files --show-diff-on-failure

Local Review

  • Beauvoir the 2nd reviewed correctness/reliability; initial stale post-mutation refresh finding was fixed and follow-up review found no must-fix issues.
  • Descartes the 2nd reviewed small-repo discipline/docs bloat; duplicate plan command was removed and follow-up review found no must-fix issues.

Summary by CodeRabbit

  • New Features
    • Added manual dashboard refresh controls with an optional auto-refresh toggle.
    • Auto-refresh now respects browser tab visibility and pauses when hidden.
  • Bug Fixes
    • Prevents overlapping refreshes and improves refresh behavior after session changes.
    • Refresh status and warning messages are now clearer and more consistent.
  • Documentation
    • Updated dashboard, CLI, MCP, and README guidance to match the new refresh behavior.
    • Added a planning note covering the refresh-control rollout and validation steps.
  • Tests
    • Added coverage for refresh controls, visibility handling, and warning formatting.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Wangmerlyn, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d47690dc-fc90-4050-8af6-93412e6ad088

📥 Commits

Reviewing files that changed from the base of the PR and between 8470e5d and 7102256.

📒 Files selected for processing (3)
  • AGENTS.md
  • README.md
  • docs/plans/dashboard-refresh-controls.md
📝 Walkthrough

Walkthrough

Replaces the dashboard's fixed 3-second polling loop with a manual "Refresh Now" action and an explicit "Auto refresh" toggle. A new lib/refresh.js module provides predicates and formatters; App.jsx is refactored to use useCallback, in-flight deduplication, and visibility-aware interval scheduling. Compiled CSS, docs, and AGENTS.md are updated to match.

Changes

Dashboard Refresh Controls

Layer / File(s) Summary
Refresh helper module and tests
web/dashboard/src/lib/refresh.js, web/dashboard/src/lib/refresh.test.js
New module exports AUTO_REFRESH_INTERVAL_MS, canRunAutoRefresh, canReuseInFlightRefresh, formatRefreshWarningMessage, and formatRefreshMode; Vitest suite covers all predicates and formatters.
App.jsx refresh refactor and UI controls
web/dashboard/src/App.jsx, web/dashboard/src/App.test.jsx, src/keep_gpu/mcp/static/assets/index.css
Imports extended; visibilityState and autoRefresh states added; refresh converted to useCallback with userInitiated/afterMutation options and in-flight deduplication; visibility and interval effects added; mutation call sites pass afterMutation: true; GPU Telemetry header gains "Refresh Now" button, "Auto refresh" checkbox, and refreshMode label; new App test asserts manual-refresh UI; compiled CSS gains .inline-flex, .hidden, .py-1.5.
Documentation and agent guidance
AGENTS.md, README.md, docs/guides/cli.md, docs/guides/mcp.md, docs/plans/dashboard-refresh-controls.md
AGENTS.md adds refresh constraints and sync instructions; README.md, cli.md, and mcp.md document manual-default / opt-in auto-refresh behavior; new plan doc describes prior behavior, goals, solution, and validation steps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Wangmerlyn/KeepGPU#66: Introduced the original dashboard with fixed-interval telemetry polling that this PR replaces.
  • Wangmerlyn/KeepGPU#114: Modified App.jsx REST call and error-formatting patterns that the new refresh warning message logic builds on.

Poem

🐇 No more spinning every three ticks,
The bunny now rests with smarter tricks.
"Refresh Now" on click, or toggle the box,
Tab hidden? We pause — no background knocks.
Low-power hops keep the GPU fox! 🦊

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: making dashboard telemetry refresh opt-in, with related docs updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/dashboard-refresh-controls

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Copy link
Copy Markdown
Contributor

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 implements low-power dashboard refresh controls, changing the telemetry refresh to manual by default and adding an opt-in auto-refresh toggle that polls every 10 seconds only when the browser tab is visible. It also collapses overlapping refresh requests and updates relevant documentation, tests, and static assets. The review feedback suggests safely handling caught errors in the refresh function to prevent potential runtime exceptions when accessing properties on non-Error objects.

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 thread web/dashboard/src/App.jsx
Comment on lines +123 to +125
} catch (error) {
setMessage(`Refresh warning: ${error.message}`)
} finally {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

If error is not an instance of Error (for example, if it is a string, a plain object, or null/undefined), accessing error.message can result in undefined or throw a TypeError which would crash the catch block. It is safer to use optional chaining and a fallback, such as error?.message || String(error).

Suggested change
} catch (error) {
setMessage(`Refresh warning: ${error.message}`)
} finally {
} catch (error) {
setMessage(`Refresh warning: ${error?.message || String(error)}`)
} finally {

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed in 8470e5d by routing refresh failures through formatRefreshWarningMessage(), with coverage for Error, string, and null rejections in web/dashboard/src/lib/refresh.test.js. The dashboard static bundle was rebuilt after the source change.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
README.md (1)

47-49: 📐 Maintainability & Code Quality | 🔵 Trivial

Consider hyphenating "auto-refresh" consistently.

The static analysis hint flags grammar at line 183. Across docs, "auto refresh" appears both hyphenated and unhyphenated. Consider standardizing on "auto-refresh" when used as a compound noun/modifier for consistency with docs/guides/cli.md and docs/guides/mcp.md.

Current occurrences:

  • Line 48: "opt-in auto refresh" (unhyphenated)
  • Line 183: "opt-in auto refresh" (unhyphenated)
  • docs/guides/cli.md line 128: "Auto refresh" (UI label, unhyphenated)
  • docs/guides/mcp.md line 225-226: "Auto refresh" toggle / "10-second polling" (mixed)

The UI label "Auto refresh" can remain unhyphenated as a proper label, but descriptive prose reads more consistently as "auto-refresh."

Also applies to: 182-183

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 47 - 49, Standardize the prose wording for the
telemetry refresh docs by changing descriptive uses of “auto refresh” to
“auto-refresh” while leaving the actual UI label “Auto refresh” unchanged.
Update the affected copy in the README and any matching prose in the related
docs so the phrasing is consistent with the style used in `docs/guides/cli.md`
and `docs/guides/mcp.md`, using the existing telemetry refresh text as the
locator.

Source: Linters/SAST tools

web/dashboard/src/App.test.jsx (1)

30-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Exercise the refresh effects, not just the initial HTML.

This only proves the controls render. It still passes if polling starts again by default or if hidden-tab pausing regresses, because the interval and visibility effects never run here. Please add a mounted test that verifies: no polling before opt-in, polling begins after checking Auto refresh, and polling stops when document.visibilityState becomes "hidden". Based on learnings, "Add tests when there is an existing test pattern; do not introduce a brand-new testing framework unless requested."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/dashboard/src/App.test.jsx` around lines 30 - 46, The current App test
only checks static markup, so it misses the refresh polling and visibility
behavior in App’s mounted effects. Add or extend a test around App that mounts
it and exercises the auto-refresh logic: verify no polling happens before opting
in, polling starts after enabling the “Auto refresh” checkbox, and polling stops
when document.visibilityState changes to "hidden". Reuse the existing App test
setup/pattern in App.test.jsx and target the refresh controls/effects rather
than only renderToStaticMarkup.

Source: Learnings

src/keep_gpu/mcp/static/assets/index.css (1)

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Stop linting the rebuilt CSS bundle directly.

Line 1 is generated output, and Stylelint is now flagging Tailwind-emitted font-family/vendor-prefix rules here. Fixing this file by hand will be overwritten on the next dashboard rebuild. Please lint the source stylesheet or exclude src/keep_gpu/mcp/static/assets/index.css from Stylelint so rebuilt assets stay reproducible.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/keep_gpu/mcp/static/assets/index.css` at line 1, The generated CSS bundle
in index.css should not be linted or edited directly because it is rebuilt
output and Stylelint is catching Tailwind-generated declarations here. Update
the linting setup to target the source stylesheet instead, or exclude
src/keep_gpu/mcp/static/assets/index.css from Stylelint, so the asset remains
reproducible after dashboard rebuilds. Use the bundled asset entrypoint and the
lint configuration as the places to adjust.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@README.md`:
- Around line 47-49: Standardize the prose wording for the telemetry refresh
docs by changing descriptive uses of “auto refresh” to “auto-refresh” while
leaving the actual UI label “Auto refresh” unchanged. Update the affected copy
in the README and any matching prose in the related docs so the phrasing is
consistent with the style used in `docs/guides/cli.md` and `docs/guides/mcp.md`,
using the existing telemetry refresh text as the locator.

In `@src/keep_gpu/mcp/static/assets/index.css`:
- Line 1: The generated CSS bundle in index.css should not be linted or edited
directly because it is rebuilt output and Stylelint is catching
Tailwind-generated declarations here. Update the linting setup to target the
source stylesheet instead, or exclude src/keep_gpu/mcp/static/assets/index.css
from Stylelint, so the asset remains reproducible after dashboard rebuilds. Use
the bundled asset entrypoint and the lint configuration as the places to adjust.

In `@web/dashboard/src/App.test.jsx`:
- Around line 30-46: The current App test only checks static markup, so it
misses the refresh polling and visibility behavior in App’s mounted effects. Add
or extend a test around App that mounts it and exercises the auto-refresh logic:
verify no polling happens before opting in, polling starts after enabling the
“Auto refresh” checkbox, and polling stops when document.visibilityState changes
to "hidden". Reuse the existing App test setup/pattern in App.test.jsx and
target the refresh controls/effects rather than only renderToStaticMarkup.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e25d69a3-ffee-4361-ad41-73c75e54edf0

📥 Commits

Reviewing files that changed from the base of the PR and between 06780b4 and 8470e5d.

📒 Files selected for processing (11)
  • AGENTS.md
  • README.md
  • docs/guides/cli.md
  • docs/guides/mcp.md
  • docs/plans/dashboard-refresh-controls.md
  • src/keep_gpu/mcp/static/assets/dashboard.js
  • src/keep_gpu/mcp/static/assets/index.css
  • web/dashboard/src/App.jsx
  • web/dashboard/src/App.test.jsx
  • web/dashboard/src/lib/refresh.js
  • web/dashboard/src/lib/refresh.test.js

@Wangmerlyn

Copy link
Copy Markdown
Owner Author

CodeRabbit nitpick follow-up:

  • Fixed the descriptive prose wording in 7102256 by standardizing on auto-refresh while keeping the UI label Auto refresh unchanged.
  • Not adding a mounted DOM/effects test for App.jsx: this dashboard test suite intentionally stays dependency-light and currently has no jsdom/happy-dom/testing-library stack. The low-power policy is covered in web/dashboard/src/lib/refresh.test.js (canRunAutoRefresh, hidden-tab pause policy, and post-mutation in-flight refresh reuse), and the static render test verifies the controls/label surface. Pulling in a DOM stack for this one effect would work against the small-repo direction.
  • The generated CSS lint suggestion is not applicable here: the repo has no Stylelint config or Stylelint pre-commit hook. Reproducibility of the generated dashboard assets is covered by web/dashboard/staticAssets.test.js plus npm --prefix web/dashboard run build.

@Wangmerlyn
Wangmerlyn merged commit ff245ed into main Jun 30, 2026
6 checks passed
@Wangmerlyn
Wangmerlyn deleted the codex/dashboard-refresh-controls branch June 30, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant