Skip to content

fix: confirm before saving derived param changes#1247

Closed
ryanbasic1 wants to merge 5 commits intoArduPilot:masterfrom
ryanbasic1:master
Closed

fix: confirm before saving derived param changes#1247
ryanbasic1 wants to merge 5 commits intoArduPilot:masterfrom
ryanbasic1:master

Conversation

@ryanbasic1
Copy link

Title :

Confirm before saving derived parameter changes

Summary

Prevents file writes from occurring without user awareness when derived parameters are recalculated.
Adds an optional confirmation callback to control disk write operations.
Prompts are shown only when derived values have actually changed.

Why

Automatic parameter corrections were creating saved changes to derived parameters without user approval.
This update ensures user consent before modifying .param files and prevents unintended writes.

How it works

Derived parameters are calculated during the update_and_export_vehicle_params_from_fc process.

When a file contains a derived value that has changed, the system calls ask_user_confirmation(title, message).

The user must confirm before the system writes the file.

If the user declines, the file is not created or modified.

If no confirmation callback is provided, the system continues operating with its existing behavior.

Copilot AI review requested due to automatic review settings February 3, 2026 19:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds user confirmation before saving automatically recalculated derived parameter changes to disk. Previously, the application would silently update parameter files when derived parameters were recalculated, which could lead to unexpected file modifications. This change ensures users are aware of and approve these modifications before they are persisted.

Changes:

  • Adds a new ask_yesno_message dialog function following the established pattern for user interaction
  • Introduces an optional ask_user_confirmation callback parameter to update_and_export_vehicle_params_from_fc
  • Implements tracking and conditional prompting for derived parameter changes during parameter export

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ardupilot_methodic_configurator/frontend_tkinter_show.py Adds ask_yesno_message function for yes/no confirmation dialogs, consistent with existing error and warning message functions
ardupilot_methodic_configurator/backend_filesystem.py Adds derived parameter change tracking and optional user confirmation before file export, allowing users to decline saving derived parameter changes
ardupilot_methodic_configurator/main.py Passes ask_yesno_message as the confirmation callback to ensure users are prompted when derived parameters change

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Collaborator

@amilcarlucas amilcarlucas left a comment

Choose a reason for hiding this comment

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

Thanks, this looks really clean.

eval_variables = self.get_eval_variables()
# the eval variables do not contain fc_parameter values
# and that is intentional, the fc_parameters are not to be used in here
derived_changed_by_file: dict[str, bool] = {}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We fully process one file after the other. I think there is no need for this dict.

derived_changed: bool = false

should be enough

Copy link
Author

Choose a reason for hiding this comment

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

That makes sense, thanks.
I’ll replace it with a boolean flag.

@amilcarlucas
Copy link
Collaborator

replaced by #1262

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants