Skip to content

Fix OTA controller update status after firmware update (#749)#753

Open
EyJunge1 wants to merge 4 commits into
jniebuhr:masterfrom
EyJunge1:fix/749-ota-controller-status
Open

Fix OTA controller update status after firmware update (#749)#753
EyJunge1 wants to merge 4 commits into
jniebuhr:masterfrom
EyJunge1:fix/749-ota-controller-status

Conversation

@EyJunge1

@EyJunge1 EyJunge1 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes [Bug] system update web screen wrong behavior #749: System Update screen no longer shows a controller update prompt for the version already installed
  • Syncs the cached OTA controller version with the live SystemInfo version before computing controllerUpdateAvailable

Test plan

  • pio run -e display
  • Verify controller version is correct and no update prompt appears when already on latest version

Summary by CodeRabbit

  • Bug Fixes

    • Removed a duplicated OTA settings field in the Web UI response.
    • Prevented unnecessary controller version resync by updating the Web UI only when the controller version changes.
  • Refactor

    • Simplified the OTA status refresh workflow: controller version is cached and reused, JSON response assembly is cleaned up, and both periodic and post-OTA refreshes follow the same streamlined update flow.

@cla-bot

cla-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have yours on file. In order for us to review and merge your code, please contact @jniebuhr (mdwasp) on Discord to get yourself added.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b7c7bf4d-c30c-4aa7-a487-32f2eb7817e4

📥 Commits

Reviewing files that changed from the base of the PR and between 8c25002 and 506c84b.

📒 Files selected for processing (2)
  • src/display/plugins/WebUIPlugin.cpp
  • src/display/plugins/WebUIPlugin.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/display/plugins/WebUIPlugin.cpp

📝 Walkthrough

Walkthrough

WebUIPlugin::updateOTAStatus no longer accepts a version param: it reads controller->getSystemInfo().version once, syncs it to the OTA instance when changed (tracking lastSyncedControllerVersion), and reuses that cached value in the res:ota-settings WebSocket response. Call sites were updated to the parameterless call.

Changes

OTA Status Version Caching

Layer / File(s) Summary
API: declaration and state field
src/display/plugins/WebUIPlugin.h
Removed version parameter from updateOTAStatus() declaration and added String lastSyncedControllerVersion = "" member.
Core: updateOTAStatus implementation and JSON response
src/display/plugins/WebUIPlugin.cpp
Cache controller->getSystemInfo().version into controllerVersion, conditionally call ota->setControllerVersion(controllerVersion) when it differs from lastSyncedControllerVersion, use the cached value for the controllerVersion JSON field, and remove a duplicate latestVersion assignment.
Call sites: periodic and settings-triggered refresh
src/display/plugins/WebUIPlugin.cpp
Updated WebUIPlugin::loop and OTA settings update path to call updateOTAStatus() without a version argument.

Sequence Diagram(s)

sequenceDiagram
  participant WebUIPlugin
  participant Controller
  participant OTA
  participant WebSocket
  WebUIPlugin->>Controller: getSystemInfo().version
  WebUIPlugin->>OTA: if version != lastSyncedControllerVersion -> setControllerVersion(controllerVersion)
  WebUIPlugin->>WebSocket: send res:ota-settings (controllerVersion, latestVersion, ...)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I peeked once at the version string,
Cached it safe before the bells could ring.
If changed, I tell OTA with a hop and a cheer,
Web UI shows one truth — no double fear.
Hooray, the screen and controller are clear!

🚥 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 Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing OTA controller update status after firmware update, directly addressing issue #749.
Linked Issues check ✅ Passed The code changes directly address issue #749 by syncing the cached OTA controller version with live SystemInfo before computing controllerUpdateAvailable, preventing stale cached values from triggering false update prompts.
Out of Scope Changes check ✅ Passed All changes are scoped to the OTA status update mechanism in WebUIPlugin, directly addressing the stale cache synchronization issue identified in #749.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/display/plugins/WebUIPlugin.cpp (2)

819-819: 💤 Low value

The version parameter appears unused.

The function signature accepts const String &version, but the parameter is not referenced in the function body (lines 819-874). Line 828 retrieves the latest version directly via ota->getCurrentVersion() instead. This parameter could be removed to simplify the signature and call sites (lines 102, 428).

🤖 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 `@src/display/plugins/WebUIPlugin.cpp` at line 819, The updateOTAStatus
function takes an unused parameter (const String &version); remove the parameter
from WebUIPlugin::updateOTAStatus (change signature to no-arg) and update its
declaration in the class header, then update every call site that passes a
version to instead call updateOTAStatus() with no arguments (also update any
function pointer/override/virtual declarations if present); verify the body
still uses ota->getCurrentVersion() as before and compile to ensure no remaining
references to the removed parameter.

824-825: 💤 Low value

Consider caching and comparing before calling setControllerVersion().

The setControllerVersion() implementation frees and re-parses the semver on every call. Since updateOTAStatus() is invoked periodically (lines 98-103), this parsing happens repeatedly even when the controller version hasn't changed. You could store the last-seen controller version as a member variable and only call setControllerVersion() when it differs.

⚡ Proposed optimization

Add a member variable to cache the last controller version:

class WebUIPlugin {
  // ... existing members ...
  String lastControllerVersion;
};

Then modify the logic:

 const String controllerVersion = controller->getSystemInfo().version;
-ota->setControllerVersion(controllerVersion);
+if (controllerVersion != lastControllerVersion) {
+  ota->setControllerVersion(controllerVersion);
+  lastControllerVersion = controllerVersion;
+}
🤖 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 `@src/display/plugins/WebUIPlugin.cpp` around lines 824 - 825, Cache the last
seen controller version in the WebUIPlugin (e.g. add a member String
lastControllerVersion) and then in the code path that currently does const
String controllerVersion = controller->getSystemInfo().version;
ota->setControllerVersion(controllerVersion); (used by updateOTAStatus) compare
controllerVersion to lastControllerVersion and only call
ota->setControllerVersion(controllerVersion) and update lastControllerVersion
when they differ; this avoids repeated semver free/parse work inside
setControllerVersion when the version is unchanged.
🤖 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.

Nitpick comments:
In `@src/display/plugins/WebUIPlugin.cpp`:
- Line 819: The updateOTAStatus function takes an unused parameter (const String
&version); remove the parameter from WebUIPlugin::updateOTAStatus (change
signature to no-arg) and update its declaration in the class header, then update
every call site that passes a version to instead call updateOTAStatus() with no
arguments (also update any function pointer/override/virtual declarations if
present); verify the body still uses ota->getCurrentVersion() as before and
compile to ensure no remaining references to the removed parameter.
- Around line 824-825: Cache the last seen controller version in the WebUIPlugin
(e.g. add a member String lastControllerVersion) and then in the code path that
currently does const String controllerVersion =
controller->getSystemInfo().version;
ota->setControllerVersion(controllerVersion); (used by updateOTAStatus) compare
controllerVersion to lastControllerVersion and only call
ota->setControllerVersion(controllerVersion) and update lastControllerVersion
when they differ; this avoids repeated semver free/parse work inside
setControllerVersion when the version is unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: cd8c20d7-b975-49a3-bdec-e221560d7ab9

📥 Commits

Reviewing files that changed from the base of the PR and between 16bc6f8 and 3d044c0.

📒 Files selected for processing (1)
  • src/display/plugins/WebUIPlugin.cpp

@cla-bot

cla-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have yours on file. In order for us to review and merge your code, please contact @jniebuhr (mdwasp) on Discord to get yourself added.

@EyJunge1

Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Jun 10, 2026
@cla-bot

cla-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

EyJunge1 and others added 2 commits June 10, 2026 14:24
Sync the cached OTA controller version with the live SystemInfo version
before computing controllerUpdateAvailable, so the web UI no longer shows
an update prompt for the version already installed.

Fixes jniebuhr#749

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove the unused version parameter from updateOTAStatus() and only
sync the OTA controller version cache when SystemInfo reports a change.

Co-authored-by: Cursor <cursoragent@cursor.com>
@EyJunge1
EyJunge1 force-pushed the fix/749-ota-controller-status branch from 8655c97 to 8c25002 Compare June 10, 2026 12:24
@sonarqubecloud

Copy link
Copy Markdown

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] system update web screen wrong behavior

1 participant