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.
MessageData(
self,
type: MessageType,
content: str,
id: str = (lambda: f'msg-{uuid.uuid4().hex[:8]}')(),
timestamp: float = time(),
tool_name: str | None = None,
tool_args: dict[str, Any] | None = None,
tool_status: ToolStatus | None = None,
tool_output: str | None = None,
tool_expanded: bool = False,
diff_file_path: str | None = None,
is_streaming: bool = False,
height_hint: int | None = None
)The kind of message (user, assistant, tool, etc.).
Primary text content of the message.
For most message types this is the display text. For TOOL messages it is
typically empty because the tool's identity comes from tool_name /
tool_args instead.
Unique identifier used to match the dataclass to its DOM widget.
Unix epoch timestamp of when the message was created.
Name of the tool that was called.
Arguments passed to the tool call.
Current execution status of the tool call.
Output returned by the tool after execution.
Whether the tool output section is expanded in the UI.
File path associated with the diff (DIFF messages only).
Whether the message is still being streamed.
While True, the corresponding widget is actively receiving content
chunks and should not be pruned or re-hydrated.
Cached widget height in terminal rows for scroll position estimation.
When _hydrate_messages_above inserts widgets above the viewport it needs
to adjust the scroll offset so the user's view doesn't jump. Currently this
uses a fixed estimate (5 rows per message). Caching the actual rendered
height here after first mount would make that estimate accurate, especially
for tall messages like diffs or long assistant responses.
Not yet populated — see _hydrate_messages_above in app.py.