companion icon indicating copy to clipboard operation
companion copied to clipboard

feat: support expressions for most internal action fields #2345

Open Julusian opened this issue 3 months ago • 3 comments

~~This is a WIP, and is in the process of being applied to all the internal code, please raise any objections/concerns around the changes asap, it would be good to know if anything needs reworking before every internal action is updated and tested for the changes.~~

This starts on implementing #2345, starting with considering just the internal actions and feedbacks.

The aim is to figure out how this will work technically, while it is easier to do on just the code in this repo before attempting to roll it out to modules.

The ui looks pretty similar to what was done for the graphics overhaul. Fields which support this gain a new button to the right of the field, which toggles it between the usual mode and expressions: image

Internally, the options object now contains something of the form: { isExpression: false, value: 123 }, with the execution auto-parsing, and the ui updating this. It is opt-in per entity for now, to avoid breaking everything while this is WIP, that may or may not remain once complete.
This data change requires upgrade scripts per-action. While it probably could be mostly automated, many actions need input fields to also be combined (they already have a checkbox to toggle between value and expression mode, and separate fields for each mode), so doing it all manually makes handling this saner/safer

Julusian avatar Sep 04 '25 22:09 Julusian

The ui looks pretty similar to what was done for the graphics overhaul. Fields which support this gain a new button to the right of the field, which toggles it between the usual mode and expressions: image

Does that mean all those options actually support it, or only the last one? What's the use case for entering a surface/group name by expression (as opposed to it's ID)?

FWIW I think to actually solve #3235 it needs some new actions.

peternewman avatar Sep 09 '25 16:09 peternewman

Does that mean all those options actually support it, or only the last one? What's the use case for entering a surface/group name by expression (as opposed to it's ID)?

in the screenshot, all of them do with the last one currently being set to expression mode. I havent updated every field of every action for this, as some do seem pointless to do.

FWIW I think to actually solve https://github.com/bitfocus/companion/issues/3235 it needs some new actions.

Or maybe it just needs a variable listing all the surfaces? Its already possible to create loops #3619

What's the use case for entering a surface/group name by expression (as opposed to it's ID)?

I dont have one, but Im sure someone will. we already support taking it from a variable (using a few fields and isVisible to do so), so changing it to expressions is largely to simplify and unify it.

Julusian avatar Sep 09 '25 20:09 Julusian

@dnmeid any thoughts on the approach taken here? (how the values are stored, and how the ui works) With 4.1 now released, I would like to wrap this up and get it into 4.2 soon; then to think about doing the same for modules

Julusian avatar Sep 16 '25 13:09 Julusian