Help with limiting RESUME macro execution to single time

Noticing a possible bug but this is specific to the user.

When a print is paused from a filament runout sensor or the pause macro in any other form (KlipperScreen, Mainsail, etc), the Resume macro can be sent multiple times and ran the number of times pressed. This is an issue when another process is happening, like filament loading for example and the user presses Resume more than once because no action happens the first time.

The result is that the print is resumed then immediately runs the RESUME macro again. If there is any homing in the RESUME macro, it raises Z each time the RESUME macro runs but doesn’t lower back down when it starts printing until after some time (buffer clearing)

Cannot think of other macros at this time that this would apply to but the RESUME macro is one that should not do anything after the first RESUME is ran. It should run once only in any case. If the printer needs to pause again, the user can initiate that.

Below is one found that would work but shouldn’t this be a global change for all users?

[gcode_macro RESUME]

description: Resume the currently running print (*)
rename_existing: RESUME_BASE
gcode:

  {% if not printer.pause_resume.is_paused %}
  
    M117 You can't use RESUME because the printer is not paused.

  {% else %}

    {% if printer.extruder.can_extrude|lower == 'true' %}

      M117 Resumed printing.
      RETRACT RECOVER=1
      RESUME_BASE

    {% else %}

      M117 Unable to resume due to nozzle temperature. Set it and try again.

    {% endif %}

  {% endif %}

If a user chooses to replace/augment a command with a macro, there’s no way to prevent them from doing unwise things in their replacement. It’s one of the downsides of the amount of flexibility that Klipper provides.

The base command correctly guards against doing anything if a print is not currently paused (klipper/pause_resume.py at 1a24e7c5b683355335b115e5659eb6fe8c8d11dc · Klipper3d/klipper · GitHub); anyone who writes a macro that replaces it has chosen to take on the responsibility of making sure their macro works the same way.