Add three-state connection-status widget to UI dashboard #10
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
The dashboard only renders a textual
service_statefield. Every Hero admin UI ships the standard three-state connection-status badge (green / yellow / red), pollingrpc.healthat a configurable interval. Seehero_ui_connection_status.Goals
/<prefix>/rpc/(rpc.health) every 5s.aria-livepolite region for accessibility.X-Forwarded-Prefix).Related skills:
hero_ui_connection_status,hero_ui_dashboard.Implementation Spec for Issue #10
Objective
Add a reusable three-state connection-status widget to the hero_livekit UI dashboard. The widget displays a colored dot (green/yellow/red) in the navbar that polls the backend health every 5 seconds, with a clickable Bootstrap popover showing detailed status information.
Requirements
connection-status.jsfrom hero_embedder_ui (the shared Hero dashboard pattern)aria-live="polite"wrapper for accessibility/healthendpoint to return JSON instead of plain text for richer status dataFiles to Modify/Create
crates/hero_livekit_ui/static/js/connection-status.js- New file: copy from hero_embedder_ui canonical widgetcrates/hero_livekit_ui/static/css/dashboard.css- Add connection status classes (.disconnected, .backend-down, pulse animation)crates/hero_livekit_ui/templates/index.html- Add aria-live wrapper around status elementscrates/hero_livekit_ui/templates/base.html- Add script tag for connection-status.jscrates/hero_livekit_ui/static/js/dashboard.js- Initialize startConnectionStatusPoller() and remove manual setServiceState pollingcrates/hero_livekit_ui/src/main.rs- Update /health endpoint to return JSONImplementation Plan
Step 1: Copy connection-status.js
Files:
crates/hero_livekit_ui/static/js/connection-status.jswindow.startConnectionStatusPoller(options)with health polling, Bootstrap popover, visibility-change handlingDependencies: none
Step 2: Update dashboard.css
Files:
crates/hero_livekit_ui/static/css/dashboard.css.status-dot.disconnectedclass (red background with pulse animation).status-dot.backend-downclass (yellow/amber background)@keyframes pulse-redanimation for disconnected state.running,.stopped,.unhealthyclasses for backward compat with room status dotsDependencies: none
Step 3: Update index.html
Files:
crates/hero_livekit_ui/templates/index.html#status-dotand#status-labelelements in a<span aria-live="polite">containerDependencies: none
Step 4: Update base.html
Files:
crates/hero_livekit_ui/templates/base.html<script src="{{ base_path }}/static/js/connection-status.js"></script>before the{% block scripts %}tagDependencies: Step 1
Step 5: Update dashboard.js
Files:
crates/hero_livekit_ui/static/js/dashboard.jssetServiceState()function and its callsstartConnectionStatusPoller()initialization with:healthUrl: BASE + '/health'pingFn: () => rpcOnce('LiveKitService.status', {})dotId: 'status-dot'labelId: 'status-label'intervalMs: 5000onStateChange: (state, detail) => { ... }to update UI behavior on state changesDependencies: Steps 1, 4
Step 6: Update /health endpoint in main.rs
Files:
crates/hero_livekit_ui/src/main.rs/healthhandler from returning plain"ok"to returning JSON:{"service": "hero_livekit_ui", "status": "ok"}axum::Jsonresponse type/healthzas-is for backward compat (plain text)Dependencies: none
Acceptance Criteria
Notes
.running/.stopped/.unhealthyCSS classes must be preserved since they are used by room card status dotssetServiceState()function in dashboard.js can be fully replaced by the connection-status poller'sonStateChangecallbackTest Results
All tests pass. cargo build and cargo test both succeed with no errors or warnings.
Implementation Summary
Changes Made
New file:
crates/hero_livekit_ui/static/js/connection-status.js-- Canonical three-state connection-status widget (copied from hero_embedder_ui). ProvidesstartConnectionStatusPoller()with health polling, Bootstrap popover, and visibility-change handling.Modified files:
crates/hero_livekit_ui/static/css/dashboard.css-- Added.disconnected(red + pulse animation) and.backend-down(yellow) status-dot classes. Existing.running/.stopped/.unhealthyclasses preserved for room card dots.crates/hero_livekit_ui/templates/index.html-- Wrapped status-dot and status-label inaria-live="polite"container for screen reader accessibility.crates/hero_livekit_ui/templates/base.html-- Added<script>tag for connection-status.js before page-specific scripts block.crates/hero_livekit_ui/static/js/dashboard.js-- Removed manualsetServiceState()/runStatus()functions. AddedstartConnectionStatusPoller()initialization with healthUrl, pingFn, and 5-second polling interval. UpdatedrefreshAll()to trigger connection-status recheck.crates/hero_livekit_ui/src/main.rs-- Changed/healthendpoint from plain text "ok" to JSON{"service":"hero_livekit_ui","status":"ok"}./healthzunchanged for backward compat.Test Results
All 34 tests pass, 0 failures.
Pull request opened: #19
This PR implements the changes discussed in this issue.