Class AiChatHubFragment

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<com.vaadin.flow.component.orderedlayout.VerticalLayout>
io.jmix.flowui.fragment.Fragment<com.vaadin.flow.component.orderedlayout.VerticalLayout>
io.jmix.aitoolsflowui.view.chathub.AiChatHubFragment
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, FacetOwner, FragmentOwner, Serializable

public class AiChatHubFragment extends Fragment<com.vaadin.flow.component.orderedlayout.VerticalLayout>
Self-contained chat hub UI. Embeds the reusable chat input, shows the current user's most recent chats next to it, and a full searchable, date-bucketed history in a SidePanelLayout. Designed to be dropped into any host view.
See Also:
  • Field Details

  • Constructor Details

    • AiChatHubFragment

      public AiChatHubFragment()
  • Method Details

    • setMarkIconSupplier

      public void setMarkIconSupplier(@Nullable com.vaadin.flow.function.SerializableSupplier<com.vaadin.flow.component.Component> markIconSupplier)
      Sets a supplier of the brand mark icon shown on the hub hero and conversation cards, letting the host override the default add-on icon. The supplier must return a fresh component on every call.
      Parameters:
      markIconSupplier - supplier of the mark icon, or null to use the default
    • setRecentChatsCount

      public void setRecentChatsCount(int recentChatsCount)
      Overrides the number of recent chats shown next to the chat input. When unset, the value comes from jmix.aitools.ui.chat-hub-recent-chats-count (default 6).
      Parameters:
      recentChatsCount - number of recent chats to show
    • onReady

      @Subscribe public void onReady(Fragment.ReadyEvent event)
    • recentConversationsLoadDelegate

      @Install(to="recentConversationsDl", target=DATA_LOADER) public List<AiConversation> recentConversationsLoadDelegate(LoadContext<AiConversation> loadContext)
    • historyConversationsLoadDelegate

      @Install(to="historyConversationsDl", target=DATA_LOADER) public List<AiConversation> historyConversationsLoadDelegate(LoadContext<AiConversation> loadContext)
    • recentConversationsGridLayoutRenderer

      @Supply(to="recentConversationsGridLayout", subject="renderer") protected com.vaadin.flow.data.renderer.ComponentRenderer<AiConversationCard,AiConversation> recentConversationsGridLayoutRenderer()
    • onShowAllHistoryBtnClick

      @Subscribe("showAllHistoryBtn") public void onShowAllHistoryBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event)
    • onHistoryCloseBtnClick

      @Subscribe("historyCloseBtn") public void onHistoryCloseBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event)
    • onHistoryNewBtnClick

      @Subscribe("historyNewBtn") public void onHistoryNewBtnClick(com.vaadin.flow.component.ClickEvent<JmixButton> event)
    • onHistorySearchFieldValueChange

      @Subscribe("historySearchField") public void onHistorySearchFieldValueChange(SupportsTypedValue.TypedValueChangeEvent<TypedTextField<String>,String> event)
    • startConversation

      protected void startConversation(String prompt)
    • refreshRecentConversationsVisibility

      protected void refreshRecentConversationsVisibility()
    • refreshComposerAvailability

      protected void refreshComposerAvailability()
      Disables the composer and warns the user when the chat model is not configured — starting a new chat would fail.
    • loadConversations

      protected void loadConversations()
    • createRecentCard

      protected AiConversationCard createRecentCard(AiConversation conversation)
    • createHistoryCard

      protected AiConversationCard createHistoryCard(AiConversation conversation)
    • createCard

      protected AiConversationCard createCard(AiConversation conversation, boolean deletable)
    • openConversation

      protected void openConversation(AiConversation conversation)
    • confirmDelete

      protected void confirmDelete(AiConversation conversation)
    • deleteConversation

      protected void deleteConversation(AiConversation conversation)
    • renderHistoryList

      protected void renderHistoryList()
    • applyHistoryFilter

      protected List<AiConversation> applyHistoryFilter(List<AiConversation> conversations)
    • groupByBucket

      protected Map<HistoryBucket,List<AiConversation>> groupByBucket(List<AiConversation> conversations)
    • bucketLabel

      protected String bucketLabel(HistoryBucket bucket)
    • createHistoryGroup

      protected com.vaadin.flow.component.Component createHistoryGroup(String bucketLabel, List<AiConversation> conversations)
    • resolveRecentChatsCount

      protected int resolveRecentChatsCount()
    • resolveMarkIcon

      protected com.vaadin.flow.component.Component resolveMarkIcon()
    • formatDateTime

      protected @Nullable String formatDateTime(@Nullable OffsetDateTime dateTime)