Skip to content

🆕 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

Merged
merged 5 commits into from
Jul 31, 2025

Conversation

haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Jul 30, 2025

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a "CLI-only mode" option, allowing users to restrict the interface to command-line interaction.
    • Added a new "Development Settings" section in the options menu, grouping advanced configuration options.
  • Improvements

    • Relocated the "Show All Serial Devices" option into the new "Development Settings" section for better organization.
    • Enhanced connection behavior to support CLI-only mode and adjusted reboot dialog display based on active tabs.
  • Localization

    • Added new English messages for "Development Settings" and "CLI-only mode" options.

Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Walkthrough

This 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

Cohort / File(s) Change Summary
Localization Updates
locales/en/messages.json
Added three new localized message entries for "developmentSettings" and "cliOnlyMode" with descriptions; no removals or modifications to existing entries.
Backend Logic for CLI-only Mode
src/js/serial_backend.js
Added isCliOnlyMode() helper and modified serial backend functions to support CLI-only mode by skipping standard UI and feature initialization, changing auto-connect conditions, and adjusting reboot dialog behavior.
Options Initialization
src/js/tabs/options.js
Added initCLiOnlyMode method to initialize and handle CLI-only mode checkbox state and config synchronization; integrated into main options initialization.
Options UI Structure
src/tabs/options.html
Created new "developmentSettings" section containing "showAllSerialDevices" and new "cliOnlyMode" checkbox; reorganized options layout accordingly.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Suggested reviewers

  • nerdCopter

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 95f958e and 60d0261.

📒 Files selected for processing (4)
  • locales/en/messages.json (1 hunks)
  • src/js/serial_backend.js (6 hunks)
  • src/js/tabs/options.js (2 hunks)
  • src/tabs/options.html (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/tabs/options.html
  • src/js/tabs/options.js
  • src/js/serial_backend.js
  • locales/en/messages.json
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 clarity

Recommend 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 around cliOnlyMode 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 be initCliOnlyMode 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c51874 and 7cd518e.

📒 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

@nerdCopter
Copy link
Member

i enabled it, but all the tabs are still accessible and still interact/save

@haslinghuis
Copy link
Member Author

It's for 4.6 only ?

@nerdCopter
Copy link
Member

It's for 4.6 only ?

apologies, i did in fact have 4.5 flashed. flashed 4.6 and :
(but i question why only 4.6+?)
image

@haslinghuis haslinghuis changed the title Add CLI Only Mode as development option 🆕 Add CLI Only Mode as development option Jul 31, 2025
Copy link

Copy link
Contributor

Preview URL: https://60d0261f.betaflight-configurator.pages.dev

@haslinghuis haslinghuis merged commit dd628c7 into betaflight:master Jul 31, 2025
8 checks passed
@haslinghuis haslinghuis deleted the cli-only-option branch July 31, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants