Merged
Conversation
HugoCLSC
approved these changes
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Select the type:
Fixes the Z-offset babystep save flow in PrintTab and refactors BabystepPage. Babystep changes made during a print were silently not persisting across Klipper restarts.
Motivation
Two bugs made the Z-offset save silently fail:
Wrong Klipper command. Z_OFFSET_APPLY_PROBE adjusts the probe's calibration z_offset — used for bed leveling accuracy. For a printer homing Z with a physical endstop, the babystep offset must be persisted into stepper_z.position_endstop, which is what Z_OFFSET_APPLY_ENDSTOP does. SAVE_CONFIG was restarting Klipper but writing to the wrong config key, so the home position was unchanged on the next boot. The correct command is now resolved dynamically at runtime by reading stepper_z.endstop_pin from the printer config, matching Mainsail's behaviour for both physical and virtual endstop setups.
Race condition. The printer's END_PRINT macro calls SET_GCODE_OFFSET Z=0, zeroing homing_origin[2] before the user confirms the dialog. Z_OFFSET_APPLY_ENDSTOP would then receive 0, Klipper would raise "Nothing to do", and SAVE_CONFIG would have nothing staged — completing silently with no effect. Capturing _pending_save_offset at dialog-open time and re-applying it with SET_GCODE_OFFSET Z={pending} MOVE=0 immediately before the apply command eliminates this window.