Interface AiChatItems<T extends AiChatMessage>

Type Parameters:
T - the application's message type
All Superinterfaces:
DataUnit
All Known Implementing Classes:
AbstractAiChatItems, ContainerAiChatItems, ListAiChatItems

public interface AiChatItems<T extends AiChatMessage> extends DataUnit
Source of conversation messages for AiChat: the component reads the rendered history from it and appends generated messages to it.

Messages are read through the AiChatMessage contract, so no property mapping is involved. Creating a message instance is not this unit's job — AiChatMessageFactory mints it, and the unit only stores it.

  • Method Details

    • getItems

      List<T> getItems()
      Returns the messages in render order. The returned list is not modifiable; use addItem(AiChatMessage) and removeItem(AiChatMessage) instead.
      Returns:
      the messages in render order
    • addItem

      void addItem(T item)
      Appends a message to the end of the conversation. Implementations must fire an AiChatItems.ItemsChangeEvent of type AiChatItems.ItemsChangeType.ADD — AiChat re-renders on that notification alone, so a silent mutation leaves the message unrendered.
      Parameters:
      item - the message to append
    • removeItem

      void removeItem(T item)
      Removes a message from the conversation. Does nothing when the message is not present. Implementations must fire an AiChatItems.ItemsChangeEvent of type AiChatItems.ItemsChangeType.REMOVE for an actual removal — AiChat re-renders on that notification alone, so a silent mutation leaves the message rendered.
      Parameters:
      item - the message to remove
    • addItemsChangeListener

      com.vaadin.flow.shared.Registration addItemsChangeListener(Consumer<AiChatItems.ItemsChangeEvent<T>> listener)
      Adds a listener notified when the messages or one of their properties change.
      Parameters:
      listener - the listener to add
      Returns:
      a registration for removing the listener