Class EventScriptReplyRenderer

java.lang.Object
com.inductiveautomation.ignition.designer.scripteditor.workspace.ai.EventScriptReplyRenderer
All Implemented Interfaces:
ReplyRenderer

public final class EventScriptReplyRenderer extends Object implements ReplyRenderer
Renders event-script assistant replies and applies an accepted suggestion to the live tab in one click. A Suggestion envelope's value must be exactly one JSON object:
{ "script": "...", "config": { ... }, "enabled": true }

Every member is optional and an omitted member changes nothing, but the object is otherwise strict: a payload that is not a JSON object, carries an unrecognized or mistyped member, proposes nothing, or proposes something this tab cannot accept — enabled on a pinned checkbox, config with no TriggerConfigSupport or failing its schema — renders with the full problem list and no Apply button. A suggestion is applied whole or not at all; there is no partial apply of the members that happened to be valid.

payloadInstructions(EventScriptTabState) is the agent-facing side of the same contract: it describes only the members the tab carries, off the same EventScriptTabState fields EventScriptPromptComposer reads, so a prompt block and its payload description move together.

One renderer is held per assist session; both render methods run on the EDT and read the tab snapshot fresh on each reply, because the popup is non-modal and the panel may have changed since the last submit.

  • Constructor Details

    • EventScriptReplyRenderer

      public EventScriptReplyRenderer(Supplier<EventScriptTabState> snapshot, EventScriptReplyRenderer.ApplyActions actions, Runnable applied)
      Parameters:
      snapshot - returns the tab's live state; read fresh on every reply, so it must snapshot inside the supplier.
      actions - the write-backs an accepted suggestion applies.
      applied - invoked once after every write-back in an accepted suggestion succeeded.
  • Method Details

    • payloadInstructions

      public static String payloadInstructions(EventScriptTabState state)
      The "Suggestion payload" contract handed to the assist agent, describing the envelope members this tab accepts: script always, enabled when the snapshot carries an enabled state, config when it carries a TriggerConfigSupport.
      Parameters:
      state - the tab state captured when the assist popup opened.
      Returns:
      the payload contract as prompt prose.
    • renderStatement

      public ReplyView renderStatement(String description)
      Description copied from interface: ReplyRenderer
      Render an informational reply with no apply-able actions. The returned ReplyView is expected to carry an empty actions list — the panel will read it as a STATEMENT card.
      Specified by:
      renderStatement in interface ReplyRenderer
      Parameters:
      description - prose explanation from the model, supporting markdown.
    • getSuggestionFailure

      public @Nullable String getSuggestionFailure(String value)
      Description copied from interface: ReplyRenderer
      Check an apply-able payload before anything renders it. A renderer that rejects a payload here gets the model asked again while the turn is still open, instead of the user reading a rejection card for a reply nothing tried to fix.

      Unlike the render methods this runs on the sending thread, not the EDT, so an implementation must inspect only value — no Swing state, no editor snapshot.

      Specified by:
      getSuggestionFailure in interface ReplyRenderer
      Parameters:
      value - the payload ReplyRenderer.renderSuggestion(String, String) would receive.
      Returns:
      null when the payload is usable. Otherwise what to tell the model, phrased for it to act on: what was wrong and what to send instead.
    • renderSuggestion

      public ReplyView renderSuggestion(String description, String value)
      Description copied from interface: ReplyRenderer
      Render an apply-able suggestion. The value is the literal content the user can write back to the host editor; description is the prose framing. The returned view typically carries one or more apply buttons (Insert, Replace, …).
      Specified by:
      renderSuggestion in interface ReplyRenderer
      Parameters:
      description - prose explanation from the model, supporting markdown.
      value - the literal content the apply buttons hand back to the host editor.