fix: tool HTML embeds vanish when the HTML contains entities like " (#31390)

Tools that return inline HTML showed no embed at all when the HTML contained an entity such as `"` or `"`, and HTML containing `&` or `<` showed up with those turned into real characters. The chat view unescaped HTML entities in a tool's embeds, arguments and file links, which is only right for chats saved by older versions, so on current chats it changed the tool's own HTML before displaying it. Embeds, tool arguments and file links now show exactly what the tool returned, and older chats render as before.

Fixes #28085
This commit is contained in:
Classic298 2026-09-30 17:50:11 +02:00 • committed by GitHub
parent fab58bd35f
commit c7caa1421d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,3 +1,5 @@
import { encode } from 'html-entities';
export type OutputContentPart = {
type?: string;
text?: unknown;
@ -228,9 +230,10 @@ function buildToolCallToken(item: OutputItem, toolOutputByCallId: Record<string,
name,
done: isDone ? 'true' : 'false',
status,
arguments: stringifyAttribute(item.arguments ?? ''),
files: stringifyAttribute(resultItem?.files),
embeds: stringifyAttribute(resultItem?.embeds)
// ToolCallDisplay HTML-decodes these, like legacy <details> attributes.
arguments: encode(stringifyAttribute(item.arguments ?? '')),
files: encode(stringifyAttribute(resultItem?.files)),
embeds: encode(stringifyAttribute(resultItem?.embeds))
}
};
}