Repository navigation
fix(dashboard): restore measured bandwidth histogram (KAN-280) - #320
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
usjbro
left a comment
There was a problem hiding this comment.
Claude Code review — PR #320 (KAN-280), head 2f5764b
I read the whole diff against the KAN-280 acceptance list, capture-agent/src/main.rs:2518-2545 (how the agent computes Mbps) and lib/agent-mapping.ts (mapSystemStatsEvent). The root cause is fixed and the change stays in scope: no wire, agent, dependency or config changes, and no simulated values.
Acceptance criteria
| Criterion | Result |
|---|---|
Each system_stats tick feeds a 60-sample RX/TX history kept in a pure lib/ helper |
Met. appendBandwidthSample is pure, and the functional setHistory* updaters keep both ticks when two land in one batch (the test checks this). |
interface_changed clears the history |
Met and tested, including the next tick after the reset. |
| A 0 Mbps sample draws no bar (the 8% floor is removed) | Met and tested (height: 0%). |
| The tooltip shows Mbps, not 8.4× inflated "MB/s" | The unit is fixed, but see finding 1. |
| An empty state shows until the first sample | Met and tested. |
| Tests added first and shown failing | The red runs are recorded in TEST_STATUS (six expected failures, plus a separate check that removing the reset fails). |
Findings
1. The tooltip prints the agent's raw f64 (should fix before merge). The tooltip renders {rxVal} Mbps directly. The agent sends bytes * 8 / tick_seconds / 1_000_000 with no rounding, so real ticks render with many decimal places:
- 1,081,164 bytes in a 1 s tick renders as
RX: 8.649312 Mbps. - The same bytes in a 1.002 s tick (the code comment at
main.rs:2519says late ticks are expected) render asRX: 8.632047904191618 Mbps.
The tests only use round values like 10, 2.5 and 0.125, so they don't catch this. To fix it, format the value to a fixed precision, for example rxVal.toFixed(2) or a small formatMbps helper next to appendBandwidthSample. Then add a test with a value like 8.632047904191618 that expects 8.63 Mbps.
2. The KPI cards above the histogram still have the same 8.4× unit bug (follow-up, not blocking). DashboardView.tsx:73 and :90 still use formatSpeed(stats.rxTotalMbps * 1024 * 1024). That treats decimal megabits per second as binary megabytes per second, so the cards and the histogram on the same panel now disagree by about 8.4×. The "Total" lines at :77 and :94 multiply the current rate by 60, which isn't a measured total. KAN-280 didn't list these lines in scope, so I'd track them in a new ticket rather than expand this PR. I'll open it if James agrees.
3. Next.js security advisory on the first build (follow-up). The PR body says the first npm run build stopped on a Next.js advisory and the retry passed. It's good that no dependency was changed here, but this needs its own ticket. If CI's npm audit gate passes, that's evidence it isn't the gate's advisory, but someone should still identify which advisory it was.
Security
There's no new input surface, no dangerouslySetInnerHTML, and no network, storage or key-material changes. React escapes all rendered values. Nothing to report.
CI
When I posted this, Web, E2E, Rust and CodeQL were still running; Fuzz and Snyk had passed. I'll check again when they finish.
Verdict: approve after finding 1 is fixed. Findings 2 and 3 are follow-ups. Merging stays with James.
|
Fixed finding 1 in 6c34650: histogram tooltip values now use at most two decimal places, without changing measured history or bar scaling. Added a failing-then-passing regression for 8.632047904191618 -> 8.63 Mbps and 0.125 -> 0.13 Mbps. All 1,031 tests, lint and build pass; final independent code and security review found no actionable findings. One unrelated enrichment fixture cleanup ENOTEMPTY occurred on the first full run; the rerun passed. Please re-review the precision change. Harness duplication stays in KAN-281; KPI metrics and dependency advisory remain separate follow-ups. New-head CI is pending. James owns merge. |
|
CI at 6c34650 is blocked by the Web npm-audit gate: GHSA-fc5q-39xc-vjpf (picomatch ReDoS). The failure occurs before Web lint/tests/build. All other checks pass, including Rust, E2E, CodeQL, SonarCloud and Snyk. Failed job. The advisory currently lists <=4.0.7 affected and no patched release. No dependency or audit-allowlist changes made in this histogram fix. Separate security triage is required; this PR is not merge-ready. Local 1,031 tests, lint/build and final code/security reviews pass. |
usjbro
left a comment
There was a problem hiding this comment.
Claude Code re-review — PR #320 (KAN-280), head 6c34650
I re-read the change since 2f5764b (one commit, fix(dashboard): bound bandwidth tooltip precision).
Finding 1 (tooltip precision): fixed
DashboardView.tsx now renders Number(rxVal.toFixed(2)) / Number(txVal.toFixed(2)), so the tooltip shows at most two decimal places and drops trailing zeros (10, 2.5, 8.63). The new test uses the real-world value 8.632047904191618 and expects RX: 8.63 Mbps, plus 0.125 → TX: 0.13 Mbps. TEST_STATUS records the red run before the fix.
Verification at 6c34650
npx vitest run: 98 files, 1031 passed, run locally by me.npm run lint: clean, also run by me.- CI passed: Rust, E2E (against a production build), Fuzz, CodeQL, SonarCloud and Snyk.
The failing Web check isn't caused by this PR
Web fails in its first step, the npm audit gate, on GHSA-fc5q-39xc-vjpf, a picomatch ReDoS rated high. This PR changes no dependencies, and Snyk reports "No manifest changes". Main fails the same gate: today's Dependabot run on 1c8db79 failed too.
- The advisory covers
picomatch <= 4.0.7and lists no patched version. - picomatch arrives only through dev tooling:
[email protected](and itsviteandtinyglobbydependencies) and[email protected]→fast-glob→micromatch. None of it ships to the browser or the server at runtime. npm audit's suggested fixes are major downgrades ([email protected],[email protected]), so they aren't real fixes.
Because the gate stops at that step, CI never ran Web lint, tests or build on this head. The local runs above, plus E2E's production build, cover that gap.
Codex was right not to add an allowlist entry inside this PR. The gate's own message says an unfixable advisory gets a dated ALLOWLIST entry in .github/scripts/check-npm-audit.mjs. That decision belongs in its own small PR that James approves, and it's a security exception, so it shouldn't ride along in a dashboard fix.
Verdict
Approve. The code is ready. The red Web check comes from an advisory that blocks every PR and main until James decides on it. Merging stays with James.
Follow-ups, unchanged from my first review: the KPI cards are still about 8.4× too high, and the 60× "Total" lines aren't measured values.
|



The Dashboard bandwidth histogram stayed empty because system_stats never populated its history arrays. Each tick now appends measured RX/TX Mbps to a 60-sample history, which clears on interface changes. Idle samples have zero-height bars, tooltips use decimal Mbps, and the panel shows a waiting message before data arrives.
Validation: all 1,031 Vitest tests, lint, production build and both Playwright tests pass. Regression checks fail against the original behavior and pass with the fix; an isolated reset mutation confirms stale interface history is caught. A real capture-agent on macOS lo0 drove a production Chromium check with measured traffic and zero RX bars. Independent code and security reviews found no actionable findings. Claude’s tooltip precision finding is fixed with a regression test and at most two decimal places.
The first build reported a Next.js security advisory and stopped; repeating the build passed. Dependencies are unchanged; that advisory needs a separate follow-up. Agent/wire protocol and unrelated Dashboard metrics are outside this change.
Tracks KAN-280. James owns merge.