Class AgiCard

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class AgiCard extends JPanel
A "sticky note" style card representing an active AI session. It provides a visual summary of the session's state, metrics, and quick actions. This component listens for property changes on the Agi object to update its display in real-time.
Author:
anahata
See Also:
  • Field Details

    • agi

      private final Agi agi
      The agi session represented by this card.
    • container

      private final AbstractAsiContainer container
      The container for handling session actions.
    • nameLabel

      private final JLabel nameLabel
      The label displaying the agi's nickname.
    • summaryArea

      private final JTextArea summaryArea
      The text area displaying the agi's summary.
    • statusLabel

      private final JLabel statusLabel
      The label displaying the current status of the agi.
    • messageCountLabel

      private final JLabel messageCountLabel
      The label displaying the total number of messages in the conversation.
    • resourceCountLabel

      private final JLabel resourceCountLabel
      The label displaying the total number of active resources.
    • usageLabel

      private final JLabel usageLabel
      The label displaying the context window usage percentage.
    • closeBtn

      private final JButton closeBtn
      The button to close the session's tab/window.
    • agiListener

      private final EdtPropertyChangeListener agiListener
      The listener for changes in the agi session's properties.
    • statusListener

      private final EdtPropertyChangeListener statusListener
      The listener for status changes in the agi session.
    • historyListener

      private final EdtPropertyChangeListener historyListener
      The listener for history changes in the context manager.
    • resourceListener

      private final EdtPropertyChangeListener resourceListener
      The listener for resource changes in the resource manager.
    • selected

      private boolean selected
      Whether the card is currently selected in the container.
    • theme

      private SwingAgiConfig.UITheme theme
      The UI theme derived from the agi's configuration.
  • Constructor Details

    • AgiCard

      public AgiCard(@NonNull @NonNull Agi agi, @NonNull @NonNull AbstractAsiContainer container)
      Constructs a new AgiCard for the given agi session.
      Parameters:
      agi - The agi session to represent.
      container - The container for session actions.
  • Method Details

    • syncState

      private void syncState()
      Synchronizes the UI state with the agi's 'open' status and updates the background.
    • updateBackground

      private void updateBackground()
      Updates the card's background color based on selection, hover, and open state.
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • setSelected

      public void setSelected(boolean selected)
      Sets the selection state of the card and updates its visual appearance.
      Parameters:
      selected - true if the card is selected.
    • updateBorder

      private void updateBorder()
      Updates the card's border thickness and color based on the selection state.
    • handleAgiChange

      private void handleAgiChange(PropertyChangeEvent evt)
      Handles property change events from the agi session.
      Parameters:
      evt - The property change event.
    • handleStatusChange

      private void handleStatusChange(PropertyChangeEvent evt)
      Handles status change events from the agi status manager.
      Parameters:
      evt - The property change event.
    • handleHistoryChange

      private void handleHistoryChange(PropertyChangeEvent evt)
      Handles history change events from the context manager.
      Parameters:
      evt - The property change event.
    • handleResourceChange

      private void handleResourceChange(PropertyChangeEvent evt)
      Handles resource change events from the resource manager.
      Parameters:
      evt - The property change event.
    • updateMetrics

      private void updateMetrics()
      Recalculates and updates the labels for message count and context usage.
    • updateUI

      public void updateUI()

      Overridden to dynamically update the theme and background colors when the Look and Feel changes.

      Overrides:
      updateUI in class JPanel
    • cleanup

      public void cleanup()
      Cleans up resources and removes listeners. Should be called when the card is no longer needed.