Skip to content

feat(cpn): refactor handling of erroneous models#7377

Open
elecpower wants to merge 2 commits into
mainfrom
elecpower/cpn-alt-inv-mdls-handling
Open

feat(cpn): refactor handling of erroneous models#7377
elecpower wants to merge 2 commits into
mainfrom
elecpower/cpn-alt-inv-mdls-handling

Conversation

@elecpower
Copy link
Copy Markdown
Collaborator

@elecpower elecpower commented May 18, 2026

Fixes #6153

Summary of changes:

  • reenable menus, toolbars and context menus even when model errors
  • display detailed model errors dialogs when attempt to run a process that prohibits erroneous data and abort the process
  • double clicking status bar model error icon displays detailed errors for all models
  • allow individual error free models to be simulated

Summary by CodeRabbit

  • Bug Fixes

    • Added model validation checks before writing settings and running simulations; operations now abort with detailed error reports if models are invalid.
  • New Features

    • Status bar errors are now interactive (double-click to display details).
    • Expanded error reporting in pre-operation dialogs with comprehensive model error lists.

Review Change Stack

@elecpower elecpower added this to the 3.0 milestone May 18, 2026
@elecpower elecpower added companion Related to the companion software bug/regression ↩️ A new version of EdgeTX broke something backport/2.12 To be backported to a 2.12 release also. labels May 18, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

The PR restructures error handling across Companion by aggregating model validation errors and shifting from disabling user actions to enabling them while validating before execution. Error details are now displayed interactively in the status bar and in contextual dialogs during simulation and write operations.

Changes

Model error handling and interactive validation

Layer / File(s) Summary
Error aggregation data structures
companion/src/firmwares/modeldata.cpp, companion/src/firmwares/radiodata.h, companion/src/firmwares/radiodata.cpp
ModelData initializes error lists with a leading separator; RadioData collects errors from all invalid models into a consolidated list.
Status bar interactive error display widget
companion/src/mdichild.h, companion/src/mdichild.cpp
StatusBarIcon subclass adds doubleClicked signal and mouse handler; MdiChild changes invalidModels() to return count and adds modelErrorsList() accessor; status bar shows conditional icon with double-click handler to display aggregated model errors.
Simulation action enable-and-validate pattern
companion/src/mdichild.cpp, companion/src/modeledit/modeledit.cpp
Radio and model simulate actions enable regardless of model validity; radioSimulate() and modelSimulate() validate before execution and show error dialogs if invalid; ModelEdit.launchSimulation() performs model validity check before starting simulation.
Write settings SD path validation
companion/src/mainwindow.cpp, companion/src/mdichild.cpp
MainWindow.updateMenus() enables write actions without model checks; writeSettingsSDPath() validates models before proceeding and displays error dialog with aggregated error list if models are invalid, blocking the SD write operation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed Description provides the linked issue, lists key changes, but lacks depth on implementation details and rationale.
Linked Issues check ✅ Passed Changes address issue #6153 by re-enabling write menus/toolbars and adding validation dialogs with detailed error reporting.
Out of Scope Changes check ✅ Passed All changes focus on improving error handling and UI responsiveness for erroneous models as defined in the linked issue.
Title check ✅ Passed The title 'feat(cpn): refactor handling of erroneous models' accurately reflects the main change—refactoring how the system handles models with validation errors, including enabling menus, showing error dialogs, and allowing individual valid models to run.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch elecpower/cpn-alt-inv-mdls-handling

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

Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@companion/src/firmwares/modeldata.cpp`:
- Line 2131: The QStringList named "list" is being pre-seeded with an empty
string (QStringList list { "" }), which causes leading blank entries in error
dialogs; change the initialization to create an empty QStringList (e.g.,
QStringList list or QStringList list{}), and leave separator/blank insertion to
the caller or explicit push_back calls where needed so no implicit blank entry
appears in aggregated outputs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a7c8b1c-c90b-428e-acfe-f0abe58e67ec

📥 Commits

Reviewing files that changed from the base of the PR and between 00d7544 and 63b9751.

📒 Files selected for processing (7)
  • companion/src/firmwares/modeldata.cpp
  • companion/src/firmwares/radiodata.cpp
  • companion/src/firmwares/radiodata.h
  • companion/src/mainwindow.cpp
  • companion/src/mdichild.cpp
  • companion/src/mdichild.h
  • companion/src/modeledit/modeledit.cpp

QStringList ModelData::errorsList()
{
QStringList list;
QStringList list { "" };
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove the pre-seeded blank entry from error lists.

At Line 2131, initializing with "" causes leading blank lines in model error dialogs and extra spacing in aggregated output. Start with an empty list and let the caller add separators if needed.

Suggested patch
-QStringList ModelData::errorsList()
-{
-  QStringList list { "" };
+QStringList ModelData::errorsList()
+{
+  QStringList list;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
QStringList list { "" };
QStringList list;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@companion/src/firmwares/modeldata.cpp` at line 2131, The QStringList named
"list" is being pre-seeded with an empty string (QStringList list { "" }), which
causes leading blank entries in error dialogs; change the initialization to
create an empty QStringList (e.g., QStringList list or QStringList list{}), and
leave separator/blank insertion to the caller or explicit push_back calls where
needed so no implicit blank entry appears in aggregated outputs.

@elecpower elecpower added enhancement ✨ New feature or request and removed bug/regression ↩️ A new version of EdgeTX broke something labels May 19, 2026
@elecpower elecpower changed the title fix(cpn): refactor handling of erroneous models feat(cpn): refactor handling of erroneous models May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. companion Related to the companion software enhancement ✨ New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.11.0 RC4 "Write Models and Settings to Radio" disabled in Companion

1 participant