Skip to content

feat(web): add privacy-redacted diagnostic report to monitor tool - #211

Merged
francescopace merged 2 commits into
francescopace:developfrom
FhDBro:feat/diagnostic-report
Nov 27, 2026
Merged

francescopace merged 2 commits into
francescopace:developfrom
FhDBro:feat/diagnostic-report

Conversation

@FhDBro

@FhDBro FhDBro commented Nov 1, 2026 •

Copy link
Copy Markdown

Resolves #198.

Summary

Reworks the diagnostic report feature into the browser-based Web Monitor (docs/web/assets/js/monitor-tool.js and docs/web/content/tools/monitor.html) per maintainer blueprint in #211 (comment).

Key Changes

  • In-Browser Sampling & Statistics:
    • Adds a Diagnostic report action to the Diagnostics panel in the Web Monitor.
    • Samples key rates (csi_occupancy, csi_accepted_pps, csi_filtered_pps, and csi_hw_error_pps) over 30 seconds and computes min, median, and max.
    • Progress bar indicates active sampling with a responsive cancel option.
  • State & Event Aggregation:
    • Gathers device state resources: capabilities, device, health, sensing, and wifi.
    • Aggregates runtime SSE fault events recorded during the session.
    • Captures browser environment context (site and user_agent).
  • Privacy Redaction in Browser:
    • Completely client-side; no raw data leaves the browser.
    • Masks SSIDs, device names, labels, hostnames, and .local domains (including appearances across free-text fields like apply_message).
    • Redacts unicast MAC addresses (aa:bb:**:**:**:**) and unicast IPv4 host octets (192.168.x.x).
    • Preserves multicast (224.0.0.0/4, 01:00:5e:*, 33:33:*), broadcast (255.255.255.255, ff:ff:ff:ff:ff:ff), and loopback (127.0.0.1, ::1).
    • Drops credential objects (credentials, *_credentials) while preserving boolean flags like password_configured.
    • Masks passwords and secret strings ([REDACTED]).
    • Shortens long device IDs (1234...5678).
  • Export UX:
    • Displays formatted preview directly inside the monitor panel.
    • Copy fenced JSON: Copies a Markdown fenced JSON block directly to the clipboard, formatted for instant pasting into GitHub issues.
    • Download JSON: Generates a timestamped JSON file download.
  • Documentation & Tests:
    • Updated docs/TROUBLESHOOTING.md and docs/web/content/guides/troubleshooting.html.
    • Added unit test suite in test/web/test_site_tools.mjs verifying rate computation, privacy boundaries, redaction rules, sampling lifecycle, and UI controls.
    • Updated web asset version hashes via .github/scripts/web_asset_versions.py.

Verification

  • cd docs/web && npm test: 254 passed across 27 suites (100% pass).
  • pytest test/python/host: 920 passed.

@francescopace francescopace self-assigned this Nov 1, 2026
@francescopace

Copy link
Copy Markdown
Owner

Hi @FhDBro, thanks a lot for this PR and for picking up #198. I really appreciate it.

While reviewing it, I realized the CLI is likely the wrong home for this feature. Most people who hit calibration or detection problems (like #165 and #188) use Home Assistant or the web tools. They never clone the repo or run ./espectre, so a CLI-only report would reach mostly developers, who can already query the device directly.

The Web Monitor is a much better fit, and it already does half the work:

  • It is connected to the device over Direct HTTP and already polls diagnostics while the diagnostics panel is open (docs/web/assets/js/monitor-tool.js).
  • It receives fault events over SSE.
  • Users already open it for setup and troubleshooting, with nothing to install.

What I have in mind is a Diagnostic report button in the Web Monitor that:

  1. Reads capabilities, device, health, sensing, and wifi.
  2. Samples diagnostics for 30–60 s and reports min, median, and max of the key rates (occupancy, accepted, filtered, and hardware-error pps), because a single snapshot hides the intermittent problems we care about.
  3. Lists any fault events seen during the session, plus the site and browser version.
  4. Redacts everything in the browser and shows a preview with Copy (as a fenced JSON block, ready to paste into an issue) and Download .json. Nothing leaves the browser, and there is no separate Markdown rendering.

Your redaction rules would carry over almost as-is. I would add or adjust a few:

  • Device name and label, hostnames, and .local names need masking too.
  • SSIDs and names must be masked where they reappear in free text, such as wifi.apply_message.
  • Credential objects should be dropped as a whole, while flags such as password_configured stay readable.
  • Multicast, loopback, and broadcast addresses can stay unmasked.

Would you like to take on the Web Monitor version? You can rework this PR or open a new one, whichever you prefer.

Thanks again, and sorry for the rework request after you put effort into the CLI version.

@HyeonbinJung, as the author of #198, I’d love your thoughts on this too.

@francescopace
francescopace force-pushed the develop branch 3 times, most recently from 2562ea1 to 8b4feb1 Compare November 7, 2026 15:07
@FhDBro
FhDBro force-pushed the feat/diagnostic-report branch from 8f75a0d to a794fa5 Compare November 14, 2026 17:38
@FhDBro FhDBro changed the title feat(cli): add privacy-redacted diagnostic report command feat(web): add privacy-redacted diagnostic report to monitor tool Nov 14, 2026
@FhDBro

FhDBro commented Nov 14, 2026

Copy link
Copy Markdown
Author

Hi @francescopace,

Thank you for the detailed feedback! Moving this into the Web Monitor makes total sense—having it right where users already monitor and troubleshoot eliminates the friction of CLI setup.

I have reworked the PR for the Web Monitor following your blueprint:

  1. Sampling & Rates: Added a Diagnostic report section inside the Live Diagnostics panel. It samples csi_occupancy, csi_accepted_pps, csi_filtered_pps, and csi_hw_error_pps over 30 seconds and calculates their min, median, and max. A progress bar tracks sampling with a cancel option.
  2. State & Events: Aggregates capabilities, device, health, sensing, wifi, session SSE fault events, and client browser metadata.
  3. Privacy Redaction: All redaction runs client-side in the browser. It masks SSIDs, device names, labels, hostnames, .local domains, and any occurrences across free text (such as wifi.apply_message). Unicast MACs and IPv4 host octets are masked while keeping multicast, broadcast, and loopback intact. Credential objects are omitted entirely while preserving boolean flags like password_configured.
  4. Export UX: Displays an in-browser preview, Copy fenced JSON (formatted for direct pasting into GitHub issues), and Download JSON.
  5. Tests & Docs: Added unit tests in test/web/test_site_tools.mjs asserting the rate statistics, redaction boundaries, sampling lifecycle, and UI controls. Also updated docs/TROUBLESHOOTING.md and docs/web/content/guides/troubleshooting.html, and refreshed asset version hashes.

All 254 web tests (npm test) are passing. Please let me know if any adjustments are needed!

@FhDBro
FhDBro force-pushed the feat/diagnostic-report branch 4 times, most recently from 3fc3c22 to e703d4a Compare November 19, 2026 03:36
@francescopace
francescopace force-pushed the develop branch 3 times, most recently from 0403201 to 9bb671a Compare November 24, 2026 15:54
@FhDBro
FhDBro force-pushed the feat/diagnostic-report branch from e703d4a to 63e0af3 Compare November 24, 2026 17:32
FhDBro and others added 2 commits November 27, 2026 18:18
Move the diagnostic report generation directly into the browser-based Web Monitor tool per maintainer blueprint.

When running diagnostics, the monitor samples four key rates (csi_occupancy, csi_accepted_pps, csi_filtered_pps, and csi_hw_error_pps) over a configurable duration (default 30 seconds) and computes their min, median, and max values. The final report aggregates the rate statistics alongside device capabilities, health, sensing, Wi-Fi, and session SSE fault events, plus client browser context.

Identifiers are redacted client-side before export: device names, labels, hostnames, .local domains, SSIDs, and unicast MAC/IPv4 addresses are masked, while credential objects are stripped. Multicast, broadcast, and loopback addresses remain intact for networking diagnosis.

The panel provides an in-browser preview, a one-click copy button formatted as fenced JSON for GitHub issues, and a JSON download button.

Signed-off-by: Tawhidul Islam <276017696+FhDBro@users.noreply.github.com>
Collect and redact device state, session faults, and sampled CSI rates using the existing API. Include client versions and fix Micro CORS headers for browser reports.

Signed-off-by: Francesco Pace <francesco.pace@gmail.com>
@francescopace
francescopace merged commit e1b989d into francescopace:develop Nov 27, 2026
64 checks passed
@francescopace

Copy link
Copy Markdown
Owner

Thanks, @FhDBro, I tightened privacy redaction, fixed how the report handles missing samples, and resolved a connection issue on MicroEspectre.
Merged on develop, ready for next release!

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.

3 participants