fix(setup): camera wizard UX follow-ups from #262 review (#263) - #268
fix(setup): camera wizard UX follow-ups from #262 review (#263)#268Adityakk9031 wants to merge 1 commit into
Conversation
jeqcho
left a comment
There was a problem hiding this comment.
Thanks @Adityakk9031 — this lands all three follow-ups from #263 cleanly, and the physical-identity duplicate check in particular is exactly the shape the issue hoped for: mapping both sides through _CameraNode.camera with a resolved-path fallback is robust, and the by-id-vs-by-path duplicate test genuinely exercises it (it fails on main, as a good regression test should). The in-place clear()/extend() rebuild after u is also the right call, since the row lists are shared by reference across slots.
Two things I'd like addressed before merge, plus a couple of optional notes:
-
test_camera_view_state_suppresses_toggle_when_rows_are_identicaldoesn't exercise the new code (tests/test_setup.py, ~line 3819). Its inventory record hasby_idset and a unique serial, so the pre-existing inventory branch already returnsadvertise_path_toggle=False— the test passes without this PR's change. To cover the new suppression line, use a record withby_id=None(and a by-path name): the old code advertises the toggle for it, both views then render the identical by-path row, and the newby_id_rows == by_path_rowsguard is what flips it toFalse. -
Reprint the active listing when the post-
urescan changes the rows (src/inspect_robots/_setup.py, ~lines 567-575). The numbered listing is printed once at section start; after a replug re-rolls udev links, the rebuilt rows can diverge from what's on screen, so a number typed at a later slot silently selects a different device than the one displayed — the very race this change is meant to close. A cheap guard: capture the old active rows, and if they differ after the rebuild, call_print_camera_listingfor the active view.
Optional, non-blocking:
- A small test for the rescan path (scripted
uwith arescan_inventorythat returns changed rows, asserting the row lists were rebuilt) would protect item 2 of the issue, which currently has no coverage. advertise_path_toggleisn't recomputed after the rescan, so a replug that changes by-id availability leaves thepadvertisement stale for later slots — fine to defer, just noting it.- Tiny style nit:
physical_idis re-defined on every loop iteration and thekind == "v4l2" and inventoryguard appears twice; hoisting the helper above the loop would tidy this.
Also a heads-up that the branch conflicts with main (the _duplicated_serials → _ambiguous_identities refactor touched _camera_view_state), so the rebase will need a little care in exactly the function this PR edits.
Thanks again — with the test fixed and the listing reprint added, this is good to go.
Closes #263.
Addresses three non-blocking camera UX follow-ups deferred from the #262 review:
_CameraNode.camera/ sysfs USB device directory or canonical resolved node) before comparing, catching duplicates acrossby-idandby-pathaliases.by_id_devicesandby_path_devicesafter a successfuluunplug-to-identify flow, clearing stale rows.pprompt whenby_id_rows == by_path_rows.Verification
ruff check .— All checks passed.ruff format --check .— All 123 files formatted.pytest tests/test_setup.py— 113 passed, 43 skipped (gated on POSIX/symlinks).