Class ChatPage

java.lang.Object
ai.mindconnect.adminui.ui.AdminPage
ai.mindconnect.adminui.ui.page.ChatPage

public final class ChatPage extends AdminPage
The agent-session chat page. Composes three components into a tabbed section:

Each page instance binds one session's domain model (session, agent, history, memory) and exposes:

  • render() — the full page, returned on GET /sessions/{id}.
  • One UiPatch method per lifecycle event of a chat turn — these are the only surface the SessionUiController needs to talk to during streaming, so the controller stays focused on orchestration.

The page is a short-lived value object: build it from the latest model at the start of each request, derive whatever patch / page is needed, throw it away. No fields beyond the components and their model; no caches.

  • Constructor Summary

    Constructors
    Constructor
    Description
    ChatPage(ai.mindconnect.agent.domain.AgentSession session, ai.mindconnect.agent.domain.AgentDefinition agent, List<ai.mindconnect.message.domain.Message> history, ai.mindconnect.agent.memory.domain.WorkingMemory memory)
     
    ChatPage(ai.mindconnect.agent.domain.AgentSession session, ai.mindconnect.agent.domain.AgentDefinition agent, List<ai.mindconnect.message.domain.Message> history, ai.mindconnect.agent.memory.domain.WorkingMemory memory, boolean streaming)
     
    ChatPage(ai.mindconnect.agent.domain.AgentSession session, ai.mindconnect.agent.domain.AgentDefinition agent, List<ai.mindconnect.message.domain.Message> history, ai.mindconnect.agent.memory.domain.WorkingMemory memory, boolean streaming, MessageListComponent.SubAgentTreeProvider subAgentTree)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    ai.mindconnect.ui.model.UiPatch
    appendApprovalCard(ai.mindconnect.ui.model.UiList.Item card)
    APPEND a live approval card pushed by a suspended (sub-)turn.
    static ai.mindconnect.ui.model.UiUpload
    attachZone(UUID sessionId)
    The attach drop-zone — lives in the dialog the chat form's "+" button opens (see SessionUiController#attachDialog), not on the page itself.
    ai.mindconnect.ui.model.UiPatch
    After a non-streaming POST /chat: refresh the conversation (and its token-bar title) and reset the input form so the user can type a follow-up.
    ai.mindconnect.ui.model.UiPatch
    Header-only refresh — used after a message deletion so the token-bar in the title catches up without redoing the form.
    ai.mindconnect.ui.model.UiPage
    Render the full page (initial GET, after navigation).
    ai.mindconnect.ui.model.UiPatch
    Turn completed successfully.
    ai.mindconnect.ui.model.UiPatch
    Streaming failed before completion.
    ai.mindconnect.ui.model.UiPatch
    Failure with a face: error bubble into the chat, form back to Send.
    ai.mindconnect.ui.model.UiPatch
    streamFirstToken(String pendingId, String thinkingId)
    First bot token arrived.
    ai.mindconnect.ui.model.UiPatch
     
    ai.mindconnect.ui.model.UiPatch
    streamStart(String userText, String thinkingId)
     
    ai.mindconnect.ui.model.UiPatch
    streamSubAgentDone(ai.mindconnect.ui.model.UiNode statusNode, String stackId, ai.mindconnect.ui.model.UiNode answerNode)
    Completes a sub-agent card without disturbing its nested child tree: REPLACE the in-body status line in place, then APPEND the final-answer markdown into the card's body stack.
    ai.mindconnect.ui.model.UiPatch
    APPEND a freshly-started task card (tool / sub-agent) to the list.
    ai.mindconnect.ui.model.UiPatch
    APPEND a freshly-started task card into a sub-agent's nested child list (childListId) rather than the top-level conversation — this is what builds the sub-agent tree live.
    ai.mindconnect.ui.model.UiPatch
    REPLACE a task card in place — used for done / failed transitions.
    ai.mindconnect.ui.model.UiPatch
    streamToken(String pendingId, String cumulativeText)
    Every subsequent token: grow the bot-pending body to the cumulative text.
    withActiveStreams(List<ai.mindconnect.ui.model.UiPage.ActiveStream> streams)
    Lets the controller hand the chat-page the streams the SPA should try to re-attach to (typically a single entry for this very session's chat turn).
    withAttachments(ai.mindconnect.ui.model.UiNode attachments)
     
    withBubbledApprovals(List<ai.mindconnect.ui.model.UiList.Item> cards)
    The open sub-agent approval cards of this (root) session — built by the controller from the ToolApprovalStore, rendered by the message list after the history.

    Methods inherited from class ai.mindconnect.adminui.ui.AdminPage

    patch

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChatPage

      public ChatPage(ai.mindconnect.agent.domain.AgentSession session, ai.mindconnect.agent.domain.AgentDefinition agent, List<ai.mindconnect.message.domain.Message> history, ai.mindconnect.agent.memory.domain.WorkingMemory memory)
    • ChatPage

      public ChatPage(ai.mindconnect.agent.domain.AgentSession session, ai.mindconnect.agent.domain.AgentDefinition agent, List<ai.mindconnect.message.domain.Message> history, ai.mindconnect.agent.memory.domain.WorkingMemory memory, boolean streaming)
    • ChatPage

      public ChatPage(ai.mindconnect.agent.domain.AgentSession session, ai.mindconnect.agent.domain.AgentDefinition agent, List<ai.mindconnect.message.domain.Message> history, ai.mindconnect.agent.memory.domain.WorkingMemory memory, boolean streaming, MessageListComponent.SubAgentTreeProvider subAgentTree)
      Parameters:
      streaming - whether the agent is currently mid-turn. When true, the chat form is rendered in Stop-button mode so a navigate-back during a live turn doesn't show a Send button the user can accidentally fire.
      subAgentTree - supplies the nested sub-agent card trees for historic rendering (rebuilt from persisted child sessions); MessageListComponent.SubAgentTreeProvider.NONE for a flat fallback.
  • Method Details

    • withActiveStreams

      public ChatPage withActiveStreams(List<ai.mindconnect.ui.model.UiPage.ActiveStream> streams)
      Lets the controller hand the chat-page the streams the SPA should try to re-attach to (typically a single entry for this very session's chat turn). Returns this for fluent chaining.
    • withAttachments

      public ChatPage withAttachments(ai.mindconnect.ui.model.UiNode attachments)
    • withBubbledApprovals

      public ChatPage withBubbledApprovals(List<ai.mindconnect.ui.model.UiList.Item> cards)
      The open sub-agent approval cards of this (root) session — built by the controller from the ToolApprovalStore, rendered by the message list after the history. Returns this for fluent chaining.
    • attachZone

      public static ai.mindconnect.ui.model.UiUpload attachZone(UUID sessionId)
      The attach drop-zone — lives in the dialog the chat form's "+" button opens (see SessionUiController#attachDialog), not on the page itself. Files land in the session's vector store via the ingestion workflow, and vector_search activates for the session.
    • render

      public ai.mindconnect.ui.model.UiPage render()
      Description copied from class: AdminPage
      Render the full page (initial GET, after navigation).
      Specified by:
      render in class AdminPage
    • chatTurnComplete

      public ai.mindconnect.ui.model.UiPatch chatTurnComplete()
      After a non-streaming POST /chat: refresh the conversation (and its token-bar title) and reset the input form so the user can type a follow-up.
    • headerOnly

      public ai.mindconnect.ui.model.UiPatch headerOnly()
      Header-only refresh — used after a message deletion so the token-bar in the title catches up without redoing the form.
    • appendApprovalCard

      public ai.mindconnect.ui.model.UiPatch appendApprovalCard(ai.mindconnect.ui.model.UiList.Item card)
      APPEND a live approval card pushed by a suspended (sub-)turn.
    • streamResume

      public ai.mindconnect.ui.model.UiPatch streamResume()
    • streamStart

      public ai.mindconnect.ui.model.UiPatch streamStart(String userText, String thinkingId)
    • streamFirstToken

      public ai.mindconnect.ui.model.UiPatch streamFirstToken(String pendingId, String thinkingId)
      First bot token arrived. Drop the thinking indicator and append the streaming-reply placeholder. Subsequent tokens grow the placeholder via streamToken(String, String).
    • streamToken

      public ai.mindconnect.ui.model.UiPatch streamToken(String pendingId, String cumulativeText)
      Every subsequent token: grow the bot-pending body to the cumulative text.
    • streamTaskStart

      public ai.mindconnect.ui.model.UiPatch streamTaskStart(TaskCardComponent card)
      APPEND a freshly-started task card (tool / sub-agent) to the list.
    • streamTaskStartInto

      public ai.mindconnect.ui.model.UiPatch streamTaskStartInto(String childListId, TaskCardComponent card)
      APPEND a freshly-started task card into a sub-agent's nested child list (childListId) rather than the top-level conversation — this is what builds the sub-agent tree live.
    • streamTaskUpdate

      public ai.mindconnect.ui.model.UiPatch streamTaskUpdate(TaskCardComponent card)
      REPLACE a task card in place — used for done / failed transitions.
    • streamSubAgentDone

      public ai.mindconnect.ui.model.UiPatch streamSubAgentDone(ai.mindconnect.ui.model.UiNode statusNode, String stackId, ai.mindconnect.ui.model.UiNode answerNode)
      Completes a sub-agent card without disturbing its nested child tree: REPLACE the in-body status line in place, then APPEND the final-answer markdown into the card's body stack. A wholesale card REPLACE would morph the nested child list back to empty and wipe the already-streamed children, so the two targeted ops are used instead.
    • streamDone

      public ai.mindconnect.ui.model.UiPatch streamDone()
      Turn completed successfully. Reset the form back to its idle variant and refresh the whole conversation so the streamed bot-pending placeholder + live task cards get swapped for the persisted assistant message and its historic task cards.
    • streamError

      public ai.mindconnect.ui.model.UiPatch streamError()
      Streaming failed before completion. Only restore the form to idle — the live partial state stays visible (the user gets a separate error banner via the SSE 'error' event), and the next page load will rebuild from persisted history.
    • streamError

      public ai.mindconnect.ui.model.UiPatch streamError(String message)
      Failure with a face: error bubble into the chat, form back to Send.