Skip to content

feat: add input field to macro prompt - #2136

Draft
meteyou wants to merge 3 commits into
mainsail-crew:developfrom
meteyou:feat/add-input-field-macro-promts
Draft

feat: add input field to macro prompt#2136
meteyou wants to merge 3 commits into
mainsail-crew:developfrom
meteyou:feat/add-input-field-macro-promts

Conversation

@meteyou

@meteyou meteyou commented Feb 3, 2025

Copy link
Copy Markdown
Member

Description

This PR adds input fields to macro pompts.

Related Tickets & Documents

none

Mobile & Desktop Screenshots/Recordings

none

[optional] Are there any post-deployment tasks we need to perform?

none

@NeighNeighNeigh

Copy link
Copy Markdown

Any movement with this one? I'd love to be able to hook this up with Eric Zimmerman's autocommit.sh GitHub tool, so I can add commit messages when invoking a commit from the macro panel

@meteyou

meteyou commented May 27, 2025

Copy link
Copy Markdown
Member Author

@NeighNeighNeigh This PR was initially just a test for a small user group. As I haven't received any feedback since its creation, it's currently stalled. If I update this PR, would you be able to test a build to see if it could work with the input field in the macro prompt?

@NeighNeighNeigh

NeighNeighNeigh commented May 27, 2025 via email

Copy link
Copy Markdown

@meteyou

meteyou commented May 27, 2025

Copy link
Copy Markdown
Member Author

@NeighNeighNeigh This branch should be up-to-date now. On this side, you can download a new test build: https://github.com/mainsail-crew/mainsail/actions/runs/15266392902?pr=2136

@NeighNeighNeigh

Copy link
Copy Markdown

Apologies for being novice, but can I test this by simply replacing the contents of /mainsail on my pi with the contents of the archive? (my pi is running mainsail os)

@meteyou

meteyou commented May 27, 2025

Copy link
Copy Markdown
Member Author

Yep! Just download this zip, unzip it (pay attention, the GitHub workflow zip a zip, so you have to unzip it twice) and then upload it with FileZilla or other sftp program to your pi in /home//mainsail. Just delete all files in this directory, bevor you upload the new files.

@NeighNeighNeigh

Copy link
Copy Markdown

Okay, I can confirm it appears to be working. The release installed easily following your instruction, and (via fumbling around) was able to actually show an input prompt via this test macro

[gcode_macro SHOW_INPUT_PROMPT]
gcode:
    RESPOND TYPE=command MSG="action:prompt_begin input a sting"
    RESPOND TYPE=command MSG="action:prompt_input"
    RESPOND TYPE=command MSG="action:prompt_show"

As soon as I type anything into the field I get the following warning in klippers console The value 'null' is not valid for MACRO but I assume this is the expected result, because I need to actually develop the macro.

So things look promising!

At this point, I need to work out how to implement this into my auto commit macro, and pass the entered string into the command (see input_result below). Any pointers here would be super welcome.

 [gcode_shell_command backup_cfg]
 command: ~/printer_data/config/autocommit.sh input_result
 timeout: 30
 verbose: True

 [gcode_macro BACKUP_CFG]
 description: Backs up config directory GitHub
 gcode:
     RUN_SHELL_COMMAND CMD=backup_cfg

More broadly, I feel like being able to set up macros to issue terminal commands with user input like this could be super useful beyond this auto backup macro!! So this is, imo, a great feature for mainsail!

@meteyou

meteyou commented May 31, 2025

Copy link
Copy Markdown
Member Author

sry for the delay. the input field will write the input value in a macro variable so you should use this syntax to define it:

action:prompt_input|<label>|<macro name>|<variable name>|<default value>|<input placeholder>

default value and placeholder are optional.

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.

2 participants