Prompt when serial devices share USB identifiers#1326
Conversation
|
@RCGV1 is attempting to deploy a commit to the Meshtastic Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthrough
ChangesSerial port selection
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/core/connections/transports.ts`:
- Around line 182-183: Update the allowPrompt branch in transports.ts to pass
the saved usbVendorId and usbProductId to serial.requestPort via its filters
option. In transports.test.ts, update the serial picker assertion to verify
requestPort receives the corresponding VID/PID filter.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 287fd0f1-bcac-4dd3-8da3-d7b849561026
📒 Files selected for processing (2)
apps/web/src/core/connections/transports.test.tsapps/web/src/core/connections/transports.ts
| if (opts.allowPrompt) { | ||
| port = await serial.requestPort({}); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## transports.ts\n'
sed -n '1,260p' apps/web/src/core/connections/transports.ts
printf '\n## transports.test.ts\n'
sed -n '1,220p' apps/web/src/core/connections/transports.test.ts
printf '\n## search for requestPort usage\n'
rg -n "requestPort\\(" apps/web/src/core/connections -SRepository: meshtastic/web
Length of output: 10620
Pass the saved VID/PID into the serial picker.
requestPort({}) can surface unrelated devices here; pass filters: [{ usbVendorId, usbProductId }] and assert that argument in the serial test.
📍 Affects 2 files
apps/web/src/core/connections/transports.ts#L182-L183(this comment)apps/web/src/core/connections/transports.test.ts#L46-L49
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@apps/web/src/core/connections/transports.ts` around lines 182 - 183, Update
the allowPrompt branch in transports.ts to pass the saved usbVendorId and
usbProductId to serial.requestPort via its filters option. In
transports.test.ts, update the serial picker assertion to verify requestPort
receives the corresponding VID/PID filter.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Summary
Root cause
The transport used
find()and silently selected the first authorized match. Multiple Meshtastic boards can expose identical USB vendor/product identifiers, so a saved connection could attach to the wrong physical node.Impact
Users with multiple identical boards are prompted to select the intended device instead of being connected to an arbitrary match.
Validation
NODE_OPTIONS=--no-experimental-webstorage pnpm vitest run apps/web/src/core/connections/transports.test.ts: 1 test passed.pnpm --filter meshtastic-web build: passed.pnpm lint: passed with existing warnings.git diff --check: passed.E2E (real device): passed in 1m48s.Notes
Summary by CodeRabbit
Bug Fixes
Tests