Skip to content

Run the COSMOS update through Moonraker's update_manager - #289

Open
kyleinoregon wants to merge 1 commit into
pellcorp:mainfrom
kyleinoregon:feat/update-manager-client
Open

kyleinoregon wants to merge 1 commit into
pellcorp:mainfrom
kyleinoregon:feat/update-manager-client

Conversation

@kyleinoregon

@kyleinoregon kyleinoregon commented Sep 5, 2026 •

Copy link
Copy Markdown

Follows the discussion in OpenCentauri/cosmos#308: COSMOS is moving its updater into Moonraker's update_manager (OpenCentauri/cosmos#313), so every UI shows the same thing. This is the screen's side of that, and it is part of the COSMOS build only (COSMOS=true).

What

A small UpdateManagerClient. The Update button sends machine.update.client for the cosmos entry over the existing websocket instead of running a shell command, and the notify_update_response stream Moonraker sends during the update is shown in a dialog: "Downloading COSMOS update... 40%", "Installing the update, do not power off the printer!", and so on. The printer reboots by itself once the update is installed, so the last dialog ("COSMOS update installed, the printer is rebooting") has no button and closes on its own after eight seconds. A failed update ends in the "Update COSMOS Failed" dialog with Moonraker's message and an OK button; a refused request (for example while printing) does the same immediately. An update started from Mainsail or Fluidd shows on the screen the same way.

Nothing is configurable: the app name is cosmos and the strings are the COSMOS build's. grumpyscreen ships as part of COSMOS, so the Moonraker side (OpenCentauri/cosmos#313) is always there and there is no fallback to the old shell command.

Notes:

  • No changes to websocket_client: it already dispatches notifications by method name and supports request callbacks.
  • The dialog is the multiline_message variant of create_configurable_dialog(), since the default no-button dialog on a 272 px high screen is too short for a two-line message.
  • Only notifications for cosmos are shown, so an unrelated update started from a browser does not pop a dialog on the printer.

Tested

Centauri Carbon (480x272, GUPPY_SMALL_SCREEN) on COSMOS 26.08.0 with the cosmos updater component from OpenCentauri/cosmos#313: dry run first (download only, flash stubbed), then a real 26.08.0 re-flash started from the screen's Update button. In both, the dialog appeared the moment the prompt was confirmed and stepped through Moonraker's messages: reinstall notice, download percentages, "Installing the update, do not power off the printer!", "Update installed, rebooting..." and the final "COSMOS update installed, the printer is rebooting". In the dry run that last dialog closed by itself after eight seconds; in the real run the printer rebooted underneath it. The same runs appeared in Mainsail's update dialog. Built with and without COSMOS=true, no warnings.

@pellcorp

pellcorp commented Sep 5, 2026

Copy link
Copy Markdown
Owner

All the update manager code must be put within #ifdef UPDATE_CMD or the like, Cosmos is the only downstream that uses the update button, I do not want any of this code being present in what we build for Simple AF.

The default grumpyscreen.cfg will not have the update manager config either.

@kyleinoregon

Copy link
Copy Markdown
Author

Done: everything in update_manager_client.{h,cpp} and its use in setting_panel is now inside #ifdef UPDATE_BUTTON_CMD, which the Makefile only defines when UPDATE_CMD is set. Built both ways: without UPDATE_CMD the binary has no reference to the update_manager API (checked with strings), with the cosmos settings it behaves as before, no warnings either way. The default grumpyscreen.cfg is untouched; the [update_manager] section only exists in cosmos's own config in OpenCentauri/cosmos#313.

@pellcorp

pellcorp commented Sep 5, 2026 •

Copy link
Copy Markdown
Owner

This pr won't be merged until the cosmos change is merged

I was planning to test and merge the dialog change after the mmu change

kyleinoregon pushed a commit to kyleinoregon/cosmos that referenced this pull request Sep 5, 2026
Review follow-up. The cosmos_update.py component is now placed into the
Moonraker source tree with the subdir fetcher option instead of being
copied in do_install. The cosmos-update-start helper, the UPDATE_COSMOS
and CHECK_FOR_UPDATES shell commands, the _UPDATE_COSMOS macro, the
startup update check, the check-update script and the check_for_updates
option are removed: update_manager refreshes on its own schedule and the
web UIs show what it finds, and grumpyscreen starts the update over its
own Moonraker connection (pellcorp/grumpyscreen#289) using the
[update_manager] application key in grumpyscreen.cfg. The screen's
cosmos_update_cmd and the recipe wording are back to what main ships.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kyleinoregon
kyleinoregon force-pushed the feat/update-manager-client branch from c295cbb to a324931 Compare September 6, 2026 21:04
@pellcorp

pellcorp commented Sep 7, 2026

Copy link
Copy Markdown
Owner

I am thinking to make some changes to the way we package the update capability, now that Cosmos is the only downstream project that uses Update I am considering changing the #ifdef logic to be a bit simpler, so likely going to be #ifdef COSMOS probably directly integrating the various messages into the main project so that the cosmos project does not need to override them, will make things a bit simpler, but at that point you will need to rebase again for this PR, assuming cosmos decides to go ahead.

@pellcorp

pellcorp commented Sep 7, 2026

Copy link
Copy Markdown
Owner

I have made some changes to grumpyscreen to make COSMOS a first class citizen, so you pass COSMOS=true to the makefile to activate the Update button now, no need to pass all the extra stuff, the Update, Switch to Stock and Factory reset messages currently defined by cosmos are now part of a COSMOS build to make things a bit easier.

@pellcorp

pellcorp commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Also just want to say, there is ZERO reason to provide config for different clients, this code is only ever going to be used by COSMOS, so you can just hardcode stuff in the update manager client code, cos we will never use it outside cosmos build.

@jamesturton

Copy link
Copy Markdown

this code is only ever going to be used by COSMOS, so you can just hardcode stuff in the update manager client code, cos we will never use it outside cosmos build.

I get your point, but from the other side, if it is implemented in moonraker using the existing API then other GUIs (such as klipperscreen running on an external display) will also "just work" without the need to make patches there. So I think this will be a much more robust solution in the long run.

@kyleinoregon
kyleinoregon force-pushed the feat/update-manager-client branch from a324931 to 2d2ad39 Compare September 7, 2026 23:05
kyleinoregon pushed a commit to kyleinoregon/cosmos that referenced this pull request Sep 7, 2026
The screen's update_manager client (pellcorp/grumpyscreen#289) is now a
COSMOS-only build and drives the cosmos updater unconditionally, so
grumpyscreen.cfg needs nothing for it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kyleinoregon

Copy link
Copy Markdown
Author

Rebased onto main with the COSMOS=true build (#290) and simplified as suggested: the client is now inside #ifdef COSMOS, the app name is fixed to cosmos, and the [update_manager] config key is gone, so grumpyscreen.cfg needs nothing for it. It is one commit now, on top of #286.

The one thing I kept is a fallback: if Moonraker answers machine.update.client with 404 (no cosmos updater, so a COSMOS without OpenCentauri/cosmos#313), the button runs cosmos_update_cmd as it does today. Happy to drop that too if you would rather not carry it.

James is right that the update itself lives in Moonraker, so Mainsail, Fluidd or a KlipperScreen see the same thing; this PR is only the screen showing that stream. Built with and without COSMOS=true, no warnings, and re-tested on the Centauri Carbon.

@kyleinoregon kyleinoregon changed the title Run the update through Moonraker's update_manager when configured Run the COSMOS update through Moonraker's update_manager Sep 7, 2026
@pellcorp

pellcorp commented Sep 8, 2026

Copy link
Copy Markdown
Owner

I don't mind so much, cos all the update code lives inside #ifdef COSMOS :-)

Comment thread src/setting_panel.cpp Outdated
@kyleinoregon
kyleinoregon force-pushed the feat/update-manager-client branch from 2d2ad39 to 7cc7d34 Compare September 8, 2026 07:38
@pellcorp

pellcorp commented Sep 8, 2026

Copy link
Copy Markdown
Owner

this code is only ever going to be used by COSMOS, so you can just hardcode stuff in the update manager client code, cos we will never use it outside cosmos build.

I get your point, but from the other side, if it is implemented in moonraker using the existing API then other GUIs (such as klipperscreen running on an external display) will also "just work" without the need to make patches there. So I think this will be a much more robust solution in the long run.

I don't mind long as the default grumpyscreen.cfg does not have this section as its not relevant to Simple AF and you guys write your own anyway.

@pellcorp

pellcorp commented Sep 8, 2026

Copy link
Copy Markdown
Owner

this code is only ever going to be used by COSMOS, so you can just hardcode stuff in the update manager client code, cos we will never use it outside cosmos build.

I get your point, but from the other side, if it is implemented in moonraker using the existing API then other GUIs (such as klipperscreen running on an external display) will also "just work" without the need to make patches there. So I think this will be a much more robust solution in the long run.

Oh maybe you misunderstood me, I just meant I dont want the update_manager config in the default grumpyscreen.cfg, nor do I necessarily think you even need to list the update manager ID either, cos GrumpyScreen is only ever going to be used for Updates by you guys, but honestly I also dont care that much, long as its contained in #ifdef COSMOS you can do whatever you want within reason :-)

The update button asks Moonraker to update the cosmos entry of
update_manager (machine.update.client) and shows the progress it reports
through notify_update_response in a dialog, the same way Mainsail and
Fluidd do. Updates started from those clients show on the screen too.

The app name is fixed to cosmos: this only exists in a COSMOS build, and
grumpyscreen ships with COSMOS, so the Moonraker side is always there.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@kyleinoregon
kyleinoregon force-pushed the feat/update-manager-client branch from 7cc7d34 to 608cb99 Compare September 11, 2026 23:22
@kyleinoregon

Copy link
Copy Markdown
Author

Rebased on current main after the theme refactor (the dialog now sizes itself, so the multiline option is gone). Builds clean with and without COSMOS=true.

@pellcorp

Copy link
Copy Markdown
Owner

apologies but more conflicts, maybe don't even bother fixing until its clear cosmos is going to merge.

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.

4 participants