# Class ChatMessageManager | EchoHub Documentation
Owns chat message storage, formatting, and mutation. Fires when a channel's message list is modified so the UI layer can refresh.

# Class ChatMessageManager

Namespace
  EchoHub.Client.UI.Chat

Assembly
  EchoHub.Client.dll

Owns chat message storage, formatting, and mutation. Fires MessagesChanged when a channel's message list is modified so the UI layer can refresh.

    public sealed class ChatMessageManager

Inheritance
  object
  ChatMessageManager

Inherited Members
  object.GetType()
  object.ToString()
  object.Equals(object)
  object.Equals(object, object)
  object.ReferenceEquals(object, object)
  object.GetHashCode()

## Constructors

### ChatMessageManager()

    public ChatMessageManager()

## Fields

### ContentIndentCols

Columns before message text starts: "HH:mm " + nick column + " │ ".

    public const int ContentIndentCols = 21

#### Field Value

int

### NickColWidth

Columns reserved for the right-aligned nick column (WeeChat-style).

    public const int NickColWidth = 12

#### Field Value

int

## Properties

### CurrentChannel

The currently active channel (used for unread tracking and @mention detection).

    public string CurrentChannel { get; set; }

#### Property Value

string

### CurrentUser

    public string CurrentUser { get; }

#### Property Value

string

### LastReadIds

Last message the user has read per channel — persisted by the orchestrator so unread/mention state can be seeded from history on the next connect.

    public IReadOnlyDictionary<string, Guid> LastReadIds { get; }

#### Property Value

IReadOnlyDictionary<string, Guid>

### MentionChannels

Channels with an unread @mention of the current user (cleared by ClearUnread(string)).

    public IReadOnlySet<string> MentionChannels { get; }

#### Property Value

IReadOnlySet<string>

## Methods

### AddMessage(MessageDto)

Format and store a received message. Increments unread count if not the active channel.

    public void AddMessage(MessageDto message)

#### Parameters

`message` MessageDto

### AddStatusMessage(string, string, string)

Add a status change message to a channel with colored styling.

    public void AddStatusMessage(string channelName, string username, string status)

#### Parameters

`channelName` string
`username` string
`status` string

### AddSystemMessage(string, string)

Add a system/informational message to a channel with colored styling.

    public void AddSystemMessage(string channelName, string text)

#### Parameters

`channelName` string
`text` string

### ClearAll()

Reset all message state (used on disconnect).

    public void ClearAll()

### ClearChannelMessages(string)

Clear all messages from a specific channel.

    public void ClearChannelMessages(string channelName)

#### Parameters

`channelName` string

### ClearUnread(string)

    public void ClearUnread(string channelName)

#### Parameters

`channelName` string

### GetMessages(string)

    public List<ChatLine>? GetMessages(string channelName)

#### Parameters

`channelName` string

#### Returns

List<ChatLine>

### GetUnreadCount(string)

    public int GetUnreadCount(string channelName)

#### Parameters

`channelName` string

#### Returns

int

### LoadHistory(string, List<MessageDto>, Guid?)

Load historical messages into a channel, replacing any existing messages. When `lastReadId` is given (persisted from a previous session), messages after it seed the unread count, @mention highlight, and the "new messages" marker — so activity that happened while offline still lights up.

    public void LoadHistory(string channelName, List<MessageDto> messages, Guid? lastReadId = null)

#### Parameters

`channelName` string
`messages` List<MessageDto>
`lastReadId` Guid?

### PrependHistory(string, List<MessageDto>)

Prepend older messages at the front of a channel's buffer, skipping any that are already present. Fires HistoryPrepended when new lines are actually inserted.

    public void PrependHistory(string channelName, List<MessageDto> olderMessages)

#### Parameters

`channelName` string
`olderMessages` List<MessageDto>

### RemoveMessage(string, Guid)

Remove all lines associated with a specific message ID.

    public void RemoveMessage(string channelName, Guid messageId)

#### Parameters

`channelName` string
`messageId` Guid

### SetChatWidth(int)

    public void SetChatWidth(int width)

#### Parameters

`width` int

### SetCurrentUser(string)

    public void SetCurrentUser(string username)

#### Parameters

`username` string

## Events

### HistoryPrepended

Fired after older messages are prepended to a channel's buffer. Parameter is the channel name.

    public event Action<string>? HistoryPrepended

#### Event Type

Action<string>

### MessagesChanged

Fired after any mutation to a channel's messages. Parameter is the channel name.

    public event Action<string>? MessagesChanged

#### Event Type

Action<string>