The address lane stops eating the columns worth reading
On a Mac the splash's DEVICE column was squeezed to the width of its own heading, and HARDWARE went with it. The lane sized itself to the longest target with no cap, and `_name_width` sizes DEVICE from whatever that leaves. On Windows and Linux the assumption held -- a MAC is 17 cells, /dev/ttyUSB0 is 12 -- so nothing ever pressed on it. macOS breaks it twice: CoreBluetooth reports no MAC at all but a per-machine 128-bit UUID, 36 cells of it, and even the ports run long (every Mac carries a /dev/cu.Bluetooth-Incoming-Port, which is 31). One of those took 36 of the 58 cells a row has, leaving DEVICE six. So the lane is capped and ellipsizes, which is what the name lane beside it has always done. The cut takes the **front**: what tells two targets apart is their tail -- usbmodem1101 from usbmodem1102, ttyUSB0 from ttyUSB1 -- while the head they share is boilerplate, and cutting the back would draw two different ports identically, which is the one thing a picker must never do. A CoreBluetooth UUID reads the same from either end, so the rule that is right for ports costs the platform that needed the cap nothing. That is also why this is not `menus.fit_cells`, whose ellipsis keeps the head. At 20 cells the cap is above every target the other platforms produce, so they are untouched by it and the change shows up only where something was wrong. DEVICE goes from 6 cells back to 18. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
730230461c
commit
1933d725b0
2 files changed
+79
-2
No files matched your search
@@ -1323,6 +1323,44 @@ def test_device_picker_builds_aligned_columns(tmp_path) -> None:
|
||||
assert device_rows[0].index("COM5") == device_rows[1].index("/dev/ttyUSB0")
|
||||
|
||||
|
||||
def test_device_picker_address_lane_gives_way_to_the_interesting_columns() -> None:
|
||||
"""A long target ellipsizes from the left instead of eating the DEVICE lane.
|
||||
|
||||
macOS is why: CoreBluetooth reports no MAC but a per-machine 36-cell UUID, and even
|
||||
its serial ports run long. Uncapped, one address sized the lane and ``_name_width``
|
||||
sized DEVICE from what was left — so the name shrank to the width of its own heading
|
||||
and took HARDWARE down with it. Cutting the *front* is what keeps the lane useful:
|
||||
what tells two targets apart is their tail.
|
||||
"""
|
||||
from rich.cells import cell_len
|
||||
|
||||
from meshterm.core.discovery import DiscoveredDevice
|
||||
from meshterm.ui.device_picker import _ADDRESS_MAX, _fit_target, _name_width
|
||||
|
||||
# Short targets are returned untouched, so Windows and Linux never notice the cap.
|
||||
for short in ("COM3", "/dev/ttyUSB0", "C6:B6:26:BC:7F:09", "/dev/cu.usbmodem1101"):
|
||||
assert _fit_target(short, _ADDRESS_MAX) == short
|
||||
|
||||
# A long one is cut at the head and fits the lane it was given.
|
||||
uuid = "12345678-1234-1234-1234-123456789ABC"
|
||||
fitted = _fit_target(uuid, _ADDRESS_MAX)
|
||||
assert cell_len(fitted) <= _ADDRESS_MAX
|
||||
assert fitted.startswith("…") and fitted.endswith("123456789ABC")
|
||||
|
||||
# THE property the cut direction exists for: sibling ports stay tellable apart.
|
||||
assert _fit_target("/dev/cu.usbmodem1101", 14) != _fit_target("/dev/cu.usbmodem1102", 14)
|
||||
|
||||
# And the lane the address was stealing comes back.
|
||||
devices = [
|
||||
DiscoveredDevice(transport="ble", address=uuid, name="MeshCore-Johnputer Wardriver"),
|
||||
DiscoveredDevice("/dev/cu.Bluetooth-Incoming-Port"),
|
||||
]
|
||||
uncapped = max(cell_len(d.target) for d in devices)
|
||||
assert _name_width(devices, {}, min(uncapped, _ADDRESS_MAX) + 4) > _name_width(
|
||||
devices, {}, uncapped + 4
|
||||
)
|
||||
|
||||
|
||||
def test_device_picker_names_and_sorts_known_devices(tmp_path) -> None:
|
||||
"""A confirmed device shows its node name (in white), sorts to the top, and marks type."""
|
||||
from meshterm.core.device_store import DeviceStore
|
||||
|
||||
Reference in new issue
Block a user