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.
MessageStore(
self,
)Total number of messages stored.
Number of messages currently visible (as widgets).
Check if there are archived messages above the visible window.
Check if there are archived messages below the visible window.
Add a new message to the store.
Load many messages at once, keeping only the tail visible.
This is optimized for thread resumption: all messages are stored as
lightweight data, but only the last WINDOW_SIZE entries are marked
visible (i.e. will need DOM widgets).
Get a message by its ID.
Get a message by its index.
Update a message's data.
Only fields in _UPDATABLE_FIELDS may be updated. Unknown field
names raise ValueError to catch typos early.
Set the currently active (streaming) message.
Active messages are never archived.
Check if a message is the active streaming message.
Check if the visible window exceeds the maximum size.
Get the oldest visible messages that should be pruned.
Returns a contiguous run of messages from the START of the visible window. Stops at the active streaming message to avoid creating gaps in the visible window (which would desync store state from the DOM).
Mark messages as pruned (widgets removed).
Advances _visible_start past consecutive pruned messages at the front
of the window.
Get messages above the visible window to hydrate.
Mark that messages above were hydrated.
Check if we should hydrate messages above the current view.
Check if we should prune messages below the current view.
Clear all messages.
Get the range of visible message indices.
Get all stored messages.
Get messages in the visible window.