-
-
Notifications
You must be signed in to change notification settings - Fork 322
fix(transport-bluetooth): server linux get_info when systemctl is disabled #23218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughThe changes modify Bluetooth adapter information retrieval in a Linux-specific context. A new helper function checks Bluetooth service status via systemctl, and the adapter info function now conditionally invokes bluetoothctl based on service availability. Error handling is restructured using a match statement that evaluates outcomes from bluetoothctl and hciconfig commands, prioritizing bluetoothctl results when available and falling back to hciconfig on failure. Platform-specific conditional compilation is added for Linux while maintaining existing macOS and Windows implementations. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/transport-bluetooth/src/server/methods/get_info.rs (2)
22-29: Good fix for the hang issue.The conditional execution of
bluetoothctlbased on service status effectively prevents the indefinite hang. The logic is clear and the error handling is appropriate.Minor suggestion: Consider making the error message more descriptive, e.g.,
"Bluetooth service is not running"instead of"Service disabled"for better clarity when debugging.
34-39: Consider simplifying the match arms.The match logic correctly prioritizes
bluetoothctloutput overhciconfigand handles all cases appropriately. However, lines 35-36 can be combined since both return the same value whenbluetoothctlsucceeds, regardless ofhciconfig's result.Optional simplification:
match (bluetoothctl, hciconfig) { - (Ok(info), Ok(_)) => Ok(info), - (Ok(info), Err(_)) => Ok(info), + (Ok(info), _) => Ok(info), (Err(_), Ok(info)) => Ok(String::from_utf8_lossy(&info.stdout).to_string()), (Err(error), Err(_)) => Err(error.into()), }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/transport-bluetooth/src/server/methods/get_info.rs(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: szymonlesisz
Repo: trezor/trezor-suite PR: 18224
File: packages/suite/src/actions/bluetooth/initBluetoothThunk.ts:19-35
Timestamp: 2025-04-09T09:15:31.193Z
Learning: The Bluetooth feature is being implemented incrementally across multiple PRs. The "TO BE DONE" comments in Bluetooth event handlers are intentional placeholders, with implementations planned for subsequent PRs after the core BluetoothProcess infrastructure is in place.
Learnt from: szymonlesisz
Repo: trezor/trezor-suite PR: 21135
File: packages/transport-bluetooth/src/server/platform/linux.rs:34-45
Timestamp: 2025-09-01T10:19:22.902Z
Learning: In the Linux Bluetooth implementation for Trezor Suite, both `connect_with_timeout` and `discover_services` functions automatically handle connecting to the peripheral if it's not already connected, so redundant connection calls are handled gracefully by the function implementations.
Learnt from: szymonlesisz
Repo: trezor/trezor-suite PR: 18126
File: packages/transport-bluetooth/src/server/methods/get_info.rs:33-33
Timestamp: 2025-04-07T18:10:35.860Z
Learning: For the trezor-bluetooth project, Windows-specific Bluetooth adapter information will be implemented using a Windows crate rather than PowerShell commands.
Learnt from: Lemonexe
Repo: trezor/trezor-suite PR: 17002
File: packages/suite/src/views/settings/SettingsDebug/Bluetooth.tsx:26-34
Timestamp: 2025-02-18T10:05:29.381Z
Learning: Error handling for Bluetooth operations in the Bluetooth settings component is planned for future implementation and should not be included in the initial implementation.
📚 Learning: 2025-04-07T18:10:35.860Z
Learnt from: szymonlesisz
Repo: trezor/trezor-suite PR: 18126
File: packages/transport-bluetooth/src/server/methods/get_info.rs:33-33
Timestamp: 2025-04-07T18:10:35.860Z
Learning: For the trezor-bluetooth project, Windows-specific Bluetooth adapter information will be implemented using a Windows crate rather than PowerShell commands.
Applied to files:
packages/transport-bluetooth/src/server/methods/get_info.rs
📚 Learning: 2025-07-22T10:14:40.261Z
Learnt from: szymonlesisz
Repo: trezor/trezor-suite PR: 20314
File: packages/transport-bluetooth/src/server/platform/linux.rs:1-37
Timestamp: 2025-07-22T10:14:40.261Z
Learning: In the btleplug Rust library on Linux with BlueZ backend, `peripheral.id()` returns the device path in the format "hciX/dev_..." which is suitable for constructing BlueZ D-Bus object paths, while `peripheral.address()` returns the Bluetooth address in the format "XX:XX:XX:XX:XX:XX".
Applied to files:
packages/transport-bluetooth/src/server/methods/get_info.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Linting and formatting
- GitHub Check: Other Checks
- GitHub Check: Check for new Circular Imports
- GitHub Check: Build libs for publishing
- GitHub Check: Unit Tests
- GitHub Check: Type Checking
- GitHub Check: build-app
- GitHub Check: build-web
🔇 Additional comments (1)
packages/transport-bluetooth/src/server/methods/get_info.rs (1)
9-18: Excellent approach to prevent the bluetoothctl hang.The helper function correctly checks if the bluetooth service is running before attempting to execute
bluetoothctl. Usingsystemctl is-active --quietwith the status check is the right approach, and theunwrap_or(false)properly handles cases where systemctl itself isn't available or fails.
Running
bluetoothctlhungs forever if system service is disabled causing suite loading/handshake issue.Steps to reproduce:
systemctl stop bluetoothbluetoothctl show🔍🖥️ Suite web test results: View in Currents
🔍🖥️ Suite desktop test results: View in Currents