fix: Make sure wired devices are listed before wireless ones#189
fix: Make sure wired devices are listed before wireless ones#189mykola-mokhnach merged 4 commits intomainfrom
Conversation
| function wirelessRank<T extends { Properties: { ConnectionType: string } }>( | ||
| device: T, | ||
| ): number { | ||
| return device.Properties.ConnectionType === 'Network' ? 1 : 0; |
There was a problem hiding this comment.
Btw, could we add type for ConnectionType with Network or USB (instead of string)?
There was a problem hiding this comment.
this would be a breaking change. also, it might become confusing if Apple eventually decides to add some other value there.
There was a problem hiding this comment.
Pull request overview
Ensures Usbmux.listDevices() prioritizes wired (USB) devices over wireless (Network) entries when the same UDID appears multiple times, preventing Wi‑Fi rows from being returned first.
Changes:
- Added
prioritizeUsbOverNetworkForDuplicateUdidsutility to reorder duplicate-UDID entries while preserving overall interleaving. - Applied the new ordering in
Usbmux.listDevices(). - Expanded unit tests to cover duplicate-UDID ordering scenarios and simplified Chai setup.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/lib/usbmux/utils.ts |
Introduces stable per-UDID reordering to prefer USB over Network for duplicate UDIDs. |
src/lib/usbmux/index.ts |
Applies the new prioritization to the device list returned by listDevices(). |
test/unit/usbmux/usbmux-specs.ts |
Adds unit tests validating ordering behavior for duplicate UDIDs and interleaving cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * Reorders **in place across the original indices** for each UDID (no pulling one | ||
| * UDID into a contiguous block). Among equal rank, input order is kept (stable). |
There was a problem hiding this comment.
The docstring says "Reorders in place" but the implementation clones the input array (const result = [...devices]) and returns a new array without mutating devices. Consider clarifying the wording (e.g., "reorders within the original indices" and explicitly stating it is non-mutating) to avoid misleading callers.
| * Reorders **in place across the original indices** for each UDID (no pulling one | |
| * UDID into a contiguous block). Among equal rank, input order is kept (stable). | |
| * Returns a reordered copy across the original indices for each UDID (no pulling | |
| * one UDID into a contiguous block). Among equal rank, input order is kept | |
| * (stable). Does not mutate `devices`. |
## [0.44.2](v0.44.1...v0.44.2) (2026-04-13) ### Bug Fixes * Make sure wired devices are listed before wireless ones ([#189](#189)) ([852655e](852655e))
|
🎉 This PR is included in version 0.44.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.