Skip to content

Conversation

@haslinghuis
Copy link
Member

@haslinghuis haslinghuis commented Nov 21, 2025

Preparing for other protocols

  • Allows for re-using existing code paths
  • Use protocols based on platform with fallback to PWA.
  • Android plugin mentioned in the code is not yet provided.

Summary by CodeRabbit

  • New Features

    • Platform-aware protocol selection on Android (uses native serial support) and always includes a virtual protocol.
  • Improvements

    • Consolidated compatibility checks into a single API for clearer device support detection.
    • Standardized device and protocol names (bluetooth, serial, tcp, virtual) for consistent UI and device handling.

✏️ Tip: You can customize this high-level summary in your review settings.

@haslinghuis haslinghuis added this to the 2026.6 milestone Nov 21, 2025
@haslinghuis haslinghuis self-assigned this Nov 21, 2025
@haslinghuis haslinghuis moved this to App in 2026.6.0 Nov 21, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 21, 2025

Walkthrough

This PR consolidates compatibility checks into a single checkCompatibility API, renames capability checks (checkWebSerialSupportcheckSerialSupport, etc.), and standardizes device/protocol identifiers from "webbluetooth"/"webserial"/"websocket" to "bluetooth"/"serial"/"tcp". It also adds Android-aware protocol initialization in serial.js.

Changes

Cohort / File(s) Summary
Compatibility utility
src/js/utils/checkCompatibility.js
Replaced previous checkBrowserCompatibility module: added checkCompatibility, renamed checkWebSerialSupportcheckSerialSupport, checkWebBluetoothSupportcheckBluetoothSupport, checkWebUSBSupportcheckUsbSupport; removed isCapacitorWeb; refactored internal naming/logging and boolean checks.
Port handling updates
src/js/port_handler.js
Switched imports to new compatibility API; call checkCompatibility(); derive showBluetoothOption/showSerialOption/showUsbOption from renamed checks; standardized deviceType values to "bluetooth", "serial", and "usb" for discovery, permission requests, add/remove events, and port-list updates.
GUI import update
src/js/gui.js
Updated import path: ./utils/checkBrowserCompatibility./utils/checkCompatibility and adjusted imported names (e.g., getOS import path change).
Serial/protocol changes
src/js/serial.js
Platform-aware protocol initialization: on Android use Capacitor-backed "serial" only; on non-Android expose "serial", "bluetooth", "tcp"; always append "virtual". Renamed protocol identifiers and updated selectProtocol/getDevices to use "serial", "bluetooth", "tcp", "virtual". Added isAndroid import from compatibility utils.

Sequence Diagram(s)

sequenceDiagram
    participant UI as GUI / User
    participant PH as PortHandler
    participant COMP as checkCompatibility
    participant DEV as Device APIs (Serial / Bluetooth / USB)

    UI->>PH: initialize / refresh ports
    PH->>COMP: checkCompatibility()
    COMP-->>PH: {serial:true, bluetooth:true, usb:false}
    PH->>DEV: discover devices (types per capability)
    DEV-->>PH: device list (bluetooth/serial/usb)
    PH-->>UI: updateDeviceList (standardized types: "bluetooth","serial","usb")
    note right of PH: Permission requests use deviceType "bluetooth"/"serial"/"usb"
Loading
sequenceDiagram
    participant Serial as SerialManager
    participant COMP as checkCompatibility

    Serial->>COMP: isAndroid()
    alt Android
        Serial->>Serial: init protocols = ["serial", "virtual"] (CapacitorSerial)
    else Non-Android
        Serial->>Serial: init protocols = ["serial","bluetooth","tcp","virtual"]
    end
    Serial-->>Caller: protocol list exposed (names: serial, bluetooth, tcp, virtual)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas to focus on:
    • Consistency of renamed deviceType strings ("bluetooth"/"serial"/"usb") across all event handlers and state updates in src/js/port_handler.js
    • Correct import and usage of the new checkCompatibility, checkBluetoothSupport, checkSerialSupport, checkUsbSupport APIs
    • Android branching in src/js/serial.js (CapacitorSerial wiring, protocol ordering, and selectProtocol resolution)
    • Any impacted logging/error messages and tests that may rely on old naming

Possibly related PRs

Suggested reviewers

  • nerdCopter
  • VitroidFPV
  • blckmn

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 2 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title "Update compatibility check" is partially related to the changeset but lacks specificity. While the changes do update compatibility checks, the title is somewhat vague and doesn't capture the significant refactoring of device type naming and protocol consolidation that are core aspects of this PR. Consider a more descriptive title that captures the main refactoring, such as "Refactor compatibility checks and standardize device type naming" or "Consolidate compatibility checks and update protocol nomenclature."
Description check ❓ Inconclusive The PR description is minimal and lacks detail about the scope of changes. While it mentions preparing for other protocols and platform-based fallbacks, it does not explain the significant changes to compatibility check naming, device type terminology, or the refactoring across multiple files. Expand the description to explain the key changes: renaming compatibility functions, updating device type constants (webbluetooth→bluetooth, webserial→serial), consolidating checks, and the platform-dependent protocol initialization logic.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • 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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/js/serial.js (1)

1-32: Missing import for CapacitorSerial causes runtime error on Android.

Line 22 references CapacitorSerial but it's never imported. This will cause a ReferenceError when the code runs on Android devices, breaking all serial functionality.

Add the missing import at the top of the file:

 import WebSerial from "./protocols/WebSerial.js";
 import WebBluetooth from "./protocols/WebBluetooth.js";
 import Websocket from "./protocols/WebSocket.js";
 import VirtualSerial from "./protocols/VirtualSerial.js";
+import CapacitorSerial from "./protocols/CapacitorSerial.js";
 import { isAndroid } from "./utils/checkCompatibility.js";
🧹 Nitpick comments (1)
src/js/utils/checkCompatibility.js (1)

128-163: Capability checks work but could use clarifying comments.

The implementation correctly handles platform-specific capabilities. However, there's a subtle semantic difference:

  • checkSerialSupport() returns true for Android because native CapacitorSerial is available (even though Web Serial API is not)
  • checkBluetoothSupport() and checkUsbSupport() return false for Android because native Capacitor implementations aren't ready yet

Consider adding brief comments explaining this distinction to help future maintainers understand why serial returns true while bluetooth/USB return false on Android.

Apply this diff to add clarifying comments:

 export function checkSerialSupport() {
     let result = false;
     if (isAndroid()) {
+        // Android uses native CapacitorSerial, not Web Serial API
         result = true;
     } else if (navigator.serial) {
         result = true;
     } else if (isIOS()) {
         // Not implemented yet
     }
 
     return result;
 }
 
 export function checkBluetoothSupport() {
     let result = false;
     if (isAndroid()) {
-        // Not implemented yet
+        // Native Capacitor Bluetooth not implemented yet
     } else if (navigator.bluetooth) {
         result = true;
     } else if (isIOS()) {
         // Not implemented yet
     }
     return result;
 }
 
 export function checkUsbSupport() {
     let result = false;
     if (isAndroid()) {
-        // Not implemented yet
+        // Native Capacitor USB not implemented yet
     } else if (navigator.usb) {
         result = true;
     } else if (isIOS()) {
         // Not implemented yet
     }
     return result;
 }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 399afa3 and 8855354.

📒 Files selected for processing (4)
  • src/js/gui.js (1 hunks)
  • src/js/port_handler.js (10 hunks)
  • src/js/serial.js (4 hunks)
  • src/js/utils/checkCompatibility.js (5 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4579
File: src/js/data_storage.js:9-9
Timestamp: 2025-08-27T22:07:26.353Z
Learning: In the betaflight-configurator CalVer refactoring, the generateVirtualApiVersions function in src/js/utils/common.js works correctly despite the apparent mathematical issue with bounds logic where compareVersions.minor() returns different ranges for API_VERSION_MAX_SUPPORTED (25.12.0) vs API_VERSION_ACCEPTED (1.44.0).
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4510
File: src/js/msp.js:384-391
Timestamp: 2025-09-19T20:41:44.286Z
Learning: When fixing MSP duplicate handling in Betaflight Configurator, avoid complex changes to callback resolution mechanisms as they can break tab switching functionality. Simple duplicate detection based on code and payload size is safer than complex requestKey-based approaches.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4597
File: src/js/utils/common.js:95-127
Timestamp: 2025-09-09T20:02:33.475Z
Learning: In the Betaflight Configurator codebase, the Chromium v140 compatibility issue with sortSelect was resolved by rewriting the implementation to use native DOM APIs (Array.from, select.options, select.remove, select.add) instead of jQuery DOM manipulation methods (this.children, this.empty().append). The fix still performs DOM operations but avoids the specific jQuery methods that were causing issues in Chromium v140.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4708
File: locales/en/messages.json:7721-7729
Timestamp: 2025-11-20T20:26:40.313Z
Learning: Betaflight Configurator – Firmware Flasher grouping semantics:
- "Verified/Partner": targets with verified schematics and tested prototypes (known working).
- "Unsupported": vendor/community-supplied targets that did not go through the verification program.
- "Legacy": legacy targets kept for existing users.
These labels surface in src/js/tabs/firmware_flasher.js via i18n keys:
firmwareFlasherOptionLabelVerifiedPartner, firmwareFlasherOptionLabelVendorCommunity, firmwareFlasherOptionLabelLegacy. Only English text should be updated directly in locales/en/messages.json; other locales are managed externally.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4510
File: src/js/msp.js:384-391
Timestamp: 2025-09-19T20:42:20.332Z
Learning: Complex MSP duplicate handling fixes in Betaflight Configurator can cause infinite loading messages when changing tabs due to disruption of the callback resolution mechanism. Simple code-only duplicate detection (using this.callbacks.some((instance) => instance.code === code)) is the safer approach that preserves tab switching functionality.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator 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
Repo: betaflight/betaflight-configurator 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
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:51:09.253Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported for BLE devices and Web USB API is supported, but Web Serial API is not supported (except limited Bluetooth serial support added in 2025). The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.
Learnt from: blckmn
Repo: betaflight/betaflight-configurator 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: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:39:16.388Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported from version 133+ (requires Android 6.0+) and Web USB API is supported from version 136+, but Web Serial API is not supported. The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4379
File: src/js/protocols/TauriSerial.js:203-259
Timestamp: 2025-10-25T21:16:32.474Z
Learning: In TauriSerial (src/js/protocols/TauriSerial.js), the requestPermissionDevice() method is not needed and not invoked. Tauri automatically discovers serial devices through the constructor's loadDevices() and startDeviceMonitoring() calls, bypassing the browser permission model that WebSerial requires. Devices are auto-detected via a 1-second polling interval without user permission prompts.
📚 Learning: 2025-05-14T21:51:09.253Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:51:09.253Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported for BLE devices and Web USB API is supported, but Web Serial API is not supported (except limited Bluetooth serial support added in 2025). The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.

Applied to files:

  • src/js/utils/checkCompatibility.js
  • src/js/serial.js
  • src/js/port_handler.js
📚 Learning: 2025-05-14T21:39:16.388Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:39:16.388Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported from version 133+ (requires Android 6.0+) and Web USB API is supported from version 136+, but Web Serial API is not supported. The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.

Applied to files:

  • src/js/utils/checkCompatibility.js
  • src/js/serial.js
  • src/js/port_handler.js
📚 Learning: 2025-10-25T21:16:32.474Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4379
File: src/js/protocols/TauriSerial.js:203-259
Timestamp: 2025-10-25T21:16:32.474Z
Learning: In TauriSerial (src/js/protocols/TauriSerial.js), the requestPermissionDevice() method is not needed and not invoked. Tauri automatically discovers serial devices through the constructor's loadDevices() and startDeviceMonitoring() calls, bypassing the browser permission model that WebSerial requires. Devices are auto-detected via a 1-second polling interval without user permission prompts.

Applied to files:

  • src/js/utils/checkCompatibility.js
  • src/js/serial.js
  • src/js/port_handler.js
📚 Learning: 2025-11-19T17:55:51.714Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4708
File: src/js/tabs/firmware_flasher.js:0-0
Timestamp: 2025-11-19T17:55:51.714Z
Learning: In the betaflight-configurator project, only current Chrome and Edge-based browsers are officially supported, and users are expected to keep their browsers up-to-date for security reasons. This means ES2023 features like Array.prototype.toSorted() and Object.groupBy() can be safely used without polyfills or transpilation.

Applied to files:

  • src/js/utils/checkCompatibility.js
📚 Learning: 2025-06-19T22:13:09.136Z
Learnt from: blckmn
Repo: betaflight/betaflight-configurator 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.

Applied to files:

  • src/js/utils/checkCompatibility.js
  • src/js/serial.js
  • src/js/port_handler.js
📚 Learning: 2025-06-09T00:32:21.385Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 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.

Applied to files:

  • src/js/serial.js
  • src/js/port_handler.js
📚 Learning: 2025-08-22T16:43:20.901Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4576
File: src/js/port_usage.js:17-23
Timestamp: 2025-08-22T16:43:20.901Z
Learning: In betaflight-configurator, the serial facade architecture requires accessing metrics like bitrate, bytesReceived, and bytesSent from serial._protocol rather than the top-level serial object. This change maintains compatibility with existing port utilization calculations that have been stable for over 11 years.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-06-09T00:33:22.959Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-06-09T00:33:22.959Z
Learning: In the betaflight-configurator codebase, port paths use counter suffixes for serial and bluetooth ports (e.g., "serial1", "serial2", "bluetooth1", "bluetooth2") instead of using connectionId, which means simple string matching against protocol map keys won't work for protocol selection.

Applied to files:

  • src/js/serial.js
  • src/js/port_handler.js
🧬 Code graph analysis (2)
src/js/serial.js (1)
src/js/utils/checkCompatibility.js (1)
  • isAndroid (42-47)
src/js/port_handler.js (4)
src/js/utils/checkCompatibility.js (4)
  • checkCompatibility (56-126)
  • checkBluetoothSupport (141-151)
  • checkSerialSupport (128-139)
  • checkUsbSupport (153-163)
src/components/eventBus.js (2)
  • EventBus (3-8)
  • EventBus (3-8)
src/js/serial.js (2)
  • serial (224-224)
  • serial (224-224)
src/js/protocols/webusbdfu.js (1)
  • WEBUSBDFU (1279-1279)
🔇 Additional comments (7)
src/js/gui.js (1)

6-6: LGTM!

Import path update aligns with the PR's consolidation of compatibility checks into a unified API.

src/js/utils/checkCompatibility.js (2)

7-8: Good defensive programming.

Using globalThis.navigator prevents potential ReferenceErrors in non-browser environments like tests or SSR contexts.


56-126: Well-structured consolidation of compatibility checks.

The new checkCompatibility() function provides a clear, unified entry point for browser capability verification. The logic correctly requires either a test environment, native platform, or Chromium with at least one working API.

src/js/serial.js (2)

81-96: Protocol selection logic correctly updated.

The mapping from port paths to protocol names now uses the standardized naming ("serial", "bluetooth") instead of the old "webserial"/"webbluetooth" convention. The logic preserves correct behavior with counter-prefixed paths like "bluetooth1", "bluetooth2".


150-154: Documentation updated to match new naming convention.

The JSDoc correctly reflects the renamed protocol types, improving API documentation clarity.

src/js/port_handler.js (2)

1-50: Clean migration to unified compatibility API.

The import updates and initialization correctly use the new checkCompatibility() function and individual capability checks to set feature flags. This aligns well with the PR's goal of consolidating compatibility logic.


53-348: Comprehensive and consistent device type naming standardization.

All references to device types have been systematically updated from "webbluetooth"/"webserial" to "bluetooth"/"serial". The changes are thorough and maintain functional equivalence while improving naming consistency across the codebase.

Copy link
Member

@nerdCopter nerdCopter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • pre-approving for workflow
  • need to locate my OTG for actual testing

@sonarqubecloud
Copy link

@github-actions
Copy link
Contributor

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/js/serial.js (2)

5-32: Android branch will throw if CapacitorSerial is not defined

On Android, isAndroid() will be true in a Capacitor-native build, and the constructor will execute new CapacitorSerial(). Because CapacitorSerial is neither imported nor guarded, this will raise a ReferenceError as soon as Serial is instantiated, which matches the PR note that the Android plugin is not yet provided.

Consider either importing the implementation once it exists or guarding the branch so current Android builds don’t hard-crash:

-        if (isAndroid()) {
-            this._protocols = [{ name: "serial", instance: new CapacitorSerial() }];
-        } else {
+        if (isAndroid() && typeof CapacitorSerial !== "undefined") {
+            this._protocols = [{ name: "serial", instance: new CapacitorSerial() }];
+        } else {
             this._protocols = [
                 { name: "serial", instance: new WebSerial() },
                 { name: "bluetooth", instance: new WebBluetooth() },
                 { name: "tcp", instance: new Websocket() },
             ];
         }

If you intend Android builds to remain unusable until the plugin lands, it would still be good to fail with an explicit error/logging message rather than an uninformative ReferenceError.


151-175: JSDoc-implementation mismatch in getDevices and requestPermissionDevice—optional fallback behavior not implemented

The verification confirms the review's concern: the JSDoc documents getDevices(protocolType = null) as optional with a fallback to current protocol, but the implementation returns an empty array with a warning when protocolType is null.

Current findings:

  • Registered protocols: "serial", "bluetooth", "tcp" (plus "virtual" is referenced but never registered at line 87)
  • Call sites in port_handler.js use explicit protocol names and always succeed
  • No legacy names (webserial, webbluetooth, websocket) are currently used in the codebase, so there is no breaking change from name migration
  • However, the JSDoc-implementation contract is violated: the documented optional parameter and fallback behavior are not provided

The suggested fix in the review (supporting legacy names and implementing the documented fallback) is reasonable for API consistency, though not required by current call sites.

Additionally, there's an orphaned check for "virtual" protocol at line 87 that references a protocol never registered in _protocols.

🧹 Nitpick comments (1)
src/js/serial.js (1)

81-96: Protocol selection logic aligns with naming, but undefined protocol on Android should be confirmed

The updated selectProtocol correctly:

  • Treats functions / "virtual" as virtual ports.
  • Routes "manual" and tcp/ws/wss URLs to the protocol named "tcp".
  • Routes paths starting with "bluetooth" to the "bluetooth" protocol, which matches the existing "bluetooth1", "bluetooth2" prefix convention. Based on learnings.

On Android, _protocols only contains "serial" (CapacitorSerial) and "virtual", so any "tcp" or "bluetooth" lookup will return undefined. connect() then throws when calling .connect on undefined, which is caught and surfaces only as a generic error.

If port paths like "bluetooth1" or tcp/ws URLs truly cannot be produced on the Android/Capacitor build, this is fine; otherwise, consider either:

  • Normalizing these paths earlier so they never reach selectProtocol on Android, or
  • Adding an explicit check and clearer error when a requested protocol type is not available on the current platform.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8855354 and 31f1fa1.

📒 Files selected for processing (1)
  • src/js/serial.js (4 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 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: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4510
File: src/js/msp.js:384-391
Timestamp: 2025-09-19T20:41:44.286Z
Learning: When fixing MSP duplicate handling in Betaflight Configurator, avoid complex changes to callback resolution mechanisms as they can break tab switching functionality. Simple duplicate detection based on code and payload size is safer than complex requestKey-based approaches.
Learnt from: blckmn
Repo: betaflight/betaflight-configurator 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: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:51:09.253Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported for BLE devices and Web USB API is supported, but Web Serial API is not supported (except limited Bluetooth serial support added in 2025). The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4379
File: src/js/protocols/TauriSerial.js:203-259
Timestamp: 2025-10-25T21:16:32.474Z
Learning: In TauriSerial (src/js/protocols/TauriSerial.js), the requestPermissionDevice() method is not needed and not invoked. Tauri automatically discovers serial devices through the constructor's loadDevices() and startDeviceMonitoring() calls, bypassing the browser permission model that WebSerial requires. Devices are auto-detected via a 1-second polling interval without user permission prompts.
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:39:16.388Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported from version 133+ (requires Android 6.0+) and Web USB API is supported from version 136+, but Web Serial API is not supported. The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.
📚 Learning: 2025-10-25T21:16:32.474Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4379
File: src/js/protocols/TauriSerial.js:203-259
Timestamp: 2025-10-25T21:16:32.474Z
Learning: In TauriSerial (src/js/protocols/TauriSerial.js), the requestPermissionDevice() method is not needed and not invoked. Tauri automatically discovers serial devices through the constructor's loadDevices() and startDeviceMonitoring() calls, bypassing the browser permission model that WebSerial requires. Devices are auto-detected via a 1-second polling interval without user permission prompts.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-06-19T22:13:09.136Z
Learnt from: blckmn
Repo: betaflight/betaflight-configurator 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.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-06-09T00:32:21.385Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 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.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-05-14T21:51:09.253Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:51:09.253Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported for BLE devices and Web USB API is supported, but Web Serial API is not supported (except limited Bluetooth serial support added in 2025). The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-08-22T16:43:20.901Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 4576
File: src/js/port_usage.js:17-23
Timestamp: 2025-08-22T16:43:20.901Z
Learning: In betaflight-configurator, the serial facade architecture requires accessing metrics like bitrate, bytesReceived, and bytesSent from serial._protocol rather than the top-level serial object. This change maintains compatibility with existing port utilization calculations that have been stable for over 11 years.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-05-14T21:39:16.388Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-05-14T21:39:16.388Z
Learning: On Android Chrome browsers, Web Bluetooth API is supported from version 133+ (requires Android 6.0+) and Web USB API is supported from version 136+, but Web Serial API is not supported. The Betaflight Configurator should detect and use available APIs on Android rather than requiring all three.

Applied to files:

  • src/js/serial.js
📚 Learning: 2025-06-09T00:33:22.959Z
Learnt from: haslinghuis
Repo: betaflight/betaflight-configurator PR: 0
File: :0-0
Timestamp: 2025-06-09T00:33:22.959Z
Learning: In the betaflight-configurator codebase, port paths use counter suffixes for serial and bluetooth ports (e.g., "serial1", "serial2", "bluetooth1", "bluetooth2") instead of using connectionId, which means simple string matching against protocol map keys won't work for protocol selection.

Applied to files:

  • src/js/serial.js
🧬 Code graph analysis (1)
src/js/serial.js (1)
src/js/utils/checkCompatibility.js (1)
  • isAndroid (42-47)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: App

Development

Successfully merging this pull request may close these issues.

3 participants