Skip to content

Fix custom defines sometimes not applying in firmware flasher #4575

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 1 commit into from
Aug 21, 2025

Conversation

ggmaniack
Copy link
Contributor

@ggmaniack ggmaniack commented Aug 19, 2025

Custom defines were occasionally not applied because they were conditional based on the wrong Expert Mode checkbox (the one visible when Connected, not the one in Firmware Flasher).

Applied minimal fix to bring it in line with other places in firmware flasher that test for this checkbox.

Summary by CodeRabbit

  • Refactor
    • Optimized the Firmware Flasher’s expert mode handling by caching the UI state, reducing redundant lookups.
    • Improves responsiveness when expert mode is enabled, especially during Unstable release selection and applying custom options.
    • No changes to visible behavior or settings; users should experience slightly smoother interactions in the flasher workflow.

Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

Replaced a runtime jQuery selector for the expert mode checkbox with a cached reference (expertMode_e) in firmware_flasher.js. The conditional logic and subsequent request construction remain unchanged.

Changes

Cohort / File(s) Summary
Firmware Flasher JS
src/js/tabs/firmware_flasher.js
Swapped $('input[name="expertModeCheckbox"]') with cached expertMode_e in an expert-mode check before setting request.commit for Unstable releases; no other logic changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

Copy link
Contributor

Preview URL: https://95eabda7.betaflight-configurator.pages.dev

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 (1)
src/js/tabs/firmware_flasher.js (1)

992-1003: Harden commit assignment and sanitize customDefines in firmware_flasher.js

We should guard against empty commits and avoid pushing empty custom-define tokens. In src/js/tabs/firmware_flasher.js (around lines 992–1003), replace:

-                    if (expertMode_e.is(":checked")) {
-                        if (targetDetail.releaseType === "Unstable") {
-                            request.commit = $('select[name="commits"] option:selected').val();
-                        }
-
-                        $('input[name="customDefines"]')
-                            .val()
-                            .split(" ")
-                            .map((element) => element.trim())
-                            .forEach((v) => {
-                                request.options.push(v);
-                            });
-                    }
+                    if (expertMode_e.is(":checked")) {
+                        if (targetDetail.releaseType === "Unstable") {
+                            const commit = $('select[name="commits"] option:selected').val();
+                            if (commit) {
+                                request.commit = commit;
+                            }
+                        }
+
+                        const definesRaw = $('input[name="customDefines"]').val() || "";
+                        definesRaw
+                            .trim()
+                            .split(/\s+/)
+                            .filter(Boolean)
+                            .forEach((v) => {
+                                request.options.push(v);
+                            });
+                    }

Verification confirmed:

  • The .tab-firmware_flasher input.expert_mode checkbox exists (no stray legacy selectors).
  • coreBuildModeCheckbox is present in firmware_flasher.html.
  • Other expert-mode references live outside this context and are unaffected.
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0259c8a and 95eabda.

📒 Files selected for processing (1)
  • src/js/tabs/firmware_flasher.js (1 hunks)
🔇 Additional comments (1)
src/js/tabs/firmware_flasher.js (1)

991-991: Correct Expert Mode source used; fixes custom defines not applying

Switching to the Firmware Flasher’s expertMode_e checkbox resolves the earlier mismatch with the Connected-tab checkbox. This aligns with how Expert Mode is handled elsewhere in the flasher. Good catch.

@VitroidFPV VitroidFPV merged commit cfd6338 into betaflight:master Aug 21, 2025
7 checks passed
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