fix: prevent code from showing up in the chat panel - #140
Conversation
Create new ChatCleaner service to handle all the cleansing.
Strip markdown code fences and XML/HTML.
Separate thought candidate parts into thinking property in LLM client.
Handle cross-chunk streaming XML/HTML thinking tags (<thought>,
<thinking>, <reasoning>) and multi-line formatted JSON arrays.
Prevent false-positive layout snapshot classification on non-JSON
bracketed text.
Refactor Standalone3pLlmClient.chatStream into a high-level
coordinator method delegating parameter construction, chunk part
parsing, XML thought extraction, and stream consumption to private
helper methods.
Recognize partial JSON arrays starting with '[' and containing A2UI keys
("version", "createSurface", or "updateComponents"). This prevents raw
incomplete JSON text from displaying in the chat bubble during active
LLM streaming.
There was a problem hiding this comment.
Code Review
This pull request introduces a new ChatCleaner service to centralize the cleaning and processing of raw LLM chat messages, including stripping pulse indicators, XML thinking tags, and markdown code fences. It refactors ChatPanel, ChatCoordinator, and Standalone3pLlmClient to utilize this service, improving streaming layout snapshot detection and thought extraction. Feedback highlights opportunities to enhance partial JSON array detection in ChatCleaner.cleanPayload during active streaming, and to clean up an unused state parameter in Standalone3pLlmClient.
Replace any parameter types in parseChunkParts and consumeStream with GenerateContentResponse and AsyncIterable<GenerateContentResponse> from @google/genai.
Support partial JSON arrays starting with '[' and containing A2UI keys in ChatCleaner.cleanPayload. Remove unused state parameter from Standalone3pLlmClient.extractXmlThoughts.
⚡ A2UI Composer PR PreviewYour automated preview is successfully live (commit
|
|
lgtm to unblock, but why not use structured output? json schema |
Description
Create new ChatCleaner service to handle all the cleansing.
Strip markdown code fences and XML/HTML.
Separate thought candidate parts into thinking property in LLM client. Handle cross-chunk streaming XML/HTML thinking tags (, , ) and multi-line formatted JSON arrays. Prevent false-positive layout snapshot classification on non-JSON bracketed text.
Refactor Standalone3pLlmClient.chatStream into a high-level coordinator method delegating parameter construction, chunk part parsing, XML thought extraction, and stream consumption to private helper methods.
Recognize partial JSON arrays starting with '[' and containing A2UI keys ("version", "createSurface", or "updateComponents"). This prevents raw incomplete JSON text from displaying in the chat bubble during active LLM streaming.
Pre-launch Checklist