Skip to content

Show USB serial ports first with two-line port selector - #371

Merged
knipknap merged 3 commits into
mainfrom
usb-first-port-selector
Aug 25, 2026
Merged

knipknap merged 3 commits into
mainfrom
usb-first-port-selector

Conversation

@knipknap

Copy link
Copy Markdown
Contributor

Summary

  • Sort serial ports so USB adapters (ttyUSB/ttyACM) come before hardware ports (ttyS*), both in SerialTransport.list_ports() and in the port dropdown, with natural ordering within each group (ttyUSB2 before ttyUSB10)
  • Add SerialTransport.list_port_info(), which provides device descriptions from pyserial metadata on regular systems, or from /dev/serial/by-id symlink names when running sandboxed (Snap), where pyserial cannot enumerate safely
  • Rework SerialPortAdapter into a two-line combo row mirroring the WCS selector: device path on the first line, dimmed USB description (e.g. CH340) on the second. The model holds raw device paths, so no label/value mapping is needed
  • A configured port that is not currently plugged in is pinned to the top of the list instead of being appended at the end

Test plan

  • New unit tests for USB detection, USB-first sorting, port info/descriptions (incl. Snap by-id parsing) — 21 transport tests pass
  • New UI tests for the adapter: ordering, value round-trip, pinning of unplugged configured ports, rescan behavior — 5 tests pass
  • pixi run lint clean (ruff, flake8, pyflakes, pyright)

Sort serial ports so USB adapters (ttyUSB/ttyACM) come before
hardware ports, both in SerialTransport.list_ports() and the
port dropdown. Add SerialTransport.list_port_info() providing
device descriptions from pyserial, or from /dev/serial/by-id
symlink names when running sandboxed.

Rework SerialPortAdapter into a two-line combo row mirroring the
WCS selector: device path plus a dimmed description line. A
configured port that is not currently plugged in is pinned to
the top of the list instead of being appended at the end.
is_usb_serial_port() treats every port as USB on non-POSIX systems,
so the new sorting and port info tests must pin os.name to posix
when exercising Linux-style /dev/tty* paths.
The adapter sorts via is_usb_serial_port(), which treats every port
as USB on non-POSIX platforms. Patch os.name alongside the port
scan so the Linux-style fixtures sort as expected on Windows.
@knipknap
knipknap merged commit 0f44321 into main Aug 25, 2026
29 checks passed
knipknap added a commit that referenced this pull request Aug 25, 2026
Show USB serial ports first with two-line port selector

This branch was previously deployed

1 inactive deployment
pypi — 5c889f92 Deployed Aug 23, 2026 by knipknap via Build and Publish Wheel #1757
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.

1 participant