Class ChatMessageActions
The hover-revealed action row under a chat message.
Inheritance
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class ChatMessageActions : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
Remarks
Copy, thumbs up, thumbs down and, when the caller offers it, retry. Copy writes content to the system clipboard and flips its glyph to a check for copiedFeedbackMs, so the user gets confirmation without a toast.
The rating is local visual state: the row remembers which way it was pressed and reports it through feedbackGiven, but the caller decides what that means and can pin it by assigning sentiment when it loads a past conversation.
Every control is an IconButton, so the row inherits the package's focus ring, hover tint and sizing rather than restating them.
Examples
An action row with retry.
var actions = new ChatMessageActions { content = answerText, retryable = true };
actions.retryRequested += Regenerate;
actions.feedbackGiven += s => Report(s);
parentElement.Add(actions);
In UXML.
<appui:ChatMessageActions content="Hello" retryable="true" />
Constructors
ChatMessageActions()
Default constructor.
Declaration
public ChatMessageActions()
Fields
copiedFeedbackMs
How long the copy control stays on its confirmation glyph, in milliseconds.
Declaration
public const long copiedFeedbackMs = 2000
Field Value
| Type | Description |
|---|---|
| long |
copiedUssClassName
The styling class applied to the copy control while it is confirming.
Declaration
public const string copiedUssClassName = "appui-chat-message-actions__copy-button--copied"
Field Value
| Type | Description |
|---|---|
| string |
copyButtonUssClassName
The styling class of the copy control.
Declaration
public const string copyButtonUssClassName = "appui-chat-message-actions__copy-button"
Field Value
| Type | Description |
|---|---|
| string |
retryButtonUssClassName
The styling class of the retry control.
Declaration
public const string retryButtonUssClassName = "appui-chat-message-actions__retry-button"
Field Value
| Type | Description |
|---|---|
| string |
thumbsDownButtonUssClassName
The styling class of the thumbs down control.
Declaration
public const string thumbsDownButtonUssClassName = "appui-chat-message-actions__thumbs-down-button"
Field Value
| Type | Description |
|---|---|
| string |
thumbsUpButtonUssClassName
The styling class of the thumbs up control.
Declaration
public const string thumbsUpButtonUssClassName = "appui-chat-message-actions__thumbs-up-button"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The ChatMessageActions main styling class.
Declaration
public const string ussClassName = "appui-chat-message-actions"
Field Value
| Type | Description |
|---|---|
| string |
Properties
content
The plain text the copy control writes to the clipboard.
Declaration
[CreateProperty]
[UxmlAttribute]
public string content { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
copied
Whether the copy control is currently showing its confirmation glyph.
Declaration
public bool copied { get; }
Property Value
| Type | Description |
|---|---|
| bool |
copyButton
The copy control.
Declaration
public IconButton copyButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
retryButton
The retry control.
Declaration
public IconButton retryButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
retryable
Whether the retry control is offered. False by default.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool retryable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
sentiment
How the answer is currently rated. None by default.
Declaration
[CreateProperty]
[UxmlAttribute]
public FeedbackSentiment sentiment { get; set; }
Property Value
| Type | Description |
|---|---|
| FeedbackSentiment |
Remarks
Setting this marks the matching control as selected and raises feedbackGiven, so a rating made in code and a rating made by clicking travel the same path. Re-setting the same value is a no-op and raises nothing.
thumbsDownButton
The thumbs down control.
Declaration
public IconButton thumbsDownButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
thumbsUpButton
The thumbs up control.
Declaration
public IconButton thumbsUpButton { get; }
Property Value
| Type | Description |
|---|---|
| IconButton |
Methods
Copy()
Writes content to the system clipboard and shows the confirmation glyph.
Declaration
public void Copy()
Events
contentCopied
Raised when content has been written to the clipboard.
Declaration
public event Action contentCopied
Event Type
| Type | Description |
|---|---|
| Action |
feedbackGiven
Raised when the user rates the answer.
Declaration
public event Action<FeedbackSentiment> feedbackGiven
Event Type
| Type | Description |
|---|---|
| Action<FeedbackSentiment> |
retryRequested
Raised when the user asks for the answer to be regenerated.
Declaration
public event Action retryRequested
Event Type
| Type | Description |
|---|---|
| Action |