Pin-imbalance gauge — new Pin Imbalance card (spread A between highest/lowest pin, 4 A scale) in the 12 VHPWR Connector row; Fan Duty moved to the Temperatures row (grid widened to 5 columns at lg).
Three WireView tab improvements:
- **Firmware check + DFU flash** — bundled firmware image comparison (version/build), dfu-util detection, flash with progress over USB DFU (serial transport only), verdicts incl. downgrade/product-mismatch/too-old-for-noctua.
- **Clear fault status/log** — per-badge clear buttons with keep-mask semantics (0x0000 clears, 0xFFFF keeps).
- **Pin-imbalance gauge** — new Pin Imbalance card (spread A between highest/lowest pin, 4 A scale) in the 12 VHPWR Connector row; Fan Duty moved to the Temperatures row (grid widened to 5 columns at lg).
Port of the wireview-linux firmware update feature:
- nvcurve/wireview_firmware.py: Intel-HEX parser (checksum-verified),
BuildStruct identity extraction (vendor/product/version/build string
at image base + 192), compatibility verdicts (version then build
date, Noctua Edition product alias + 2026-09-02 floor), and a
dfu-util flasher (progress parsing, exit-74-after-:leave quirk,
timeouts).
- Bundle TG-WV-PRO2-FW.hex (v05, build 20260902_0741, base
0x08000000) in nvcurve/firmware/.
- WireViewSerialDevice.enter_bootloader() sends the top-level 0xF1
command; vendor/product ids are exposed in info().
- GET /api/wireview/firmware (device vs. bundled verdict, dfu-util
availability, flash state) and POST /api/wireview/firmware/flash
(gates: serial transport, product match, Noctua floor, downgrade/
same require override). The flash runs as a background task
(bootloader -> wait for 0483:df11 -> dfu-util) with progress
streamed over /ws/wireview.
- WireView tab: Firmware card with device vs. bundled firmware,
verdict, dfu-util/hwmon warnings, confirm dialog, live progress
bar; re-checks after the device reboots.
- tests/test_wireview_firmware.py: 66 tests (HEX parser, checksum
rejection, identity, all verdict paths, mocked flasher, bootloader
command via pty); added to the Makefile test target.
- Docs: firmware section in docs/WireView.md, README note.
- WireViewSerialDevice.clear_faults() sends CMD_CLEAR_FAULTS (0x0E)
with 16-bit keep masks (0x0000 clears, 0xFFFF keeps); all port
access is now serialized with an RLock so the poller, the
clear-fault endpoint and the watchdog cannot interleave on the
port mid-transaction.
- POST /api/wireview/clear-fault (serial transport only — in hwmon
mode wireviewd owns the port and the masks are read-only); the
sample is re-read immediately so clients see the cleared masks
without waiting for the next poll tick.
- WireView tab: Clear buttons on the fault status/log badges.
- tests: protocol-level clear-fault tests via pty (byte-exact
command framing, keep-mask semantics).
This PR was large (14 files reviewed). Each file was reviewed individually.
Makefile
No issues found.
README.md
No issues found.
The Markdown is well-formed, the link and code formatting are correct, and there are no typos. One minor observation: the README update mentions the firmware check/DFU feature but does not reference the other two features in this PR (fault clearing, pin-imbalance gauge). This is a completeness gap rather than a bug, but worth considering if the README aims to summarize all WireView capabilities.
docs/WireView.md
Review: docs/WireView.md
Potential Logic Contradiction
The flash procedure states:
the device reboots on its own and the watchdog reconnects it
However, the dfu-util command uses the :leave suffix:
dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D <image>
In dfu-util, the :leave suffix on -s means "leave the device in DFU mode" (i.e., do not send the leave/exit-DFU command). If the device is left in DFU mode, it will not reboot on its own — it stays in the bootloader until explicitly told to exit.
Either:
The command should omit :leave (so the device exits DFU and reboots), or
The prose should be corrected to say the device remains in DFU mode and NVCurve sends a separate exit command / the watchdog handles reconnection from the DFU state.
Minor: API Error Code
POST /api/wireview/firmware/flash returns 409 for both "refused" and "already running." 409 Conflict fits "already running" well, but "refused" (e.g., downgrade without override, product mismatch) is more naturally a 400 Bad Request or 422 Unprocessable Entity. Not a bug, but worth noting if the API contract is being documented for the first time.
No other issues found. Markdown structure, headings, and formatting are correct.
refreshFirmware is recreated every render (no useCallback), so react-hooks/exhaustive-deps would flag this. It's functionally safe here because the function body only references module-level api and stable setState setters, but the eslint-disable comment above only suppresses react-hooks/set-state-in-effect, not the exhaustive-deps rule. Either add refreshFirmware to the deps (and wrap it in useCallback), or add a second disable line.
If the backend ever sends progress as null/undefined before the first progress event (e.g., during the "waiting" state), this renders NaN%. A guard like flash.progress ?? 0 would be defensive.
Not a bug—just easier to verify at a glance that the masks are complementary.
frontend/src/hooks/useWireview.ts
No issues found.
frontend/src/types.ts
Review: frontend/src/types.ts
No issues found.
The types are well-structured and syntactically correct. One minor observation (not a bug):
Duplication between WireViewWsMessage firmware variant and WireViewFlashProgress: The new { type: "firmware"; state; progress; status } variant re-declares the same three fields that WireViewFlashProgress already defines, rather than reusing the interface (e.g. flash: WireViewFlashProgress). This is likely intentional for a flat WebSocket payload, but it creates a maintenance coupling—if WireViewFlashProgress gains a field, the message variant won't automatically track it. Consider a comment or a Pick<WireViewFlashProgress, "state" | "progress" | "status"> to make the relationship explicit.
nvcurve/firmware/TG-WV-PRO2-FW.hex
Review for nvcurve/firmware/TG-WV-PRO2-FW.hex: LLM API error.
nvcurve/server.py
Review: nvcurve/server.py
Bug: Race condition on flash state
In api_wireview_firmware_flash, the state is set to "idle" immediately before spawning the background task:
The task won't begin executing (and won't call announce("bootloader", …)) until the current coroutine yields. A second concurrent request arriving in that window will pass the guard:
If the bundled image file does not exist on disk, read_firmware_info will raise OSError/FileNotFoundError (not FirmwareImageError), producing an unhandled 500 with a stack trace. The earlier api_wireview_firmware endpoint correctly guards with if image_path.is_file(). The same pattern should be applied here (or catch OSError as well).
Minor: Redundant device.info() calls
Both api_wireview_firmware and api_wireview_firmware_flash call device.info() twice — once inside _wireview_device_firmware and once directly for vendor_id/product_id. This is a serial read on each call; consider returning the full info dict from the helper or caching it locally.
Minor: Temp file leak on hard crash
bin_path is cleaned up in finally, but if the process is killed (SIGKILL) between write_bytes and unlink, the file persists in /tmp. Low severity, but a startup-time cleanup of stale nvcurve-wireview-fw-*.bin files would be a nice safety net.
nvcurve/wireview.py
Review: nvcurve/wireview.py
⚠️ Potential Issue: 0xF1 Command Collision
CMD_BOOTLOADER=0xF1...SCREEN_RESUME_UPDATES=0xF1
Both constants share the same byte value. The comment clarifies they live in different command namespaces (top-level vs. screen subcommand), so this is not a bug, but it's a maintenance hazard — a future reader or refactoring could easily conflate them. Consider adding a brief comment on SCREEN_RESUME_UPDATES noting the overlap, or renaming one for clarity.
✅ Everything else looks clean
Locking: RLock correctly serializes all port access. clear_faults and enter_bootloader both route through _transaction → _transaction_unlocked, so they're protected. The self.close() call in enter_bootloader is outside the lock, but since _transaction_unlocked already closes the serial port internally, close() is just resetting _connected — no race.
clear_faults: & 0xFFFF masks are defensive and correct. response_size=0 matches the documented "no reply" protocol.
enter_bootloader: Correctly closes the port after sending the command, since the device re-enumerates as a DFU device.
Hwmon stubs: clear_faults / enter_bootloader returning False with explanatory docstrings is consistent with the interface contract.
Identity dict: vendor_id / product_id added to both serial and hwmon variants — consistent.
No syntax errors, no logic bugs, no security concerns.
nvcurve/wireview_firmware.py
Review: nvcurve/wireview_firmware.py
Potential Stderr Pipe Deadlock
In DfuUtilFlasher.flash, stderr is piped but not drained until afterproc.wait():
proc=subprocess.Popen(args,stdout=subprocess.PIPE,stderr=subprocess.PIPE,text=True)# ...reader=threading.Thread(target=_read_stdout,daemon=True)# drains stdout onlyreader.start()proc.wait(timeout=timeout_s)# blocks herestderr=proc.stderr.read()# stderr drained only now
If dfu-util ever writes more than the OS pipe buffer (~64 KB on Linux) to stderr, the child process blocks on write(2), proc.wait() hangs until the timeout fires, and the flash is reported as failed despite possibly having succeeded. In practice dfu-util's stderr output during a flash is a few lines at most, so this is low-probability — but it's a latent correctness bug. A second reader thread (or select-based loop) for stderr would eliminate the risk.
Performance: Character-by-Character Pipe Read
_read_stdout calls proc.stdout.read(1) in a loop, issuing one read(2) syscall per character. For a typical flash session this is a few thousand syscalls. A chunked read (e.g. read(256)) with a small internal buffer for the current line would reduce this by orders of magnitude with no functional change:
def_read_stdout()->None:buf=""whileTrue:chunk=proc.stdout.read(256)ifnotchunk:breakbuf+=chunkwhile"\r"inbufor"\n"inbuf:# split on \r or \n, process the completed line, keep remainder...
Minor: Inconsistent Field-Check Order in read_firmware_info
The method validates VERSION_OFFSET before VENDOR_ID_OFFSET / PRODUCT_ID_OFFSET, but the dataclass fields are ordered vendor → product → version. If only the version byte is missing, the error says "version byte not found" before the vendor/product check even runs — which is fine functionally, but the reversed order relative to the dataclass definition is slightly confusing when reading the code.
No syntax errors, security issues (subprocess uses list args, no shell injection), or logic bugs in the HEX parser, compatibility verdicts, or build-timestamp parsing were found.
tests/test_wireview.py
No issues found.
tests/test_wireview_firmware.py
Review: tests/test_wireview_firmware.py
Significant Issue
Tests don't fail under pytest — The check() function only prints and increments counters; it never raises an exception. The docstring claims "Also works under pytest," but pytest will report every test_* function as passed regardless of how many individual check() calls fail. The main() function (which returns a non-zero exit code on failure) is never invoked by pytest.
defcheck(name:str,cond:bool)->None:globalPASS,FAILifcond:PASS+=1print(f" PASS {name}")else:FAIL+=1print(f" FAIL {name}")# ← no assertion raised
Fix: Add an assertion that only fires under pytest (or always):
importpytestdefcheck(name:str,cond:bool)->None:globalPASS,FAILifcond:PASS+=1print(f" PASS {name}")else:FAIL+=1print(f" FAIL {name}")pytest.fail(name)# raises under pytest; standalone run is unaffected
Or, if the intent is truly standalone-only, correct the docstring to "collectible by pytest but failures are only visible in stdout."
Minor Observations
Location
Note
test_enter_bootloader
No explicit synchronization between thread start and dev.connect(). It works in practice because the blocking PTY read implicitly waits for the thread, but a threading.Event set after the first os.read would make the intent clearer and guard against subtle scheduling issues on loaded CI.
test_dfu_flash — progress check
progress == [0.0, 0.25, 0.5, 1.0] depends on the parser emitting exactly one callback per percentage line. If the implementation ever coalesces or skips (e.g., a 0% line that's considered "start"), this will be a brittle assertion. Consider assert progress[-1] == 1.0 plus a length check.
test_hex_parser — bad-checksum corruption
The logic bad[:-2] + ("00" if bad[-2:] != "00" else "01") is correct but slightly hard to read. A comment or assert bad[-2:] != "00" before the mutation would make the intent self-documenting.
No syntax errors, typos, or security issues found.
⚠️1 file(s) had review errors and may not have been fully reviewed.
# Per-File Review Summary
This PR was large (14 files reviewed). Each file was reviewed individually.
---
### Makefile
No issues found.
---
### README.md
No issues found.
The Markdown is well-formed, the link and code formatting are correct, and there are no typos. One minor observation: the README update mentions the firmware check/DFU feature but does not reference the other two features in this PR (fault clearing, pin-imbalance gauge). This is a completeness gap rather than a bug, but worth considering if the README aims to summarize all WireView capabilities.
---
### docs/WireView.md
## Review: `docs/WireView.md`
### Potential Logic Contradiction
The flash procedure states:
> the device reboots on its own and the watchdog reconnects it
However, the `dfu-util` command uses the `:leave` suffix:
```
dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D <image>
```
In `dfu-util`, the `:leave` suffix on `-s` means **"leave the device in DFU mode"** (i.e., do *not* send the leave/exit-DFU command). If the device is left in DFU mode, it will **not** reboot on its own — it stays in the bootloader until explicitly told to exit.
Either:
- The command should omit `:leave` (so the device exits DFU and reboots), or
- The prose should be corrected to say the device remains in DFU mode and NVCurve sends a separate exit command / the watchdog handles reconnection from the DFU state.
### Minor: API Error Code
`POST /api/wireview/firmware/flash` returns `409` for both "refused" and "already running." `409 Conflict` fits "already running" well, but "refused" (e.g., downgrade without override, product mismatch) is more naturally a `400 Bad Request` or `422 Unprocessable Entity`. Not a bug, but worth noting if the API contract is being documented for the first time.
---
No other issues found. Markdown structure, headings, and formatting are correct.
---
### frontend/src/App.tsx
No issues found.
---
### frontend/src/api/client.ts
No issues found.
---
### frontend/src/components/WireView/WireViewPanel.tsx
## Review: `WireViewPanel.tsx`
**No critical bugs found.** The logic for fault clearing, firmware state management, and grid layout changes is correct. A few minor observations:
### Minor: Incomplete `useEffect` dependency
```tsx
useEffect(() => {
if (hasSample) refreshFirmware();
}, [hasSample]); // ← refreshFirmware missing
```
`refreshFirmware` is recreated every render (no `useCallback`), so `react-hooks/exhaustive-deps` would flag this. It's functionally safe here because the function body only references module-level `api` and stable `setState` setters, but the eslint-disable comment above only suppresses `react-hooks/set-state-in-effect`, not the exhaustive-deps rule. Either add `refreshFirmware` to the deps (and wrap it in `useCallback`), or add a second disable line.
### Minor: `flash.progress` could render "NaN%"
```tsx
<span className="font-mono">
{Math.round(flash.progress * 100)}%
</span>
```
If the backend ever sends `progress` as `null`/`undefined` before the first progress event (e.g., during the `"waiting"` state), this renders `NaN%`. A guard like `flash.progress ?? 0` would be defensive.
### Nit: Redundant ternary in `handleClear`
```tsx
await api.wireviewClearFault(
which === "status" ? 0x0000 : 0xffff,
which === "log" ? 0x0000 : 0xffff,
);
```
The two arguments are always the logical inverse of each other. A single expression would be clearer:
```tsx
const clear = 0x0000, keep = 0xffff;
const statusMask = which === "status" ? clear : keep;
const logMask = which === "status" ? keep : clear;
await api.wireviewClearFault(statusMask, logMask);
```
Not a bug—just easier to verify at a glance that the masks are complementary.
---
### frontend/src/hooks/useWireview.ts
No issues found.
---
### frontend/src/types.ts
## Review: `frontend/src/types.ts`
No issues found.
The types are well-structured and syntactically correct. One minor observation (not a bug):
- **Duplication between `WireViewWsMessage` firmware variant and `WireViewFlashProgress`**: The new `{ type: "firmware"; state; progress; status }` variant re-declares the same three fields that `WireViewFlashProgress` already defines, rather than reusing the interface (e.g. `flash: WireViewFlashProgress`). This is likely intentional for a flat WebSocket payload, but it creates a maintenance coupling—if `WireViewFlashProgress` gains a field, the message variant won't automatically track it. Consider a comment or a `Pick<WireViewFlashProgress, "state" | "progress" | "status">` to make the relationship explicit.
---
### nvcurve/firmware/TG-WV-PRO2-FW.hex
_Review for `nvcurve/firmware/TG-WV-PRO2-FW.hex`: LLM API error._
---
### nvcurve/server.py
## Review: `nvcurve/server.py`
### Bug: Race condition on flash state
In `api_wireview_firmware_flash`, the state is set to `"idle"` immediately before spawning the background task:
```python
fw.update(state="idle", progress=0.0, status="Starting…")
wv["flash_task"] = asyncio.create_task(_wireview_firmware_flash())
```
The task won't begin executing (and won't call `announce("bootloader", …)`) until the current coroutine yields. A second concurrent request arriving in that window will pass the guard:
```python
if fw["state"] not in ("idle", "done", "failed"):
raise HTTPException(status_code=409, …)
```
**Fix:** Set a non-idle state (e.g. `"bootloader"` or a dedicated `"starting"`) *before* creating the task, so the guard is effective immediately.
---
### Bug: Missing file-existence check before `read_firmware_info`
In `api_wireview_firmware_flash`:
```python
try:
image = await _run(read_firmware_info, bundled_firmware_path())
except FirmwareImageError as exc:
raise HTTPException(status_code=500, …) from exc
```
If the bundled image file does not exist on disk, `read_firmware_info` will raise `OSError`/`FileNotFoundError` (not `FirmwareImageError`), producing an unhandled 500 with a stack trace. The earlier `api_wireview_firmware` endpoint correctly guards with `if image_path.is_file()`. The same pattern should be applied here (or catch `OSError` as well).
---
### Minor: Redundant `device.info()` calls
Both `api_wireview_firmware` and `api_wireview_firmware_flash` call `device.info()` twice — once inside `_wireview_device_firmware` and once directly for `vendor_id`/`product_id`. This is a serial read on each call; consider returning the full info dict from the helper or caching it locally.
---
### Minor: Temp file leak on hard crash
`bin_path` is cleaned up in `finally`, but if the process is killed (`SIGKILL`) between `write_bytes` and `unlink`, the file persists in `/tmp`. Low severity, but a startup-time cleanup of stale `nvcurve-wireview-fw-*.bin` files would be a nice safety net.
---
### nvcurve/wireview.py
## Review: `nvcurve/wireview.py`
### ⚠️ Potential Issue: `0xF1` Command Collision
```python
CMD_BOOTLOADER = 0xF1
...
SCREEN_RESUME_UPDATES = 0xF1
```
Both constants share the same byte value. The comment clarifies they live in different command namespaces (top-level vs. screen subcommand), so this is **not a bug**, but it's a maintenance hazard — a future reader or refactoring could easily conflate them. Consider adding a brief comment on `SCREEN_RESUME_UPDATES` noting the overlap, or renaming one for clarity.
### ✅ Everything else looks clean
- **Locking**: `RLock` correctly serializes all port access. `clear_faults` and `enter_bootloader` both route through `_transaction` → `_transaction_unlocked`, so they're protected. The `self.close()` call in `enter_bootloader` is outside the lock, but since `_transaction_unlocked` already closes the serial port internally, `close()` is just resetting `_connected` — no race.
- **`clear_faults`**: `& 0xFFFF` masks are defensive and correct. `response_size=0` matches the documented "no reply" protocol.
- **`enter_bootloader`**: Correctly closes the port after sending the command, since the device re-enumerates as a DFU device.
- **Hwmon stubs**: `clear_faults` / `enter_bootloader` returning `False` with explanatory docstrings is consistent with the interface contract.
- **Identity dict**: `vendor_id` / `product_id` added to both serial and hwmon variants — consistent.
No syntax errors, no logic bugs, no security concerns.
---
### nvcurve/wireview_firmware.py
## Review: `nvcurve/wireview_firmware.py`
### Potential Stderr Pipe Deadlock
In `DfuUtilFlasher.flash`, stderr is piped but not drained until *after* `proc.wait()`:
```python
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
# ...
reader = threading.Thread(target=_read_stdout, daemon=True) # drains stdout only
reader.start()
proc.wait(timeout=timeout_s) # blocks here
stderr = proc.stderr.read() # stderr drained only now
```
If dfu-util ever writes more than the OS pipe buffer (~64 KB on Linux) to stderr, the child process blocks on `write(2)`, `proc.wait()` hangs until the timeout fires, and the flash is reported as failed despite possibly having succeeded. In practice dfu-util's stderr output during a flash is a few lines at most, so this is low-probability — but it's a latent correctness bug. A second reader thread (or `select`-based loop) for stderr would eliminate the risk.
### Performance: Character-by-Character Pipe Read
`_read_stdout` calls `proc.stdout.read(1)` in a loop, issuing one `read(2)` syscall per character. For a typical flash session this is a few thousand syscalls. A chunked read (e.g. `read(256)`) with a small internal buffer for the current line would reduce this by orders of magnitude with no functional change:
```python
def _read_stdout() -> None:
buf = ""
while True:
chunk = proc.stdout.read(256)
if not chunk:
break
buf += chunk
while "\r" in buf or "\n" in buf:
# split on \r or \n, process the completed line, keep remainder
...
```
### Minor: Inconsistent Field-Check Order in `read_firmware_info`
The method validates `VERSION_OFFSET` before `VENDOR_ID_OFFSET` / `PRODUCT_ID_OFFSET`, but the dataclass fields are ordered vendor → product → version. If only the version byte is missing, the error says "version byte not found" before the vendor/product check even runs — which is fine functionally, but the reversed order relative to the dataclass definition is slightly confusing when reading the code.
---
No syntax errors, security issues (subprocess uses list args, no shell injection), or logic bugs in the HEX parser, compatibility verdicts, or build-timestamp parsing were found.
---
### tests/test_wireview.py
No issues found.
---
### tests/test_wireview_firmware.py
## Review: `tests/test_wireview_firmware.py`
### Significant Issue
**Tests don't fail under pytest** — The `check()` function only prints and increments counters; it never raises an exception. The docstring claims "Also works under pytest," but pytest will report every `test_*` function as **passed** regardless of how many individual `check()` calls fail. The `main()` function (which returns a non-zero exit code on failure) is never invoked by pytest.
```python
def check(name: str, cond: bool) -> None:
global PASS, FAIL
if cond:
PASS += 1
print(f" PASS {name}")
else:
FAIL += 1
print(f" FAIL {name}") # ← no assertion raised
```
**Fix**: Add an assertion that only fires under pytest (or always):
```python
import pytest
def check(name: str, cond: bool) -> None:
global PASS, FAIL
if cond:
PASS += 1
print(f" PASS {name}")
else:
FAIL += 1
print(f" FAIL {name}")
pytest.fail(name) # raises under pytest; standalone run is unaffected
```
Or, if the intent is truly standalone-only, correct the docstring to "collectible by pytest but failures are only visible in stdout."
---
### Minor Observations
| Location | Note |
|----------|------|
| `test_enter_bootloader` | No explicit synchronization between thread start and `dev.connect()`. It works in practice because the blocking PTY read implicitly waits for the thread, but a `threading.Event` set after the first `os.read` would make the intent clearer and guard against subtle scheduling issues on loaded CI. |
| `test_dfu_flash` — progress check | `progress == [0.0, 0.25, 0.5, 1.0]` depends on the parser emitting exactly one callback per percentage line. If the implementation ever coalesces or skips (e.g., a `0%` line that's considered "start"), this will be a brittle assertion. Consider `assert progress[-1] == 1.0` plus a length check. |
| `test_hex_parser` — bad-checksum corruption | The logic `bad[:-2] + ("00" if bad[-2:] != "00" else "01")` is correct but slightly hard to read. A comment or `assert bad[-2:] != "00"` before the mutation would make the intent self-documenting. |
No syntax errors, typos, or security issues found.
---
⚠️ *1 file(s) had review errors and may not have been fully reviewed.*
- server.py: claim the flash (state=bootloader) before spawning the task so
the concurrent-request guard is effective immediately; guard the bundled
image existence in the flash endpoint; single device.info() call per
endpoint; 400 for refused flashes (409 stays for already-running);
remove stale nvcurve-wireview-fw-*.bin temp files at startup
- wireview_firmware.py: drain stderr in its own reader thread (a full pipe
buffer would have hung the flash until timeout); chunked stdout reads
instead of per-character read(2); BuildStruct field checks in dataclass
order
- wireview.py: document the intentional 0xF1 overlap between CMD_BOOTLOADER
and SCREEN_RESUME_UPDATES (different command namespaces)
- tests: check() now fails loudly under pytest (optional import, standalone
runs unaffected); explicit reader-thread sync in test_enter_bootloader;
less brittle flash-progress assertion; self-documenting checksum
corruption in test_hex_parser
- frontend: refreshFirmware in useCallback + effect deps; NaN% guard on
flash.progress; explicit clear/keep masks in handleClear; WS firmware
message reuses WireViewFlashProgress via Pick
- docs: clarify that the dfu-util :leave modifier is what makes the device
exit the bootloader and reboot; document the 400 vs 409 API contract;
README now mentions per-pin readings, pin-imbalance gauge and fault
clearing
Flash state race — fixed: the endpoint claims the flash (state="bootloader") beforecreate_task, so the guard is effective immediately.
Missing file check — added an explicit is_file() guard with a clear 500 (the parser already raised FirmwareImageError for a missing file; this makes it explicit).
Tests can't fail under pytest — check() now calls pytest.fail(name); pytest is an optional import, so the standalone run still works.
stderr pipe deadlock — stderr is drained in its own reader thread (joined on the timeout path too).
:leave — the docs were correct: the dfu-util man page defines :leave as "ask the device to leave DFU mode". Prose now says exactly that.
409 vs 400 — refused flashes now return 400; 409 stays for "already running"; documented.
Nits — all done: refreshFirmware in useCallback + effect deps; flash.progress ?? 0 guard; explicit clear/keep masks; WS message via Pick<WireViewFlashProgress, …>; single device.info() per endpoint; stale temp .bin cleanup at startup; 0xF1 overlap comment; chunked stdout reads; BuildStruct checks in dataclass order; threading.Event sync in test_enter_bootloader; monotonicity-based progress assertion; self-documenting checksum corruption; README mentions per-pin readings, pin-imbalance gauge and fault clearing.
Verified: make test (67 checks), tsc --noEmit, eslint, vitest and the production build all clean.
Thanks for the review — addressed in `6e87dcf`:
1. Flash state race — fixed: the endpoint claims the flash (`state="bootloader"`) *before* `create_task`, so the guard is effective immediately.
2. Missing file check — added an explicit `is_file()` guard with a clear 500 (the parser already raised `FirmwareImageError` for a missing file; this makes it explicit).
3. Tests can't fail under pytest — `check()` now calls `pytest.fail(name)`; pytest is an optional import, so the standalone run still works.
4. stderr pipe deadlock — stderr is drained in its own reader thread (joined on the timeout path too).
5. `:leave` — the docs were correct: the dfu-util man page defines `:leave` as "ask the device to leave DFU mode". Prose now says exactly that.
6. 409 vs 400 — refused flashes now return `400`; `409` stays for "already running"; documented.
Nits — all done: `refreshFirmware` in `useCallback` + effect deps; `flash.progress ?? 0` guard; explicit clear/keep masks; WS message via `Pick<WireViewFlashProgress, …>`; single `device.info()` per endpoint; stale temp `.bin` cleanup at startup; `0xF1` overlap comment; chunked stdout reads; BuildStruct checks in dataclass order; `threading.Event` sync in `test_enter_bootloader`; monotonicity-based progress assertion; self-documenting checksum corruption; README mentions per-pin readings, pin-imbalance gauge and fault clearing.
Verified: `make test` (67 checks), `tsc --noEmit`, `eslint`, `vitest` and the production build all clean.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Three WireView tab improvements:
Per-File Review Summary
This PR was large (14 files reviewed). Each file was reviewed individually.
Makefile
No issues found.
README.md
No issues found.
The Markdown is well-formed, the link and code formatting are correct, and there are no typos. One minor observation: the README update mentions the firmware check/DFU feature but does not reference the other two features in this PR (fault clearing, pin-imbalance gauge). This is a completeness gap rather than a bug, but worth considering if the README aims to summarize all WireView capabilities.
docs/WireView.md
Review:
docs/WireView.mdPotential Logic Contradiction
The flash procedure states:
However, the
dfu-utilcommand uses the:leavesuffix:In
dfu-util, the:leavesuffix on-smeans "leave the device in DFU mode" (i.e., do not send the leave/exit-DFU command). If the device is left in DFU mode, it will not reboot on its own — it stays in the bootloader until explicitly told to exit.Either:
:leave(so the device exits DFU and reboots), orMinor: API Error Code
POST /api/wireview/firmware/flashreturns409for both "refused" and "already running."409 Conflictfits "already running" well, but "refused" (e.g., downgrade without override, product mismatch) is more naturally a400 Bad Requestor422 Unprocessable Entity. Not a bug, but worth noting if the API contract is being documented for the first time.No other issues found. Markdown structure, headings, and formatting are correct.
frontend/src/App.tsx
No issues found.
frontend/src/api/client.ts
No issues found.
frontend/src/components/WireView/WireViewPanel.tsx
Review:
WireViewPanel.tsxNo critical bugs found. The logic for fault clearing, firmware state management, and grid layout changes is correct. A few minor observations:
Minor: Incomplete
useEffectdependencyrefreshFirmwareis recreated every render (nouseCallback), soreact-hooks/exhaustive-depswould flag this. It's functionally safe here because the function body only references module-levelapiand stablesetStatesetters, but the eslint-disable comment above only suppressesreact-hooks/set-state-in-effect, not the exhaustive-deps rule. Either addrefreshFirmwareto the deps (and wrap it inuseCallback), or add a second disable line.Minor:
flash.progresscould render "NaN%"If the backend ever sends
progressasnull/undefinedbefore the first progress event (e.g., during the"waiting"state), this rendersNaN%. A guard likeflash.progress ?? 0would be defensive.Nit: Redundant ternary in
handleClearThe two arguments are always the logical inverse of each other. A single expression would be clearer:
Not a bug—just easier to verify at a glance that the masks are complementary.
frontend/src/hooks/useWireview.ts
No issues found.
frontend/src/types.ts
Review:
frontend/src/types.tsNo issues found.
The types are well-structured and syntactically correct. One minor observation (not a bug):
WireViewWsMessagefirmware variant andWireViewFlashProgress: The new{ type: "firmware"; state; progress; status }variant re-declares the same three fields thatWireViewFlashProgressalready defines, rather than reusing the interface (e.g.flash: WireViewFlashProgress). This is likely intentional for a flat WebSocket payload, but it creates a maintenance coupling—ifWireViewFlashProgressgains a field, the message variant won't automatically track it. Consider a comment or aPick<WireViewFlashProgress, "state" | "progress" | "status">to make the relationship explicit.nvcurve/firmware/TG-WV-PRO2-FW.hex
Review for
nvcurve/firmware/TG-WV-PRO2-FW.hex: LLM API error.nvcurve/server.py
Review:
nvcurve/server.pyBug: Race condition on flash state
In
api_wireview_firmware_flash, the state is set to"idle"immediately before spawning the background task:The task won't begin executing (and won't call
announce("bootloader", …)) until the current coroutine yields. A second concurrent request arriving in that window will pass the guard:Fix: Set a non-idle state (e.g.
"bootloader"or a dedicated"starting") before creating the task, so the guard is effective immediately.Bug: Missing file-existence check before
read_firmware_infoIn
api_wireview_firmware_flash:If the bundled image file does not exist on disk,
read_firmware_infowill raiseOSError/FileNotFoundError(notFirmwareImageError), producing an unhandled 500 with a stack trace. The earlierapi_wireview_firmwareendpoint correctly guards withif image_path.is_file(). The same pattern should be applied here (or catchOSErroras well).Minor: Redundant
device.info()callsBoth
api_wireview_firmwareandapi_wireview_firmware_flashcalldevice.info()twice — once inside_wireview_device_firmwareand once directly forvendor_id/product_id. This is a serial read on each call; consider returning the full info dict from the helper or caching it locally.Minor: Temp file leak on hard crash
bin_pathis cleaned up infinally, but if the process is killed (SIGKILL) betweenwrite_bytesandunlink, the file persists in/tmp. Low severity, but a startup-time cleanup of stalenvcurve-wireview-fw-*.binfiles would be a nice safety net.nvcurve/wireview.py
Review:
nvcurve/wireview.py⚠️ Potential Issue:
0xF1Command CollisionBoth constants share the same byte value. The comment clarifies they live in different command namespaces (top-level vs. screen subcommand), so this is not a bug, but it's a maintenance hazard — a future reader or refactoring could easily conflate them. Consider adding a brief comment on
SCREEN_RESUME_UPDATESnoting the overlap, or renaming one for clarity.✅ Everything else looks clean
RLockcorrectly serializes all port access.clear_faultsandenter_bootloaderboth route through_transaction→_transaction_unlocked, so they're protected. Theself.close()call inenter_bootloaderis outside the lock, but since_transaction_unlockedalready closes the serial port internally,close()is just resetting_connected— no race.clear_faults:& 0xFFFFmasks are defensive and correct.response_size=0matches the documented "no reply" protocol.enter_bootloader: Correctly closes the port after sending the command, since the device re-enumerates as a DFU device.clear_faults/enter_bootloaderreturningFalsewith explanatory docstrings is consistent with the interface contract.vendor_id/product_idadded to both serial and hwmon variants — consistent.No syntax errors, no logic bugs, no security concerns.
nvcurve/wireview_firmware.py
Review:
nvcurve/wireview_firmware.pyPotential Stderr Pipe Deadlock
In
DfuUtilFlasher.flash, stderr is piped but not drained until afterproc.wait():If dfu-util ever writes more than the OS pipe buffer (~64 KB on Linux) to stderr, the child process blocks on
write(2),proc.wait()hangs until the timeout fires, and the flash is reported as failed despite possibly having succeeded. In practice dfu-util's stderr output during a flash is a few lines at most, so this is low-probability — but it's a latent correctness bug. A second reader thread (orselect-based loop) for stderr would eliminate the risk.Performance: Character-by-Character Pipe Read
_read_stdoutcallsproc.stdout.read(1)in a loop, issuing oneread(2)syscall per character. For a typical flash session this is a few thousand syscalls. A chunked read (e.g.read(256)) with a small internal buffer for the current line would reduce this by orders of magnitude with no functional change:Minor: Inconsistent Field-Check Order in
read_firmware_infoThe method validates
VERSION_OFFSETbeforeVENDOR_ID_OFFSET/PRODUCT_ID_OFFSET, but the dataclass fields are ordered vendor → product → version. If only the version byte is missing, the error says "version byte not found" before the vendor/product check even runs — which is fine functionally, but the reversed order relative to the dataclass definition is slightly confusing when reading the code.No syntax errors, security issues (subprocess uses list args, no shell injection), or logic bugs in the HEX parser, compatibility verdicts, or build-timestamp parsing were found.
tests/test_wireview.py
No issues found.
tests/test_wireview_firmware.py
Review:
tests/test_wireview_firmware.pySignificant Issue
Tests don't fail under pytest — The
check()function only prints and increments counters; it never raises an exception. The docstring claims "Also works under pytest," but pytest will report everytest_*function as passed regardless of how many individualcheck()calls fail. Themain()function (which returns a non-zero exit code on failure) is never invoked by pytest.Fix: Add an assertion that only fires under pytest (or always):
Or, if the intent is truly standalone-only, correct the docstring to "collectible by pytest but failures are only visible in stdout."
Minor Observations
test_enter_bootloaderdev.connect(). It works in practice because the blocking PTY read implicitly waits for the thread, but athreading.Eventset after the firstos.readwould make the intent clearer and guard against subtle scheduling issues on loaded CI.test_dfu_flash— progress checkprogress == [0.0, 0.25, 0.5, 1.0]depends on the parser emitting exactly one callback per percentage line. If the implementation ever coalesces or skips (e.g., a0%line that's considered "start"), this will be a brittle assertion. Considerassert progress[-1] == 1.0plus a length check.test_hex_parser— bad-checksum corruptionbad[:-2] + ("00" if bad[-2:] != "00" else "01")is correct but slightly hard to read. A comment orassert bad[-2:] != "00"before the mutation would make the intent self-documenting.No syntax errors, typos, or security issues found.
⚠️ 1 file(s) had review errors and may not have been fully reviewed.
Thanks for the review — addressed in
6e87dcf:state="bootloader") beforecreate_task, so the guard is effective immediately.is_file()guard with a clear 500 (the parser already raisedFirmwareImageErrorfor a missing file; this makes it explicit).check()now callspytest.fail(name); pytest is an optional import, so the standalone run still works.:leave— the docs were correct: the dfu-util man page defines:leaveas "ask the device to leave DFU mode". Prose now says exactly that.400;409stays for "already running"; documented.Nits — all done:
refreshFirmwareinuseCallback+ effect deps;flash.progress ?? 0guard; explicit clear/keep masks; WS message viaPick<WireViewFlashProgress, …>; singledevice.info()per endpoint; stale temp.bincleanup at startup;0xF1overlap comment; chunked stdout reads; BuildStruct checks in dataclass order;threading.Eventsync intest_enter_bootloader; monotonicity-based progress assertion; self-documenting checksum corruption; README mentions per-pin readings, pin-imbalance gauge and fault clearing.Verified:
make test(67 checks),tsc --noEmit,eslint,vitestand the production build all clean.