ui_message_reducer(
left: list[AnyUIMessage] | AnyUIMessage,
right: list[AnyUIMessage| Name | Type | Description |
|---|---|---|
left* | list[AnyUIMessage] | AnyUIMessage | |
right* | list[AnyUIMessage] | AnyUIMessage |
Merge two lists of UI messages, supporting removing UI messages.
This function combines two lists of UI messages, handling both regular UI messages
and remove-ui messages. When a remove-ui message is encountered, it removes any
UI message with the matching ID from the current state.
Example:
messages = ui_message_reducer(
[{"type": "ui", "id": "1", "name": "Chat", "props": {}}],
{"type": "remove-ui", "id": "1"},
)First list of UI messages or single UI message.
Second list of UI messages or single UI message.