Class AiMessageRegenerateAction

All Implemented Interfaces:
TargetAction<AiChat<?>>, Action, HasShortcutCombination

@ActionType("aichat_messageRegenerate") public class AiMessageRegenerateAction extends AiMessageAction<AiMessageRegenerateAction> implements TargetAction<AiChat<?>>
Built-in action that rewinds the conversation to the prompt the clicked message belongs to and streams a fresh answer. Everything after that prompt — the message itself and every message following it — is removed from the chat's source first, so the answer replaces the tail rather than being appended to it.

The prompt is the nearest AiMessageRole.USER message at or before the clicked one, which is why the same action serves both roles: under an assistant message it re-asks the question that message answers, under a user message it re-asks that message.

Rewinding needs the message source, which only AiChat has, so the action is a TargetAction: the chat wires itself as the target when the action is assigned to one of its roles. Assigned to a standalone AiMessageList it has no target and execute(io.jmix.aichat.action.AiMessageActionPerformedEvent) throws.

Like AiMessageCopyAction it carries no icon component — the glyph comes from CSS through the jmix-ai-message-action-regenerate class and the --jmix-ai-message-icon-regenerate mask — and its description is localized from the message bundle through an injected Messages, so an instance built with new rather than through the registry carries none.

See Also:
  • Field Details

    • ID

      public static final String ID
      The action type id, for <action type="aichat_messageRegenerate"/> in a descriptor.
      See Also:
    • REGENERATE_CLASS_NAME

      public static final String REGENERATE_CLASS_NAME
      The class name applied to the rendered button, so the action can be styled per theme.
      See Also:
    • target

      protected @Nullable AiChat<?> target
  • Constructor Details

    • AiMessageRegenerateAction

      public AiMessageRegenerateAction()
      Creates the action with the default id ID.
    • AiMessageRegenerateAction

      public AiMessageRegenerateAction(String id)
      Creates the action with the given id.
      Parameters:
      id - the action id
  • Method Details