feat: publish Mac Pulse live GitHub app - #37
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 594f116613
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| async function livePayload() { | ||
| const [status, history] = await Promise.all([ | ||
| apiRequest("/api/status"), | ||
| apiRequest("/api/history?range=24h&limit=120"), |
There was a problem hiding this comment.
Load enough samples for the 24-hour chart
At the standard 60-second heartbeat cadence, this request retrieves only the newest 120 samples—about two hours—and renderChart subsequently keeps only the newest 60, so the panel labelled “Last 24 hours” normally plots roughly one hour of data. Paginate through the full 24-hour range and downsample across that range rather than truncating its newest samples.
Useful? React with 👍 / 👎.
| setText("hardware-state", batteryHealth === null ? tr("unavailable") : tr("healthValue", { value: number(batteryHealth, 1) })); | ||
| setText("hardware-detail", tr("hardwareDetail", { cycles: number(latest.batteryCycleCount), thermal: latest.thermalState || tr("unknown") })); | ||
|
|
||
| const speedAvailable = Number.isFinite(Number(latest.internetDownloadMbps)); |
There was a problem hiding this comment.
Treat null speed measurements as unavailable
When the opt-in internet-speed test is disabled, the status API returns internetDownloadMbps: null; Number(null) is 0 and is finite, so connected mode reports a 0 Mbps measurement as “Excellent” instead of unavailable. Check for null/undefined before numeric coercion, including the related upload and latency fields.
Useful? React with 👍 / 👎.
|
|
||
| <section class="content-grid lower-grid"> | ||
| <article class="panel diagnostics-panel"> | ||
| <div class="panel-heading"><div><p class="eyebrow" data-i18n="faultIsolation">Fault isolation</p><h2 data-i18n="diagnostics">Network diagnostics</h2></div><span class="health-pill">5 / 5</span></div> |
There was a problem hiding this comment.
Derive the diagnostics score from the live result
In connected mode this badge remains 5 / 5 even when one or more diagnostics are false or all five are unknown because diagnostics collection is disabled. Although the individual rows are updated, the headline therefore presents a contradictory healthy score; give the badge an update path and calculate it from the five returned diagnostic values.
Useful? React with 👍 / 👎.
| const payload = connection ? await livePayload() : demoPayload(); | ||
| render(payload); |
There was a problem hiding this comment.
Discard responses from a disconnected session
If the user disconnects while a private status/history request is still in flight, disconnect() renders the demo immediately, but the older request can later reach this unconditional render(payload) and put private readings back on screen under the now-public-demo banner until the next refresh. Abort outstanding requests or associate each refresh with a connection generation and ignore results from obsolete sessions.
Useful? React with 👍 / 👎.
Summary
Verification
Privacy boundary
The public page never publishes live Mac data by default. Connected mode requires the separate dashboard view token and a backend configured with PUBLIC_VIEWER_ORIGIN=https://xudaniel.github.io. The heartbeat ingest/signing key must never be entered into the viewer.