mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 10:16:44 +00:00
fix(ui): ignore malformed tool stream entries (#111145)
Prevent malformed transient tool-stream entries from aborting Control UI chat reconciliation while preserving valid tool message order and rendering.
This commit is contained in:
@@ -1870,6 +1870,26 @@ describe("buildCachedChatItems", () => {
|
||||
expect(messageRecord(groupAt(groups, 0)).content).toBe("still visible");
|
||||
});
|
||||
|
||||
it("does not expose malformed tool stream entries to message rendering", () => {
|
||||
const items = buildCachedChatItems(
|
||||
createProps({
|
||||
toolMessages: [
|
||||
null,
|
||||
undefined,
|
||||
{
|
||||
role: "assistant",
|
||||
content: [{ type: "toolcall", name: "heartbeat_respond", arguments: {} }],
|
||||
timestamp: 1,
|
||||
},
|
||||
],
|
||||
}),
|
||||
);
|
||||
|
||||
const groups = items.filter((item) => item.kind === "group");
|
||||
expect(groups).toHaveLength(1);
|
||||
expect(messageRecord(groupAt(groups, 0)).role).toBe("assistant");
|
||||
});
|
||||
|
||||
it("does not collapse duplicate text messages separated by another message", () => {
|
||||
const groups = messageGroups({
|
||||
messages: [
|
||||
|
||||
@@ -1187,7 +1187,9 @@ function buildChatItems(props: BuildChatItemsProps): Array<ChatItem | MessageGro
|
||||
const history = (Array.isArray(props.messages) ? props.messages : []).filter(
|
||||
(message) => !isAssistantHeartbeatAckForDisplay(message),
|
||||
);
|
||||
const tools = Array.isArray(props.toolMessages) ? props.toolMessages : [];
|
||||
const tools = Array.isArray(props.toolMessages)
|
||||
? props.toolMessages.filter((message) => asRecord(message) !== null)
|
||||
: [];
|
||||
const historyKeys = buildMessageKeys(history);
|
||||
const toolKeys = buildMessageKeys(tools, history.length);
|
||||
const liftedCanvasSources = tools.flatMap((message, index) => {
|
||||
|
||||
Reference in New Issue
Block a user