From 7b97d7e6831002f84f2ede512b71d9d9a21eb0f0 Mon Sep 17 00:00:00 2001 From: PeriklisTs <158848356+PeriklisTs@users.noreply.github.com> Date: Sun, 30 Aug 2026 12:02:46 +0300 Subject: [PATCH] Keep the peak network speed-test sample instead of the last The speed-test backend streams one throughput sample per second for the whole phase, and updateSpeedTestLine() overwrote the reported value on every line. The figure shown was therefore whichever single sample happened to arrive last before speedTestPhaseDuration fired. With the 5s phase budget that window is dominated by TCP slow-start, so the reported speed can be several times lower than the link. On a wired gigabit connection sustaining ~975 Mbps the widget reported 127 Mbps; the backend's samples over that window were 456, 283, 118, 127. Keep the highest sample of the phase instead. runSpeedTest() already clears both values per run, so the peak does not leak between runs. Add a ramping fixture whose samples rise and then dip, so the final sample is not the peak, and assert the service reports the peak. --- hancore.shibumi.network/Service.qml | 10 ++++++- tests/fixtures/omarchy-network-speedtest-ramp | 26 +++++++++++++++++++ tests/network-plugin-regression.sh | 3 ++- tests/network-plugin-smoke.qml | 21 +++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100755 tests/fixtures/omarchy-network-speedtest-ramp diff --git a/hancore.shibumi.network/Service.qml b/hancore.shibumi.network/Service.qml index 079d4bd..180bf9d 100644 --- a/hancore.shibumi.network/Service.qml +++ b/hancore.shibumi.network/Service.qml @@ -540,9 +540,17 @@ Item { if (!/^(?:\d+(?:\.\d*)?|\.\d+)$/.test(raw)) return const value = Number(raw) if (!isFinite(value) || value < 0) return + if (speedTestPhase !== "down" && speedTestPhase !== "up") return + // The backend streams one sample per second for the whole phase and the + // early samples land while the transfer is still ramping. Keep the peak so + // the reported figure reflects the link rather than whichever sample + // happened to arrive last before the phase timer fired. + const current = speedTestPhase === "down" + ? speedTestDownloadMbps : speedTestUploadMbps + if (current !== "" && Number(current) >= value) return const normalized = String(value) if (speedTestPhase === "down") speedTestDownloadMbps = normalized - else if (speedTestPhase === "up") speedTestUploadMbps = normalized + else speedTestUploadMbps = normalized } function startSpeedTestPhase(phaseValue) { diff --git a/tests/fixtures/omarchy-network-speedtest-ramp b/tests/fixtures/omarchy-network-speedtest-ramp new file mode 100755 index 0000000..4b24cee --- /dev/null +++ b/tests/fixtures/omarchy-network-speedtest-ramp @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +# Emits a ramping sample stream whose final value is not the peak, mirroring a +# real transfer that starts in TCP slow-start and dips before the phase ends. + +set -euo pipefail + +case "${1:-}" in + down) samples=(120 880 210) ;; + up) samples=(45 310 90) ;; + *) + printf 'unexpected speed-test phase\n' >&2 + exit 2 + ;; +esac + +trap 'exit 0' TERM INT + +for value in "${samples[@]}"; do + printf '%s\n' "$value" + sleep 0.05 +done + +while true; do + sleep 0.1 +done diff --git a/tests/network-plugin-regression.sh b/tests/network-plugin-regression.sh index e3cfc3e..576b1f0 100755 --- a/tests/network-plugin-regression.sh +++ b/tests/network-plugin-regression.sh @@ -35,7 +35,8 @@ install -m 0755 "$repo_root/tests/fixtures/omarchy-network-speedtest" \ "$repo_root/tests/fixtures/omarchy-network-speedtest-fail" \ "$repo_root/tests/fixtures/omarchy-network-speedtest-empty" \ "$repo_root/tests/fixtures/omarchy-network-speedtest-malformed" \ - "$repo_root/tests/fixtures/omarchy-network-speedtest-resistant" "$tmpdir/bin/" + "$repo_root/tests/fixtures/omarchy-network-speedtest-resistant" \ + "$repo_root/tests/fixtures/omarchy-network-speedtest-ramp" "$tmpdir/bin/" install -m 0755 "$repo_root/tests/fixtures/network-bin/omarchy-network-status" \ "$repo_root/tests/fixtures/network-bin/nmcli" "$tmpdir/bin/" diff --git a/tests/network-plugin-smoke.qml b/tests/network-plugin-smoke.qml index 2f391ef..6a3d2b0 100644 --- a/tests/network-plugin-smoke.qml +++ b/tests/network-plugin-smoke.qml @@ -170,6 +170,14 @@ ShellRoot { speedTestPhaseDuration: 10000 } + Network.Service { + id: rampSpeedService + bar: fakeBar + panelComponent: currentNetworkPanelComponent + speedTestExecutable: "omarchy-network-speedtest-ramp" + speedTestPhaseDuration: 1500 + } + Loader { id: immediateDestructionLoader active: false @@ -364,6 +372,19 @@ ShellRoot { || destructionSpeedLoader.item !== null) return root.fail("active speed-test service survived Loader teardown") if (root.destructionTicks < 140 || !root.restartContractPassed) return + if (!rampSpeedService.ready || !rampSpeedService.runSpeedTest()) + return root.fail("ramping inline speed-test startup") + root.speedPhase = 11 + return + } + + if (root.speedPhase === 11) { + if (rampSpeedService.speedTestRunning) return + if (rampSpeedService.speedTestPhase !== "" + || rampSpeedService.speedTestDownloadMbps !== "880" + || rampSpeedService.speedTestUploadMbps !== "310" + || rampSpeedService.speedTestError !== "") + return root.fail("ramping inline speed-test peak retention") root.speedContractPassed = true } }