Message store for virtualized chat history.
This module provides data structures and management for message virtualization, allowing the TUI to handle large message histories efficiently by keeping only a sliding window of widgets in the DOM while storing all message data as lightweight dataclasses.
The approach is inspired by Textual's Log widget, which only keeps N lines
in the DOM and recreates older ones on demand.
Estimated terminal rows for a message whose rendered height is unknown.
Smallest row estimate for a displayed message in spacer and range math.
A row folded out of view (e.g. a tool hidden behind a ToolGroupSummary) may
store a smaller hint, down to 0. See MessageStore.set_height_hint.
Line counts for a change, named so the pair cannot be swapped silently.
Keyword-only and frozen so that claim holds at construction as well as in transit: a positional pair is exactly the transposition this type exists to rule out, and the counts are read long after they are computed.
Types of messages in the chat.
Status of a tool call.
In-memory message data for virtualization.
This dataclass holds all information needed to recreate a message widget. It is designed to be lightweight so that thousands of messages can be stored without meaningful memory overhead.
Manages message data and widget window for virtualization.
This class stores all messages as data and manages a sliding window of widgets that are actually mounted in the DOM.