Class AgisTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
uno.anahata.asi.swing.AgisTableModel
All Implemented Interfaces:
Serializable, TableModel

public class AgisTableModel extends AbstractTableModel
A reusable table model for displaying active AI agi sessions. This model tracks the AbstractAsiContainer and provides real-time updates on session status, message count, and context usage through reactive listeners.
Author:
anahata
See Also:
  • Field Details

    • sessions

      private final List<Agi> sessions
      The list of active agi sessions being tracked.
    • columnNames

      private final String[] columnNames
      The localized column names for the table.
    • metricsListener

      private final PropertyChangeListener metricsListener
      The listener for metric changes in individual sessions.
    • asiConfig

      private final AbstractAsiContainer asiConfig
      The container configuration providing session data.
    • asiListener

      private final PropertyChangeListener asiListener
      The listener for changes in the container's session list.
    • SESSION_COL

      public static final int SESSION_COL
      The column index for the session name.
      See Also:
    • ID_COL

      public static final int ID_COL
      The column index for the session ID.
      See Also:
    • STATUS_COL

      public static final int STATUS_COL
      The column index for the session status.
      See Also:
    • MESSAGES_COL

      public static final int MESSAGES_COL
      The column index for the message count.
      See Also:
    • RESOURCES_COL

      public static final int RESOURCES_COL
      The column index for the resource count.
      See Also:
    • CONTEXT_COL

      public static final int CONTEXT_COL
      The column index for context window usage.
      See Also:
    • SUMMARY_COL

      public static final int SUMMARY_COL
      The column index for the conversation summary.
      See Also:
  • Constructor Details

    • AgisTableModel

      public AgisTableModel(@NonNull @NonNull AbstractAsiContainer asiConfig)
      Constructs a new model and registers a listener on the provided container.
      Parameters:
      asiConfig - The container to track.
  • Method Details

    • getRowCount

      public int getRowCount()
    • getColumnCount

      public int getColumnCount()
    • getColumnName

      public String getColumnName(int column)
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
    • getColumnClass

      public Class<?> getColumnClass(int columnIndex)
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
    • refresh

      public final void refresh()
      Refreshes the table model by synchronizing with the AbstractAsiContainer. This method manages the attachment and detachment of per-session listeners.
    • attachListeners

      private void attachListeners(Agi agi)
      Attaches reactive property change listeners to the given AGI session. This registers the metrics listener for properties like nickname, summary, history, resources, and current status.
      Parameters:
      agi - The AGI session to attach listeners to.
    • detachListeners

      private void detachListeners(Agi agi)
      Detaches reactive property change listeners from the given AGI session. This unregisters the metrics listener to prevent memory leaks.
      Parameters:
      agi - The AGI session to detach listeners from.
    • handleMetricsChange

      private void handleMetricsChange(PropertyChangeEvent evt)
      Handles property change events from individual sessions to update specific rows.
      Parameters:
      evt - The property change event.
    • getAgiAt

      public Agi getAgiAt(int row)
      Retrieves the agi session at the specified row index.
      Parameters:
      row - The model row index.
      Returns:
      The session, or null if the index is out of bounds.
    • handleAsiChange

      private void handleAsiChange(PropertyChangeEvent evt)
      Handles property change events from the ASI container to trigger a refresh.
      Parameters:
      evt - The property change event.
    • dispose

      public void dispose()
      Unregisters the listener from the container and cleans up the model.