Skip to content

Fix Mainsail livestats: wrong progress percentage and remaining time - #1041

Open
HK-Moebius wants to merge 1 commit into
linuxserver:masterfrom
HK-Moebius:fix/mainsail-livestats
Open

HK-Moebius wants to merge 1 commit into
linuxserver:masterfrom
HK-Moebius:fix/mainsail-livestats

Conversation

@HK-Moebius

@HK-Moebius HK-Moebius commented Sep 16, 2026

Copy link
Copy Markdown

The Mainsail enhanced app (added in #642) shows wrong values while a print is running. This affects every Klipper/Moonraker printer, not a specific model.

Problems

  1. Progress is always 0% or 1%.
    Moonraker reports display_status.progress as a fraction between 0.0 and 1.0. The app rounds that value directly without multiplying by 100, so a print at 45% is shown as 0%, and anything from 50% onwards as 1%.

  2. The remaining time is unrelated to the print.
    toolhead.estimated_print_time is not the estimated duration of the print job. It is Klipper's internal print time clock, which keeps running since Klipper started. Subtracting print_stats.print_duration from it produces a value that depends on the printer's uptime, so the "Finish" value grows the longer the printer has been powered on.

Changes

  • Multiply the progress by 100. If display_status.progress is not set (no M73 in the G-code), fall back to virtual_sdcard.progress.
  • Calculate the remaining time from the slicer estimate in the file metadata (/server/files/metadata, estimated_time) minus print_stats.print_duration. This is the same data Mainsail itself uses for its slicer-based estimate.
  • If no slicer estimate is available, extrapolate from progress and elapsed print time.
  • Query virtual_sdcard instead of toolhead, since toolhead is no longer needed.
  • Use null-coalescing for the status fields so a missing object does not cause a PHP notice.

The output keys (completed_pct, estimated, state) and the presentation are unchanged, so livestats.blade.php does not need to change.

Testing

Tested with a Klipper/Moonraker printer (Prusa Pro HT90) during a running print. Progress and remaining time now match what Mainsail shows.

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants