Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 24, 2025

Fixes a bug where the return altitude input field was hidden when GPS rescue failsafe was configured for "fixed altitude" mode on initial page load. Users had to manually change the altitude mode to another option and back to "fixed altitude" to make the field visible.

Problem

The issue occurred in src/js/tabs/failsafe.js where the showReturnAlt() function was called before the altitude mode select element was populated with the saved configuration value:

// Bug: showReturnAlt() called before select value is set
function showReturnAlt() {
    let altitude_number_field = $('input[name="gps_rescue_return_altitude"]').closest(".number");
    if ($("#failsafeGpsRescueItemAltitudeSelect").val() === "1") {
        altitude_number_field.show();
    } else {
        altitude_number_field.hide();
    }
}
showReturnAlt(); // Called when select still has default value "0"
// ... other code ...
$('select[name="gps_rescue_altitude_mode"]').val(FC.GPS_RESCUE.altitudeMode); // Set to "1" too late

This caused the function to check the select's default value ("0" - Max Altitude) instead of the actual saved configuration ("1" - Fixed Altitude), incorrectly hiding the field.

Solution

Moved the showReturnAlt() function call to occur after the altitude mode select value is populated from the saved configuration:

function showReturnAlt() { /* ... */ }
$("#failsafeGpsRescueItemAltitudeSelect").on("change", showReturnAlt);
// ... other code ...
$('select[name="gps_rescue_altitude_mode"]').val(FC.GPS_RESCUE.altitudeMode);

// Call showReturnAlt after the altitude mode value is set
showReturnAlt(); // Now called with correct value "1"

Changes

  • File: src/js/tabs/failsafe.js
  • Lines modified: 3 (minimal surgical change)
  • Moved showReturnAlt() call from line 326 to after line 333
  • Added explanatory comment

Testing

Created a test scenario that demonstrates the fix:

Test Results

The test shows that with the fix, when GPS rescue is configured for "Fixed Altitude" mode, the return altitude field is correctly visible on first load.

Impact

  • ✅ Users with GPS rescue set to "fixed altitude" will see the return altitude field immediately
  • ✅ No manual mode switching required to reveal the field
  • ✅ Dynamic show/hide behavior for mode changes remains unchanged
  • ✅ No impact on other altitude modes (Max/Current altitude)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • repo.huaweicloud.com
    • Triggering command: node /usr/local/bin/yarn install (dns block)
    • Triggering command: npm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


Additional instructions:

fix bug. it is probably the the existing if-then gating for the .show and .hide .

Fixes #4628


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@sonarqubecloud
Copy link

Copilot AI changed the title [WIP] failsafe bug for "fixed altitude" mode Fix failsafe bug: Show return altitude field for fixed altitude mode on first load Sep 24, 2025
Copilot AI requested a review from nerdCopter September 24, 2025 13:37
Copilot finished work on behalf of nerdCopter September 24, 2025 13:37
@nerdCopter
Copy link
Member

@denis-sher , please test

@github-actions
Copy link
Contributor

Preview URL: https://pr4629.betaflight-app.pages.dev

@nerdCopter nerdCopter marked this pull request as ready for review September 24, 2025 13:50
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

@denis-sher
Copy link

denis-sher commented Sep 24, 2025

@nerdCopter , working correct now in Preview URL: https://pr4629.betaflight-app.pages.dev/
,Thank you

@haslinghuis haslinghuis moved this to App in 2025.12.0 Sep 24, 2025
@haslinghuis haslinghuis added this to the 2025.12 milestone Sep 24, 2025
@haslinghuis haslinghuis merged commit 9b8da64 into master Sep 25, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from App to Done in 2025.12.0 Sep 25, 2025
@haslinghuis haslinghuis deleted the copilot/fix-8989d697-5489-4c0e-a6a0-77de8c6a4e44 branch September 25, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

failsafe bug for "fixed altitude" mode

6 participants