Class PerspectiveScriptAssistMounter
Attaches a shared "Ask AI" toolbar button to a Perspective component script surface — one of the
PerspectiveScriptSurface editors, or another module's script surface bound to a Perspective
component. Not every Perspective script editor mounts here: session and page event scripts get
their assist elsewhere, and script actions and script transforms have none. The package
documentation lists the split.
var grounding =
new PerspectiveScriptGrounding(
adapter, this::getPrimaryComponentPath, frame.getTargetSnapshot());
PerspectiveScriptAssistMounter.attach(
editor, grounding, grounding.callerContextFor(PerspectiveScriptSurface.CUSTOM_METHOD));
What the agent knows comes from the PerspectiveScriptGrounding: its tools and @-reference
sources are taken from it here rather than passed by each host, so every surface is grounded the
same way. Only the framing is surface-specific, and it is picked from the same grounding. How
that knowledge reaches the agent is this class's job.
The caller context and the function signature travel with each message, through
PerspectiveScriptPromptComposer, rather than in the agent's context. The agent is built once,
when the Ask AI popup opens, and the popup stays open while the user edits the form around the
script; framing held in the agent would describe the form as it was at that moment.
The agent is always an extension function agent, because every Perspective scripting surface edits an
ExtensionFunctionPanel whose first line is a locked def the host owns. Writing back through
TextlikeComponent replaces the body only, so an agent that re-emitted the signature would
nest a second def inside the first.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<AssistToolbarButton> attach(com.inductiveautomation.ignition.designer.gui.tools.ExtensionFunctionPanel editor, PerspectiveScriptGrounding grounding, Supplier<String> callerContext) Mounts an icon-only "Ask AI" button oneditor's toolbar when the AI module is installed and ready; a no-op otherwise, so callers need not gate on readiness themselves.
-
Method Details
-
attach
public static Optional<AssistToolbarButton> attach(com.inductiveautomation.ignition.designer.gui.tools.ExtensionFunctionPanel editor, PerspectiveScriptGrounding grounding, Supplier<String> callerContext) Mounts an icon-only "Ask AI" button oneditor's toolbar when the AI module is installed and ready; a no-op otherwise, so callers need not gate on readiness themselves.- Parameters:
editor- the extension-function editor this assistant reads from and writes back to. Its descriptor is read when the popup opens and again on each Send, so it need not be set yet — and a descriptor replaced while the popup is open, as happens while a custom method's name and parameters are being edited, reaches the agent with the next message.grounding- the grounding for the component the editor window was opened on; the source of the agent's read tools and the prompt's@-reference sources.callerContext- the surface's framing, taken fromgroundingthroughPerspectiveScriptGrounding.callerContextFor(PerspectiveScriptSurface)or one of its surface-specific variants. Evaluated on the EDT on each Send, so it may read live form state but must not block.- Returns:
- the mounted button, or empty when the AI module is absent or unconfigured. The bound
action rewrites the button's enabled state whenever AI readiness changes, so surfaces
behind an "enable" checkbox must combine that checkbox with the action's
enabledflag and re-apply it on the action'senabledproperty changes, rather than setting the button's enabled state directly.
-