-
-
Notifications
You must be signed in to change notification settings - Fork 977
🆕 Add CLI Only Mode as development option #4559
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
Conversation
WalkthroughThis change introduces a new "CLI-only mode" option in the application's settings, including both UI and configuration logic. It updates the English localization file, reorganizes the options HTML to group development settings, adds initialization for the new setting, and modifies the backend logic to support the new mode based on API version and configuration. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant OptionsUI
participant Config
participant SerialBackend
User->>OptionsUI: Opens Options Tab
OptionsUI->>Config: Load config values
OptionsUI->>OptionsUI: Initialize CLI-only checkbox
User->>OptionsUI: Toggles CLI-only checkbox
OptionsUI->>Config: Update cliOnlyMode config
User->>SerialBackend: Connects to Flight Controller
SerialBackend->>Config: Read cliOnlyMode, API version
alt CLI-only mode enabled and API >= 1.47
SerialBackend->>SerialBackend: Call connectCli(), skip tab setup
else
SerialBackend->>SerialBackend: Usual tab and feature setup
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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 (3)
locales/en/messages.json (1)
164-167
: Minor wording/style polish for end-user clarityRecommend using a hyphen so “CLI-only” reads naturally and in line with conventional usage elsewhere in the app.
- "message": "Enable CLI only mode", + "message": "Enable CLI-only mode",src/tabs/options.html (1)
103-110
: Remove redundant nesting in development settings.The
developmentSettings
div wrapper aroundcliOnlyMode
appears unnecessary since both elements are already within the development settings section.- <div class="developmentSettings margin-bottom"> - <div class="cliOnlyMode margin-bottom"> - <div> - <input type="checkbox" class="toggle" /> - </div> - <span class="freelabel" i18n="cliOnlyMode"></span> - </div> - </div> + <div class="cliOnlyMode margin-bottom"> + <div> + <input type="checkbox" class="toggle" /> + </div> + <span class="freelabel" i18n="cliOnlyMode"></span> + </div>src/js/tabs/options.js (1)
265-274
: Fix inconsistent function naming.The function name
initCLiOnlyMode
uses inconsistent casing. It should beinitCliOnlyMode
to match the camelCase convention used throughout the codebase.-options.initCLiOnlyMode = function () { +options.initCliOnlyMode = function () {Also update the call site on Line 35:
- TABS.options.initCLiOnlyMode(); + TABS.options.initCliOnlyMode();
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
locales/en/messages.json
(1 hunks)src/js/serial_backend.js
(5 hunks)src/js/tabs/options.js
(2 hunks)src/tabs/options.html
(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
src/tabs/options.html (2)
Learnt from: mituritsyn
PR: #4526
File: src/js/gui.js:43-43
Timestamp: 2025-06-20T12:35:49.283Z
Learning: In the Betaflight Configurator codebase, tabs in defaultCloudBuildTabOptions
are conditionally displayed based on firmware build options. The logic in serial_backend.js
checks FC.CONFIG.buildOptions
and only adds tabs to GUI.allowedTabs
if the firmware was built with support for that feature.
Learnt from: haslinghuis
PR: #4485
File: src/js/sensor_types.js:96-99
Timestamp: 2025-05-24T15:12:50.241Z
Learning: In src/js/sensor_types.js, the sonar element selection UI is only displayed when firmware version >= API_VERSION_1_47, so sonar sensor types can be added directly to the static elements array without requiring additional version guards.
src/js/tabs/options.js (1)
Learnt from: mituritsyn
PR: #4526
File: src/js/gui.js:43-43
Timestamp: 2025-06-20T12:35:49.283Z
Learning: In the Betaflight Configurator codebase, tabs in defaultCloudBuildTabOptions
are conditionally displayed based on firmware build options. The logic in serial_backend.js
checks FC.CONFIG.buildOptions
and only adds tabs to GUI.allowedTabs
if the firmware was built with support for that feature.
locales/en/messages.json (1)
Learnt from: haslinghuis
PR: #4490
File: locales/en/messages.json:1534-1545
Timestamp: 2025-05-26T11:37:09.758Z
Learning: In the Betaflight Configurator repository, only English messages should be added directly to locales/en/messages.json
; other language translations are handled via Crowdin automation and should not be manually updated in PRs.
src/js/serial_backend.js (8)
Learnt from: mituritsyn
PR: #4526
File: src/js/gui.js:43-43
Timestamp: 2025-06-20T12:35:49.283Z
Learning: In the Betaflight Configurator codebase, tabs in defaultCloudBuildTabOptions
are conditionally displayed based on firmware build options. The logic in serial_backend.js
checks FC.CONFIG.buildOptions
and only adds tabs to GUI.allowedTabs
if the firmware was built with support for that feature.
Learnt from: haslinghuis
PR: #4532
File: src/js/VirtualFC.js:234-234
Timestamp: 2025-06-27T22:06:49.210Z
Learning: In the betaflight-configurator codebase, the VirtualFC.js AUX_CONFIG array must stay synchronized with the betaflight firmware's msp_box.c definitions to ensure proper auxiliary mode functionality. Changes to mode names should follow the firmware source code even if it potentially breaks backward compatibility with saved presets.
Learnt from: haslinghuis
PR: #4532
File: src/js/VirtualFC.js:234-234
Timestamp: 2025-06-27T22:06:49.210Z
Learning: In the betaflight-configurator codebase, the VirtualFC.js AUX_CONFIG array must stay synchronized with the betaflight firmware's msp_box.c definitions to ensure proper auxiliary mode functionality. Changes to mode names should follow the firmware source code even if it potentially breaks backward compatibility with saved presets.
Learnt from: haslinghuis
PR: #4485
File: src/js/sensor_types.js:96-99
Timestamp: 2025-05-24T15:12:50.241Z
Learning: In src/js/sensor_types.js, the sonar element selection UI is only displayed when firmware version >= API_VERSION_1_47, so sonar sensor types can be added directly to the static elements array without requiring additional version guards.
Learnt from: haslinghuis
PR: betaflight/betaflight-configurator#0
File: :0-0
Timestamp: 2025-06-09T00:32:21.385Z
Learning: In the betaflight-configurator codebase, port paths use counter prefixes (e.g., "bluetooth1", "bluetooth2", "serial1") rather than direct protocol identifiers. The protocol selection logic correctly uses portPath.startsWith("bluetooth")
to detect bluetooth ports regardless of the counter suffix, rather than direct string matching against protocol map keys.
Learnt from: blckmn
PR: #4521
File: src/js/protocols/WebSerial.js:148-151
Timestamp: 2025-06-19T22:13:09.136Z
Learning: In WebSerial.js, there's a timing issue where the cached this.ports
array doesn't immediately reflect newly permitted devices after requestPermissionDevice()
completes. The getDevices()
method needs to refresh the device list from the browser API to return accurate data immediately following a permission request and user acceptance.
Learnt from: DavidAnson
PR: #4450
File: src/js/tabs/setup.js:0-0
Timestamp: 2025-05-01T05:41:03.282Z
Learning: In the Betaflight Configurator, FC.CONFIG.buildKey is defaulted to an empty string when not present, making the length check (FC.CONFIG.buildKey.length === 32) safe without additional type checking.
Learnt from: haslinghuis
PR: #4379
File: src-tauri/tauri.conf.json:12-14
Timestamp: 2025-06-07T23:27:01.841Z
Learning: Betaflight Configurator only connects with local embedded devices (flight controllers), not external web resources, which affects the security threat model and CSP requirements.
🧬 Code Graph Analysis (1)
src/js/serial_backend.js (3)
src/js/fc.js (1)
FC
(130-993)src/js/data_storage.js (2)
API_VERSION_1_47
(5-5)API_VERSION_1_47
(5-5)src/js/gui.js (1)
GUI
(483-483)
🔇 Additional comments (7)
locales/en/messages.json (1)
156-159
: Looks good – new section key added correctly.Key and value structure match the existing JSON schema and follow the repository rule of touching English only.
Just double-check that the front-end code actually references"developmentSettings"
; an unused key will bloat the file.src/tabs/options.html (1)
91-112
: LGTM! Well-structured development settings section.The new development settings section follows the existing HTML patterns and properly groups related development options. Moving
showAllSerialDevices
into this section makes logical sense.src/js/tabs/options.js (1)
265-274
: LGTM! Proper option initialization pattern.The implementation correctly follows the established pattern for option initialization in this file, including proper config retrieval, event binding, and initial state setting.
src/js/serial_backend.js (4)
564-569
: LGTM! Proper CLI-only mode integration.The implementation correctly checks both API version compatibility and the configuration setting before enabling CLI-only mode. The early return after
connectCli()
properly bypasses the normal connection flow.
636-641
: Excellent comprehensive CLI-only mode detection.The
isCliOnlyMode
computation properly validates all necessary conditions:
- API version compatibility (>= 1.47)
- Configuration setting enabled
- Only CLI tab is allowed
- Single tab restriction
This ensures CLI-only mode is only active when all prerequisites are met.
642-661
: LGTM! Proper conditional UI initialization.The logic correctly skips feature, beeper, and UI initialization when in CLI-only mode while still showing the necessary UI elements for non-CLI-only connections. The conditional display of sensor status and dataflash elements is appropriate.
95-95
: Good maintenance: whitespace cleanup.The trailing whitespace removal is a nice touch for code cleanliness.
Also applies to: 531-531
i enabled it, but all the tabs are still accessible and still interact/save |
It's for 4.6 only ? |
95f958e
to
60d0261
Compare
|
Preview URL: https://60d0261f.betaflight-configurator.pages.dev |
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Improvements
Localization