Class AiMessageActionPerformedEvent

All Implemented Interfaces:
Serializable

public class AiMessageActionPerformedEvent extends ActionPerformedEvent
Event sent when an AiMessageAction is performed on a message.

Unlike a plain ActionPerformedEvent, it names the message the action was invoked on — the whole point of a per-message action — both as the rendered item and as the domain message that item was rendered from. The triggering component is the host AiMessageList: the action button itself lives in the client's shadow DOM and has no server-side counterpart.

Subscribe to it from a view controller by the declared action's id:


 @Subscribe("chat.regenerate")
 public void onRegenerate(AiMessageActionPerformedEvent event) {
     ChatMessage message = event.getMessage();     // the domain message
     AiMessageListItem item = event.getItem();     // the rendered item
 }
 
See Also:
  • Field Details

  • Constructor Details

    • AiMessageActionPerformedEvent

      public AiMessageActionPerformedEvent(AiMessageAction<?> source, AiMessageList messageList, AiMessageListItem item)
      Parameters:
      source - the action that was performed
      messageList - the host message list
      item - the rendered item the action was invoked on
  • Method Details

    • getItem

      public AiMessageListItem getItem()
      Returns:
      the rendered item the action was invoked on (never null)
    • getMessage

      public <M extends AiChatMessage> @Nullable M getMessage()
      Gets the domain message the action was invoked on — the message this chat rendered the clicked item from, which is what identifies the persisted row. Self-typed, so no cast is needed:
      
       ChatMessage message = event.getMessage();
       
      Type Parameters:
      M - the application's own message type
      Returns:
      the domain message, or null when the clicked item has none — the transient bubble a stopped or failed generation leaves behind is rendered but never committed, and its action bar is clickable, so a handler that writes to a persisted row must check this
    • getSource

      public AiMessageAction<?> getSource()
      Overrides:
      getSource in class ActionPerformedEvent
    • getComponent

      public AiMessageList getComponent()
      Overrides:
      getComponent in class ActionPerformedEvent
      Returns:
      Component that triggered this action.