ChatMessageNode

Everywhere · realtime, chat-tree, branching-conversations, ui

Represents a node in a chat tree, holding a message, child references, and a chosen child index. Enables branching conversations with observable properties and serialization support.

[MessagePackObject(AllowPrivate = true)]
public sealed partial class ChatMessageNode : ObservableObject, IDisposable
{
    [Key(0)]
    public Guid Id { get; }

    [Key(1)]
    public ChatMessage Message { get; }

    [Key(2)]
    public IReadOnlyList<Guid> Children => _children.Items;

    /// <summary>
    /// Index of the chosen child in <see cref="Children"/> (-1 when none).
    /// When persisted, it should be mapped to the child's ID (ChoiceChildId) to avoid index drift under concurrent inserts.
    /// </summary>
    [Key(3)]
    public int ChoiceIndex
    {
        get => Math.Min(field, Children.Count - 1);
        set => SetProperty(ref field, Math.Clamp(value, -1, Children.Count - 1));
    }

    [IgnoreMember]
    public int ChoiceCount => Children.Count;

    [IgnoreMember]
 

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key