Skip to content

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Oct 5, 2025

Follow up for #19019.
Discussion in https://community.openhab.org/t/rules-and-return-codes/166438.

  • This enables the wrapper that allows the use of let, const, class, function, return etc. always for script actions.
  • The wrapper is only configurable for conditions anymore, and the option defaults to false to avoid breaking existing conditions.
  • To allow disabling/enabling the script condition wrapper per action or condition, a directive is introduced: "use wrapper"
    • "use wrapper" & "use wrapper=true" enables the wrapper
    • "use wrapper=false" disables the wrapper

…e for conditions with default disabled

See https://community.openhab.org/t/rules-and-return-codes/166438 for discussion.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 added the enhancement An enhancement or new feature for an existing add-on label Oct 5, 2025
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/rules-and-return-codes/166438/60

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/rules-and-return-codes/166438/65

Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 requested review from Nadahar and jimtng October 6, 2025 22:38
Copy link
Contributor

@Nadahar Nadahar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 requested a review from Copilot October 7, 2025 22:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates JavaScript scripting behavior: the wrapper is now always intended to be enabled for script actions, while being configurable (and defaulting to disabled) for script conditions via a new directive ("use wrapper") and a renamed configuration parameter. Key changes include replacing the legacy wrapperEnabled config with scriptConditionWrapperEnabled, refining script environment detection, and introducing directive-based wrapper control in scripts.

  • Introduces directive-based wrapper selection ("use wrapper[=true|false]") for conditions; actions are meant to always be wrapped.
  • Refactors environment detection from "UI-based" to explicit script module/action/condition classification.
  • Renames and adjusts configuration and i18n keys to reflect the new behavior.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
jsscripting.properties Renames wrapper configuration keys and updates description text for script condition wrapper behavior.
config.xml Replaces wrapperEnabled parameter with scriptConditionWrapperEnabled and changes its default to false.
OpenhabGraalJSScriptEngine.java Adds environment classification, wrapper directive parsing, and refactors injection logic.
GraalJSScriptEngineConfiguration.java Renames config fields/methods and adds scriptConditionWrapperEnabled handling.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 requested a review from Copilot October 7, 2025 23:26
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, LGTM.

@jlaur jlaur merged commit 6bacd8e into openhab:main Oct 9, 2025
2 checks passed
@jlaur jlaur added this to the 5.1 milestone Oct 9, 2025
@florian-h05 florian-h05 deleted the jsscripting-wrapper branch October 9, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants