Class MessageNode


public class MessageNode extends AbstractContextNode<AbstractMessage>
A context tree node representing a single message in the conversation.
Author:
anahata
  • Constructor Details

    • MessageNode

      public MessageNode(AgiPanel agiPanel, AbstractMessage userObject)
      Constructs a new MessageNode.
      Parameters:
      agiPanel - The parent agi panel.
      userObject - The message to wrap.
  • Method Details

    • getName

      public String getName()
      Gets the human-readable display name for this node.

      Implementation details: Returns a composite string containing the role (USER, MODEL) and the sequential identifier from the timeline.

      Specified by:
      getName in class AbstractContextNode<AbstractMessage>
      Returns:
      The name to be displayed in the tree.
    • getDescription

      public String getDescription()
      Gets a detailed description of the node's purpose or content.

      Implementation details: Provides a human-readable summary of the message's origin and timestamp for the tree sidebar.

      Specified by:
      getDescription in class AbstractContextNode<AbstractMessage>
      Returns:
      The description string.
    • fetchChildObjects

      protected List<?> fetchChildObjects()
      Fetches the current list of domain objects that should be represented as children of this node.

      Implementation details: Retrieves the list of AbstractParts contained in the message, including effectively pruned parts for visualization.

      Specified by:
      fetchChildObjects in class AbstractContextNode<AbstractMessage>
      Returns:
      A list of domain objects.
    • createChildNode

      protected AbstractContextNode<?> createChildNode(Object obj)
      Creates a new child node for the given domain object.

      Implementation details: Maps message parts to their navigable PartNode representation.

      Specified by:
      createChildNode in class AbstractContextNode<AbstractMessage>
      Parameters:
      obj - The domain object to wrap.
      Returns:
      A new AbstractContextNode, or null if the object type is not supported.
    • calculateLocalTokens

      protected void calculateLocalTokens()
      Calculates the token counts for this node's own content (excluding children).

      Implementation details: Message-level tokens are calculated as the sum of tokens from all contained parts.

      Specified by:
      calculateLocalTokens in class AbstractContextNode<AbstractMessage>
    • isActive

      public boolean isActive()
      Checks if the underlying domain object is currently active in the context.

      Subclasses override this method to define their specific active-state policy, allowing for clean, polymorphic evaluation without dirty instanceof chains.

      Specified by:
      isActive in class AbstractContextNode<AbstractMessage>
      Returns:
      true if active, false otherwise.
    • updateStatus

      protected void updateStatus()
      Updates the status string for this node.

      Implementation details: Updates the status label based on whether the message is pinned, effectively pruned from the context window, or active.

      Specified by:
      updateStatus in class AbstractContextNode<AbstractMessage>